fix string array unpack bug in accounts/abi (#18364)

This commit is contained in:
weimumu
2018-12-28 15:43:55 +08:00
committed by Guillaume Ballet
parent 9e9fc87e70
commit 735343430d
3 changed files with 69 additions and 1 deletions

View File

@ -195,8 +195,15 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
switch t.T {
case SliceTy:
if (*t.Elem).T == StringTy {
return forEachUnpack(t, output[begin:], 0, end)
}
return forEachUnpack(t, output, begin, end)
case ArrayTy:
if (*t.Elem).T == StringTy {
offset := int64(binary.BigEndian.Uint64(returnOutput[len(returnOutput)-8:]))
return forEachUnpack(t, output[offset:], 0, t.Size)
}
return forEachUnpack(t, output, index, t.Size)
case StringTy: // variable arrays are written at the end of the return bytes
return string(output[begin : begin+end]), nil