@@ -77,18 +77,18 @@ func (arguments Arguments) isTuple() bool {
77
77
}
78
78
79
79
// Unpack performs the operation hexdata -> Go format.
80
- func (arguments Arguments ) Unpack (data []byte ) ([]interface {} , error ) {
80
+ func (arguments Arguments ) Unpack (data []byte ) ([]any , error ) {
81
81
if len (data ) == 0 {
82
82
if len (arguments .NonIndexed ()) != 0 {
83
83
return nil , errors .New ("abi: attempting to unmarshal an empty string while arguments are expected" )
84
84
}
85
- return make ([]interface {} , 0 ), nil
85
+ return make ([]any , 0 ), nil
86
86
}
87
87
return arguments .UnpackValues (data )
88
88
}
89
89
90
90
// UnpackIntoMap performs the operation hexdata -> mapping of argument name to argument value.
91
- func (arguments Arguments ) UnpackIntoMap (v map [string ]interface {} , data []byte ) error {
91
+ func (arguments Arguments ) UnpackIntoMap (v map [string ]any , data []byte ) error {
92
92
// Make sure map is not nil
93
93
if v == nil {
94
94
return errors .New ("abi: cannot unpack into a nil map" )
@@ -110,7 +110,7 @@ func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte)
110
110
}
111
111
112
112
// Copy performs the operation go format -> provided struct.
113
- func (arguments Arguments ) Copy (v interface {} , values []interface {} ) error {
113
+ func (arguments Arguments ) Copy (v any , values []any ) error {
114
114
// make sure the passed value is arguments pointer
115
115
if reflect .Ptr != reflect .ValueOf (v ).Kind () {
116
116
return fmt .Errorf ("abi: Unpack(non-pointer %T)" , v )
@@ -128,7 +128,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
128
128
}
129
129
130
130
// copyAtomic copies ( hexdata -> go ) a single value
131
- func (arguments Arguments ) copyAtomic (v interface {} , marshalledValues interface {} ) error {
131
+ func (arguments Arguments ) copyAtomic (v any , marshalledValues any ) error {
132
132
dst := reflect .ValueOf (v ).Elem ()
133
133
src := reflect .ValueOf (marshalledValues )
134
134
@@ -139,7 +139,7 @@ func (arguments Arguments) copyAtomic(v interface{}, marshalledValues interface{
139
139
}
140
140
141
141
// copyTuple copies a batch of values from marshalledValues to v.
142
- func (arguments Arguments ) copyTuple (v interface {} , marshalledValues []interface {} ) error {
142
+ func (arguments Arguments ) copyTuple (v any , marshalledValues []any ) error {
143
143
value := reflect .ValueOf (v ).Elem ()
144
144
nonIndexedArgs := arguments .NonIndexed ()
145
145
@@ -181,11 +181,17 @@ func (arguments Arguments) copyTuple(v interface{}, marshalledValues []interface
181
181
// UnpackValues can be used to unpack ABI-encoded hexdata according to the ABI-specification,
182
182
// without supplying a struct to unpack into. Instead, this method returns a list containing the
183
183
// values. An atomic argument will be a list with one element.
184
- func (arguments Arguments ) UnpackValues (data []byte ) ([]interface {}, error ) {
185
- nonIndexedArgs := arguments .NonIndexed ()
186
- retval := make ([]interface {}, 0 , len (nonIndexedArgs ))
187
- virtualArgs := 0
188
- for index , arg := range nonIndexedArgs {
184
+ func (arguments Arguments ) UnpackValues (data []byte ) ([]any , error ) {
185
+ var (
186
+ retval = make ([]any , 0 )
187
+ virtualArgs = 0
188
+ index = 0
189
+ )
190
+
191
+ for _ , arg := range arguments {
192
+ if arg .Indexed {
193
+ continue
194
+ }
189
195
marshalledValue , err := toGoType ((index + virtualArgs )* 32 , arg .Type , data )
190
196
if err != nil {
191
197
return nil , err
@@ -208,18 +214,19 @@ func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error) {
208
214
virtualArgs += getTypeSize (arg .Type )/ 32 - 1
209
215
}
210
216
retval = append (retval , marshalledValue )
217
+ index ++
211
218
}
212
219
return retval , nil
213
220
}
214
221
215
222
// PackValues performs the operation Go format -> Hexdata.
216
223
// It is the semantic opposite of UnpackValues.
217
- func (arguments Arguments ) PackValues (args []interface {} ) ([]byte , error ) {
224
+ func (arguments Arguments ) PackValues (args []any ) ([]byte , error ) {
218
225
return arguments .Pack (args ... )
219
226
}
220
227
221
228
// Pack performs the operation Go format -> Hexdata.
222
- func (arguments Arguments ) Pack (args ... interface {} ) ([]byte , error ) {
229
+ func (arguments Arguments ) Pack (args ... any ) ([]byte , error ) {
223
230
// Make sure arguments match up and pack them
224
231
abiArgs := arguments
225
232
if len (args ) != len (abiArgs ) {
0 commit comments