web3 7.0.0b2__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 (144) hide show
  1. ens/__init__.py +13 -2
  2. ens/_normalization.py +4 -4
  3. ens/async_ens.py +27 -15
  4. ens/base_ens.py +3 -1
  5. ens/contract_data.py +2 -2
  6. ens/ens.py +10 -7
  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 +24 -32
  11. web3/__init__.py +23 -12
  12. web3/_utils/abi.py +157 -263
  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 +49 -34
  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 -17
  89. web3/manager.py +362 -95
  90. web3/method.py +43 -15
  91. web3/middleware/__init__.py +17 -0
  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 +61 -25
  100. web3/providers/__init__.py +21 -0
  101. web3/providers/async_base.py +87 -32
  102. web3/providers/base.py +77 -32
  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 +41 -15
  106. web3/providers/eth_tester/middleware.py +16 -17
  107. web3/providers/ipc.py +41 -17
  108. web3/providers/legacy_websocket.py +26 -1
  109. web3/providers/persistent/__init__.py +7 -0
  110. web3/providers/persistent/async_ipc.py +61 -121
  111. web3/providers/persistent/persistent.py +323 -16
  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.0b2.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.0b2.dist-info → web3-7.7.0.dist-info}/WHEEL +1 -1
  137. web3/_utils/caching.py +0 -155
  138. web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
  139. web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
  140. web3/_utils/request.py +0 -265
  141. web3-7.0.0b2.dist-info/METADATA +0 -106
  142. web3-7.0.0b2.dist-info/RECORD +0 -163
  143. /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
  144. {web3-7.0.0b2.dist-info → web3-7.7.0.dist-info}/top_level.txt +0 -0
ens/utils.py CHANGED
@@ -6,8 +6,6 @@ from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
8
  Collection,
9
- Dict,
10
- List,
11
9
  Optional,
12
10
  Sequence,
13
11
  Tuple,
@@ -28,16 +26,15 @@ from eth_utils import (
28
26
  to_bytes,
29
27
  to_normalized_address,
30
28
  )
31
- from eth_utils.abi import (
32
- collapse_if_tuple,
33
- )
34
29
  from hexbytes import (
35
30
  HexBytes,
36
31
  )
37
32
 
