73
73
)
74
74
from eth_utils .toolz import (
75
75
curry ,
76
- partial ,
77
76
pipe ,
78
77
)
79
78
@@ -611,17 +610,19 @@ def normalizer(datatype, data):
611
610
2. Recursively mapping each of the normalizers to the data
612
611
3. Stripping the types back out of the tree
613
612
"""
614
- pipeline = itertools .chain (
615
- [abi_data_tree (types )],
616
- map (data_tree_map , normalizers ),
617
- [partial (recursive_map , strip_abi_type )],
613
+ return pipe (
614
+ data ,
615
+ # 1. Decorating the data tree with types
616
+ abi_data_tree (types ),
617
+ # 2. Recursively mapping each of the normalizers to the data
618
+ * map (data_tree_map , normalizers ),
619
+ # 3. Stripping the types back out of the tree
620
+ strip_abi_types ,
618
621
)
619
622
620
- return pipe (data , * pipeline )
621
-
622
623
623
624
@curry
624
- def abi_data_tree (types : Sequence [TypeStr ], data : Sequence [Any ]) -> List [Any ]:
625
+ def abi_data_tree (types : Sequence [TypeStr ], data : Sequence [Any ]) -> List ["ABITypedData" ]:
625
626
"""
626
627
Decorate the data tree with pairs of (type, data). The pair tuple is actually an
627
628
ABITypedData, but can be accessed as a tuple.
@@ -631,10 +632,7 @@ def abi_data_tree(types: Sequence[TypeStr], data: Sequence[Any]) -> List[Any]:
631
632
>>> abi_data_tree(types=["bool[2]", "uint"], data=[[True, False], 0])
632
633
[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]
633
634
"""
634
- return [
635
- abi_sub_tree (data_type , data_value )
636
- for data_type , data_value in zip (types , data )
637
- ]
635
+ return list (map (abi_sub_tree , types , data ))
638
636
639
637
640
638
@curry
@@ -723,6 +721,10 @@ def strip_abi_type(elements: Any) -> Any:
723
721
return elements
724
722
725
723
724
+ def strip_abi_types (elements : Any ) -> Any :
725
+ return recursive_map (strip_abi_type , elements )
726
+
727
+
726
728
def build_non_strict_registry () -> ABIRegistry :
727
729
# We make a copy here just to make sure that eth-abi's default registry is not
728
730
# affected by our custom encoder subclasses
0 commit comments