@@ -235,13 +235,13 @@ def check_if_arguments_can_be_encoded(function_abi, args, kwargs):
235
235
return False
236
236
237
237
try :
238
- types , arguments = get_abi_inputs (function_abi , arguments )
238
+ types , aligned_args = get_aligned_abi_inputs (function_abi , arguments )
239
239
except TypeError :
240
240
return False
241
241
242
242
return all (
243
243
is_encodable (_type , arg )
244
- for _type , arg in zip (types , arguments )
244
+ for _type , arg in zip (types , aligned_args )
245
245
)
246
246
247
247
@@ -332,13 +332,13 @@ def get_tuple_type_str_parts(s: str) -> Optional[Tuple[str, Optional[str]]]:
332
332
return None
333
333
334
334
335
- def _convert_abi_input (comp , arg ):
335
+ def _convert_abi_input (arg_abi , arg ):
336
336
"""
337
- Converts an argument ``arg`` corresponding to an ABI component ``comp ``
337
+ Converts an argument ``arg`` corresponding to an ABI component ``arg_abi ``
338
338
into a plain value (for non-tuple components) or a properly converted and
339
339
ordered sequence (for tuple list components or tuple components).
340
340
"""
341
- tuple_parts = get_tuple_type_str_parts (comp ['type' ])
341
+ tuple_parts = get_tuple_type_str_parts (arg_abi ['type' ])
342
342
343
343
if tuple_parts is None :
344
344
# Component is non-tuple. Just return value.
@@ -348,37 +348,37 @@ def _convert_abi_input(comp, arg):
348
348
if tuple_dims is None :
349
349
# Component is non-list tuple. Each sub component of tuple will be
350
350
# applied to each element in `arg`.
351
- sub_comps = comp ['components' ]
351
+ sub_abis = arg_abi ['components' ]
352
352
else :
353
353
# Component is list tuple. A non-list version of this component will be
354
354
# repeatedly applied to each element in `arg`.
355
- new_comp = copy .copy (comp )
356
- new_comp ['type' ] = tuple_prefix
355
+ new_abi = copy .copy (arg_abi )
356
+ new_abi ['type' ] = tuple_prefix
357
357
358
- sub_comps = itertools .repeat (new_comp )
358
+ sub_abis = itertools .repeat (new_abi )
359
359
360
360
if isinstance (arg , abc .Mapping ):
361
361
# Arg is mapping. Convert to properly ordered sequence.
362
- arg = tuple (arg [c ['name' ]] for c in sub_comps )
362
+ arg = tuple (arg [c ['name' ]] for c in sub_abis )
363
363
364
364
if not is_list_like (arg ):
365
365
raise TypeError (
366
366
'Expected non-string sequence for "{}" component type: got {}' .format (
367
- comp ['type' ],
367
+ arg_abi ['type' ],
368
368
arg ,
369
369
),
370
370
)
371
371
372
- return type (arg )(_convert_abi_input (c , a ) for c , a in zip (sub_comps , arg ))
372
+ return type (arg )(_convert_abi_input (c , a ) for c , a in zip (sub_abis , arg ))
373
373
374
374
375
- def get_abi_inputs (abi , args ):
375
+ def get_aligned_abi_inputs (abi , args ):
376
376
"""
377
- Takes a function ABI (``abi``) and a sequence or mapping of args
378
- (``args``). Returns a list of canonical type names for the function's
379
- inputs and a list of arguments in corresponding order . The args contained
380
- in ``args`` may contain nested mappings or sequences corresponding to
381
- tuple-encoded values in ``abi``.
377
+ Takes a function ABI (``abi``) and a sequence or mapping of args (``args``).
378
+ Returns a list of type strings for the function's inputs and a list of
379
+ arguments which have been aligned to the layout of those types . The args
380
+ contained in ``args`` may contain nested mappings or sequences corresponding
381
+ to tuple-encoded values in ``abi``.
382
382
"""
383
383
inputs = abi .get ('inputs' , [])
384
384
0 commit comments