Skip to content

Commit 1709f03

Browse files
author
pacrob
committed
remove change to decode_function_input to a separate pr
1 parent 9febd3d commit 1709f03

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

web3/_utils/abi.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,10 @@ def build_strict_registry() -> ABIRegistry:
908908
return registry
909909

910910

911-
def named_tree(abi: List[Dict[str, Any]], data: Tuple[Any, ...]) -> Dict[str, Any]:
911+
# def named_tree(abi: List[Dict[str, Any]], data: Tuple[Any, ...]) -> Dict[str, Any]:
912+
def named_tree(
913+
abi: Sequence[ABIFunctionParams], data: Tuple[Any, ...]
914+
) -> Dict[str, Any]:
912915
"""
913916
Convert function inputs/outputs or event data tuple to dict with names from ABI.
914917
"""

web3/contract/base_contract.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
check_if_arguments_can_be_encoded,
4444
fallback_func_abi_exists,
4545
filter_by_type,
46+
get_abi_input_names,
47+
get_abi_input_types,
4648
get_constructor_abi,
4749
is_array_type,
50+
map_abi_data,
4851
merge_args_and_kwargs,
4952
receive_func_abi_exists,
5053
)
5154
from web3._utils.contracts import (
52-
decode_transaction_data,
5355
encode_abi,
5456
find_matching_event_abi,
5557
find_matching_fn_abi,
@@ -253,11 +255,16 @@ def decode_function_input(
253255
) -> Tuple["BaseContractFunction", Dict[str, Any]]:
254256
# type ignored b/c expects data arg to be HexBytes
255257
data = HexBytes(data) # type: ignore
256-
func = self.get_function_by_selector(data[:4])
257-
arguments = decode_transaction_data(
258-
func.abi, data, normalizers=BASE_RETURN_NORMALIZERS
259-
)
260-
return func, arguments
258+
selector, params = data[:4], data[4:]
259+
func = self.get_function_by_selector(selector)
260+
261+
names = get_abi_input_names(func.abi)
262+
types = get_abi_input_types(func.abi)
263+
264+
decoded = self.w3.codec.decode(types, cast(HexBytes, params))
265+
normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded)
266+
267+
return func, dict(zip(names, normalized))
261268

262269
@combomethod
263270
def find_functions_by_args(self, *args: Any) -> "BaseContractFunction":

0 commit comments

Comments
 (0)