@@ -358,19 +358,21 @@ def _align_abi_input(arg_abi, arg):
358358
359359 if isinstance (arg , abc .Mapping ):
360360 # Arg is mapping. Align values according to abi order.
361- arg = tuple (arg [abi ['name' ]] for abi in sub_abis )
361+ aligned_arg = tuple (arg [abi ['name' ]] for abi in sub_abis )
362+ else :
363+ aligned_arg = arg
362364
363- if not is_list_like (arg ):
365+ if not is_list_like (aligned_arg ):
364366 raise TypeError (
365367 'Expected non-string sequence for "{}" component type: got {}' .format (
366368 arg_abi ['type' ],
367- arg ,
369+ aligned_arg ,
368370 ),
369371 )
370372
371- return type (arg )(
373+ return type (aligned_arg )(
372374 _align_abi_input (sub_abi , sub_arg )
373- for sub_abi , sub_arg in zip (sub_abis , arg )
375+ for sub_abi , sub_arg in zip (sub_abis , aligned_arg )
374376 )
375377
376378
@@ -668,34 +670,39 @@ def __new__(cls, iterable):
668670 return super ().__new__ (cls , * iterable )
669671
670672
671- def abi_sub_tree (abi_type : Optional [Union [TypeStr , ABIType ]], data_value : Any ) -> ABITypedData :
672- if abi_type is None :
673+ def abi_sub_tree (type_str_or_abi_type : Optional [Union [TypeStr , ABIType ]],
674+ data_value : Any ) -> ABITypedData :
675+ if type_str_or_abi_type is None :
673676 return ABITypedData ([None , data_value ])
674677
675- if isinstance (abi_type , TypeStr ):
676- abi_type = parse (abi_type )
678+ if isinstance (type_str_or_abi_type , TypeStr ):
679+ abi_type = parse (type_str_or_abi_type )
680+ else :
681+ abi_type = type_str_or_abi_type
677682
678683 # In the two special cases below, we rebuild the given data structures with
679684 # annotated items
680685 if abi_type .is_array :
681686 # If type is array, determine item type and annotate all
682687 # items in iterable with that type
683688 item_type_str = abi_type .item_type .to_type_str ()
684- data_value = [
689+ value_to_annotate = [
685690 abi_sub_tree (item_type_str , item_value )
686691 for item_value in data_value
687692 ]
688693 elif isinstance (abi_type , TupleType ):
689694 # Otherwise, if type is tuple, determine component types and annotate
690695 # tuple components in iterable respectively with those types
691- data_value = type (data_value )(
696+ value_to_annotate = type (data_value )(
692697 abi_sub_tree (comp_type .to_type_str (), comp_value )
693698 for comp_type , comp_value in zip (abi_type .components , data_value )
694699 )
700+ else :
701+ value_to_annotate = data_value
695702
696703 return ABITypedData ([
697704 abi_type .to_type_str (),
698- data_value ,
705+ value_to_annotate ,
699706 ])
700707
701708
0 commit comments