web3 6.20.2__py3-none-any.whl → 7.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ens/__init__.py +13 -2
- ens/_normalization.py +2 -17
- ens/async_ens.py +33 -21
- ens/base_ens.py +3 -1
- ens/ens.py +16 -11
- ens/exceptions.py +16 -29
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +52 -63
- web3/__init__.py +20 -24
- web3/_utils/abi.py +115 -271
- web3/_utils/async_transactions.py +7 -4
- web3/_utils/batching.py +217 -0
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching.py +128 -5
- web3/_utils/compat/__init__.py +2 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
- web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/event_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
- web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
- web3/_utils/contracts.py +130 -236
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +13 -23
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +16 -12
- web3/_utils/ens.py +2 -1
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +66 -69
- web3/_utils/fee_utils.py +1 -3
- web3/_utils/filters.py +24 -22
- web3/_utils/formatters.py +2 -2
- web3/_utils/http.py +5 -3
- web3/_utils/http_session_manager.py +303 -0
- web3/_utils/math.py +14 -15
- web3/_utils/method_formatters.py +34 -36
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +695 -643
- web3/_utils/module_testing/module_testing_utils.py +61 -34
- web3/_utils/module_testing/persistent_connection_provider.py +56 -25
- web3/_utils/module_testing/utils.py +258 -0
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/normalizers.py +13 -11
- web3/_utils/rpc_abi.py +5 -32
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +14 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +17 -17
- web3/auto/gethdev.py +7 -2
- web3/beacon/__init__.py +6 -1
- web3/beacon/async_beacon.py +9 -5
- web3/beacon/{main.py → beacon.py} +7 -5
- web3/contract/__init__.py +7 -0
- web3/contract/async_contract.py +47 -46
- web3/contract/base_contract.py +183 -158
- web3/contract/contract.py +49 -43
- web3/contract/utils.py +203 -59
- web3/datastructures.py +79 -31
- web3/eth/__init__.py +7 -0
- web3/eth/async_eth.py +39 -51
- web3/eth/base_eth.py +17 -10
- web3/eth/eth.py +30 -68
- web3/exceptions.py +108 -82
- web3/gas_strategies/time_based.py +8 -6
- web3/geth.py +1 -254
- web3/main.py +75 -122
- web3/manager.py +316 -146
- web3/method.py +38 -31
- web3/middleware/__init__.py +67 -89
- web3/middleware/attrdict.py +36 -49
- web3/middleware/base.py +174 -0
- web3/middleware/buffered_gas_estimate.py +20 -21
- web3/middleware/filter.py +157 -117
- web3/middleware/formatting.py +124 -108
- web3/middleware/gas_price_strategy.py +20 -32
- web3/middleware/names.py +29 -26
- web3/middleware/proof_of_authority.py +68 -0
- web3/middleware/pythonic.py +2 -2
- web3/middleware/signing.py +74 -89
- web3/middleware/stalecheck.py +52 -79
- web3/middleware/validation.py +5 -13
- web3/module.py +54 -10
- web3/providers/__init__.py +10 -6
- web3/providers/async_base.py +117 -39
- web3/providers/auto.py +3 -3
- web3/providers/base.py +89 -33
- web3/providers/eth_tester/__init__.py +5 -0
- web3/providers/eth_tester/defaults.py +1 -64
- web3/providers/eth_tester/main.py +99 -31
- web3/providers/eth_tester/middleware.py +45 -73
- web3/providers/ipc.py +42 -46
- web3/providers/{websocket/websocket.py → legacy_websocket.py} +32 -7
- web3/providers/persistent/__init__.py +22 -0
- web3/providers/persistent/async_ipc.py +153 -0
- web3/providers/{persistent.py → persistent/persistent.py} +106 -25
- web3/providers/persistent/persistent_connection.py +84 -0
- web3/providers/{websocket → persistent}/request_processor.py +94 -32
- web3/providers/persistent/utils.py +43 -0
- web3/providers/{websocket/websocket_v2.py → persistent/websocket.py} +29 -28
- web3/providers/rpc/__init__.py +11 -0
- web3/providers/rpc/async_rpc.py +171 -0
- web3/providers/rpc/rpc.py +179 -0
- web3/providers/rpc/utils.py +92 -0
- web3/testing.py +4 -4
- web3/tools/benchmark/main.py +22 -22
- web3/tools/benchmark/node.py +2 -8
- web3/tools/benchmark/reporting.py +2 -2
- web3/tools/benchmark/utils.py +1 -1
- web3/tracing.py +9 -5
- web3/types.py +30 -107
- web3/utils/__init__.py +58 -5
- web3/utils/abi.py +575 -10
- web3/utils/async_exception_handling.py +19 -7
- web3/utils/caching.py +32 -13
- web3/utils/exception_handling.py +7 -5
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/LICENSE +1 -1
- web3-7.0.0.dist-info/METADATA +112 -0
- web3-7.0.0.dist-info/RECORD +167 -0
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/WHEEL +1 -1
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/top_level.txt +0 -1
- ethpm/__init__.py +0 -20
- ethpm/_utils/__init__.py +0 -0
- ethpm/_utils/backend.py +0 -93
- ethpm/_utils/cache.py +0 -44
- ethpm/_utils/chains.py +0 -119
- ethpm/_utils/contract.py +0 -35
- ethpm/_utils/deployments.py +0 -145
- ethpm/_utils/ipfs.py +0 -116
- ethpm/_utils/protobuf/__init__.py +0 -0
- ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
- ethpm/_utils/registry.py +0 -29
- ethpm/assets/__init__.py +0 -0
- ethpm/assets/ens/v3.json +0 -1
- ethpm/assets/escrow/with_bytecode_v3.json +0 -1
- ethpm/assets/ipfs_file.proto +0 -32
- ethpm/assets/owned/output_v3.json +0 -1
- ethpm/assets/owned/with_contract_type_v3.json +0 -1
- ethpm/assets/registry/contracts/Authority.sol +0 -156
- ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
- ethpm/assets/registry/contracts/PackageDB.sol +0 -225
- ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
- ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
- ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
- ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
- ethpm/assets/registry/solc_input.json +0 -1
- ethpm/assets/registry/solc_output.json +0 -1
- ethpm/assets/registry/v3.json +0 -1
- ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
- ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
- ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
- ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
- ethpm/assets/simple-registry/solc_input.json +0 -33
- ethpm/assets/simple-registry/solc_output.json +0 -1
- ethpm/assets/simple-registry/v3.json +0 -1
- ethpm/assets/standard-token/output_v3.json +0 -1
- ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
- ethpm/assets/vyper_registry/0.1.0.json +0 -1
- ethpm/assets/vyper_registry/registry.vy +0 -216
- ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
- ethpm/backends/__init__.py +0 -0
- ethpm/backends/base.py +0 -43
- ethpm/backends/http.py +0 -108
- ethpm/backends/ipfs.py +0 -219
- ethpm/backends/registry.py +0 -154
- ethpm/constants.py +0 -17
- ethpm/contract.py +0 -187
- ethpm/dependencies.py +0 -58
- ethpm/deployments.py +0 -80
- ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
- ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
- ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
- ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
- ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
- ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
- ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/owned/v3.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
- ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
- ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
- ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
- ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
- ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
- ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
- ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
- ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
- ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
- ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
- ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
- ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
- ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
- ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
- ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
- ethpm/ethpm-spec/spec/package.spec.json +0 -379
- ethpm/ethpm-spec/spec/v3.spec.json +0 -483
- ethpm/exceptions.py +0 -68
- ethpm/package.py +0 -438
- ethpm/tools/__init__.py +0 -4
- ethpm/tools/builder.py +0 -930
- ethpm/tools/checker.py +0 -312
- ethpm/tools/get_manifest.py +0 -19
- ethpm/uri.py +0 -141
- ethpm/validation/__init__.py +0 -0
- ethpm/validation/manifest.py +0 -146
- ethpm/validation/misc.py +0 -39
- ethpm/validation/package.py +0 -80
- ethpm/validation/uri.py +0 -163
- web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
- web3/_utils/miner.py +0 -88
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -323
- web3/_utils/request.py +0 -265
- web3/middleware/abi.py +0 -11
- web3/middleware/async_cache.py +0 -99
- web3/middleware/cache.py +0 -374
- web3/middleware/exception_handling.py +0 -49
- web3/middleware/exception_retry_request.py +0 -188
- web3/middleware/fixture.py +0 -190
- web3/middleware/geth_poa.py +0 -81
- web3/middleware/normalize_request_parameters.py +0 -11
- web3/middleware/simulate_unmined_transaction.py +0 -43
- web3/pm.py +0 -602
- web3/providers/async_rpc.py +0 -99
- web3/providers/rpc.py +0 -98
- web3/providers/websocket/__init__.py +0 -11
- web3/providers/websocket/websocket_connection.py +0 -42
- web3/tools/__init__.py +0 -4
- web3/tools/pytest_ethereum/__init__.py +0 -0
- web3/tools/pytest_ethereum/_utils.py +0 -145
- web3/tools/pytest_ethereum/deployer.py +0 -48
- web3/tools/pytest_ethereum/exceptions.py +0 -22
- web3/tools/pytest_ethereum/linker.py +0 -128
- web3/tools/pytest_ethereum/plugins.py +0 -33
- web3-6.20.2.dist-info/METADATA +0 -103
- web3-6.20.2.dist-info/RECORD +0 -283
- web3-6.20.2.dist-info/entry_points.txt +0 -2
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
web3/_utils/abi.py
CHANGED
|
@@ -25,7 +25,6 @@ from typing import (
|
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
from eth_abi import (
|
|
28
|
-
codec,
|
|
29
28
|
decoding,
|
|
30
29
|
encoding,
|
|
31
30
|
)
|
|
@@ -47,11 +46,23 @@ from eth_abi.registry import (
|
|
|
47
46
|
registry as default_registry,
|
|
48
47
|
)
|
|
49
48
|
from eth_typing import (
|
|
49
|
+
ABI,
|
|
50
|
+
ABIComponent,
|
|
51
|
+
ABIComponentIndexed,
|
|
52
|
+
ABIConstructor,
|
|
53
|
+
ABIElement,
|
|
54
|
+
ABIEvent,
|
|
55
|
+
ABIFallback,
|
|
56
|
+
ABIFunction,
|
|
57
|
+
ABIReceive,
|
|
50
58
|
HexStr,
|
|
51
59
|
TypeStr,
|
|
52
60
|
)
|
|
53
61
|
from eth_utils import (
|
|
62
|
+
collapse_if_tuple,
|
|
54
63
|
decode_hex,
|
|
64
|
+
filter_abi_by_type,
|
|
65
|
+
get_abi_input_names,
|
|
55
66
|
is_bytes,
|
|
56
67
|
is_list_like,
|
|
57
68
|
is_string,
|
|
@@ -59,9 +70,6 @@ from eth_utils import (
|
|
|
59
70
|
to_text,
|
|
60
71
|
to_tuple,
|
|
61
72
|
)
|
|
62
|
-
from eth_utils.abi import (
|
|
63
|
-
collapse_if_tuple,
|
|
64
|
-
)
|
|
65
73
|
from eth_utils.toolz import (
|
|
66
74
|
curry,
|
|
67
75
|
partial,
|
|
@@ -78,20 +86,14 @@ from web3._utils.formatters import (
|
|
|
78
86
|
recursive_map,
|
|
79
87
|
)
|
|
80
88
|
from web3.exceptions import (
|
|
81
|
-
FallbackNotFound,
|
|
82
89
|
MismatchedABI,
|
|
90
|
+
Web3AttributeError,
|
|
91
|
+
Web3TypeError,
|
|
92
|
+
Web3ValueError,
|
|
83
93
|
)
|
|
84
94
|
from web3.types import (
|
|
85
|
-
ABI,
|
|
86
|
-
ABIEvent,
|
|
87
|
-
ABIEventParams,
|
|
88
|
-
ABIFunction,
|
|
89
|
-
ABIFunctionParams,
|
|
90
95
|
TReturn,
|
|
91
96
|
)
|
|
92
|
-
from web3.utils import ( # public utils module
|
|
93
|
-
get_abi_input_names,
|
|
94
|
-
)
|
|
95
97
|
|
|
96
98
|
if TYPE_CHECKING:
|
|
97
99
|
from web3 import ( # noqa: F401
|
|
@@ -99,92 +101,50 @@ if TYPE_CHECKING:
|
|
|
99
101
|
)
|
|
100
102
|
|
|
101
103
|
|
|
102
|
-
def
|
|
103
|
-
return
|
|
104
|
+
def fallback_func_abi_exists(contract_abi: ABI) -> Sequence[ABIFallback]:
|
|
105
|
+
return filter_abi_by_type("fallback", contract_abi)
|
|
104
106
|
|
|
105
107
|
|
|
106
|
-
def
|
|
107
|
-
return
|
|
108
|
-
abi
|
|
109
|
-
for abi in contract_abi
|
|
110
|
-
if (
|
|
111
|
-
abi["type"] not in ("fallback", "constructor", "receive")
|
|
112
|
-
and abi["name"] == name
|
|
113
|
-
)
|
|
114
|
-
]
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def get_abi_input_types(abi: ABIFunction) -> List[str]:
|
|
118
|
-
if "inputs" not in abi and (abi["type"] == "fallback" or abi["type"] == "receive"):
|
|
119
|
-
return []
|
|
120
|
-
else:
|
|
121
|
-
return [collapse_if_tuple(cast(Dict[str, Any], arg)) for arg in abi["inputs"]]
|
|
108
|
+
def receive_func_abi_exists(contract_abi: ABI) -> Sequence[ABIReceive]:
|
|
109
|
+
return filter_abi_by_type("receive", contract_abi)
|
|
122
110
|
|
|
123
111
|
|
|
124
|
-
def
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def get_receive_func_abi(contract_abi: ABI) -> ABIFunction:
|
|
132
|
-
receive_abis = filter_by_type("receive", contract_abi)
|
|
133
|
-
if receive_abis:
|
|
134
|
-
return cast(ABIFunction, receive_abis[0])
|
|
135
|
-
else:
|
|
136
|
-
raise FallbackNotFound("No receive function was found in the contract ABI.")
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def get_fallback_func_abi(contract_abi: ABI) -> ABIFunction:
|
|
140
|
-
fallback_abis = filter_by_type("fallback", contract_abi)
|
|
141
|
-
if fallback_abis:
|
|
142
|
-
return cast(ABIFunction, fallback_abis[0])
|
|
143
|
-
else:
|
|
144
|
-
raise FallbackNotFound("No fallback function was found in the contract ABI.")
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def fallback_func_abi_exists(contract_abi: ABI) -> List[Union[ABIFunction, ABIEvent]]:
|
|
148
|
-
return filter_by_type("fallback", contract_abi)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
def receive_func_abi_exists(contract_abi: ABI) -> List[Union[ABIFunction, ABIEvent]]:
|
|
152
|
-
return filter_by_type("receive", contract_abi)
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def get_indexed_event_inputs(event_abi: ABIEvent) -> List[ABIEventParams]:
|
|
156
|
-
return [arg for arg in event_abi["inputs"] if arg["indexed"] is True]
|
|
112
|
+
def get_indexed_event_inputs(event_abi: ABIEvent) -> Sequence[ABIComponentIndexed]:
|
|
113
|
+
return [
|
|
114
|
+
cast(ABIComponentIndexed, arg)
|
|
115
|
+
for arg in event_abi["inputs"]
|
|
116
|
+
if cast(ABIComponentIndexed, arg)["indexed"] is True
|
|
117
|
+
]
|
|
157
118
|
|
|
158
119
|
|
|
159
|
-
def exclude_indexed_event_inputs(event_abi: ABIEvent) ->
|
|
160
|
-
return [
|
|
120
|
+
def exclude_indexed_event_inputs(event_abi: ABIEvent) -> Sequence[ABIComponent]:
|
|
121
|
+
return [
|
|
122
|
+
arg
|
|
123
|
+
for arg in event_abi["inputs"]
|
|
124
|
+
if cast(ABIComponentIndexed, arg)["indexed"] is False
|
|
125
|
+
]
|
|
161
126
|
|
|
162
127
|
|
|
163
|
-
def
|
|
128
|
+
def filter_by_argument_name(
|
|
129
|
+
argument_names: Collection[str], contract_abi: ABI
|
|
130
|
+
) -> List[ABIElement]:
|
|
164
131
|
"""
|
|
165
|
-
Return
|
|
166
|
-
|
|
167
|
-
makes use of `collapse_if_tuple()` to collapse the appropriate component
|
|
168
|
-
types within a tuple type, if present.
|
|
132
|
+
Return a list of each ``ABIElement`` which contain arguments matching provided
|
|
133
|
+
names.
|
|
169
134
|
"""
|
|
170
|
-
|
|
135
|
+
abis_with_matching_args = []
|
|
136
|
+
for abi_element in contract_abi:
|
|
137
|
+
try:
|
|
138
|
+
abi_arg_names = get_abi_input_names(abi_element)
|
|
171
139
|
|
|
140
|
+
if set(argument_names).intersection(abi_arg_names) == set(argument_names):
|
|
141
|
+
abis_with_matching_args.append(abi_element)
|
|
142
|
+
except TypeError:
|
|
143
|
+
# fallback or receive functions do not have arguments
|
|
144
|
+
# proceed to next ABIElement
|
|
145
|
+
continue
|
|
172
146
|
|
|
173
|
-
|
|
174
|
-
num_arguments: int, contract_abi: ABI
|
|
175
|
-
) -> List[Union[ABIFunction, ABIEvent]]:
|
|
176
|
-
return [abi for abi in contract_abi if len(abi["inputs"]) == num_arguments]
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def filter_by_argument_name(
|
|
180
|
-
argument_names: Collection[str], contract_abi: ABI
|
|
181
|
-
) -> List[Union[ABIFunction, ABIEvent]]:
|
|
182
|
-
return [
|
|
183
|
-
abi
|
|
184
|
-
for abi in contract_abi
|
|
185
|
-
if set(argument_names).intersection(get_abi_input_names(abi))
|
|
186
|
-
== set(argument_names)
|
|
187
|
-
]
|
|
147
|
+
return abis_with_matching_args
|
|
188
148
|
|
|
189
149
|
|
|
190
150
|
class AddressEncoder(encoding.AddressEncoder):
|
|
@@ -193,7 +153,7 @@ class AddressEncoder(encoding.AddressEncoder):
|
|
|
193
153
|
if is_ens_name(value):
|
|
194
154
|
return
|
|
195
155
|
|
|
196
|
-
super().validate_value(value)
|
|
156
|
+
super().validate_value(value) # type: ignore[no-untyped-call]
|
|
197
157
|
|
|
198
158
|
|
|
199
159
|
class AcceptsHexStrEncoder(encoding.BaseEncoder):
|
|
@@ -208,7 +168,7 @@ class AcceptsHexStrEncoder(encoding.BaseEncoder):
|
|
|
208
168
|
subencoder: encoding.BaseEncoder,
|
|
209
169
|
**kwargs: Dict[str, Any],
|
|
210
170
|
) -> None:
|
|
211
|
-
super().__init__(**kwargs)
|
|
171
|
+
super().__init__(**kwargs) # type: ignore[no-untyped-call]
|
|
212
172
|
self.subencoder = subencoder
|
|
213
173
|
self.is_dynamic = subencoder.is_dynamic
|
|
214
174
|
|
|
@@ -220,14 +180,14 @@ class AcceptsHexStrEncoder(encoding.BaseEncoder):
|
|
|
220
180
|
# cast b/c expects BaseCoder but `from_type_string`
|
|
221
181
|
# restricted to BaseEncoder subclasses
|
|
222
182
|
subencoder = cast(
|
|
223
|
-
encoding.BaseEncoder, subencoder_cls.from_type_str(abi_type, registry)
|
|
183
|
+
encoding.BaseEncoder, subencoder_cls.from_type_str(abi_type, registry) # type: ignore[no-untyped-call] # noqa: E501
|
|
224
184
|
)
|
|
225
185
|
return cls(subencoder)
|
|
226
186
|
|
|
227
187
|
@classmethod
|
|
228
188
|
def get_subencoder_class(cls) -> Type[encoding.BaseEncoder]:
|
|
229
189
|
if cls.subencoder_cls is None:
|
|
230
|
-
raise
|
|
190
|
+
raise Web3AttributeError(f"No subencoder class is set. {cls.__name__}")
|
|
231
191
|
return cls.subencoder_cls
|
|
232
192
|
|
|
233
193
|
def validate_value(self, value: Any) -> None:
|
|
@@ -285,35 +245,39 @@ class ExactLengthBytesEncoder(BytesEncoder):
|
|
|
285
245
|
is_strict = True
|
|
286
246
|
|
|
287
247
|
def validate(self) -> None:
|
|
288
|
-
super().validate()
|
|
248
|
+
super().validate() # type: ignore[no-untyped-call]
|
|
289
249
|
if self.value_bit_size is None:
|
|
290
|
-
raise
|
|
250
|
+
raise Web3ValueError("`value_bit_size` may not be none")
|
|
291
251
|
if self.data_byte_size is None:
|
|
292
|
-
raise
|
|
252
|
+
raise Web3ValueError("`data_byte_size` may not be none")
|
|
293
253
|
if self.is_big_endian is None:
|
|
294
|
-
raise
|
|
254
|
+
raise Web3ValueError("`is_big_endian` may not be none")
|
|
295
255
|
|
|
296
256
|
if self.value_bit_size % 8 != 0:
|
|
297
|
-
raise
|
|
257
|
+
raise Web3ValueError(
|
|
298
258
|
f"Invalid value bit size: {self.value_bit_size}. "
|
|
299
259
|
"Must be a multiple of 8"
|
|
300
260
|
)
|
|
301
261
|
|
|
302
262
|
if self.value_bit_size > self.data_byte_size * 8:
|
|
303
|
-
raise
|
|
263
|
+
raise Web3ValueError("Value byte size exceeds data size")
|
|
304
264
|
|
|
305
|
-
@parse_type_str("bytes")
|
|
265
|
+
@parse_type_str("bytes") # type: ignore[no-untyped-call]
|
|
306
266
|
def from_type_str(
|
|
307
267
|
cls, abi_type: BasicType, registry: ABIRegistry
|
|
308
268
|
) -> "ExactLengthBytesEncoder":
|
|
309
269
|
subencoder_cls = cls.get_subencoder_class()
|
|
310
|
-
subencoder = subencoder_cls.from_type_str(abi_type.to_type_str(), registry)
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
270
|
+
subencoder = subencoder_cls.from_type_str(abi_type.to_type_str(), registry) # type: ignore[no-untyped-call] # noqa: E501
|
|
271
|
+
return cast(
|
|
272
|
+
ExactLengthBytesEncoder,
|
|
273
|
+
# type ignored b/c mypy thinks the __call__ is from BaseEncoder, but it's
|
|
274
|
+
# from ExactLengthBytesEncoder, which does have value_bit_size and
|
|
275
|
+
# data_byte_size attributes
|
|
276
|
+
cls( # type: ignore[call-arg]
|
|
277
|
+
subencoder,
|
|
278
|
+
value_bit_size=abi_type.sub * 8,
|
|
279
|
+
data_byte_size=abi_type.sub,
|
|
280
|
+
),
|
|
317
281
|
)
|
|
318
282
|
|
|
319
283
|
|
|
@@ -339,110 +303,7 @@ class TextStringEncoder(encoding.TextStringEncoder):
|
|
|
339
303
|
msg="not decodable as unicode string",
|
|
340
304
|
)
|
|
341
305
|
|
|
342
|
-
super().validate_value(value)
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
def filter_by_encodability(
|
|
346
|
-
abi_codec: codec.ABIEncoder,
|
|
347
|
-
args: Sequence[Any],
|
|
348
|
-
kwargs: Dict[str, Any],
|
|
349
|
-
contract_abi: ABI,
|
|
350
|
-
) -> List[ABIFunction]:
|
|
351
|
-
return [
|
|
352
|
-
cast(ABIFunction, function_abi)
|
|
353
|
-
for function_abi in contract_abi
|
|
354
|
-
if check_if_arguments_can_be_encoded(
|
|
355
|
-
cast(ABIFunction, function_abi), abi_codec, args, kwargs
|
|
356
|
-
)
|
|
357
|
-
]
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
def check_if_arguments_can_be_encoded(
|
|
361
|
-
function_abi: ABIFunction,
|
|
362
|
-
abi_codec: codec.ABIEncoder,
|
|
363
|
-
args: Sequence[Any],
|
|
364
|
-
kwargs: Dict[str, Any],
|
|
365
|
-
) -> bool:
|
|
366
|
-
try:
|
|
367
|
-
arguments = merge_args_and_kwargs(function_abi, args, kwargs)
|
|
368
|
-
except TypeError:
|
|
369
|
-
return False
|
|
370
|
-
|
|
371
|
-
if len(function_abi.get("inputs", [])) != len(arguments):
|
|
372
|
-
return False
|
|
373
|
-
|
|
374
|
-
try:
|
|
375
|
-
types, aligned_args = get_aligned_abi_inputs(function_abi, arguments)
|
|
376
|
-
except TypeError:
|
|
377
|
-
return False
|
|
378
|
-
|
|
379
|
-
return all(
|
|
380
|
-
abi_codec.is_encodable(_type, arg) for _type, arg in zip(types, aligned_args)
|
|
381
|
-
)
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
def merge_args_and_kwargs(
|
|
385
|
-
function_abi: ABIFunction, args: Sequence[Any], kwargs: Dict[str, Any]
|
|
386
|
-
) -> Tuple[Any, ...]:
|
|
387
|
-
"""
|
|
388
|
-
Takes a list of positional args (``args``) and a dict of keyword args
|
|
389
|
-
(``kwargs``) defining values to be passed to a call to the contract function
|
|
390
|
-
described by ``function_abi``. Checks to ensure that the correct number of
|
|
391
|
-
args were given, no duplicate args were given, and no unknown args were
|
|
392
|
-
given. Returns a list of argument values aligned to the order of inputs
|
|
393
|
-
defined in ``function_abi``.
|
|
394
|
-
"""
|
|
395
|
-
# Ensure the function is being applied to the correct number of args
|
|
396
|
-
if len(args) + len(kwargs) != len(function_abi.get("inputs", [])):
|
|
397
|
-
raise TypeError(
|
|
398
|
-
f"Incorrect argument count. Expected '{len(function_abi['inputs'])}'"
|
|
399
|
-
f". Got '{len(args) + len(kwargs)}'"
|
|
400
|
-
)
|
|
401
|
-
|
|
402
|
-
# If no keyword args were given, we don't need to align them
|
|
403
|
-
if not kwargs:
|
|
404
|
-
return cast(Tuple[Any, ...], args)
|
|
405
|
-
|
|
406
|
-
kwarg_names = set(kwargs.keys())
|
|
407
|
-
sorted_arg_names = tuple(arg_abi["name"] for arg_abi in function_abi["inputs"])
|
|
408
|
-
args_as_kwargs = dict(zip(sorted_arg_names, args))
|
|
409
|
-
|
|
410
|
-
# Check for duplicate args
|
|
411
|
-
duplicate_args = kwarg_names.intersection(args_as_kwargs.keys())
|
|
412
|
-
if duplicate_args:
|
|
413
|
-
raise TypeError(
|
|
414
|
-
f"{function_abi.get('name')}() got multiple values for argument(s) "
|
|
415
|
-
f"'{', '.join(duplicate_args)}'"
|
|
416
|
-
)
|
|
417
|
-
|
|
418
|
-
# Check for unknown args
|
|
419
|
-
unknown_args = kwarg_names.difference(sorted_arg_names)
|
|
420
|
-
if unknown_args:
|
|
421
|
-
if function_abi.get("name"):
|
|
422
|
-
raise TypeError(
|
|
423
|
-
f"{function_abi.get('name')}() got unexpected keyword argument(s)"
|
|
424
|
-
f" '{', '.join(unknown_args)}'"
|
|
425
|
-
)
|
|
426
|
-
raise TypeError(
|
|
427
|
-
f"Type: '{function_abi.get('type')}' got unexpected keyword argument(s)"
|
|
428
|
-
f" '{', '.join(unknown_args)}'"
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
# Sort args according to their position in the ABI and unzip them from their
|
|
432
|
-
# names
|
|
433
|
-
sorted_args = tuple(
|
|
434
|
-
zip(
|
|
435
|
-
*sorted(
|
|
436
|
-
itertools.chain(kwargs.items(), args_as_kwargs.items()),
|
|
437
|
-
key=lambda kv: sorted_arg_names.index(kv[0]),
|
|
438
|
-
)
|
|
439
|
-
)
|
|
440
|
-
)
|
|
441
|
-
|
|
442
|
-
if sorted_args:
|
|
443
|
-
return sorted_args[1]
|
|
444
|
-
else:
|
|
445
|
-
return tuple()
|
|
306
|
+
super().validate_value(value) # type: ignore[no-untyped-call]
|
|
446
307
|
|
|
447
308
|
|
|
448
309
|
TUPLE_TYPE_STR_RE = re.compile(r"^(tuple)((\[([1-9]\d*\b)?])*)??$")
|
|
@@ -464,7 +325,9 @@ def get_tuple_type_str_parts(s: str) -> Optional[Tuple[str, Optional[str]]]:
|
|
|
464
325
|
return None
|
|
465
326
|
|
|
466
327
|
|
|
467
|
-
def _align_abi_input(
|
|
328
|
+
def _align_abi_input(
|
|
329
|
+
arg_abi: Union[ABIComponent, ABIComponentIndexed], arg: Any
|
|
330
|
+
) -> Tuple[Any, ...]:
|
|
468
331
|
"""
|
|
469
332
|
Aligns the values of any mapping at any level of nesting in ``arg``
|
|
470
333
|
according to the layout of the corresponding abi spec.
|
|
@@ -488,7 +351,7 @@ def _align_abi_input(arg_abi: ABIFunctionParams, arg: Any) -> Tuple[Any, ...]:
|
|
|
488
351
|
new_abi = copy.copy(arg_abi)
|
|
489
352
|
new_abi["type"] = tuple_prefix + "[]" * (num_dims - 1)
|
|
490
353
|
|
|
491
|
-
sub_abis = itertools.repeat(new_abi)
|
|
354
|
+
sub_abis = [cast(ABIComponent, abi) for abi in itertools.repeat(new_abi)]
|
|
492
355
|
|
|
493
356
|
if isinstance(arg, abc.Mapping):
|
|
494
357
|
# Arg is mapping. Align values according to abi order.
|
|
@@ -497,7 +360,7 @@ def _align_abi_input(arg_abi: ABIFunctionParams, arg: Any) -> Tuple[Any, ...]:
|
|
|
497
360
|
aligned_arg = arg
|
|
498
361
|
|
|
499
362
|
if not is_list_like(aligned_arg):
|
|
500
|
-
raise
|
|
363
|
+
raise Web3TypeError(
|
|
501
364
|
f'Expected non-string sequence for "{arg_abi.get("type")}" '
|
|
502
365
|
f"component type: got {aligned_arg}"
|
|
503
366
|
)
|
|
@@ -511,38 +374,21 @@ def _align_abi_input(arg_abi: ABIFunctionParams, arg: Any) -> Tuple[Any, ...]:
|
|
|
511
374
|
)
|
|
512
375
|
|
|
513
376
|
|
|
514
|
-
def
|
|
515
|
-
abi: ABIFunction, args: Union[Tuple[Any, ...], Mapping[Any, Any]]
|
|
516
|
-
) -> Tuple[Tuple[Any, ...], Tuple[Any, ...]]:
|
|
517
|
-
"""
|
|
518
|
-
Takes a function ABI (``abi``) and a sequence or mapping of args (``args``).
|
|
519
|
-
Returns a list of type strings for the function's inputs and a list of
|
|
520
|
-
arguments which have been aligned to the layout of those types. The args
|
|
521
|
-
contained in ``args`` may contain nested mappings or sequences corresponding
|
|
522
|
-
to tuple-encoded values in ``abi``.
|
|
377
|
+
def find_constructor_abi_element_by_type(contract_abi: ABI) -> ABIConstructor:
|
|
523
378
|
"""
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if isinstance(args, abc.Mapping):
|
|
527
|
-
# `args` is mapping. Align values according to abi order.
|
|
528
|
-
args = tuple(args[abi["name"]] for abi in input_abis)
|
|
529
|
-
|
|
530
|
-
return (
|
|
531
|
-
# typed dict cannot be used w/ a normal Dict
|
|
532
|
-
# https://github.com/python/mypy/issues/4976
|
|
533
|
-
tuple(collapse_if_tuple(abi) for abi in input_abis), # type: ignore
|
|
534
|
-
type(args)(_align_abi_input(abi, arg) for abi, arg in zip(input_abis, args)),
|
|
535
|
-
)
|
|
379
|
+
Find the constructor ABI element in the contract ABI.
|
|
536
380
|
|
|
537
|
-
|
|
538
|
-
|
|
381
|
+
This function is often used in place of `web3.utils.abi.get_abi_element` to find
|
|
382
|
+
a constructor without considering it's argument types. This is used prior to
|
|
383
|
+
encoding the abi, since the argument types are not known at that time.
|
|
384
|
+
"""
|
|
539
385
|
candidates = [abi for abi in contract_abi if abi["type"] == "constructor"]
|
|
540
386
|
if len(candidates) == 1:
|
|
541
387
|
return candidates[0]
|
|
542
388
|
elif len(candidates) == 0:
|
|
543
389
|
return None
|
|
544
390
|
elif len(candidates) > 1:
|
|
545
|
-
raise
|
|
391
|
+
raise Web3ValueError("Found multiple constructors.")
|
|
546
392
|
return None
|
|
547
393
|
|
|
548
394
|
|
|
@@ -564,7 +410,7 @@ STATIC_TYPES = list(
|
|
|
564
410
|
)
|
|
565
411
|
|
|
566
412
|
BASE_TYPE_REGEX = "|".join(
|
|
567
|
-
|
|
413
|
+
_type + "(?![a-z0-9])" for _type in itertools.chain(STATIC_TYPES, DYNAMIC_TYPES)
|
|
568
414
|
)
|
|
569
415
|
|
|
570
416
|
SUB_TYPE_REGEX = r"\[" "[0-9]*" r"\]"
|
|
@@ -630,14 +476,14 @@ END_BRACKETS_OF_ARRAY_TYPE_REGEX = r"\[[^]]*\]$"
|
|
|
630
476
|
|
|
631
477
|
def sub_type_of_array_type(abi_type: TypeStr) -> str:
|
|
632
478
|
if not is_array_type(abi_type):
|
|
633
|
-
raise
|
|
479
|
+
raise Web3ValueError(f"Cannot parse subtype of nonarray abi-type: {abi_type}")
|
|
634
480
|
|
|
635
|
-
return re.sub(END_BRACKETS_OF_ARRAY_TYPE_REGEX, "", abi_type, 1)
|
|
481
|
+
return re.sub(END_BRACKETS_OF_ARRAY_TYPE_REGEX, "", abi_type, count=1)
|
|
636
482
|
|
|
637
483
|
|
|
638
484
|
def length_of_array_type(abi_type: TypeStr) -> int:
|
|
639
485
|
if not is_array_type(abi_type):
|
|
640
|
-
raise
|
|
486
|
+
raise Web3ValueError(f"Cannot parse length of nonarray abi-type: {abi_type}")
|
|
641
487
|
|
|
642
488
|
inner_brackets = (
|
|
643
489
|
re.search(END_BRACKETS_OF_ARRAY_TYPE_REGEX, abi_type).group(0).strip("[]")
|
|
@@ -669,8 +515,8 @@ def is_probably_enum(abi_type: TypeStr) -> bool:
|
|
|
669
515
|
|
|
670
516
|
@to_tuple
|
|
671
517
|
def normalize_event_input_types(
|
|
672
|
-
abi_args: Collection[
|
|
673
|
-
) -> Iterable[Union[
|
|
518
|
+
abi_args: Collection[ABIEvent],
|
|
519
|
+
) -> Iterable[Union[ABIEvent, Dict[TypeStr, Any]]]:
|
|
674
520
|
for arg in abi_args:
|
|
675
521
|
if is_recognized_type(arg["type"]):
|
|
676
522
|
yield arg
|
|
@@ -680,17 +526,6 @@ def normalize_event_input_types(
|
|
|
680
526
|
yield arg
|
|
681
527
|
|
|
682
528
|
|
|
683
|
-
def abi_to_signature(abi: Union[ABIFunction, ABIEvent]) -> str:
|
|
684
|
-
function_signature = "{fn_name}({fn_input_types})".format(
|
|
685
|
-
fn_name=abi["name"],
|
|
686
|
-
fn_input_types=",".join(
|
|
687
|
-
collapse_if_tuple(dict(arg))
|
|
688
|
-
for arg in normalize_event_input_types(abi.get("inputs", []))
|
|
689
|
-
),
|
|
690
|
-
)
|
|
691
|
-
return function_signature
|
|
692
|
-
|
|
693
|
-
|
|
694
529
|
########################################################
|
|
695
530
|
#
|
|
696
531
|
# Conditionally modifying data, tagged with ABI Types
|
|
@@ -705,8 +540,8 @@ def map_abi_data(
|
|
|
705
540
|
data: Sequence[Any],
|
|
706
541
|
) -> Any:
|
|
707
542
|
"""
|
|
708
|
-
|
|
709
|
-
|
|
543
|
+
Applies normalizers to your data, in the context of the relevant types.
|
|
544
|
+
Each normalizer is in the format:
|
|
710
545
|
|
|
711
546
|
def normalizer(datatype, data):
|
|
712
547
|
# Conditionally modify data
|
|
@@ -772,7 +607,7 @@ def data_tree_map(
|
|
|
772
607
|
|
|
773
608
|
class ABITypedData(namedtuple("ABITypedData", "abi_type, data")):
|
|
774
609
|
"""
|
|
775
|
-
|
|
610
|
+
Marks data as having a certain ABI-type.
|
|
776
611
|
|
|
777
612
|
>>> a1 = ABITypedData(['address', addr1])
|
|
778
613
|
>>> a2 = ABITypedData(['address', addr2])
|
|
@@ -841,7 +676,7 @@ def strip_abi_type(elements: Any) -> Any:
|
|
|
841
676
|
def build_non_strict_registry() -> ABIRegistry:
|
|
842
677
|
# We make a copy here just to make sure that eth-abi's default registry is not
|
|
843
678
|
# affected by our custom encoder subclasses
|
|
844
|
-
registry = default_registry.copy()
|
|
679
|
+
registry = default_registry.copy() # type: ignore[no-untyped-call]
|
|
845
680
|
|
|
846
681
|
registry.unregister("address")
|
|
847
682
|
registry.unregister("bytes<M>")
|
|
@@ -849,25 +684,25 @@ def build_non_strict_registry() -> ABIRegistry:
|
|
|
849
684
|
registry.unregister("string")
|
|
850
685
|
|
|
851
686
|
registry.register(
|
|
852
|
-
BaseEquals("address"),
|
|
687
|
+
BaseEquals("address"), # type: ignore[no-untyped-call]
|
|
853
688
|
AddressEncoder,
|
|
854
689
|
decoding.AddressDecoder,
|
|
855
690
|
label="address",
|
|
856
691
|
)
|
|
857
692
|
registry.register(
|
|
858
|
-
BaseEquals("bytes", with_sub=True),
|
|
693
|
+
BaseEquals("bytes", with_sub=True), # type: ignore[no-untyped-call]
|
|
859
694
|
BytesEncoder,
|
|
860
695
|
decoding.BytesDecoder,
|
|
861
696
|
label="bytes<M>",
|
|
862
697
|
)
|
|
863
698
|
registry.register(
|
|
864
|
-
BaseEquals("bytes", with_sub=False),
|
|
699
|
+
BaseEquals("bytes", with_sub=False), # type: ignore[no-untyped-call]
|
|
865
700
|
ByteStringEncoder,
|
|
866
701
|
decoding.ByteStringDecoder,
|
|
867
702
|
label="bytes",
|
|
868
703
|
)
|
|
869
704
|
registry.register(
|
|
870
|
-
BaseEquals("string"),
|
|
705
|
+
BaseEquals("string"), # type: ignore[no-untyped-call]
|
|
871
706
|
TextStringEncoder,
|
|
872
707
|
decoding.StringDecoder,
|
|
873
708
|
label="string",
|
|
@@ -876,7 +711,7 @@ def build_non_strict_registry() -> ABIRegistry:
|
|
|
876
711
|
|
|
877
712
|
|
|
878
713
|
def build_strict_registry() -> ABIRegistry:
|
|
879
|
-
registry = default_registry.copy()
|
|
714
|
+
registry = default_registry.copy() # type: ignore[no-untyped-call]
|
|
880
715
|
|
|
881
716
|
registry.unregister("address")
|
|
882
717
|
registry.unregister("bytes<M>")
|
|
@@ -884,25 +719,25 @@ def build_strict_registry() -> ABIRegistry:
|
|
|
884
719
|
registry.unregister("string")
|
|
885
720
|
|
|
886
721
|
registry.register(
|
|
887
|
-
BaseEquals("address"),
|
|
722
|
+
BaseEquals("address"), # type: ignore[no-untyped-call]
|
|
888
723
|
AddressEncoder,
|
|
889
724
|
decoding.AddressDecoder,
|
|
890
725
|
label="address",
|
|
891
726
|
)
|
|
892
727
|
registry.register(
|
|
893
|
-
BaseEquals("bytes", with_sub=True),
|
|
728
|
+
BaseEquals("bytes", with_sub=True), # type: ignore[no-untyped-call]
|
|
894
729
|
ExactLengthBytesEncoder,
|
|
895
730
|
decoding.BytesDecoder,
|
|
896
731
|
label="bytes<M>",
|
|
897
732
|
)
|
|
898
733
|
registry.register(
|
|
899
|
-
BaseEquals("bytes", with_sub=False),
|
|
734
|
+
BaseEquals("bytes", with_sub=False), # type: ignore[no-untyped-call]
|
|
900
735
|
StrictByteStringEncoder,
|
|
901
736
|
decoding.ByteStringDecoder,
|
|
902
737
|
label="bytes",
|
|
903
738
|
)
|
|
904
739
|
registry.register(
|
|
905
|
-
BaseEquals("string"),
|
|
740
|
+
BaseEquals("string"), # type: ignore[no-untyped-call]
|
|
906
741
|
encoding.TextStringEncoder,
|
|
907
742
|
decoding.StringDecoder,
|
|
908
743
|
label="string",
|
|
@@ -911,7 +746,11 @@ def build_strict_registry() -> ABIRegistry:
|
|
|
911
746
|
|
|
912
747
|
|
|
913
748
|
def named_tree(
|
|
914
|
-
abi: Iterable[
|
|
749
|
+
abi: Iterable[
|
|
750
|
+
Union[
|
|
751
|
+
ABIComponent, ABIComponentIndexed, ABIFunction, ABIEvent, Dict[TypeStr, Any]
|
|
752
|
+
]
|
|
753
|
+
],
|
|
915
754
|
data: Iterable[Tuple[Any, ...]],
|
|
916
755
|
) -> Dict[str, Any]:
|
|
917
756
|
"""
|
|
@@ -924,10 +763,12 @@ def named_tree(
|
|
|
924
763
|
|
|
925
764
|
|
|
926
765
|
def _named_subtree(
|
|
927
|
-
abi: Union[
|
|
766
|
+
abi: Union[
|
|
767
|
+
ABIComponent, ABIComponentIndexed, ABIFunction, ABIEvent, Dict[TypeStr, Any]
|
|
768
|
+
],
|
|
928
769
|
data: Tuple[Any, ...],
|
|
929
770
|
) -> Union[Dict[str, Any], Tuple[Any, ...], List[Any]]:
|
|
930
|
-
abi_type = parse(collapse_if_tuple(
|
|
771
|
+
abi_type = parse(collapse_if_tuple(cast(Dict[str, Any], abi)))
|
|
931
772
|
|
|
932
773
|
if abi_type.is_array:
|
|
933
774
|
item_type = abi_type.item_type.to_type_str()
|
|
@@ -936,7 +777,11 @@ def _named_subtree(
|
|
|
936
777
|
return items
|
|
937
778
|
|
|
938
779
|
elif isinstance(abi_type, TupleType):
|
|
939
|
-
abi
|
|
780
|
+
if abi.get("indexed"):
|
|
781
|
+
abi = cast(ABIComponentIndexed, abi)
|
|
782
|
+
else:
|
|
783
|
+
abi = cast(ABIComponent, abi)
|
|
784
|
+
|
|
940
785
|
names = [item["name"] for item in abi["components"]]
|
|
941
786
|
items = [_named_subtree(*item) for item in zip(abi["components"], data)]
|
|
942
787
|
|
|
@@ -1029,7 +874,6 @@ async def async_map_if_collection(
|
|
|
1029
874
|
Apply an awaitable method to each element of a collection or value of a dictionary.
|
|
1030
875
|
If the value is not a collection, return it unmodified.
|
|
1031
876
|
"""
|
|
1032
|
-
|
|
1033
877
|
datatype = type(value)
|
|
1034
878
|
if isinstance(value, Mapping):
|
|
1035
879
|
return datatype({key: await func(val) for key, val in value.values()})
|