aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/reflect.go
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/abi/reflect.go')
-rw-r--r--accounts/abi/reflect.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/accounts/abi/reflect.go b/accounts/abi/reflect.go
index e953b77c1..7a9cdacd5 100644
--- a/accounts/abi/reflect.go
+++ b/accounts/abi/reflect.go
@@ -85,3 +85,28 @@ func set(dst, src reflect.Value, output Argument) error {
}
return nil
}
+
+// requireAssignable assures that `dest` is a pointer and it's not an interface.
+func requireAssignable(dst, src reflect.Value) error {
+ if dst.Kind() != reflect.Ptr && dst.Kind() != reflect.Interface {
+ return fmt.Errorf("abi: cannot unmarshal %v into %v", src.Type(), dst.Type())
+ }
+ 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
+}