diff options
Diffstat (limited to 'accounts/abi/reflect.go')
-rw-r--r-- | accounts/abi/reflect.go | 17 |
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 +} |