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
ens/__init__.py CHANGED
@@ -1,5 +1,3 @@
1
- # flake8: noqa
2
-
3
1
  from .async_ens import (
4
2
  AsyncENS,
5
3
  )
@@ -18,3 +16,16 @@ from .exceptions import (
18
16
  UnderfundedBid,
19
17
  UnownedName,
20
18
  )
19
+
20
+ __all__ = [
21
+ "AsyncENS",
22
+ "BaseENS",
23
+ "ENS",
24
+ "AddressMismatch",
25
+ "BidTooLow",
26
+ "InvalidLabel",
27
+ "InvalidName",
28
+ "UnauthorizedError",
29
+ "UnderfundedBid",
30
+ "UnownedName",
31
+ ]
ens/_normalization.py CHANGED
@@ -48,7 +48,7 @@ with open(os.path.join(specs_dir_path, "normalization_spec.json")) as spec:
48
48
  # clean `FE0F` (65039) from entries since it's optional
49
49
  for e in NORMALIZATION_SPEC["emoji"]:
50
50
  if 65039 in e:
51
- for i in range(e.count(65039)):
51
+ for _ in range(e.count(65039)):
52
52
  e.remove(65039)
53
53
 
54
54
  with open(os.path.join(specs_dir_path, "nf.json")) as nf:
@@ -222,7 +222,6 @@ def _validate_tokens_and_get_label_type(tokens: List[Token]) -> str:
222
222
  :param List[Token] tokens: the tokens to validate
223
223
  :raises InvalidName: if any of the tokens are invalid
224
224
  """
225
-
226
225
  if all(token.type == TokenType.EMOJI for token in tokens):
227
226
  return "emoji"
228
227
 
@@ -423,9 +422,8 @@ def normalize_name_ensip15(name: str) -> ENSNormalizedName:
423
422
  :param str name: the dot-separated ENS name
424
423
  :raises InvalidName: if ``name`` has invalid syntax
425
424
  """
426
-
427
425
  if not name:
428
- raise InvalidName("Name cannot be empty")
426
+ return ENSNormalizedName([])
429
427
  elif isinstance(name, (bytes, bytearray)):
430
428
  name = name.decode("utf-8")
431
429
 
@@ -457,6 +455,8 @@ def normalize_name_ensip15(name: str) -> ENSNormalizedName:
457
455
  elif 65039 in current_emoji_sequence:
458
456
  current_emoji_sequence.remove(65039)
459
457
  _input.remove(65039)
458
+ if len(_input) == 0:
459
+ raise InvalidName("Empty name after removing 65039 (0xFE0F)")
460
460
  end_index -= 1 # reset end_index after removing 0xFE0F
461
461
 
462
462
  if current_emoji_sequence in NORMALIZATION_SPEC["emoji"]:
