accounts/abi: ABI fixes & added types
Changed field `input` to new `inputs`. Addad Hash and Address as input types. Added bytes[N] and N validation
This commit is contained in:
@ -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())
|
||||
}
|
||||
|
Reference in New Issue
Block a user