From c3a32e9131c0b318693c12cdca28b386693acf92 Mon Sep 17 00:00:00 2001 From: maskpp Date: Sun, 21 Jul 2024 11:39:14 +0800 Subject: [PATCH] translate byte32 to common.Hash --- accounts/abi/bind/bind.go | 6 +++++- accounts/abi/bind/bind_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index e902345f09..4ca3cd75fe 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -321,7 +321,11 @@ func bindBasicTypeGo(kind abi.Type) string { } return "*big.Int" case abi.FixedBytesTy: - return fmt.Sprintf("[%d]byte", kind.Size) + if kind.Size == 32 { + return "common.Hash" + } else { + return fmt.Sprintf("[%d]byte", kind.Size) + } case abi.BytesTy: return "[]byte" case abi.FunctionTy: diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index a390a3c47c..b99e3f54de 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -943,7 +943,7 @@ var bindTests = []struct { sim.Commit() } // Test filtering for certain events and ensure they can be found - sit, err := eventer.FilterSimpleEvent(nil, []common.Address{common.Address{1}, common.Address{3}}, [][32]byte{{byte(1)}, {byte(2)}, {byte(3)}}, []bool{true}) + sit, err := eventer.FilterSimpleEvent(nil, []common.Address{common.Address{1}, common.Address{3}}, []common.Hash{{1}, {2}, {3}}, []bool{true}) if err != nil { t.Fatalf("failed to filter for simple events: %v", err) }