ens/async_ens.py CHANGED
@@ -4,6 +4,7 @@ from copy import (
4
4
  from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
+ Coroutine,
7
8
  Optional,
8
9
  Sequence,
9
10
  Tuple,
@@ -46,6 +47,7 @@ from ens.constants import (
46
47
  )
47
48
  from ens.exceptions import (
48
49
  AddressMismatch,
50
+ ENSValueError,
49
51
  ResolverNotFound,
50
52
  UnauthorizedError,
51
53
  UnownedName,
@@ -89,7 +91,7 @@ class AsyncENS(BaseENS):
89
91
  like getting the address for a name.
90
92
 
91
93
  Unless otherwise specified, all addresses are assumed to be a `str` in
92
- `checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_,
94
+ `checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_, # blocklint: pragma # noqa: E501
93
95
  like: ``"0x314159265dD8dbb310642f98f50C066173C1259b"``
94
96
  """
95
97
 
@@ -98,9 +100,9 @@ class AsyncENS(BaseENS):
98
100
 
99
101
  def __init__(
100
102
  self,
101
- provider: "AsyncBaseProvider" = cast("AsyncBaseProvider", default),
103
+ provider: "AsyncBaseProvider" = None,
102
104
  addr: ChecksumAddress = None,
103
- middlewares: Optional[Sequence[Tuple["Middleware", str]]] = None,
105
+ middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
104
106
  ) -> None:
105
107
  """
106
108
  :param provider: a single provider used to connect to Ethereum
@@ -108,7 +110,8 @@ class AsyncENS(BaseENS):
108
110
  :param hex-string addr: the address of the ENS registry on-chain.
109
111
  If not provided, ENS.py will default to the mainnet ENS registry address.
110
112
  """
111
- self.w3 = init_async_web3(provider, middlewares)
113
+ provider = provider or cast("AsyncBaseProvider", default)
114
+ self.w3 = init_async_web3(provider, middleware)
112
115
 
113
116
  ens_addr = addr if addr else ENS_MAINNET_ADDR
114
117
  self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr)
@@ -129,10 +132,8 @@ class AsyncENS(BaseENS):
129
132
  provided, defaults to the mainnet ENS registry address.
130
133
  """
131
134
  provider = w3.manager.provider
132
- middlewares = w3.middleware_onion.middlewares
133
- ns = cls(
134
- cast("AsyncBaseProvider", provider), addr=addr, middlewares=middlewares
135
- )
135
+ middleware = w3.middleware_onion.middleware
136
+ ns = cls(cast("AsyncBaseProvider", provider), addr=addr, middleware=middleware)
136
137
 
137
138
  # inherit strict bytes checking from w3 instance
138
139
  ns.strict_bytes_type_checking = w3.strict_bytes_type_checking
@@ -169,7 +170,7 @@ class AsyncENS(BaseENS):
169
170
  async def setup_address(
170
171
  self,
171
172
  name: str,
172
- address: Union[Address, ChecksumAddress, HexAddress] = cast(
173
+ address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
173
174
  ChecksumAddress, default
174
175
  ),
175
176
  coin_type: Optional[int] = None,
@@ -206,7 +207,7 @@ class AsyncENS(BaseENS):
206
207
  elif is_binary_address(address):
207
208
  address = to_checksum_address(cast(str, address))
208
209
  elif not is_checksum_address(address):
209
- raise ValueError("You must supply the address in checksum format")
210
+ raise ENSValueError("You must supply the address in checksum format")
210
211
  if await self.address(name) == address:
211
212
  return None
212
213
  if address is None:
@@ -284,7 +285,7 @@ class AsyncENS(BaseENS):
284
285
  if is_binary_address(address):
285
286
  address = to_checksum_address(address)
286
287
  if not is_checksum_address(address):
287
- raise ValueError("You must supply the address in checksum format")
288
+ raise ENSValueError("You must supply the address in checksum format")
288
289
  await self._assert_control(address, name)
289
290
  if not resolved:
290
291
  await self.setup_address(name, address, transact=transact)
@@ -307,7 +308,7 @@ class AsyncENS(BaseENS):
307
308
  async def setup_owner(
308
309
  self,
309
310
  name: str,
310
- new_owner: ChecksumAddress = cast(ChecksumAddress, default),
311
+ new_owner: ChecksumAddress = None,
311
312
  transact: Optional["TxParams"] = None,
312
313
  ) -> Optional[ChecksumAddress]:
313
314
  """
@@ -334,6 +335,7 @@ class AsyncENS(BaseENS):
334
335
  :raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
335
336
  :returns: the new owner's address
336
337
  """
338
+ new_owner = new_owner or cast(ChecksumAddress, default)
337
339
  if not transact:
338
340
  transact = {}
339
341
  transact = deepcopy(transact)
@@ -468,9 +470,13 @@ class AsyncENS(BaseENS):
468
470
  resolver_addr = await self.address("resolver.eth")
469
471
  namehash = raw_name_to_hash(name)
470
472
  if await self.ens.caller.resolver(namehash) != resolver_addr:
471
- await self.ens.functions.setResolver( # type: ignore
472
- namehash, resolver_addr
473
- ).transact(transact)
473
+ coro = cast(
474
+ Coroutine[Any, Any, HexBytes],
475
+ self.ens.functions.setResolver(namehash, resolver_addr).transact(
476
+ transact
477
+ ),
478
+ )
479
+ await coro
474
480
  return cast("AsyncContract", self._resolver_contract(address=resolver_addr))
475
481
 
476
482
  async def _resolve(
@@ -492,7 +498,7 @@ class AsyncENS(BaseENS):
492
498
  ):
493
499
  contract_func_with_args = (fn_name, [node])
494
500
 
495
- calldata = resolver.encodeABI(*contract_func_with_args)
501
+ calldata = resolver.encode_abi(*contract_func_with_args)
496
502
  contract_call_result = await resolver.caller.resolve(
497
503
  ens_encode_name(normal_name),
498
504
  calldata,
@@ -552,11 +558,15 @@ class AsyncENS(BaseENS):
552
558
  transact = deepcopy(transact)
553
559
  transact["from"] = old_owner or owner
554
560
  for label in reversed(unowned):
555
- await self.ens.functions.setSubnodeOwner( # type: ignore
556
- raw_name_to_hash(owned),
557
- label_to_hash(label),
558
- owner,
559
- ).transact(transact)
561
+ coro = cast(
562
+ Coroutine[Any, Any, HexBytes],
563
+ self.ens.functions.setSubnodeOwner(
564
+ raw_name_to_hash(owned),
565
+ label_to_hash(label),
566
+ owner,
567
+ ).transact(transact),
568
+ )
569
+ await coro
560
570
  owned = f"{label}.{owned}"
561
571
 
562
572
  async def _setup_reverse(
ens/base_ens.py CHANGED
@@ -11,13 +11,15 @@ from typing import (
11
11
  from eth_typing import (
12
12
  ChecksumAddress,
13
13
  )
14
+ from eth_utils.abi import (
15
+ get_abi_output_types,
16
+ )
14
17
  from hexbytes import (
15
18
  HexBytes,
16
19
  )
17
20
 
18
21
  from .utils import (
19
22
  address_to_reverse_domain,
20
- get_abi_output_types,
21
23
  is_valid_name,
22
24
  label_to_hash,
23
25
  normalize_name,
ens/contract_data.py CHANGED
@@ -3,8 +3,8 @@ import json
3
3
 
4
4
  """
5
5
  This contract data is taken from the actual ENS contracts deployed on mainnet.
6
- The information was taken from etherscan.io and may need to be updated as the ENS
7
- contracts are updated.
6
+ The information was taken from etherscan.io and may need to be updated as the ENS
7
+ contracts are updated.
8
8
 
9
9
  https://etherscan.io/accounts/label/ens
10
10
  """
ens/ens.py CHANGED
@@ -46,6 +46,7 @@ from .constants import (
46
46
  )
47
47
  from .exceptions import (
48
48
  AddressMismatch,
49
+ ENSValueError,
49
50
  ResolverNotFound,
50
51
  UnauthorizedError,
51
52
  UnownedName,
@@ -88,7 +89,7 @@ class ENS(BaseENS):
88
89
  like getting the address for a name.
89
90
 
90
91
  Unless otherwise specified, all addresses are assumed to be a `str` in
91
- `checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_,
92
+ `checksum format <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md>`_, # blocklint: pragma # noqa: E501
92
93
  like: ``"0x314159265dD8dbb310642f98f50C066173C1259b"``
93
94
  """
94
95
 
@@ -97,9 +98,9 @@ class ENS(BaseENS):
97
98
 
98
99
  def __init__(
99
100
  self,
100
- provider: "BaseProvider" = cast("BaseProvider", default),
101
+ provider: "BaseProvider" = None,
101
102
  addr: ChecksumAddress = None,
102
- middlewares: Optional[Sequence[Tuple["Middleware", str]]] = None,
103
+ middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
103
104
  ) -> None:
104
105
  """
105
106
  :param provider: a single provider used to connect to Ethereum
@@ -108,7 +109,8 @@ class ENS(BaseENS):
108
109
  If not provided, ENS.py will default to the mainnet ENS
109
110
  registry address.
110
111
  """
111
- self.w3 = init_web3(provider, middlewares)
112
+ provider = provider or cast("BaseProvider", default)
113
+ self.w3 = init_web3(provider, middleware)
112
114
 
113
115
  ens_addr = addr if addr else ENS_MAINNET_ADDR
114
116
  self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr)
@@ -129,8 +131,8 @@ class ENS(BaseENS):
129
131
  provided, defaults to the mainnet ENS registry address.
130
132
  """
131
133
  provider = w3.manager.provider
132
- middlewares = w3.middleware_onion.middlewares
133
- ns = cls(cast("BaseProvider", provider), addr=addr, middlewares=middlewares)
134
+ middleware = w3.middleware_onion.middleware
135
+ ns = cls(cast("BaseProvider", provider), addr=addr, middleware=middleware)
134
136
 
135
137
  # inherit strict bytes checking from w3 instance
136
138
  ns.strict_bytes_type_checking = w3.strict_bytes_type_checking
@@ -170,7 +172,7 @@ class ENS(BaseENS):
170
172
  def setup_address(
171
173
  self,
172
174
  name: str,
173
- address: Union[Address, ChecksumAddress, HexAddress] = cast(
175
+ address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
174
176
  ChecksumAddress, default
175
177
  ),
176
178
  coin_type: Optional[int] = None,
@@ -208,7 +210,7 @@ class ENS(BaseENS):
208
210
  elif is_binary_address(address):
209
211
  address = to_checksum_address(cast(str, address))
210
212
  elif not is_checksum_address(address):
211
- raise ValueError("You must supply the address in checksum format")
213
+ raise ENSValueError("You must supply the address in checksum format")
212
214
  if self.address(name) == address:
213
215
  return None
214
216
  if address is None:
@@ -284,7 +286,7 @@ class ENS(BaseENS):
284
286
  if is_binary_address(address):
285
287
  address = to_checksum_address(address)
286
288
  if not is_checksum_address(address):
287
- raise ValueError("You must supply the address in checksum format")
289
+ raise ENSValueError("You must supply the address in checksum format")
288
290
  self._assert_control(address, name)
289
291
  if not resolved:
290
292
  self.setup_address(name, address, transact=transact)
@@ -307,7 +309,7 @@ class ENS(BaseENS):
307
309
  def setup_owner(
308
310
  self,
309
311
  name: str,
310
- new_owner: ChecksumAddress = cast(ChecksumAddress, default),
312
+ new_owner: ChecksumAddress = None,
311
313
  transact: Optional["TxParams"] = None,
312
314
  ) -> Optional[ChecksumAddress]:
313
315
  """
@@ -334,6 +336,7 @@ class ENS(BaseENS):
334
336
  :raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
335
337
  :returns: the new owner's address
336
338
  """
339
+ new_owner = new_owner or cast(ChecksumAddress, default)
337
340
  if not transact:
338
341
  transact = {}
339
342
 
@@ -477,7 +480,7 @@ class ENS(BaseENS):
477
480
  if _resolver_supports_interface(resolver, ENS_EXTENDED_RESOLVER_INTERFACE_ID):
478
481
  contract_func_with_args = (fn_name, [node])
479
482
 
480
- calldata = resolver.encodeABI(*contract_func_with_args)
483
+ calldata = resolver.encode_abi(*contract_func_with_args)
481
484
  contract_call_result = resolver.caller.resolve(
482
485
  ens_encode_name(normal_name),
483
486
  calldata,
ens/exceptions.py CHANGED
@@ -1,6 +1,3 @@
1
- from eth_utils import (
2
- ValidationError,
3
- )
4
1
  import idna
5
2
 
6
3
 
@@ -9,7 +6,19 @@ class ENSException(Exception):
9
6
  Base class for all ENS Errors
10
7
  """
11
8
 
12
- pass
9
+
10
+ class ENSValueError(ENSException, ValueError):
11
+ """
12
+ An ENS exception wrapper for `ValueError`, for better control over
13
+ exception handling.
14
+ """
15
+
16
+
17
+ class ENSTypeError(ENSException, TypeError):
18
+ """
19
+ An ENS exception wrapper for `TypeError`, for better control over
20
+ exception handling.
21
+ """
13
22
 
14
23
 
15
24
  class AddressMismatch(ENSException):
@@ -19,18 +28,14 @@ class AddressMismatch(ENSException):
19
28
  not currently point to the address.
20
29
  """
21
30
 
22
- pass
23
-
24
31
 
25
32
  class InvalidName(idna.IDNAError, ENSException):
26
33
  """
27
- This exception is raised if the provided name does not meet
28
- the normalization standards specified in `ENSIP-15
34
+ Raised if the provided name does not meet the normalization
35
+ standards specified in `ENSIP-15
29
36
  <https://docs.ens.domains/ens-improvement-proposals/ensip-15-normalization-standard>`_.
30
37
  """
31
38
 
32
- pass
33
-
34
39
 
35
40
  class UnauthorizedError(ENSException):
36
41
  """
@@ -39,8 +44,6 @@ class UnauthorizedError(ENSException):
39
44
  ``transact`` keyword argument to the owner of the name.
40
45
  """
41
46
 
42
- pass
43
-
44
47
 
45
48
  class UnownedName(ENSException):
46
49
  """
@@ -50,48 +53,36 @@ class UnownedName(ENSException):
50
53
  first with :meth:`~ens.ENS.setup_address`.
51
54
  """
52
55
 
53
- pass
54
-
55
56
 
56
57
  class ResolverNotFound(ENSException):
57
58
  """
58
59
  Raised if no resolver was found for the name you are trying to resolve.
59
60
  """
60
61
 
61
- pass
62
-
63
62
 
64
63
  class UnsupportedFunction(ENSException):
65
64
  """
66
65
  Raised if a resolver does not support a particular method.
67
66
  """
68
67
 
69
- pass
70
-
71
68
 
72
69
  class BidTooLow(ENSException):
73
70
  """
74
71
  Raised if you bid less than the minimum amount
75
72
  """
76
73
 
77
- pass
78
-
79
74
 
80
75
  class InvalidBidHash(ENSException):
81
76
  """
82
77
  Raised if you supply incorrect data to generate the bid hash.
83
78
  """
84
79
 
85
- pass
86
-
87
80
 
88
81
  class InvalidLabel(ENSException):
89
82
  """
90
83
  Raised if you supply an invalid label
91
84
  """
92
85
 
93
- pass
94
-
95
86
 
96
87
  class OversizeTransaction(ENSException):
97
88
  """
@@ -101,8 +92,6 @@ class OversizeTransaction(ENSException):
101
92
  For example: when you try to start too many auctions at once.
102
93
  """
103
94
 
104
- pass
105
-
106
95
 
107
96
  class UnderfundedBid(ENSException):
108
97
  """
@@ -110,10 +99,8 @@ class UnderfundedBid(ENSException):
110
99
  as your intent to bid.
111
100
  """
112
101
 
113
- pass
114
-
115
102
 
116
- class ENSValidationError(ENSException, ValidationError):
103
+ class ENSValidationError(ENSException):
117
104
  """
118
105
  Raised if there is a validation error
119
106
  """