aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/abi.go
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2017-12-21 23:18:37 +0800
committerMartin Holst Swende <martin@swende.se>2017-12-23 02:26:57 +0800
commitc095c87e117785ba5467487336215f86a958409b (patch)
tree74ff72e3798c2f14220113bc1b839d57141a0a47 /accounts/abi/abi.go
parent73d4a57d47d3381faa0516b319fa5598e71681f9 (diff)
downloaddexon-c095c87e117785ba5467487336215f86a958409b.tar
dexon-c095c87e117785ba5467487336215f86a958409b.tar.gz
dexon-c095c87e117785ba5467487336215f86a958409b.tar.bz2
dexon-c095c87e117785ba5467487336215f86a958409b.tar.lz
dexon-c095c87e117785ba5467487336215f86a958409b.tar.xz
dexon-c095c87e117785ba5467487336215f86a958409b.tar.zst
dexon-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.go12
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
+}