aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/type.go
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/abi/type.go')
-rw-r--r--accounts/abi/type.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/accounts/abi/type.go b/accounts/abi/type.go
index b16822d3b..16d7491e7 100644
--- a/accounts/abi/type.go
+++ b/accounts/abi/type.go
@@ -43,7 +43,7 @@ type Type struct {
stringKind string // holds the unparsed string for deriving signatures
}
-// New type returns a fully parsed Type given by the input string or an error if it can't be parsed.
+// NewType returns a fully parsed Type given by the input string or an error if it can't be parsed.
//
// Strings can be in the format of:
//
@@ -130,6 +130,10 @@ func NewType(t string) (typ Type, err error) {
if vsize > 0 {
typ.Size = 32
}
+ case "bytes":
+ typ.Kind = reflect.Slice
+ typ.Type = byte_ts
+ typ.Size = vsize
default:
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}
@@ -200,7 +204,13 @@ func (t Type) pack(v interface{}) ([]byte, error) {
} else {
return common.LeftPadBytes(common.Big0.Bytes(), 32), nil
}
+ case reflect.Array:
+ if v, ok := value.Interface().(common.Address); ok {
+ return t.pack(v[:])
+ } else if v, ok := value.Interface().(common.Hash); ok {
+ return t.pack(v[:])
+ }
}
- panic("unreached")
+ return nil, fmt.Errorf("ABI: bad input given %T", value.Kind())
}