38
- from ._normalization import (
39
- normalize_name_ensip15,
33
+ from ens.exceptions import (
34
+ ENSTypeError,
35
+ ENSValueError,
40
36
  )
37
+
41
38
  from .constants import (
42
39
  ACCEPTABLE_STALE_HOURS,
43
40
  AUCTION_START_GAS_CONSTANT,
@@ -66,9 +63,6 @@ if TYPE_CHECKING:
66
63
  AsyncBaseProvider,
67
64
  BaseProvider,
68
65
  )
69
- from web3.types import ( # noqa: F401
70
- ABIFunction,
71
- )
72
66
 
73
67
 
74
68
  def Web3() -> Type["_Web3"]:
@@ -80,7 +74,7 @@ def Web3() -> Type["_Web3"]:
80
74
 
81
75
 
82
76
  def init_web3(
83
- provider: "BaseProvider" = cast("BaseProvider", default),
77
+ provider: "BaseProvider" = None,
84
78
  middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
85
79
  ) -> "_Web3":
86
80
  from web3 import (
@@ -90,6 +84,7 @@ def init_web3(
90
84
  Eth as EthMain,
91
85
  )
92
86
 
87
+ provider = provider or cast("BaseProvider", default)
93
88
  if provider is default:
94
89
  w3 = Web3Main(ens=None, modules={"eth": (EthMain)})
95
90
  else:
@@ -117,13 +112,18 @@ def customize_web3(w3: "_Web3") -> "_Web3":
117
112
  def normalize_name(name: str) -> str:
118
113
  """
119
114
  Clean the fully qualified name, as defined in ENS `EIP-137
120
- <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_
115
+ <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_ # blocklint: pragma # noqa: E501
121
116
 
122
117
  This does *not* enforce whether ``name`` is a label or fully qualified domain.
123
118
 
124
119
  :param str name: the dot-separated ENS name
125
120
  :raises InvalidName: if ``name`` has invalid syntax
126
121
  """
122
+ # Defer import because module initialization takes > 0.1 ms
123
+ from ._normalization import (
124
+ normalize_name_ensip15,
125
+ )
126
+
127
127
  if is_empty_name(name):
128
128
  return ""
129
129
  elif isinstance(name, (bytes, bytearray)):
@@ -133,7 +133,7 @@ def normalize_name(name: str) -> str:
133
133
 
134
134
 
135
135
  def ens_encode_name(name: str) -> bytes:
136
- """
136
+ r"""
137
137
  Encode a name according to DNS standards specified in section 3.1
138
138
  of RFC1035 with the following validations:
139
139
 
@@ -169,7 +169,7 @@ def ens_encode_name(name: str) -> bytes:
169
169
  def is_valid_name(name: str) -> bool:
170
170
  """
171
171
  Validate whether the fully qualified name is valid, as defined in ENS `EIP-137
172
- <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_
172
+ <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_ # blocklint: pragma # noqa: E501
173
173
 
174
174
  :param str name: the dot-separated ENS name
175
175
  :returns: True if ``name`` is set, and :meth:`~ens.ENS.nameprep` will not
@@ -197,17 +197,17 @@ def sha3_text(val: Union[str, bytes]) -> HexBytes:
197
197
  def label_to_hash(label: str) -> HexBytes:
198
198
  label = normalize_name(label)
199
199
  if "." in label:
200
- raise ValueError(f"Cannot generate hash for label {label!r} with a '.'")
200
+ raise ENSValueError(f"Cannot generate hash for label {label!r} with a '.'")
201
201
  return Web3().keccak(text=label)
202
202
 
203
203
 
204
204
  def normal_name_to_hash(name: str) -> HexBytes:
205
205
  """
206
- This method will not normalize the name. 'normal' name here means the name
207
- should already be normalized before calling this method.
206
+ Hashes a pre-normalized name.
207
+ The normalization of the name is a prerequisite and is not handled by this function.
208
208
 
209
- :param name: the name to hash - should already be normalized
210
- :return: namehash the hash of the name
209
+ :param str name: A normalized name string to be hashed.
210
+ :return: namehash - the hash of the name
211
211
  :rtype: HexBytes
212
212
  """
213
213
  node = EMPTY_SHA3_BYTES
@@ -229,7 +229,7 @@ def raw_name_to_hash(name: str) -> HexBytes:
229
229
  behind the scenes. For advanced usage, it is a helpful utility.
230
230
 
231
231
  This normalizes the name with `nameprep
232
- <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_
232
+ <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-137.md#name-syntax>`_ # blocklint: pragma # noqa: E501
233
233
  before hashing.
234
234
 
235
235
  :param str name: ENS name to hash
@@ -262,7 +262,7 @@ def assert_signer_in_modifier_kwargs(modifier_kwargs: Any) -> ChecksumAddress:
262
262
 
263
263
  _modifier_type, modifier_dict = dict(modifier_kwargs).popitem()
264
264
  if "from" not in modifier_dict:
265
- raise TypeError(ERR_MSG)
265
+ raise ENSTypeError(ERR_MSG)
266
266
 
267
267
  return modifier_dict["from"]
268
268
 
@@ -285,20 +285,11 @@ def is_valid_ens_name(ens_name: str) -> bool:
285
285
  return True
286
286
 
287
287
 
288
- # borrowed from similar method at `web3._utils.abi` due to circular dependency
289
- def get_abi_output_types(abi: "ABIFunction") -> List[str]:
290
- return (
291
- []
292
- if abi["type"] == "fallback"
293
- else [collapse_if_tuple(cast(Dict[str, Any], arg)) for arg in abi["outputs"]]
294
- )
295
-
296
-
297
288
  # -- async -- #
298
289
 
299
290
 
300
291
  def init_async_web3(
301
- provider: "AsyncBaseProvider" = cast("AsyncBaseProvider", default),
292
+ provider: "AsyncBaseProvider" = None,
302
293
  middleware: Optional[Sequence[Tuple["Middleware", str]]] = (),
303
294
  ) -> "AsyncWeb3":
304
295
  from web3 import (
@@ -311,8 +302,9 @@ def init_async_web3(
311
302
  StalecheckMiddlewareBuilder,
312
303
  )
313
304
 
305
+ provider = provider or cast("AsyncBaseProvider", default)
314
306
  middleware = list(middleware)
315
- for i, (mw, name) in enumerate(middleware):
307
+ for i, (_mw, name) in enumerate(middleware):
316
308
  if name == "ens_name_to_address":
317
309
  middleware.pop(i)
318
310
 
web3/__init__.py CHANGED
@@ -1,26 +1,28 @@
1
1
  from eth_account import Account # noqa: E402
2
- import sys
3
2
 
4
- if sys.version_info.major == 3 and sys.version_info.minor < 8:
5
- import pkg_resources
3
+ from importlib.metadata import version
6
4
 
7
- __version__ = pkg_resources.get_distribution("web3").version
8
- else:
9
- from importlib.metadata import version
10
-
11
- __version__ = version("web3")
5
+ __version__ = version("web3")
12
6
 
13
7
 
14
8
  from web3.main import (
15
9
  AsyncWeb3,
16
10
  Web3,
17
11
  )
12
+ from web3.providers import (
13
+ AsyncBaseProvider,
14
+ AutoProvider,
15
+ BaseProvider,
16
+ JSONBaseProvider,
17
+ PersistentConnection,
18
+ )
18
19
  from web3.providers.persistent import ( # noqa: E402
19
20
  AsyncIPCProvider,
20
21
  PersistentConnectionProvider,
21
22
  WebSocketProvider,
22
23
  )
23
24
  from web3.providers.eth_tester import ( # noqa: E402
25
+ AsyncEthereumTesterProvider,
24
26
  EthereumTesterProvider,
25
27
  )
26
28
  from web3.providers.ipc import ( # noqa: E402
@@ -37,14 +39,23 @@ from web3.providers.legacy_websocket import ( # noqa: E402
37
39
 
38
40
  __all__ = [
39
41
  "__version__",
42
+ "Account",
43
+ # web3:
40
44
  "AsyncWeb3",
41
45
  "Web3",
46
+ # providers:
47
+ "AsyncBaseProvider",
48
+ "AsyncEthereumTesterProvider",
49
+ "AsyncHTTPProvider",
50
+ "AsyncIPCProvider",
51
+ "AutoProvider",
52
+ "BaseProvider",
53
+ "EthereumTesterProvider",
42
54
  "HTTPProvider",
43
55
  "IPCProvider",
56
+ "JSONBaseProvider",
44
57
  "LegacyWebSocketProvider",
58
+ "PersistentConnection",
59
+ "PersistentConnectionProvider",
45
60
  "WebSocketProvider",
46
- "EthereumTesterProvider",
47
- "Account",
48
- "AsyncHTTPProvider",
49
- "AsyncIPCProvider",
50
61
  ]