accounts/abi: fixed tuple unpack

This commit is contained in:
Marius van der Wijden 2020-05-02 16:40:39 +02:00
parent b7f9ce5e45
commit bd38dc1cca

View file

@ -110,7 +110,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array") return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array")
} }
// convert // convert
array := reflect.New(reflect.ArrayOf(t.Size, reflect.TypeOf(byte(0)))).Elem() array := reflect.New(t.getType()).Elem()
reflect.Copy(array, reflect.ValueOf(word[0:t.Size])) reflect.Copy(array, reflect.ValueOf(word[0:t.Size]))
return array.Interface(), nil return array.Interface(), nil
@ -158,7 +158,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
} }
func forTupleUnpack(t Type, output []byte) (interface{}, error) { func forTupleUnpack(t Type, output []byte) (interface{}, error) {
retval := reflect.New(t.getType()) retval := reflect.New(t.getType()).Elem()
virtualArgs := 0 virtualArgs := 0
for index, elem := range t.TupleElems { for index, elem := range t.TupleElems {
marshalledValue, err := ToGoType((index+virtualArgs)*32, *elem, output) marshalledValue, err := ToGoType((index+virtualArgs)*32, *elem, output)