diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index fa46d6728a..7af53ef92d 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -70,7 +70,7 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) { return nil, err } // Pack up the method ID too if not a constructor and return - return append(method.Id(), arguments...), nil + return append(method.ID(), arguments...), nil } // Unpack output in v according to the abi specification @@ -138,7 +138,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error { // returns nil if none found func (abi *ABI) MethodByID(sigdata []byte) (*Method, error) { for _, method := range abi.Methods { - if bytes.Equal(method.Id(), sigdata[:4]) { + if bytes.Equal(method.ID(), sigdata[:4]) { return &method, nil } } diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index 3360ef7d31..4b881e0aea 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -185,8 +185,8 @@ func TestMethodSignature(t *testing.T) { } idexp := crypto.Keccak256([]byte(exp))[:4] - if !bytes.Equal(m.Id(), idexp) { - t.Errorf("expected ids to match %x != %x", m.Id(), idexp) + if !bytes.Equal(m.ID(), idexp) { + t.Errorf("expected ids to match %x != %x", m.ID(), idexp) } uintt, _ := NewType("uint256") @@ -702,13 +702,13 @@ func TestABI_MethodByID(t *testing.T) { } for name, m := range abi.Methods { a := fmt.Sprintf("%v", m) - m2, err := abi.MethodByID(m.Id()) + m2, err := abi.MethodByID(m.ID()) if err != nil { t.Fatalf("Failed to look up ABI method: %v", err) } b := fmt.Sprintf("%v", m2) if a != b { - t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.Id())) + t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.ID())) } } diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index 83ad1c8ae7..6eb2a7c7c1 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -252,7 +252,7 @@ func (c *BoundContract) FilterLogs(opts *FilterOpts, name string, query ...[]int opts = new(FilterOpts) } // Append the event selector to the query parameters and construct the topic set - query = append([][]interface{}{{c.abi.Events[name].Id()}}, query...) + query = append([][]interface{}{{c.abi.Events[name].ID()}}, query...) topics, err := makeTopics(query...) if err != nil { @@ -301,7 +301,7 @@ func (c *BoundContract) WatchLogs(opts *WatchOpts, name string, query ...[]inter opts = new(WatchOpts) } // Append the event selector to the query parameters and construct the topic set - query = append([][]interface{}{{c.abi.Events[name].Id()}}, query...) + query = append([][]interface{}{{c.abi.Events[name].ID()}}, query...) topics, err := makeTopics(query...) if err != nil { diff --git a/accounts/abi/event.go b/accounts/abi/event.go index a3f6be9732..2fd9a15143 100644 --- a/accounts/abi/event.go +++ b/accounts/abi/event.go @@ -44,9 +44,9 @@ func (e Event) String() string { return fmt.Sprintf("e %v(%v)", e.Name, strings.Join(inputs, ", ")) } -// Id returns the canonical representation of the event's signature used by the +// ID returns the canonical representation of the event's signature used by the // abi definition to identify event names and types. -func (e Event) Id() common.Hash { +func (e Event) ID() common.Hash { types := make([]string, len(e.Inputs)) i := 0 for _, input := range e.Inputs { diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go index 3bfdd7c0ab..4bad70b4c8 100644 --- a/accounts/abi/event_test.go +++ b/accounts/abi/event_test.go @@ -104,8 +104,8 @@ func TestEventId(t *testing.T) { } for name, event := range abi.Events { - if event.Id() != test.expectations[name] { - t.Errorf("expected id to be %x, got %x", test.expectations[name], event.Id()) + if event.ID() != test.expectations[name] { + t.Errorf("expected id to be %x, got %x", test.expectations[name], event.ID()) } } } diff --git a/accounts/abi/method.go b/accounts/abi/method.go index f434ffdbef..a59133a8b7 100644 --- a/accounts/abi/method.go +++ b/accounts/abi/method.go @@ -74,6 +74,6 @@ func (method Method) String() string { return fmt.Sprintf("function %v(%v) %sreturns(%v)", method.Name, strings.Join(inputs, ", "), constant, strings.Join(outputs, ", ")) } -func (method Method) Id() []byte { +func (method Method) ID() []byte { return crypto.Keccak256([]byte(method.Sig()))[:4] } diff --git a/accounts/abi/pack_test.go b/accounts/abi/pack_test.go index 58a5b7a581..f4a20fba61 100644 --- a/accounts/abi/pack_test.go +++ b/accounts/abi/pack_test.go @@ -347,7 +347,7 @@ func TestMethodPack(t *testing.T) { t.Fatal(err) } - sig := abi.Methods["slice"].Id() + sig := abi.Methods["slice"].ID() sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...) sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...) @@ -361,7 +361,7 @@ func TestMethodPack(t *testing.T) { } var addrA, addrB = common.Address{1}, common.Address{2} - sig = abi.Methods["sliceAddress"].Id() + sig = abi.Methods["sliceAddress"].ID() sig = append(sig, common.LeftPadBytes([]byte{32}, 32)...) sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...) sig = append(sig, common.LeftPadBytes(addrA[:], 32)...) @@ -376,7 +376,7 @@ func TestMethodPack(t *testing.T) { } var addrC, addrD = common.Address{3}, common.Address{4} - sig = abi.Methods["sliceMultiAddress"].Id() + sig = abi.Methods["sliceMultiAddress"].ID() sig = append(sig, common.LeftPadBytes([]byte{64}, 32)...) sig = append(sig, common.LeftPadBytes([]byte{160}, 32)...) sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...) @@ -394,7 +394,7 @@ func TestMethodPack(t *testing.T) { t.Errorf("expected %x got %x", sig, packed) } - sig = abi.Methods["slice256"].Id() + sig = abi.Methods["slice256"].ID() sig = append(sig, common.LeftPadBytes([]byte{1}, 32)...) sig = append(sig, common.LeftPadBytes([]byte{2}, 32)...)