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.
Files changed (270) hide show
  1. ens/__init__.py +13 -2
  2. ens/_normalization.py +2 -17
  3. ens/async_ens.py +33 -21
  4. ens/base_ens.py +3 -1
  5. ens/ens.py +16 -11
  6. ens/exceptions.py +16 -29
  7. ens/specs/nf.json +1 -1
  8. ens/specs/normalization_spec.json +1 -1
  9. ens/utils.py +52 -63
  10. web3/__init__.py +20 -24
  11. web3/_utils/abi.py +115 -271
  12. web3/_utils/async_transactions.py +7 -4
  13. web3/_utils/batching.py +217 -0
  14. web3/_utils/blocks.py +6 -2
  15. web3/_utils/caching.py +128 -5
  16. web3/_utils/compat/__init__.py +2 -3
  17. web3/_utils/contract_sources/compile_contracts.py +1 -1
  18. web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
  19. web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
  20. web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
  21. web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
  22. web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
  23. web3/_utils/contract_sources/contract_data/event_contracts.py +5 -5
  24. web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
  25. web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
  26. web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
  27. web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
  28. web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
  29. web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
  30. web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
  31. web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
  32. web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
  33. web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
  34. web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
  35. web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
  36. web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
  37. web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
  38. web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
  39. web3/_utils/contracts.py +130 -236
  40. web3/_utils/datatypes.py +5 -1
  41. web3/_utils/decorators.py +13 -23
  42. web3/_utils/empty.py +1 -1
  43. web3/_utils/encoding.py +16 -12
  44. web3/_utils/ens.py +2 -1
  45. web3/_utils/error_formatters_utils.py +5 -3
  46. web3/_utils/events.py +66 -69
  47. web3/_utils/fee_utils.py +1 -3
  48. web3/_utils/filters.py +24 -22
  49. web3/_utils/formatters.py +2 -2
  50. web3/_utils/http.py +5 -3
  51. web3/_utils/http_session_manager.py +303 -0
  52. web3/_utils/math.py +14 -15
  53. web3/_utils/method_formatters.py +34 -36
  54. web3/_utils/module.py +2 -1
  55. web3/_utils/module_testing/__init__.py +0 -3
  56. web3/_utils/module_testing/eth_module.py +695 -643
  57. web3/_utils/module_testing/module_testing_utils.py +61 -34
  58. web3/_utils/module_testing/persistent_connection_provider.py +56 -25
  59. web3/_utils/module_testing/utils.py +258 -0
  60. web3/_utils/module_testing/web3_module.py +438 -17
  61. web3/_utils/normalizers.py +13 -11
  62. web3/_utils/rpc_abi.py +5 -32
  63. web3/_utils/threads.py +8 -7
  64. web3/_utils/transactions.py +14 -12
  65. web3/_utils/type_conversion.py +5 -1
  66. web3/_utils/validation.py +17 -17
  67. web3/auto/gethdev.py +7 -2
  68. web3/beacon/__init__.py +6 -1
  69. web3/beacon/async_beacon.py +9 -5
  70. web3/beacon/{main.py → beacon.py} +7 -5
  71. web3/contract/__init__.py +7 -0
  72. web3/contract/async_contract.py +47 -46
  73. web3/contract/base_contract.py +183 -158
  74. web3/contract/contract.py +49 -43
  75. web3/contract/utils.py +203 -59
  76. web3/datastructures.py +79 -31
  77. web3/eth/__init__.py +7 -0
  78. web3/eth/async_eth.py +39 -51
  79. web3/eth/base_eth.py +17 -10
  80. web3/eth/eth.py +30 -68
  81. web3/exceptions.py +108 -82
  82. web3/gas_strategies/time_based.py +8 -6
  83. web3/geth.py +1 -254
  84. web3/main.py +75 -122
  85. web3/manager.py +316 -146
  86. web3/method.py +38 -31
  87. web3/middleware/__init__.py +67 -89
  88. web3/middleware/attrdict.py +36 -49
  89. web3/middleware/base.py +174 -0
  90. web3/middleware/buffered_gas_estimate.py +20 -21
  91. web3/middleware/filter.py +157 -117
  92. web3/middleware/formatting.py +124 -108
  93. web3/middleware/gas_price_strategy.py +20 -32
  94. web3/middleware/names.py +29 -26
  95. web3/middleware/proof_of_authority.py +68 -0
  96. web3/middleware/pythonic.py +2 -2
  97. web3/middleware/signing.py +74 -89
  98. web3/middleware/stalecheck.py +52 -79
  99. web3/middleware/validation.py +5 -13
  100. web3/module.py +54 -10
  101. web3/providers/__init__.py +10 -6
  102. web3/providers/async_base.py +117 -39
  103. web3/providers/auto.py +3 -3
  104. web3/providers/base.py +89 -33
  105. web3/providers/eth_tester/__init__.py +5 -0
  106. web3/providers/eth_tester/defaults.py +1 -64
  107. web3/providers/eth_tester/main.py +99 -31
  108. web3/providers/eth_tester/middleware.py +45 -73
  109. web3/providers/ipc.py +42 -46
  110. web3/providers/{websocket/websocket.py → legacy_websocket.py} +32 -7
  111. web3/providers/persistent/__init__.py +22 -0
  112. web3/providers/persistent/async_ipc.py +153 -0
  113. web3/providers/{persistent.py → persistent/persistent.py} +106 -25
  114. web3/providers/persistent/persistent_connection.py +84 -0
  115. web3/providers/{websocket → persistent}/request_processor.py +94 -32
  116. web3/providers/persistent/utils.py +43 -0
  117. web3/providers/{websocket/websocket_v2.py → persistent/websocket.py} +29 -28
  118. web3/providers/rpc/__init__.py +11 -0
  119. web3/providers/rpc/async_rpc.py +171 -0
  120. web3/providers/rpc/rpc.py +179 -0
  121. web3/providers/rpc/utils.py +92 -0
  122. web3/testing.py +4 -4
  123. web3/tools/benchmark/main.py +22 -22
  124. web3/tools/benchmark/node.py +2 -8
  125. web3/tools/benchmark/reporting.py +2 -2
  126. web3/tools/benchmark/utils.py +1 -1
  127. web3/tracing.py +9 -5
  128. web3/types.py +30 -107
  129. web3/utils/__init__.py +58 -5
  130. web3/utils/abi.py +575 -10
  131. web3/utils/async_exception_handling.py +19 -7
  132. web3/utils/caching.py +32 -13
  133. web3/utils/exception_handling.py +7 -5
  134. {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/LICENSE +1 -1
  135. web3-7.0.0.dist-info/METADATA +112 -0
  136. web3-7.0.0.dist-info/RECORD +167 -0
  137. {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/WHEEL +1 -1
  138. {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/top_level.txt +0 -1
  139. ethpm/__init__.py +0 -20
  140. ethpm/_utils/__init__.py +0 -0
  141. ethpm/_utils/backend.py +0 -93
  142. ethpm/_utils/cache.py +0 -44
  143. ethpm/_utils/chains.py +0 -119
  144. ethpm/_utils/contract.py +0 -35
  145. ethpm/_utils/deployments.py +0 -145
  146. ethpm/_utils/ipfs.py +0 -116
  147. ethpm/_utils/protobuf/__init__.py +0 -0
  148. ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
  149. ethpm/_utils/registry.py +0 -29
  150. ethpm/assets/__init__.py +0 -0
  151. ethpm/assets/ens/v3.json +0 -1
  152. ethpm/assets/escrow/with_bytecode_v3.json +0 -1
  153. ethpm/assets/ipfs_file.proto +0 -32
  154. ethpm/assets/owned/output_v3.json +0 -1
  155. ethpm/assets/owned/with_contract_type_v3.json +0 -1
  156. ethpm/assets/registry/contracts/Authority.sol +0 -156
  157. ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
  158. ethpm/assets/registry/contracts/PackageDB.sol +0 -225
  159. ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
  160. ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
  161. ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
  162. ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
  163. ethpm/assets/registry/solc_input.json +0 -1
  164. ethpm/assets/registry/solc_output.json +0 -1
  165. ethpm/assets/registry/v3.json +0 -1
  166. ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
  167. ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
  168. ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
  169. ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
  170. ethpm/assets/simple-registry/solc_input.json +0 -33
  171. ethpm/assets/simple-registry/solc_output.json +0 -1
  172. ethpm/assets/simple-registry/v3.json +0 -1
  173. ethpm/assets/standard-token/output_v3.json +0 -1
  174. ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
  175. ethpm/assets/vyper_registry/0.1.0.json +0 -1
  176. ethpm/assets/vyper_registry/registry.vy +0 -216
  177. ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
  178. ethpm/backends/__init__.py +0 -0
  179. ethpm/backends/base.py +0 -43
  180. ethpm/backends/http.py +0 -108
  181. ethpm/backends/ipfs.py +0 -219
  182. ethpm/backends/registry.py +0 -154
  183. ethpm/constants.py +0 -17
  184. ethpm/contract.py +0 -187
  185. ethpm/dependencies.py +0 -58
  186. ethpm/deployments.py +0 -80
  187. ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
  188. ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
  189. ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
  190. ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
  191. ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
  192. ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
  193. ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
  194. ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
  195. ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
  196. ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
  197. ethpm/ethpm-spec/examples/owned/v3.json +0 -1
  198. ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
  199. ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
  200. ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
  201. ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
  202. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
  203. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
  204. ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
  205. ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
  206. ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
  207. ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
  208. ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
  209. ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
  210. ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
  211. ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
  212. ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
  213. ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
  214. ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
  215. ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
  216. ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
  217. ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
  218. ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
  219. ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
  220. ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
  221. ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
  222. ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
  223. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
  224. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
  225. ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
  226. ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
  227. ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
  228. ethpm/ethpm-spec/spec/package.spec.json +0 -379
  229. ethpm/ethpm-spec/spec/v3.spec.json +0 -483
  230. ethpm/exceptions.py +0 -68
  231. ethpm/package.py +0 -438
  232. ethpm/tools/__init__.py +0 -4
  233. ethpm/tools/builder.py +0 -930
  234. ethpm/tools/checker.py +0 -312
  235. ethpm/tools/get_manifest.py +0 -19
  236. ethpm/uri.py +0 -141
  237. ethpm/validation/__init__.py +0 -0
  238. ethpm/validation/manifest.py +0 -146
  239. ethpm/validation/misc.py +0 -39
  240. ethpm/validation/package.py +0 -80
  241. ethpm/validation/uri.py +0 -163
  242. web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
  243. web3/_utils/miner.py +0 -88
  244. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -323
  245. web3/_utils/request.py +0 -265
  246. web3/middleware/abi.py +0 -11
  247. web3/middleware/async_cache.py +0 -99
  248. web3/middleware/cache.py +0 -374
  249. web3/middleware/exception_handling.py +0 -49
  250. web3/middleware/exception_retry_request.py +0 -188
  251. web3/middleware/fixture.py +0 -190
  252. web3/middleware/geth_poa.py +0 -81
  253. web3/middleware/normalize_request_parameters.py +0 -11
  254. web3/middleware/simulate_unmined_transaction.py +0 -43
  255. web3/pm.py +0 -602
  256. web3/providers/async_rpc.py +0 -99
  257. web3/providers/rpc.py +0 -98
  258. web3/providers/websocket/__init__.py +0 -11
  259. web3/providers/websocket/websocket_connection.py +0 -42
  260. web3/tools/__init__.py +0 -4
  261. web3/tools/pytest_ethereum/__init__.py +0 -0
  262. web3/tools/pytest_ethereum/_utils.py +0 -145
  263. web3/tools/pytest_ethereum/deployer.py +0 -48
  264. web3/tools/pytest_ethereum/exceptions.py +0 -22
  265. web3/tools/pytest_ethereum/linker.py +0 -128
  266. web3/tools/pytest_ethereum/plugins.py +0 -33
  267. web3-6.20.2.dist-info/METADATA +0 -103
  268. web3-6.20.2.dist-info/RECORD +0 -283
  269. web3-6.20.2.dist-info/entry_points.txt +0 -2
  270. /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
web3/contract/utils.py CHANGED
@@ -9,21 +9,32 @@ from typing import (
9
9
  Tuple,
10
10
  Type,
11
11
  Union,
12
+ cast,
12
13
  )
13
14
 
14
15
  from eth_abi.exceptions import (
15
16
  DecodingError,
16
17
  )
17
18
  from eth_typing import (
19
+ ABI,
20
+ ABICallable,
21
+ ABIFunction,
18
22
  ChecksumAddress,
23
+ TypeStr,
24
+ )
25
+ from eth_utils.abi import (
26
+ filter_abi_by_type,
27
+ get_abi_output_types,
28
+ )
29
+ from eth_utils.toolz import (
30
+ compose,
31
+ curry,
19
32
  )
20
33
  from hexbytes import (
21
34
  HexBytes,
22
35
  )
23
36
 
24
37
  from web3._utils.abi import (
25
- filter_by_type,
26
- get_abi_output_types,
27
38
  map_abi_data,
28
39
  named_tree,
29
40
  recursive_dict_to_namedtuple,
@@ -31,8 +42,10 @@ from web3._utils.abi import (
31
42
  from web3._utils.async_transactions import (
32
43
  async_fill_transaction_defaults,
33
44
  )
45
+ from web3._utils.compat import (
46
+ TypeAlias,
47
+ )
34
48
  from web3._utils.contracts import (
35
- find_matching_fn_abi,
36
49
  prepare_transaction,
37
50
  )
38
51
  from web3._utils.normalizers import (
@@ -43,36 +56,79 @@ from web3._utils.transactions import (
43
56
  )
44
57
  from web3.exceptions import (
45
58
  BadFunctionCallOutput,
59
+ Web3ValueError,
46
60
  )
47
61
  from web3.types import (
48
- ABI,
49
- ABIFunction,
62
+ ABIElementIdentifier,
50
63
  BlockIdentifier,
51
- CallOverride,
52
- FunctionIdentifier,
64
+ RPCEndpoint,
65
+ StateOverride,
53
66
  TContractFn,
54
67
  TxParams,
55
68
  )
69
+ from web3.utils.abi import (
70
+ get_abi_element,
71
+ )
56
72
 
57
73
  if TYPE_CHECKING:
58
74
  from web3 import ( # noqa: F401
59
75
  AsyncWeb3,
60
76
  Web3,
61
77
  )
78
+ from web3.providers.persistent import ( # noqa: F401
79
+ PersistentConnectionProvider,
80
+ )
62
81
 
63
82
  ACCEPTABLE_EMPTY_STRINGS = ["0x", b"0x", "", b""]
64
83
 
65
84
 
85
+ @curry
86
+ def format_contract_call_return_data_curried(
87
+ async_w3: Union["AsyncWeb3", "Web3"],
88
+ decode_tuples: bool,
89
+ fn_abi: ABICallable,
90
+ abi_element_identifier: ABIElementIdentifier,
91
+ normalizers: Tuple[Callable[..., Any], ...],
92
+ output_types: Sequence[TypeStr],
93
+ return_data: Any,
94
+ ) -> Any:
95
+ """
96
+ Helper function for formatting contract call return data for batch requests. Curry
97
+ with all arguments except `return_data` and process `return_data` once it is
98
+ available.
99
+ """
100
+ try:
101
+ output_data = async_w3.codec.decode(output_types, return_data)
102
+ except DecodingError as e:
103
+ msg = (
104
+ f"Could not decode contract function call to {abi_element_identifier} "
105
+ f"with return data: {str(return_data)}, output_types: {output_types}"
106
+ )
107
+ raise BadFunctionCallOutput(msg) from e
108
+
109
+ _normalizers = itertools.chain(
110
+ BASE_RETURN_NORMALIZERS,
111
+ normalizers,
112
+ )
113
+ normalized_data = map_abi_data(_normalizers, output_types, output_data)
114
+
115
+ if decode_tuples and fn_abi["type"] == "function":
116
+ decoded = named_tree(fn_abi["outputs"], normalized_data)
117
+ normalized_data = recursive_dict_to_namedtuple(decoded)
118
+
119
+ return normalized_data[0] if len(normalized_data) == 1 else normalized_data
120
+
121
+
66
122
  def call_contract_function(
67
123
  w3: "Web3",
68
124
  address: ChecksumAddress,
69
125
  normalizers: Tuple[Callable[..., Any], ...],
70
- function_identifier: FunctionIdentifier,
126
+ abi_element_identifier: ABIElementIdentifier,
71
127
  transaction: TxParams,
72
128
  block_id: Optional[BlockIdentifier] = None,
73
129
  contract_abi: Optional[ABI] = None,
74
- fn_abi: Optional[ABIFunction] = None,
75
- state_override: Optional[CallOverride] = None,
130
+ abi_callable: Optional[ABICallable] = None,
131
+ state_override: Optional[StateOverride] = None,
76
132
  ccip_read_enabled: Optional[bool] = None,
77
133
  decode_tuples: Optional[bool] = False,
78
134
  *args: Any,
@@ -85,9 +141,9 @@ def call_contract_function(
85
141
  call_transaction = prepare_transaction(
86
142
  address,
87
143
  w3,
88
- fn_identifier=function_identifier,
144
+ abi_element_identifier=abi_element_identifier,
89
145
  contract_abi=contract_abi,
90
- fn_abi=fn_abi,
146
+ abi_callable=abi_callable,
91
147
  transaction=transaction,
92
148
  fn_args=args,
93
149
  fn_kwargs=kwargs,
@@ -100,12 +156,50 @@ def call_contract_function(
100
156
  ccip_read_enabled=ccip_read_enabled,
101
157
  )
102
158
 
103
- if fn_abi is None:
104
- fn_abi = find_matching_fn_abi(
105
- contract_abi, w3.codec, function_identifier, args, kwargs
159
+ if abi_callable is None:
160
+ abi_callable = cast(
161
+ ABIFunction,
162
+ get_abi_element(
163
+ contract_abi,
164
+ abi_element_identifier,
165
+ *args,
166
+ abi_codec=w3.codec,
167
+ **kwargs,
168
+ ),
106
169
  )
107
170
 
108
- output_types = get_abi_output_types(fn_abi)
171
+ # get the output types, which only exist for function types
172
+ output_types = []
173
+ if abi_callable["type"] == "function":
174
+ output_types = get_abi_output_types(abi_callable)
175
+
176
+ provider = w3.provider
177
+ if hasattr(provider, "_is_batching") and provider._is_batching:
178
+ BatchingReturnData: TypeAlias = Tuple[Tuple[RPCEndpoint, Any], Tuple[Any, ...]]
179
+ request_information = tuple(cast(BatchingReturnData, return_data))
180
+ method_and_params = request_information[0]
181
+
182
+ # append return data formatting to result formatters
183
+ current_response_formatters = request_information[1]
184
+ current_result_formatters = current_response_formatters[0]
185
+ updated_result_formatters = compose(
186
+ # contract call return data formatter
187
+ format_contract_call_return_data_curried(
188
+ w3,
189
+ decode_tuples,
190
+ abi_callable,
191
+ abi_element_identifier,
192
+ normalizers,
193
+ output_types,
194
+ ),
195
+ current_result_formatters,
196
+ )
197
+ response_formatters = (
198
+ updated_result_formatters, # result formatters
199
+ current_response_formatters[1], # error formatters
200
+ current_response_formatters[2], # null result formatters
201
+ )
202
+ return (method_and_params, response_formatters)
109
203
 
110
204
  try:
111
205
  output_data = w3.codec.decode(output_types, return_data)
@@ -123,7 +217,7 @@ def call_contract_function(
123
217
  )
124
218
  else:
125
219
  msg = (
126
- f"Could not decode contract function call to {function_identifier} "
220
+ f"Could not decode contract function call to {abi_element_identifier} "
127
221
  f"with return data: {str(return_data)}, output_types: {output_types}"
128
222
  )
129
223
  raise BadFunctionCallOutput(msg) from e
@@ -134,8 +228,8 @@ def call_contract_function(
134
228
  )
135
229
  normalized_data = map_abi_data(_normalizers, output_types, output_data)
136
230
 
137
- if decode_tuples:
138
- decoded = named_tree(fn_abi["outputs"], normalized_data)
231
+ if decode_tuples and abi_callable["type"] == "function":
232
+ decoded = named_tree(abi_callable["outputs"], normalized_data)
139
233
  normalized_data = recursive_dict_to_namedtuple(decoded)
140
234
 
141
235
  if len(normalized_data) == 1:
@@ -147,7 +241,7 @@ def call_contract_function(
147
241
  def transact_with_contract_function(
148
242
  address: ChecksumAddress,
149
243
  w3: "Web3",
150
- function_name: Optional[FunctionIdentifier] = None,
244
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
151
245
  transaction: Optional[TxParams] = None,
152
246
  contract_abi: Optional[ABI] = None,
153
247
  fn_abi: Optional[ABIFunction] = None,
@@ -161,10 +255,10 @@ def transact_with_contract_function(
161
255
  transact_transaction = prepare_transaction(
162
256
  address,
163
257
  w3,
164
- fn_identifier=function_name,
258
+ abi_element_identifier=abi_element_identifier,
165
259
  contract_abi=contract_abi,
166
260
  transaction=transaction,
167
- fn_abi=fn_abi,
261
+ abi_callable=fn_abi,
168
262
  fn_args=args,
169
263
  fn_kwargs=kwargs,
170
264
  )
@@ -176,16 +270,17 @@ def transact_with_contract_function(
176
270
  def estimate_gas_for_function(
177
271
  address: ChecksumAddress,
178
272
  w3: "Web3",
179
- fn_identifier: Optional[FunctionIdentifier] = None,
273
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
180
274
  transaction: Optional[TxParams] = None,
181
275
  contract_abi: Optional[ABI] = None,
182
276
  fn_abi: Optional[ABIFunction] = None,
183
277
  block_identifier: Optional[BlockIdentifier] = None,
184
- state_override: Optional[CallOverride] = None,
278
+ state_override: Optional[StateOverride] = None,
185
279
  *args: Any,
186
280
  **kwargs: Any,
187
281
  ) -> int:
188
- """Estimates gas cost a function call would take.
282
+ """
283
+ Estimates gas cost a function call would take.
189
284
 
190
285
  Don't call this directly, instead use :meth:`Contract.estimate_gas`
191
286
  on your contract instance.
@@ -193,9 +288,9 @@ def estimate_gas_for_function(
193
288
  estimate_transaction = prepare_transaction(
194
289
  address,
195
290
  w3,
196
- fn_identifier=fn_identifier,
291
+ abi_element_identifier=abi_element_identifier,
197
292
  contract_abi=contract_abi,
198
- fn_abi=fn_abi,
293
+ abi_callable=fn_abi,
199
294
  transaction=transaction,
200
295
  fn_args=args,
201
296
  fn_kwargs=kwargs,
@@ -207,14 +302,15 @@ def estimate_gas_for_function(
207
302
  def build_transaction_for_function(
208
303
  address: ChecksumAddress,
209
304
  w3: "Web3",
210
- function_name: Optional[FunctionIdentifier] = None,
305
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
211
306
  transaction: Optional[TxParams] = None,
212
307
  contract_abi: Optional[ABI] = None,
213
308
  fn_abi: Optional[ABIFunction] = None,
214
309
  *args: Any,
215
310
  **kwargs: Any,
216
311
  ) -> TxParams:
217
- """Builds a dictionary with the fields required to make the given transaction
312
+ """
313
+ Builds a dictionary with the fields required to make the given transaction
218
314
 
219
315
  Don't call this directly, instead use :meth:`Contract.build_transaction`
220
316
  on your contract instance.
@@ -222,9 +318,9 @@ def build_transaction_for_function(
222
318
  prepared_transaction = prepare_transaction(
223
319
  address,
224
320
  w3,
225
- fn_identifier=function_name,
321
+ abi_element_identifier=abi_element_identifier,
226
322
  contract_abi=contract_abi,
227
- fn_abi=fn_abi,
323
+ abi_callable=fn_abi,
228
324
  transaction=transaction,
229
325
  fn_args=args,
230
326
  fn_kwargs=kwargs,
@@ -242,14 +338,14 @@ def find_functions_by_identifier(
242
338
  callable_check: Callable[..., Any],
243
339
  function_type: Type[TContractFn],
244
340
  ) -> List[TContractFn]:
245
- fns_abi = filter_by_type("function", contract_abi)
341
+ fns_abi = filter_abi_by_type("function", contract_abi)
246
342
  return [
247
343
  function_type.factory(
248
344
  fn_abi["name"],
249
345
  w3=w3,
250
346
  contract_abi=contract_abi,
251
347
  address=address,
252
- function_identifier=fn_abi["name"],
348
+ abi_element_identifier=fn_abi["name"],
253
349
  abi=fn_abi,
254
350
  )
255
351
  for fn_abi in fns_abi
@@ -261,11 +357,11 @@ def get_function_by_identifier(
261
357
  fns: Sequence[TContractFn], identifier: str
262
358
  ) -> TContractFn:
263
359
  if len(fns) > 1:
264
- raise ValueError(
360
+ raise Web3ValueError(
265
361
  f"Found multiple functions with matching {identifier}. " f"Found: {fns!r}"
266
362
  )
267
363
  elif len(fns) == 0:
268
- raise ValueError(f"Could not find any function with matching {identifier}")
364
+ raise Web3ValueError(f"Could not find any function with matching {identifier}")
269
365
  return fns[0]
270
366
 
271
367
 
@@ -276,12 +372,12 @@ async def async_call_contract_function(
276
372
  async_w3: "AsyncWeb3",
277
373
  address: ChecksumAddress,
278
374
  normalizers: Tuple[Callable[..., Any], ...],
279
- function_identifier: FunctionIdentifier,
375
+ abi_element_identifier: ABIElementIdentifier,
280
376
  transaction: TxParams,
281
377
  block_id: Optional[BlockIdentifier] = None,
282
378
  contract_abi: Optional[ABI] = None,
283
379
  fn_abi: Optional[ABIFunction] = None,
284
- state_override: Optional[CallOverride] = None,
380
+ state_override: Optional[StateOverride] = None,
285
381
  ccip_read_enabled: Optional[bool] = None,
286
382
  decode_tuples: Optional[bool] = False,
287
383
  *args: Any,
@@ -294,9 +390,9 @@ async def async_call_contract_function(
294
390
  call_transaction = prepare_transaction(
295
391
  address,
296
392
  async_w3,
297
- fn_identifier=function_identifier,
393
+ abi_element_identifier=abi_element_identifier,
298
394
  contract_abi=contract_abi,
299
- fn_abi=fn_abi,
395
+ abi_callable=fn_abi,
300
396
  transaction=transaction,
301
397
  fn_args=args,
302
398
  fn_kwargs=kwargs,
@@ -310,11 +406,60 @@ async def async_call_contract_function(
310
406
  )
311
407
 
312
408
  if fn_abi is None:
313
- fn_abi = find_matching_fn_abi(
314
- contract_abi, async_w3.codec, function_identifier, args, kwargs
409
+ fn_abi = cast(
410
+ ABIFunction,
411
+ get_abi_element(
412
+ contract_abi,
413
+ abi_element_identifier,
414
+ *args,
415
+ abi_codec=async_w3.codec,
416
+ **kwargs,
417
+ ),
418
+ )
419
+
420
+ # get the output types, which only exist for function types
421
+ output_types = []
422
+ if fn_abi["type"] == "function":
423
+ output_types = get_abi_output_types(fn_abi)
424
+
425
+ if async_w3.provider._is_batching:
426
+ contract_call_return_data_formatter = format_contract_call_return_data_curried(
427
+ async_w3,
428
+ decode_tuples,
429
+ fn_abi,
430
+ abi_element_identifier,
431
+ normalizers,
432
+ output_types,
315
433
  )
434
+ if async_w3.provider.has_persistent_connection:
435
+ # get the current request id
436
+ provider = cast("PersistentConnectionProvider", async_w3.provider)
437
+ current_request_id = provider._batch_request_counter - 1
438
+ provider._request_processor.append_result_formatter_for_request(
439
+ current_request_id, contract_call_return_data_formatter
440
+ )
441
+ else:
442
+ BatchingReturnData: TypeAlias = Tuple[
443
+ Tuple[RPCEndpoint, Any], Tuple[Any, ...]
444
+ ]
445
+ request_information = tuple(cast(BatchingReturnData, return_data))
446
+ method_and_params = request_information[0]
447
+
448
+ # append return data formatter to result formatters
449
+ current_response_formatters = request_information[1]
450
+ current_result_formatters = current_response_formatters[0]
451
+ updated_result_formatters = compose(
452
+ contract_call_return_data_formatter,
453
+ current_result_formatters,
454
+ )
455
+ response_formatters = (
456
+ updated_result_formatters, # result formatters
457
+ current_response_formatters[1], # error formatters
458
+ current_response_formatters[2], # null result formatters
459
+ )
460
+ return (method_and_params, response_formatters)
316
461
 
317
- output_types = get_abi_output_types(fn_abi)
462
+ return return_data
318
463
 
319
464
  try:
320
465
  output_data = async_w3.codec.decode(output_types, return_data)
@@ -332,7 +477,7 @@ async def async_call_contract_function(
332
477
  )
333
478
  else:
334
479
  msg = (
335
- f"Could not decode contract function call to {function_identifier} "
480
+ f"Could not decode contract function call to {abi_element_identifier} "
336
481
  f"with return data: {str(return_data)}, output_types: {output_types}"
337
482
  )
338
483
  raise BadFunctionCallOutput(msg) from e
@@ -347,16 +492,13 @@ async def async_call_contract_function(
347
492
  decoded = named_tree(fn_abi["outputs"], normalized_data)
348
493
  normalized_data = recursive_dict_to_namedtuple(decoded)
349
494
 
350
- if len(normalized_data) == 1:
351
- return normalized_data[0]
352
- else:
353
- return normalized_data
495
+ return normalized_data[0] if len(normalized_data) == 1 else normalized_data
354
496
 
355
497
 
356
498
  async def async_transact_with_contract_function(
357
499
  address: ChecksumAddress,
358
500
  async_w3: "AsyncWeb3",
359
- function_name: Optional[FunctionIdentifier] = None,
501
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
360
502
  transaction: Optional[TxParams] = None,
361
503
  contract_abi: Optional[ABI] = None,
362
504
  fn_abi: Optional[ABIFunction] = None,
@@ -370,10 +512,10 @@ async def async_transact_with_contract_function(
370
512
  transact_transaction = prepare_transaction(
371
513
  address,
372
514
  async_w3,
373
- fn_identifier=function_name,
515
+ abi_element_identifier=abi_element_identifier,
374
516
  contract_abi=contract_abi,
375
517
  transaction=transaction,
376
- fn_abi=fn_abi,
518
+ abi_callable=fn_abi,
377
519
  fn_args=args,
378
520
  fn_kwargs=kwargs,
379
521
  )
@@ -385,16 +527,17 @@ async def async_transact_with_contract_function(
385
527
  async def async_estimate_gas_for_function(
386
528
  address: ChecksumAddress,
387
529
  async_w3: "AsyncWeb3",
388
- fn_identifier: Optional[FunctionIdentifier] = None,
530
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
389
531
  transaction: Optional[TxParams] = None,
390
532
  contract_abi: Optional[ABI] = None,
391
533
  fn_abi: Optional[ABIFunction] = None,
392
534
  block_identifier: Optional[BlockIdentifier] = None,
393
- state_override: Optional[CallOverride] = None,
535
+ state_override: Optional[StateOverride] = None,
394
536
  *args: Any,
395
537
  **kwargs: Any,
396
538
  ) -> int:
397
- """Estimates gas cost a function call would take.
539
+ """
540
+ Estimates gas cost a function call would take.
398
541
 
399
542
  Don't call this directly, instead use :meth:`Contract.estimate_gas`
400
543
  on your contract instance.
@@ -402,9 +545,9 @@ async def async_estimate_gas_for_function(
402
545
  estimate_transaction = prepare_transaction(
403
546
  address,
404
547
  async_w3,
405
- fn_identifier=fn_identifier,
548
+ abi_element_identifier=abi_element_identifier,
406
549
  contract_abi=contract_abi,
407
- fn_abi=fn_abi,
550
+ abi_callable=fn_abi,
408
551
  transaction=transaction,
409
552
  fn_args=args,
410
553
  fn_kwargs=kwargs,
@@ -418,14 +561,15 @@ async def async_estimate_gas_for_function(
418
561
  async def async_build_transaction_for_function(
419
562
  address: ChecksumAddress,
420
563
  async_w3: "AsyncWeb3",
421
- function_name: Optional[FunctionIdentifier] = None,
564
+ abi_element_identifier: Optional[ABIElementIdentifier] = None,
422
565
  transaction: Optional[TxParams] = None,
423
566
  contract_abi: Optional[ABI] = None,
424
567
  fn_abi: Optional[ABIFunction] = None,
425
568
  *args: Any,
426
569
  **kwargs: Any,
427
570
  ) -> TxParams:
428
- """Builds a dictionary with the fields required to make the given transaction
571
+ """
572
+ Builds a dictionary with the fields required to make the given transaction
429
573
 
430
574
  Don't call this directly, instead use :meth:`Contract.build_transaction`
431
575
  on your contract instance.
@@ -433,9 +577,9 @@ async def async_build_transaction_for_function(
433
577
  prepared_transaction = prepare_transaction(
434
578
  address,
435
579
  async_w3,
436
- fn_identifier=function_name,
580
+ abi_element_identifier=abi_element_identifier,
437
581
  contract_abi=contract_abi,
438
- fn_abi=fn_abi,
582
+ abi_callable=fn_abi,
439
583
  transaction=transaction,
440
584
  fn_args=args,
441
585
  fn_kwargs=kwargs,