From e99fad669336f9b28ceb04acb52a240ad3ca1731 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 29 Sep 2022 11:47:12 +0300 Subject: [PATCH] accounts/abi: return toGoType error immediately (#25565) --- accounts/abi/argument.go | 6 +++--- accounts/abi/unpack.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accounts/abi/argument.go b/accounts/abi/argument.go index ed204e0a81dd..2e48d539e0dc 100644 --- a/accounts/abi/argument.go +++ b/accounts/abi/argument.go @@ -187,6 +187,9 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) { virtualArgs := 0 for index, arg := range nonIndexedArgs { marshalledValue, err := toGoType((index+virtualArgs)*32, arg.Type, data) + if err != nil { + return nil, err + } if arg.Type.T == ArrayTy && !isDynamicType(arg.Type) { // If we have a static array, like [3]uint256, these are coded as // just like uint256,uint256,uint256. @@ -204,9 +207,6 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) { // coded as just like uint256,bool,uint256 virtualArgs += getTypeSize(arg.Type)/32 - 1 } - if err != nil { - return nil, err - } retval = append(retval, marshalledValue) } return retval, nil diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 0de99cd2b68c..b6ca0a038480 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -162,6 +162,9 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) { virtualArgs := 0 for index, elem := range t.TupleElems { marshalledValue, err := toGoType((index+virtualArgs)*32, *elem, output) + if err != nil { + return nil, err + } if elem.T == ArrayTy && !isDynamicType(*elem) { // If we have a static array, like [3]uint256, these are coded as // just like uint256,uint256,uint256. @@ -179,9 +182,6 @@ func forTupleUnpack(t Type, output []byte) (interface{}, error) { // coded as just like uint256,bool,uint256 virtualArgs += getTypeSize(*elem)/32 - 1 } - if err != nil { - return nil, err - } retval.Field(index).Set(reflect.ValueOf(marshalledValue)) } return retval.Interface(), nil