accounts/abi: fixed return tuple and string, bytes return type parsing

Removed old unmarshalling of return types: `abi.Call(...).([]byte)`.
This is now replaced by a new syntax:

```
var a []byte
err := abi.Call(&a, ...)
```

It also addresses a few issues with Bytes and Strings and can also
handle both fixed and arbitrary sized byte slices, including strings.
This commit is contained in:
Jeffrey Wilcke
2016-02-09 13:57:00 +01:00
parent 856b9e9c50
commit ecc876cec0
3 changed files with 363 additions and 30 deletions

View File

@ -29,8 +29,11 @@ const (
IntTy byte = iota
UintTy
BoolTy
StringTy
SliceTy
AddressTy
FixedBytesTy
BytesTy
HashTy
RealTy
)
@ -118,6 +121,7 @@ func NewType(t string) (typ Type, err error) {
typ.T = UintTy
case "bool":
typ.Kind = reflect.Bool
typ.T = BoolTy
case "real": // TODO
typ.Kind = reflect.Invalid
case "address":
@ -128,6 +132,7 @@ func NewType(t string) (typ Type, err error) {
case "string":
typ.Kind = reflect.String
typ.Size = -1
typ.T = StringTy
if vsize > 0 {
typ.Size = 32
}
@ -140,6 +145,11 @@ func NewType(t string) (typ Type, err error) {
typ.Kind = reflect.Slice
typ.Type = byte_ts
typ.Size = vsize
if vsize == 0 {
typ.T = BytesTy
} else {
typ.T = FixedBytesTy
}
default:
return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}