|
65 | 65 | to_tuple, |
66 | 66 | ) |
67 | 67 | from eth_utils.abi import ( |
68 | | - collapse_if_tuple, |
69 | 68 | get_abi_input_names, |
| 69 | + get_normalized_abi_arg_type, |
70 | 70 | get_normalized_abi_inputs, |
71 | 71 | ) |
72 | 72 | from eth_utils.toolz import ( |
@@ -120,14 +120,20 @@ def get_abi_input_types(abi: ABIFunction) -> List[str]: |
120 | 120 | if "inputs" not in abi and (abi["type"] == "fallback" or abi["type"] == "receive"): |
121 | 121 | return [] |
122 | 122 | else: |
123 | | - return [collapse_if_tuple(cast(Dict[str, Any], arg)) for arg in abi["inputs"]] |
| 123 | + return [ |
| 124 | + get_normalized_abi_arg_type(cast(Dict[str, Any], arg)) |
| 125 | + for arg in abi["inputs"] |
| 126 | + ] |
124 | 127 |
|
125 | 128 |
|
126 | 129 | def get_abi_output_types(abi: ABIFunction) -> List[str]: |
127 | 130 | if abi["type"] == "fallback": |
128 | 131 | return [] |
129 | 132 | else: |
130 | | - return [collapse_if_tuple(cast(Dict[str, Any], arg)) for arg in abi["outputs"]] |
| 133 | + return [ |
| 134 | + get_normalized_abi_arg_type(cast(Dict[str, Any], arg)) |
| 135 | + for arg in abi["outputs"] |
| 136 | + ] |
131 | 137 |
|
132 | 138 |
|
133 | 139 | def get_receive_func_abi(contract_abi: ABI) -> ABIFunction: |
@@ -162,18 +168,6 @@ def exclude_indexed_event_inputs(event_abi: ABIEvent) -> List[ABIComponent]: |
162 | 168 | return [arg for arg in event_abi["inputs"] if arg["indexed"] is False] |
163 | 169 |
|
164 | 170 |
|
165 | | -def get_normalized_abi_arg_type( |
166 | | - abi_arg: Union[ABIComponent, ABIComponentIndexed] |
167 | | -) -> str: |
168 | | - """ |
169 | | - Return the normalized type for the abi argument provided. |
170 | | - In order to account for tuple argument types, this abstraction |
171 | | - makes use of `collapse_if_tuple()` to collapse the appropriate component |
172 | | - types within a tuple type, if present. |
173 | | - """ |
174 | | - return collapse_if_tuple(dict(abi_arg)) |
175 | | - |
176 | | - |
177 | 171 | def filter_by_argument_count( |
178 | 172 | num_arguments: int, contract_abi: ABI |
179 | 173 | ) -> List[Union[ABIFunction, ABIEvent]]: |
@@ -471,7 +465,7 @@ def get_aligned_abi_inputs( |
471 | 465 | args = tuple(args[abi["name"]] for abi in input_abis) |
472 | 466 |
|
473 | 467 | return ( |
474 | | - tuple(collapse_if_tuple(abi) for abi in input_abis), |
| 468 | + tuple(get_normalized_abi_arg_type(abi) for abi in input_abis), |
475 | 469 | type(args)(_align_abi_input(abi, arg) for abi, arg in zip(input_abis, args)), |
476 | 470 | ) |
477 | 471 |
|
@@ -625,7 +619,7 @@ def abi_to_signature(abi: Union[ABIFunction, ABIEvent]) -> str: |
625 | 619 | function_signature = "{fn_name}({fn_input_types})".format( |
626 | 620 | fn_name=abi["name"], |
627 | 621 | fn_input_types=",".join( |
628 | | - collapse_if_tuple(dict(arg)) |
| 622 | + get_normalized_abi_arg_type(dict(arg)) |
629 | 623 | for arg in normalize_event_input_types(abi.get("inputs", [])) |
630 | 624 | ), |
631 | 625 | ) |
@@ -869,12 +863,10 @@ def named_tree( |
869 | 863 |
|
870 | 864 |
|
871 | 865 | def _named_subtree( |
872 | | - abi: Union[ |
873 | | - ABIComponent, ABIComponentIndexed, ABIFunction, ABIEvent, Dict[TypeStr, Any] |
874 | | - ], |
| 866 | + abi: Union[ABIComponent, ABIComponentIndexed], |
875 | 867 | data: Tuple[Any, ...], |
876 | 868 | ) -> Union[Dict[str, Any], Tuple[Any, ...], List[Any]]: |
877 | | - abi_type = parse(collapse_if_tuple(dict(abi))) |
| 869 | + abi_type = parse(get_normalized_abi_arg_type(abi)) |
878 | 870 |
|
879 | 871 | if abi_type.is_array: |
880 | 872 | item_type = abi_type.item_type.to_type_str() |
|
0 commit comments