diff options
author | Martin Holst Swende <martin@swende.se> | 2017-12-21 23:18:37 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2017-12-23 02:26:57 +0800 |
commit | c095c87e117785ba5467487336215f86a958409b (patch) | |
tree | 74ff72e3798c2f14220113bc1b839d57141a0a47 /accounts/abi/abi.go | |
parent | 73d4a57d47d3381faa0516b319fa5598e71681f9 (diff) | |
download | go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar.gz go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar.bz2 go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar.lz go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar.xz go-tangerine-c095c87e117785ba5467487336215f86a958409b.tar.zst go-tangerine-c095c87e117785ba5467487336215f86a958409b.zip |
accounts/abi: merging of https://github.com/ethereum/go-ethereum/pull/15452 + lookup by id
Diffstat (limited to 'accounts/abi/abi.go')
-rw-r--r-- | accounts/abi/abi.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 7229a67bf..cbcf4ca92 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -17,6 +17,7 @@ package abi import ( + "bytes" "encoding/json" "fmt" "io" @@ -133,3 +134,14 @@ func (abi *ABI) UnmarshalJSON(data []byte) error { return nil } + +// MethodById looks up a method by the 4-byte id +// returns nil if none found +func (abi *ABI) MethodById(sigdata []byte) *Method { + for _, method := range abi.Methods { + if bytes.Equal(method.Id(), sigdata[:4]) { + return &method + } + } + return nil +} |