@@ -67,6 +67,7 @@ func (arguments Arguments) LengthNonIndexed() int {
6767 return out
6868}
6969
70+ // NonIndexed returns the arguments with indexed arguments filtered out
7071func (arguments Arguments ) NonIndexed () Arguments {
7172 var ret []Argument
7273 for _ , arg := range arguments {
@@ -89,12 +90,10 @@ func (arguments Arguments) Unpack(v interface{}, data []byte) error {
8990 if reflect .Ptr != reflect .ValueOf (v ).Kind () {
9091 return fmt .Errorf ("abi: Unpack(non-pointer %T)" , v )
9192 }
92-
9393 marshalledValues , err := arguments .UnpackValues (data )
9494 if err != nil {
9595 return err
9696 }
97-
9897 if arguments .isTuple () {
9998 return arguments .unpackTuple (v , marshalledValues )
10099 }
@@ -162,11 +161,9 @@ func (arguments Arguments) unpackTuple(v interface{}, marshalledValues []interfa
162161
163162// unpackAtomic unpacks ( hexdata -> go ) a single value
164163func (arguments Arguments ) unpackAtomic (v interface {}, marshalledValues []interface {}) error {
165-
166164 if len (marshalledValues ) != 1 {
167165 return fmt .Errorf ("abi: wrong length, expected single value, got %d" , len (marshalledValues ))
168166 }
169-
170167 elem := reflect .ValueOf (v ).Elem ()
171168 reflectValue := reflect .ValueOf (marshalledValues [0 ])
172169 return set (elem , reflectValue , arguments .NonIndexed ()[0 ])
@@ -176,24 +173,18 @@ func (arguments Arguments) unpackAtomic(v interface{}, marshalledValues []interf
176173// without supplying a struct to unpack into. Instead, this method returns a list containing the
177174// values. An atomic argument will be a list with one element.
178175func (arguments Arguments ) UnpackValues (data []byte ) ([]interface {}, error ) {
179-
180176 retval := make ([]interface {}, 0 , arguments .LengthNonIndexed ())
181-
182177 virtualArgs := 0
183-
184178 for index , arg := range arguments .NonIndexed () {
185-
186179 marshalledValue , err := toGoType ((index + virtualArgs )* 32 , arg .Type , data )
187-
188180 if arg .Type .T == ArrayTy {
189- //If we have a static array, like [3]uint256, these are coded as
181+ // If we have a static array, like [3]uint256, these are coded as
190182 // just like uint256,uint256,uint256.
191183 // This means that we need to add two 'virtual' arguments when
192184 // we count the index from now on
193185
194186 virtualArgs += arg .Type .Size - 1
195187 }
196-
197188 if err != nil {
198189 return nil , err
199190 }
@@ -202,7 +193,7 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
202193 return retval , nil
203194}
204195
205- // UnpackValues performs the operation Go format -> Hexdata
196+ // PackValues performs the operation Go format -> Hexdata
206197// It is the semantic opposite of UnpackValues
207198func (arguments Arguments ) PackValues (args []interface {}) ([]byte , error ) {
208199 return arguments .Pack (args ... )
@@ -215,7 +206,6 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
215206 if len (args ) != len (abiArgs ) {
216207 return nil , fmt .Errorf ("argument count mismatch: %d for %d" , len (args ), len (abiArgs ))
217208 }
218-
219209 // variable input is the output appended at the end of packed
220210 // output. This is used for strings and bytes types input.
221211 var variableInput []byte
@@ -229,7 +219,6 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
229219 inputOffset += 32
230220 }
231221 }
232-
233222 var ret []byte
234223 for i , a := range args {
235224 input := abiArgs [i ]
@@ -238,7 +227,6 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
238227 if err != nil {
239228 return nil , err
240229 }
241-
242230 // check for a slice type (string, bytes, slice)
243231 if input .Type .requiresLengthPrefix () {
244232 // calculate the offset
0 commit comments