web3 7.0.0b1__py3-none-any.whl → 7.7.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 (261) hide show
  1. ens/__init__.py +13 -2
  2. ens/_normalization.py +4 -4
  3. ens/async_ens.py +31 -21
  4. ens/base_ens.py +3 -1
  5. ens/contract_data.py +2 -2
  6. ens/ens.py +14 -11
  7. ens/exceptions.py +16 -29
  8. ens/specs/nf.json +1 -1
  9. ens/specs/normalization_spec.json +1 -1
  10. ens/utils.py +33 -41
  11. web3/__init__.py +23 -12
  12. web3/_utils/abi.py +162 -274
  13. web3/_utils/async_transactions.py +34 -20
  14. web3/_utils/batching.py +217 -0
  15. web3/_utils/blocks.py +6 -2
  16. web3/_utils/caching/__init__.py +12 -0
  17. web3/_utils/caching/caching_utils.py +433 -0
  18. web3/_utils/caching/request_caching_validation.py +287 -0
  19. web3/_utils/compat/__init__.py +2 -3
  20. web3/_utils/contract_sources/compile_contracts.py +1 -1
  21. web3/_utils/contract_sources/contract_data/ambiguous_function_contract.py +42 -0
  22. web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
  23. web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
  24. web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
  25. web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
  26. web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
  27. web3/_utils/contract_sources/contract_data/event_contracts.py +50 -5
  28. web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
  29. web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
  30. web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
  31. web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
  32. web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
  33. web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
  34. web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
  35. web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
  36. web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
  37. web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
  38. web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
  39. web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
  40. web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
  41. web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
  42. web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
  43. web3/_utils/contracts.py +172 -220
  44. web3/_utils/datatypes.py +5 -1
  45. web3/_utils/decorators.py +6 -1
  46. web3/_utils/empty.py +1 -1
  47. web3/_utils/encoding.py +16 -12
  48. web3/_utils/error_formatters_utils.py +5 -3
  49. web3/_utils/events.py +78 -72
  50. web3/_utils/fee_utils.py +1 -3
  51. web3/_utils/filters.py +24 -22
  52. web3/_utils/formatters.py +2 -2
  53. web3/_utils/http.py +8 -2
  54. web3/_utils/http_session_manager.py +314 -0
  55. web3/_utils/math.py +14 -15
  56. web3/_utils/method_formatters.py +161 -34
  57. web3/_utils/module.py +2 -1
  58. web3/_utils/module_testing/__init__.py +3 -2
  59. web3/_utils/module_testing/eth_module.py +736 -583
  60. web3/_utils/module_testing/go_ethereum_debug_module.py +128 -0
  61. web3/_utils/module_testing/module_testing_utils.py +81 -24
  62. web3/_utils/module_testing/persistent_connection_provider.py +702 -220
  63. web3/_utils/module_testing/utils.py +114 -33
  64. web3/_utils/module_testing/web3_module.py +438 -17
  65. web3/_utils/normalizers.py +13 -11
  66. web3/_utils/rpc_abi.py +10 -22
  67. web3/_utils/threads.py +8 -7
  68. web3/_utils/transactions.py +32 -25
  69. web3/_utils/type_conversion.py +5 -1
  70. web3/_utils/validation.py +20 -17
  71. web3/beacon/__init__.py +5 -0
  72. web3/beacon/api_endpoints.py +3 -0
  73. web3/beacon/async_beacon.py +29 -6
  74. web3/beacon/beacon.py +24 -6
  75. web3/contract/__init__.py +7 -0
  76. web3/contract/async_contract.py +285 -82
  77. web3/contract/base_contract.py +556 -258
  78. web3/contract/contract.py +295 -84
  79. web3/contract/utils.py +251 -55
  80. web3/datastructures.py +56 -41
  81. web3/eth/__init__.py +7 -0
  82. web3/eth/async_eth.py +89 -69
  83. web3/eth/base_eth.py +7 -3
  84. web3/eth/eth.py +43 -66
  85. web3/exceptions.py +158 -83
  86. web3/gas_strategies/time_based.py +8 -6
  87. web3/geth.py +53 -184
  88. web3/main.py +77 -43
  89. web3/manager.py +368 -101
  90. web3/method.py +43 -15
  91. web3/middleware/__init__.py +26 -8
  92. web3/middleware/attrdict.py +12 -22
  93. web3/middleware/base.py +55 -2
  94. web3/middleware/filter.py +45 -23
  95. web3/middleware/formatting.py +6 -3
  96. web3/middleware/names.py +4 -1
  97. web3/middleware/signing.py +15 -6
  98. web3/middleware/stalecheck.py +2 -1
  99. web3/module.py +62 -26
  100. web3/providers/__init__.py +21 -0
  101. web3/providers/async_base.py +93 -38
  102. web3/providers/base.py +85 -40
  103. web3/providers/eth_tester/__init__.py +5 -0
  104. web3/providers/eth_tester/defaults.py +2 -55
  105. web3/providers/eth_tester/main.py +57 -35
  106. web3/providers/eth_tester/middleware.py +16 -17
  107. web3/providers/ipc.py +42 -18
  108. web3/providers/legacy_websocket.py +27 -2
  109. web3/providers/persistent/__init__.py +7 -0
  110. web3/providers/persistent/async_ipc.py +61 -121
  111. web3/providers/persistent/persistent.py +324 -17
  112. web3/providers/persistent/persistent_connection.py +54 -5
  113. web3/providers/persistent/request_processor.py +136 -56
  114. web3/providers/persistent/subscription_container.py +56 -0
  115. web3/providers/persistent/subscription_manager.py +233 -0
  116. web3/providers/persistent/websocket.py +29 -92
  117. web3/providers/rpc/__init__.py +5 -0
  118. web3/providers/rpc/async_rpc.py +73 -18
  119. web3/providers/rpc/rpc.py +73 -30
  120. web3/providers/rpc/utils.py +1 -13
  121. web3/scripts/install_pre_releases.py +33 -0
  122. web3/scripts/parse_pygeth_version.py +16 -0
  123. web3/testing.py +4 -4
  124. web3/tracing.py +9 -5
  125. web3/types.py +141 -74
  126. web3/utils/__init__.py +64 -5
  127. web3/utils/abi.py +790 -10
  128. web3/utils/address.py +8 -0
  129. web3/utils/async_exception_handling.py +20 -11
  130. web3/utils/caching.py +34 -4
  131. web3/utils/exception_handling.py +9 -12
  132. web3/utils/subscriptions.py +285 -0
  133. {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/LICENSE +1 -1
  134. web3-7.7.0.dist-info/METADATA +130 -0
  135. web3-7.7.0.dist-info/RECORD +171 -0
  136. {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/WHEEL +1 -1
  137. {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/top_level.txt +0 -1
  138. ethpm/__init__.py +0 -20
  139. ethpm/_utils/__init__.py +0 -0
  140. ethpm/_utils/backend.py +0 -93
  141. ethpm/_utils/cache.py +0 -44
  142. ethpm/_utils/chains.py +0 -119
  143. ethpm/_utils/contract.py +0 -35
  144. ethpm/_utils/deployments.py +0 -145
  145. ethpm/_utils/ipfs.py +0 -116
  146. ethpm/_utils/protobuf/__init__.py +0 -0
  147. ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
  148. ethpm/_utils/registry.py +0 -29
  149. ethpm/assets/__init__.py +0 -0
  150. ethpm/assets/ens/v3.json +0 -1
  151. ethpm/assets/escrow/with_bytecode_v3.json +0 -1
  152. ethpm/assets/ipfs_file.proto +0 -32
  153. ethpm/assets/owned/output_v3.json +0 -1
  154. ethpm/assets/owned/with_contract_type_v3.json +0 -1
  155. ethpm/assets/registry/contracts/Authority.sol +0 -156
  156. ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
  157. ethpm/assets/registry/contracts/PackageDB.sol +0 -225
  158. ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
  159. ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
  160. ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
  161. ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
  162. ethpm/assets/registry/solc_input.json +0 -1
  163. ethpm/assets/registry/solc_output.json +0 -1
  164. ethpm/assets/registry/v3.json +0 -1
  165. ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
  166. ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
  167. ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
  168. ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
  169. ethpm/assets/simple-registry/solc_input.json +0 -33
  170. ethpm/assets/simple-registry/solc_output.json +0 -1
  171. ethpm/assets/simple-registry/v3.json +0 -1
  172. ethpm/assets/standard-token/output_v3.json +0 -1
  173. ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
  174. ethpm/assets/vyper_registry/0.1.0.json +0 -1
  175. ethpm/assets/vyper_registry/registry.vy +0 -216
  176. ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
  177. ethpm/backends/__init__.py +0 -0
  178. ethpm/backends/base.py +0 -43
  179. ethpm/backends/http.py +0 -108
  180. ethpm/backends/ipfs.py +0 -219
  181. ethpm/backends/registry.py +0 -154
  182. ethpm/constants.py +0 -17
  183. ethpm/contract.py +0 -187
  184. ethpm/dependencies.py +0 -58
  185. ethpm/deployments.py +0 -80
  186. ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
  187. ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
  188. ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
  189. ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
  190. ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
  191. ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
  192. ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
  193. ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
  194. ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
  195. ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
  196. ethpm/ethpm-spec/examples/owned/v3.json +0 -1
  197. ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
  198. ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
  199. ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
  200. ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
  201. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
  202. ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
  203. ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
  204. ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
  205. ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
  206. ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
  207. ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
  208. ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
  209. ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
  210. ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
  211. ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
  212. ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
  213. ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
  214. ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
  215. ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
  216. ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
  217. ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
  218. ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
  219. ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
  220. ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
  221. ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
  222. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
  223. ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
  224. ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
  225. ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
  226. ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
  227. ethpm/ethpm-spec/spec/package.spec.json +0 -379
  228. ethpm/ethpm-spec/spec/v3.spec.json +0 -483
  229. ethpm/exceptions.py +0 -68
  230. ethpm/package.py +0 -438
  231. ethpm/tools/__init__.py +0 -4
  232. ethpm/tools/builder.py +0 -930
  233. ethpm/tools/checker.py +0 -312
  234. ethpm/tools/get_manifest.py +0 -19
  235. ethpm/uri.py +0 -141
  236. ethpm/validation/__init__.py +0 -0
  237. ethpm/validation/manifest.py +0 -146
  238. ethpm/validation/misc.py +0 -39
  239. ethpm/validation/package.py +0 -80
  240. ethpm/validation/uri.py +0 -163
  241. web3/_utils/caching.py +0 -155
  242. web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
  243. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
  244. web3/_utils/request.py +0 -265
  245. web3/pm.py +0 -602
  246. web3/tools/__init__.py +0 -4
  247. web3/tools/benchmark/__init__.py +0 -0
  248. web3/tools/benchmark/main.py +0 -185
  249. web3/tools/benchmark/node.py +0 -126
  250. web3/tools/benchmark/reporting.py +0 -39
  251. web3/tools/benchmark/utils.py +0 -69
  252. web3/tools/pytest_ethereum/__init__.py +0 -0
  253. web3/tools/pytest_ethereum/_utils.py +0 -145
  254. web3/tools/pytest_ethereum/deployer.py +0 -48
  255. web3/tools/pytest_ethereum/exceptions.py +0 -22
  256. web3/tools/pytest_ethereum/linker.py +0 -128
  257. web3/tools/pytest_ethereum/plugins.py +0 -33
  258. web3-7.0.0b1.dist-info/METADATA +0 -114
  259. web3-7.0.0b1.dist-info/RECORD +0 -280
  260. web3-7.0.0b1.dist-info/entry_points.txt +0 -2
  261. /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
web3/geth.py CHANGED
@@ -1,26 +1,17 @@
1
1
  from typing import (
2
- Any,
3
2
  Awaitable,
4
3
  Callable,
5
- Dict,
6
4
  List,
7
5
  Optional,
6
+ Protocol,
8
7
  Tuple,
8
+ Union,
9
9
  )
10
10
 
11
- from eth_typing.encoding import (
12
- HexStr,
13
- )
14
11
  from eth_typing.evm import (
15
12
  ChecksumAddress,
16
13
  )
17
- from hexbytes.main import (
18
- HexBytes,
19
- )
20
14
 
21
- from web3._utils.compat import (
22
- Protocol,
23
- )
24
15
  from web3._utils.rpc_abi import (
25
16
  RPC,
26
17
  )
@@ -32,14 +23,19 @@ from web3.module import (
32
23
  Module,
33
24
  )
34
25
  from web3.types import (
26
+ CallTrace,
27
+ DiffModeTrace,
35
28
  EnodeURI,
36
- GethWallet,
29
+ FourByteTrace,
37
30
  NodeInfo,
31
+ OpcodeTrace,
38
32
  Peer,
39
- TxParams,
33
+ PrestateTrace,
34
+ TraceConfig,
40
35
  TxPoolContent,
41
36
  TxPoolInspect,
42
37
  TxPoolStatus,
38
+ _Hash32,
43
39
  )
44
40
 
45
41
 
@@ -53,66 +49,6 @@ class UnlockAccountWrapper(Protocol):
53
49
  pass
54
50
 
55
51
 
56
- class GethPersonal(Module):
57
- """
58
- https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
59
- """
60
-
61
- is_async = False
62
-
63
- ec_recover: Method[Callable[[str, HexStr], ChecksumAddress]] = Method(
64
- RPC.personal_ecRecover,
65
- mungers=[default_root_munger],
66
- )
67
-
68
- import_raw_key: Method[Callable[[str, str], ChecksumAddress]] = Method(
69
- RPC.personal_importRawKey,
70
- mungers=[default_root_munger],
71
- )
72
-
73
- list_accounts: Method[Callable[[], List[ChecksumAddress]]] = Method(
74
- RPC.personal_listAccounts,
75
- is_property=True,
76
- )
77
-
78
- list_wallets: Method[Callable[[], List[GethWallet]]] = Method(
79
- RPC.personal_listWallets,
80
- is_property=True,
81
- )
82
-
83
- send_transaction: Method[Callable[[TxParams, str], HexBytes]] = Method(
84
- RPC.personal_sendTransaction,
85
- mungers=[default_root_munger],
86
- )
87
-
88
- sign: Method[Callable[[str, ChecksumAddress, Optional[str]], HexStr]] = Method(
89
- RPC.personal_sign,
90
- mungers=[default_root_munger],
91
- )
92
-
93
- sign_typed_data: Method[
94
- Callable[[Dict[str, Any], ChecksumAddress, str], HexStr]
95
- ] = Method(
96
- RPC.personal_signTypedData,
97
- mungers=[default_root_munger],
98
- )
99
-
100
- new_account: Method[Callable[[str], ChecksumAddress]] = Method(
101
- RPC.personal_newAccount,
102
- mungers=[default_root_munger],
103
- )
104
-
105
- lock_account: Method[Callable[[ChecksumAddress], bool]] = Method(
106
- RPC.personal_lockAccount,
107
- mungers=[default_root_munger],
108
- )
109
-
110
- unlock_account: Method[UnlockAccountWrapper] = Method(
111
- RPC.personal_unlockAccount,
112
- mungers=[default_root_munger],
113
- )
114
-
115
-
116
52
  class GethTxPool(Module):
117
53
  """
118
54
  https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-txpool
@@ -205,10 +141,33 @@ class GethAdmin(Module):
205
141
  )
206
142
 
207
143
 
144
+ class GethDebug(Module):
145
+ """
146
+ https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug
147
+ """
148
+
149
+ def trace_transaction_munger(
150
+ self,
151
+ transaction_hash: _Hash32,
152
+ trace_config: Optional[TraceConfig] = None,
153
+ ) -> Tuple[_Hash32, TraceConfig]:
154
+ return (transaction_hash, trace_config)
155
+
156
+ trace_transaction: Method[
157
+ Callable[
158
+ ...,
159
+ Union[CallTrace, PrestateTrace, OpcodeTrace, DiffModeTrace, FourByteTrace],
160
+ ]
161
+ ] = Method(
162
+ RPC.debug_traceTransaction,
163
+ mungers=[trace_transaction_munger],
164
+ )
165
+
166
+
208
167
  class Geth(Module):
209
- personal: GethPersonal
210
168
  admin: GethAdmin
211
169
  txpool: GethTxPool
170
+ debug: GethDebug
212
171
 
213
172
 
214
173
  # --- async --- #
@@ -334,125 +293,35 @@ class AsyncGethAdmin(Module):
334
293
  return await self._stop_ws()
335
294
 
336
295
 
337
- class AsyncGethPersonal(Module):
296
+ class AsyncGethDebug(Module):
338
297
  """
339
- https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-personal
298
+ https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug
340
299
  """
341
300
 
342
301
  is_async = True
343
302
 
344
- # ec_recover
345
-
346
- _ec_recover: Method[Callable[[str, HexStr], Awaitable[ChecksumAddress]]] = Method(
347
- RPC.personal_ecRecover,
348
- mungers=[default_root_munger],
349
- )
350
-
351
- async def ec_recover(self, message: str, signature: HexStr) -> ChecksumAddress:
352
- return await self._ec_recover(message, signature)
353
-
354
- # import_raw_key
355
-
356
- _import_raw_key: Method[Callable[[str, str], Awaitable[ChecksumAddress]]] = Method(
357
- RPC.personal_importRawKey,
358
- mungers=[default_root_munger],
359
- )
360
-
361
- async def import_raw_key(
362
- self, private_key: str, passphrase: str
363
- ) -> ChecksumAddress:
364
- return await self._import_raw_key(private_key, passphrase)
365
-
366
- # list_accounts and list_wallets
367
-
368
- _list_accounts: Method[Callable[[], Awaitable[List[ChecksumAddress]]]] = Method(
369
- RPC.personal_listAccounts,
370
- is_property=True,
371
- )
372
-
373
- _list_wallets: Method[Callable[[], Awaitable[List[GethWallet]]]] = Method(
374
- RPC.personal_listWallets,
375
- is_property=True,
376
- )
377
-
378
- async def list_accounts(self) -> List[ChecksumAddress]:
379
- return await self._list_accounts()
380
-
381
- async def list_wallets(self) -> List[GethWallet]:
382
- return await self._list_wallets()
383
-
384
- # send_transaction
385
-
386
- _send_transaction: Method[Callable[[TxParams, str], Awaitable[HexBytes]]] = Method(
387
- RPC.personal_sendTransaction,
388
- mungers=[default_root_munger],
389
- )
390
-
391
- async def send_transaction(
392
- self, transaction: TxParams, passphrase: str
393
- ) -> HexBytes:
394
- return await self._send_transaction(transaction, passphrase)
395
-
396
- # sign and sign_typed_data
397
-
398
- _sign: Method[
399
- Callable[[str, ChecksumAddress, Optional[str]], Awaitable[HexStr]]
400
- ] = Method(
401
- RPC.personal_sign,
402
- mungers=[default_root_munger],
403
- )
404
-
405
- _sign_typed_data: Method[
406
- Callable[[Dict[str, Any], ChecksumAddress, str], Awaitable[HexStr]]
407
- ] = Method(
408
- RPC.personal_signTypedData,
409
- mungers=[default_root_munger],
410
- )
411
-
412
- async def sign(
413
- self, message: str, account: ChecksumAddress, passphrase: str
414
- ) -> HexStr:
415
- return await self._sign(message, account, passphrase)
416
-
417
- async def sign_typed_data(
418
- self, message: Dict[str, Any], account: ChecksumAddress, passphrase: str
419
- ) -> HexStr:
420
- return await self._sign_typed_data(message, account, passphrase)
421
-
422
- # new_account, lock_account, and unlock_account
423
-
424
- _new_account: Method[Callable[[str], Awaitable[ChecksumAddress]]] = Method(
425
- RPC.personal_newAccount,
426
- mungers=[default_root_munger],
427
- )
428
-
429
- _lock_account: Method[Callable[[ChecksumAddress], Awaitable[bool]]] = Method(
430
- RPC.personal_lockAccount,
431
- mungers=[default_root_munger],
432
- )
433
-
434
- _unlock_account: Method[
435
- Callable[[ChecksumAddress, str, Optional[int]], Awaitable[bool]]
436
- ] = Method(
437
- RPC.personal_unlockAccount,
438
- mungers=[default_root_munger],
439
- )
440
-
441
- async def new_account(self, passphrase: str) -> ChecksumAddress:
442
- return await self._new_account(passphrase)
443
-
444
- async def lock_account(self, account: ChecksumAddress) -> bool:
445
- return await self._lock_account(account)
446
-
447
- async def unlock_account(
448
- self, account: ChecksumAddress, passphrase: str, duration: Optional[int] = None
449
- ) -> bool:
450
- return await self._unlock_account(account, passphrase, duration)
303
+ _trace_transaction: Method[
304
+ Callable[
305
+ ...,
306
+ Awaitable[
307
+ Union[
308
+ CallTrace, PrestateTrace, OpcodeTrace, FourByteTrace, DiffModeTrace
309
+ ]
310
+ ],
311
+ ]
312
+ ] = Method(RPC.debug_traceTransaction)
313
+
314
+ async def trace_transaction(
315
+ self,
316
+ transaction_hash: _Hash32,
317
+ trace_config: Optional[TraceConfig] = None,
318
+ ) -> Union[CallTrace, PrestateTrace, OpcodeTrace, FourByteTrace, DiffModeTrace]:
319
+ return await self._trace_transaction(transaction_hash, trace_config)
451
320
 
452
321
 
453
322
  class AsyncGeth(Module):
454
323
  is_async = True
455
324
 
456
- personal: AsyncGethPersonal
457
325
  admin: AsyncGethAdmin
458
326
  txpool: AsyncGethTxPool
327
+ debug: AsyncGethDebug
web3/main.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import decimal
2
- import warnings
3
2
  from types import (
4
3
  TracebackType,
5
4
  )
@@ -35,6 +34,7 @@ from typing import (
35
34
  TYPE_CHECKING,
36
35
  Any,
37
36
  AsyncIterator,
37
+ Callable,
38
38
  Dict,
39
39
  Generator,
40
40
  List,
@@ -85,20 +85,28 @@ from web3.eth import (
85
85
  AsyncEth,
86
86
  Eth,
87
87
  )
88
+ from web3.exceptions import (
89
+ Web3TypeError,
90
+ Web3ValidationError,
91
+ Web3ValueError,
92
+ )
88
93
  from web3.geth import (
89
94
  AsyncGeth,
90
95
  AsyncGethAdmin,
91
- AsyncGethPersonal,
96
+ AsyncGethDebug,
92
97
  AsyncGethTxPool,
93
98
  Geth,
94
99
  GethAdmin,
95
- GethPersonal,
100
+ GethDebug,
96
101
  GethTxPool,
97
102
  )
98
103
  from web3.manager import (
99
104
  RequestManager as DefaultRequestManager,
100
105
  )
101
106
  from web3.middleware.base import MiddlewareOnion
107
+ from web3.method import (
108
+ Method,
109
+ )
102
110
  from web3.module import (
103
111
  Module,
104
112
  )
@@ -140,10 +148,14 @@ from web3.tracing import (
140
148
  from web3.types import (
141
149
  Wei,
142
150
  )
151
+ from web3.providers.persistent.subscription_manager import (
152
+ SubscriptionManager,
153
+ )
143
154
 
144
155
  if TYPE_CHECKING:
145
- from web3.pm import PM # noqa: F401
156
+ from web3._utils.batching import RequestBatcher # noqa: F401
146
157
  from web3._utils.empty import Empty # noqa: F401
158
+ from web3.providers.persistent import PersistentConnectionProvider # noqa: F401
147
159
 
148
160
 
149
161
  def get_async_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]:
@@ -154,8 +166,8 @@ def get_async_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]
154
166
  AsyncGeth,
155
167
  {
156
168
  "admin": AsyncGethAdmin,
157
- "personal": AsyncGethPersonal,
158
169
  "txpool": AsyncGethTxPool,
170
+ "debug": AsyncGethDebug,
159
171
  },
160
172
  ),
161
173
  }
@@ -169,8 +181,8 @@ def get_default_modules() -> Dict[str, Union[Type[Module], Sequence[Any]]]:
169
181
  Geth,
170
182
  {
171
183
  "admin": GethAdmin,
172
- "personal": GethPersonal,
173
184
  "txpool": GethTxPool,
185
+ "debug": GethDebug,
174
186
  },
175
187
  ),
176
188
  "tracing": Tracing,
@@ -285,7 +297,7 @@ class BaseWeb3:
285
297
  input_bytes = to_bytes(primitive, hexstr=hexstr, text=text)
286
298
  return eth_utils_keccak(input_bytes)
287
299
 
288
- raise TypeError(
300
+ raise Web3TypeError(
289
301
  f"You called keccak with first arg {primitive!r} and keywords "
290
302
  f"{{'text': {text!r}, 'hexstr': {hexstr!r}}}. You must call it with "
291
303
  "one of these approaches: keccak(text='txt'), keccak(hexstr='0x747874'), "
@@ -306,7 +318,7 @@ class BaseWeb3:
306
318
  and list of corresponding values -- `[20, [-1, 5, 0], True]`
307
319
  """
308
320
  if len(abi_types) != len(values):
309
- raise ValueError(
321
+ raise Web3ValueError(
310
322
  "Length mismatch between provided abi types and values. Got "
311
323
  f"{len(abi_types)} types and {len(values)} values."
312
324
  )
@@ -338,29 +350,30 @@ class BaseWeb3:
338
350
  def is_encodable(self, _type: TypeStr, value: Any) -> bool:
339
351
  return self.codec.is_encodable(_type, value)
340
352
 
341
- @property
342
- def pm(self) -> "PM":
343
- if hasattr(self, "_pm"):
344
- # ignored b/c property is dynamically set
345
- # via enable_unstable_package_management_api
346
- return self._pm
347
- else:
348
- raise AttributeError(
349
- "The Package Management feature is disabled by default until "
350
- "its API stabilizes. To use these features, please enable them by "
351
- "running `w3.enable_unstable_package_management_api()` and try again."
352
- )
353
+ # -- APIs for high-level requests -- #
353
354
 
354
- def enable_unstable_package_management_api(self) -> None:
355
- if not hasattr(self, "_pm"):
356
- warnings.warn(
357
- "The ``ethPM`` module is no longer being maintained and will be "
358
- "deprecated with ``web3.py`` version 7",
359
- UserWarning,
355
+ def batch_requests(
356
+ self,
357
+ ) -> "RequestBatcher[Method[Callable[..., Any]]]":
358
+ return self.manager._batch_requests()
359
+
360
+
361
+ def _validate_provider(
362
+ w3: Union["Web3", "AsyncWeb3"],
363
+ provider: Optional[Union[BaseProvider, AsyncBaseProvider]],
364
+ ) -> None:
365
+ if provider is not None:
366
+ if isinstance(w3, AsyncWeb3) and not isinstance(provider, AsyncBaseProvider):
367
+ raise Web3ValidationError(
368
+ "Provider must be an instance of `AsyncBaseProvider` for "
369
+ f"`AsyncWeb3`, got {type(provider)}."
360
370
  )
361
- from web3.pm import PM # noqa: F811
362
371
 
363
- self.attach_modules({"_pm": PM})
372
+ if isinstance(w3, Web3) and not isinstance(provider, BaseProvider):
373
+ raise Web3ValidationError(
374
+ "Provider must be an instance of `BaseProvider` for `Web3`, "
375
+ f"got {type(provider)}."
376
+ )
364
377
 
365
378
 
366
379
  class Web3(BaseWeb3):
@@ -378,14 +391,16 @@ class Web3(BaseWeb3):
378
391
  def __init__(
379
392
  self,
380
393
  provider: Optional[BaseProvider] = None,
381
- middlewares: Optional[Sequence[Any]] = None,
394
+ middleware: Optional[Sequence[Any]] = None,
382
395
  modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None,
383
396
  external_modules: Optional[
384
397
  Dict[str, Union[Type[Module], Sequence[Any]]]
385
398
  ] = None,
386
399
  ens: Union[ENS, "Empty"] = empty,
387
400
  ) -> None:
388
- self.manager = self.RequestManager(self, provider, middlewares)
401
+ _validate_provider(self, provider)
402
+
403
+ self.manager = self.RequestManager(self, provider, middleware)
389
404
  self.codec = ABICodec(build_strict_registry())
390
405
 
391
406
  if modules is None:
@@ -446,14 +461,16 @@ class AsyncWeb3(BaseWeb3):
446
461
  def __init__(
447
462
  self,
448
463
  provider: Optional[AsyncBaseProvider] = None,
449
- middlewares: Optional[Sequence[Any]] = None,
464
+ middleware: Optional[Sequence[Any]] = None,
450
465
  modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None,
451
466
  external_modules: Optional[
452
467
  Dict[str, Union[Type[Module], Sequence[Any]]]
453
468
  ] = None,
454
469
  ens: Union[AsyncENS, "Empty"] = empty,
455
470
  ) -> None:
456
- self.manager = self.RequestManager(self, provider, middlewares)
471
+ _validate_provider(self, provider)
472
+
473
+ self.manager = self.RequestManager(self, provider, middleware)
457
474
  self.codec = ABICodec(build_strict_registry())
458
475
 
459
476
  self._modules = get_async_default_modules() if modules is None else modules
@@ -494,12 +511,27 @@ class AsyncWeb3(BaseWeb3):
494
511
  new_ens.w3 = self # set self object reference for ``AsyncENS.w3``
495
512
  self._ens = new_ens
496
513
 
497
- # -- persistent connection methods -- #
514
+ # -- persistent connection settings -- #
515
+
516
+ _subscription_manager: Optional[SubscriptionManager] = None
517
+ _persistent_connection: Optional["PersistentConnection"] = None
518
+
519
+ @property
520
+ @persistent_connection_provider_method()
521
+ def subscription_manager(self) -> SubscriptionManager:
522
+ """
523
+ Access the subscription manager for the current PersistentConnectionProvider.
524
+ """
525
+ if not self._subscription_manager:
526
+ self._subscription_manager = SubscriptionManager(self)
527
+ return self._subscription_manager
498
528
 
499
529
  @property
500
530
  @persistent_connection_provider_method()
501
531
  def socket(self) -> PersistentConnection:
502
- return PersistentConnection(self)
532
+ if self._persistent_connection is None:
533
+ self._persistent_connection = PersistentConnection(self)
534
+ return self._persistent_connection
503
535
 
504
536
  # w3 = await AsyncWeb3(PersistentConnectionProvider(...))
505
537
  @persistent_connection_provider_method(
@@ -508,7 +540,10 @@ class AsyncWeb3(BaseWeb3):
508
540
  )
509
541
  def __await__(self) -> Generator[Any, None, Self]:
510
542
  async def __async_init__() -> Self:
511
- await self.provider.connect()
543
+ provider = cast("PersistentConnectionProvider", self.provider)
544
+ await provider.connect()
545
+ # set signal handlers since not within a context manager
546
+ provider._set_signal_handlers()
512
547
  return self
513
548
 
514
549
  return __async_init__().__await__()
@@ -537,12 +572,11 @@ class AsyncWeb3(BaseWeb3):
537
572
  "when instantiating via ``async for``."
538
573
  )
539
574
  async def __aiter__(self) -> AsyncIterator[Self]:
540
- if not await self.provider.is_connected():
541
- await self.provider.connect()
542
-
575
+ provider = self.provider
543
576
  while True:
544
- try:
545
- yield self
546
- except Exception:
547
- # provider should handle connection / reconnection
548
- continue
577
+ await provider.connect()
578
+ yield self
579
+ cast("PersistentConnectionProvider", provider).logger.error(
580
+ "Connection interrupted, attempting to reconnect..."
581
+ )
582
+ await provider.disconnect()