aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/reflect.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/reflect.go
parent73d4a57d47d3381faa0516b319fa5598e71681f9 (diff)
downloadgo-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/reflect.go')
-rw-r--r--accounts/abi/reflect.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/accounts/abi/reflect.go b/accounts/abi/reflect.go
index fbcd576e5..7a9cdacd5 100644
--- a/accounts/abi/reflect.go
+++ b/accounts/abi/reflect.go
@@ -93,3 +93,20 @@ func requireAssignable(dst, src reflect.Value) error {
}
return nil
}
+
+// requireUnpackKind verifies preconditions for unpacking `args` into `kind`
+func requireUnpackKind(v reflect.Value, t reflect.Type, k reflect.Kind,
+ args Arguments) error {
+
+ switch k {
+ case reflect.Struct:
+ case reflect.Slice, reflect.Array:
+ if minLen := args.LengthNonIndexed(); v.Len() < minLen {
+ return fmt.Errorf("abi: insufficient number of elements in the list/array for unpack, want %d, got %d",
+ minLen, v.Len())
+ }
+ default:
+ return fmt.Errorf("abi: cannot unmarshal tuple into %v", t)
+ }
+ return nil
+}