web3 6.20.2__py3-none-any.whl → 7.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ens/__init__.py +13 -2
- ens/_normalization.py +2 -17
- ens/async_ens.py +33 -21
- ens/base_ens.py +3 -1
- ens/ens.py +16 -11
- ens/exceptions.py +16 -29
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +52 -63
- web3/__init__.py +20 -24
- web3/_utils/abi.py +115 -271
- web3/_utils/async_transactions.py +7 -4
- web3/_utils/batching.py +217 -0
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching.py +128 -5
- web3/_utils/compat/__init__.py +2 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contract_sources/contract_data/arrays_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/bytes_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/constructor_contracts.py +7 -7
- web3/_utils/contract_sources/contract_data/contract_caller_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/emitter_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/event_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/extended_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/fallback_function_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/function_name_tester_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/math_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_lookup.py +3 -3
- web3/_utils/contract_sources/contract_data/offchain_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/panic_errors_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/payable_tester.py +3 -3
- web3/_utils/contract_sources/contract_data/receive_function_contracts.py +5 -5
- web3/_utils/contract_sources/contract_data/reflector_contracts.py +3 -3
- web3/_utils/contract_sources/contract_data/revert_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/simple_resolver.py +3 -3
- web3/_utils/contract_sources/contract_data/storage_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/string_contract.py +3 -3
- web3/_utils/contract_sources/contract_data/tuple_contracts.py +5 -5
- web3/_utils/contracts.py +130 -236
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +13 -23
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +16 -12
- web3/_utils/ens.py +2 -1
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +66 -69
- web3/_utils/fee_utils.py +1 -3
- web3/_utils/filters.py +24 -22
- web3/_utils/formatters.py +2 -2
- web3/_utils/http.py +5 -3
- web3/_utils/http_session_manager.py +303 -0
- web3/_utils/math.py +14 -15
- web3/_utils/method_formatters.py +34 -36
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +695 -643
- web3/_utils/module_testing/module_testing_utils.py +61 -34
- web3/_utils/module_testing/persistent_connection_provider.py +56 -25
- web3/_utils/module_testing/utils.py +258 -0
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/normalizers.py +13 -11
- web3/_utils/rpc_abi.py +5 -32
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +14 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +17 -17
- web3/auto/gethdev.py +7 -2
- web3/beacon/__init__.py +6 -1
- web3/beacon/async_beacon.py +9 -5
- web3/beacon/{main.py → beacon.py} +7 -5
- web3/contract/__init__.py +7 -0
- web3/contract/async_contract.py +47 -46
- web3/contract/base_contract.py +183 -158
- web3/contract/contract.py +49 -43
- web3/contract/utils.py +203 -59
- web3/datastructures.py +79 -31
- web3/eth/__init__.py +7 -0
- web3/eth/async_eth.py +39 -51
- web3/eth/base_eth.py +17 -10
- web3/eth/eth.py +30 -68
- web3/exceptions.py +108 -82
- web3/gas_strategies/time_based.py +8 -6
- web3/geth.py +1 -254
- web3/main.py +75 -122
- web3/manager.py +316 -146
- web3/method.py +38 -31
- web3/middleware/__init__.py +67 -89
- web3/middleware/attrdict.py +36 -49
- web3/middleware/base.py +174 -0
- web3/middleware/buffered_gas_estimate.py +20 -21
- web3/middleware/filter.py +157 -117
- web3/middleware/formatting.py +124 -108
- web3/middleware/gas_price_strategy.py +20 -32
- web3/middleware/names.py +29 -26
- web3/middleware/proof_of_authority.py +68 -0
- web3/middleware/pythonic.py +2 -2
- web3/middleware/signing.py +74 -89
- web3/middleware/stalecheck.py +52 -79
- web3/middleware/validation.py +5 -13
- web3/module.py +54 -10
- web3/providers/__init__.py +10 -6
- web3/providers/async_base.py +117 -39
- web3/providers/auto.py +3 -3
- web3/providers/base.py +89 -33
- web3/providers/eth_tester/__init__.py +5 -0
- web3/providers/eth_tester/defaults.py +1 -64
- web3/providers/eth_tester/main.py +99 -31
- web3/providers/eth_tester/middleware.py +45 -73
- web3/providers/ipc.py +42 -46
- web3/providers/{websocket/websocket.py → legacy_websocket.py} +32 -7
- web3/providers/persistent/__init__.py +22 -0
- web3/providers/persistent/async_ipc.py +153 -0
- web3/providers/{persistent.py → persistent/persistent.py} +106 -25
- web3/providers/persistent/persistent_connection.py +84 -0
- web3/providers/{websocket → persistent}/request_processor.py +94 -32
- web3/providers/persistent/utils.py +43 -0
- web3/providers/{websocket/websocket_v2.py → persistent/websocket.py} +29 -28
- web3/providers/rpc/__init__.py +11 -0
- web3/providers/rpc/async_rpc.py +171 -0
- web3/providers/rpc/rpc.py +179 -0
- web3/providers/rpc/utils.py +92 -0
- web3/testing.py +4 -4
- web3/tools/benchmark/main.py +22 -22
- web3/tools/benchmark/node.py +2 -8
- web3/tools/benchmark/reporting.py +2 -2
- web3/tools/benchmark/utils.py +1 -1
- web3/tracing.py +9 -5
- web3/types.py +30 -107
- web3/utils/__init__.py +58 -5
- web3/utils/abi.py +575 -10
- web3/utils/async_exception_handling.py +19 -7
- web3/utils/caching.py +32 -13
- web3/utils/exception_handling.py +7 -5
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/LICENSE +1 -1
- web3-7.0.0.dist-info/METADATA +112 -0
- web3-7.0.0.dist-info/RECORD +167 -0
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/WHEEL +1 -1
- {web3-6.20.2.dist-info → web3-7.0.0.dist-info}/top_level.txt +0 -1
- ethpm/__init__.py +0 -20
- ethpm/_utils/__init__.py +0 -0
- ethpm/_utils/backend.py +0 -93
- ethpm/_utils/cache.py +0 -44
- ethpm/_utils/chains.py +0 -119
- ethpm/_utils/contract.py +0 -35
- ethpm/_utils/deployments.py +0 -145
- ethpm/_utils/ipfs.py +0 -116
- ethpm/_utils/protobuf/__init__.py +0 -0
- ethpm/_utils/protobuf/ipfs_file_pb2.py +0 -33
- ethpm/_utils/registry.py +0 -29
- ethpm/assets/__init__.py +0 -0
- ethpm/assets/ens/v3.json +0 -1
- ethpm/assets/escrow/with_bytecode_v3.json +0 -1
- ethpm/assets/ipfs_file.proto +0 -32
- ethpm/assets/owned/output_v3.json +0 -1
- ethpm/assets/owned/with_contract_type_v3.json +0 -1
- ethpm/assets/registry/contracts/Authority.sol +0 -156
- ethpm/assets/registry/contracts/IndexedOrderedSetLib.sol +0 -106
- ethpm/assets/registry/contracts/PackageDB.sol +0 -225
- ethpm/assets/registry/contracts/PackageRegistry.sol +0 -361
- ethpm/assets/registry/contracts/PackageRegistryInterface.sol +0 -97
- ethpm/assets/registry/contracts/ReleaseDB.sol +0 -309
- ethpm/assets/registry/contracts/ReleaseValidator.sol +0 -152
- ethpm/assets/registry/solc_input.json +0 -1
- ethpm/assets/registry/solc_output.json +0 -1
- ethpm/assets/registry/v3.json +0 -1
- ethpm/assets/safe-math-lib/v3-strict-no-deployments.json +0 -1
- ethpm/assets/simple-registry/contracts/Ownable.sol +0 -63
- ethpm/assets/simple-registry/contracts/PackageRegistry.sol +0 -373
- ethpm/assets/simple-registry/contracts/PackageRegistryInterface.sol +0 -96
- ethpm/assets/simple-registry/solc_input.json +0 -33
- ethpm/assets/simple-registry/solc_output.json +0 -1
- ethpm/assets/simple-registry/v3.json +0 -1
- ethpm/assets/standard-token/output_v3.json +0 -1
- ethpm/assets/standard-token/with_bytecode_v3.json +0 -1
- ethpm/assets/vyper_registry/0.1.0.json +0 -1
- ethpm/assets/vyper_registry/registry.vy +0 -216
- ethpm/assets/vyper_registry/registry_with_delete.vy +0 -244
- ethpm/backends/__init__.py +0 -0
- ethpm/backends/base.py +0 -43
- ethpm/backends/http.py +0 -108
- ethpm/backends/ipfs.py +0 -219
- ethpm/backends/registry.py +0 -154
- ethpm/constants.py +0 -17
- ethpm/contract.py +0 -187
- ethpm/dependencies.py +0 -58
- ethpm/deployments.py +0 -80
- ethpm/ethpm-spec/examples/escrow/1.0.0-pretty.json +0 -146
- ethpm/ethpm-spec/examples/escrow/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/escrow/contracts/Escrow.sol +0 -32
- ethpm/ethpm-spec/examples/escrow/contracts/SafeSendLib.sol +0 -20
- ethpm/ethpm-spec/examples/escrow/v3-pretty.json +0 -171
- ethpm/ethpm-spec/examples/escrow/v3.json +0 -1
- ethpm/ethpm-spec/examples/owned/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/owned/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/owned/contracts/Owned.sol +0 -12
- ethpm/ethpm-spec/examples/owned/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/owned/v3.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/1.0.0-pretty.json +0 -31
- ethpm/ethpm-spec/examples/piper-coin/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/piper-coin/v3-pretty.json +0 -21
- ethpm/ethpm-spec/examples/piper-coin/v3.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0-pretty.json +0 -85
- ethpm/ethpm-spec/examples/safe-math-lib/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/safe-math-lib/contracts/SafeMathLib.sol +0 -24
- ethpm/ethpm-spec/examples/safe-math-lib/v3-pretty.json +0 -117
- ethpm/ethpm-spec/examples/safe-math-lib/v3.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/1.0.0-pretty.json +0 -55
- ethpm/ethpm-spec/examples/standard-token/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/standard-token/contracts/AbstractToken.sol +0 -20
- ethpm/ethpm-spec/examples/standard-token/contracts/StandardToken.sol +0 -84
- ethpm/ethpm-spec/examples/standard-token/v3-pretty.json +0 -460
- ethpm/ethpm-spec/examples/standard-token/v3.json +0 -1
- ethpm/ethpm-spec/examples/transferable/1.0.0-pretty.json +0 -21
- ethpm/ethpm-spec/examples/transferable/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/transferable/contracts/Transferable.sol +0 -14
- ethpm/ethpm-spec/examples/transferable/v3-pretty.json +0 -27
- ethpm/ethpm-spec/examples/transferable/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet/1.0.0-pretty.json +0 -120
- ethpm/ethpm-spec/examples/wallet/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet/contracts/Wallet.sol +0 -41
- ethpm/ethpm-spec/examples/wallet/v3-pretty.json +0 -181
- ethpm/ethpm-spec/examples/wallet/v3.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0-pretty.json +0 -135
- ethpm/ethpm-spec/examples/wallet-with-send/1.0.0.json +0 -1
- ethpm/ethpm-spec/examples/wallet-with-send/contracts/WalletWithSend.sol +0 -18
- ethpm/ethpm-spec/examples/wallet-with-send/v3-pretty.json +0 -207
- ethpm/ethpm-spec/examples/wallet-with-send/v3.json +0 -1
- ethpm/ethpm-spec/spec/package.spec.json +0 -379
- ethpm/ethpm-spec/spec/v3.spec.json +0 -483
- ethpm/exceptions.py +0 -68
- ethpm/package.py +0 -438
- ethpm/tools/__init__.py +0 -4
- ethpm/tools/builder.py +0 -930
- ethpm/tools/checker.py +0 -312
- ethpm/tools/get_manifest.py +0 -19
- ethpm/uri.py +0 -141
- ethpm/validation/__init__.py +0 -0
- ethpm/validation/manifest.py +0 -146
- ethpm/validation/misc.py +0 -39
- ethpm/validation/package.py +0 -80
- ethpm/validation/uri.py +0 -163
- web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
- web3/_utils/miner.py +0 -88
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -323
- web3/_utils/request.py +0 -265
- web3/middleware/abi.py +0 -11
- web3/middleware/async_cache.py +0 -99
- web3/middleware/cache.py +0 -374
- web3/middleware/exception_handling.py +0 -49
- web3/middleware/exception_retry_request.py +0 -188
- web3/middleware/fixture.py +0 -190
- web3/middleware/geth_poa.py +0 -81
- web3/middleware/normalize_request_parameters.py +0 -11
- web3/middleware/simulate_unmined_transaction.py +0 -43
- web3/pm.py +0 -602
- web3/providers/async_rpc.py +0 -99
- web3/providers/rpc.py +0 -98
- web3/providers/websocket/__init__.py +0 -11
- web3/providers/websocket/websocket_connection.py +0 -42
- web3/tools/__init__.py +0 -4
- web3/tools/pytest_ethereum/__init__.py +0 -0
- web3/tools/pytest_ethereum/_utils.py +0 -145
- web3/tools/pytest_ethereum/deployer.py +0 -48
- web3/tools/pytest_ethereum/exceptions.py +0 -22
- web3/tools/pytest_ethereum/linker.py +0 -128
- web3/tools/pytest_ethereum/plugins.py +0 -33
- web3-6.20.2.dist-info/METADATA +0 -103
- web3-6.20.2.dist-info/RECORD +0 -283
- web3-6.20.2.dist-info/entry_points.txt +0 -2
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
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
|
@@ -3,13 +3,11 @@ from enum import (
|
|
|
3
3
|
)
|
|
4
4
|
import json
|
|
5
5
|
import os
|
|
6
|
-
from sys import (
|
|
7
|
-
version_info,
|
|
8
|
-
)
|
|
9
6
|
from typing import (
|
|
10
7
|
Any,
|
|
11
8
|
Dict,
|
|
12
9
|
List,
|
|
10
|
+
Literal,
|
|
13
11
|
Optional,
|
|
14
12
|
Set,
|
|
15
13
|
Tuple,
|
|
@@ -25,17 +23,6 @@ from .exceptions import (
|
|
|
25
23
|
InvalidName,
|
|
26
24
|
)
|
|
27
25
|
|
|
28
|
-
# TODO: remove once web3 supports python>=3.8
|
|
29
|
-
if version_info >= (3, 8):
|
|
30
|
-
from typing import (
|
|
31
|
-
Literal,
|
|
32
|
-
)
|
|
33
|
-
else:
|
|
34
|
-
from typing_extensions import ( # type: ignore
|
|
35
|
-
Literal,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
|
|
39
26
|
# -- setup -- #
|
|
40
27
|
|
|
41
28
|
|
|
@@ -61,7 +48,7 @@ with open(os.path.join(specs_dir_path, "normalization_spec.json")) as spec:
|
|
|
61
48
|
# clean `FE0F` (65039) from entries since it's optional
|
|
62
49
|
for e in NORMALIZATION_SPEC["emoji"]:
|
|
63
50
|
if 65039 in e:
|
|
64
|
-
for
|
|
51
|
+
for _ in range(e.count(65039)):
|
|
65
52
|
e.remove(65039)
|
|
66
53
|
|
|
67
54
|
with open(os.path.join(specs_dir_path, "nf.json")) as nf:
|
|
@@ -235,7 +222,6 @@ def _validate_tokens_and_get_label_type(tokens: List[Token]) -> str:
|
|
|
235
222
|
:param List[Token] tokens: the tokens to validate
|
|
236
223
|
:raises InvalidName: if any of the tokens are invalid
|
|
237
224
|
"""
|
|
238
|
-
|
|
239
225
|
if all(token.type == TokenType.EMOJI for token in tokens):
|
|
240
226
|
return "emoji"
|
|
241
227
|
|
|
@@ -436,7 +422,6 @@ def normalize_name_ensip15(name: str) -> ENSNormalizedName:
|
|
|
436
422
|
:param str name: the dot-separated ENS name
|
|
437
423
|
:raises InvalidName: if ``name`` has invalid syntax
|
|
438
424
|
"""
|
|
439
|
-
|
|
440
425
|
if not name:
|
|
441
426
|
raise InvalidName("Name cannot be empty")
|
|
442
427
|
elif isinstance(name, (bytes, bytearray)):
|
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,
|
|
@@ -71,12 +73,14 @@ if TYPE_CHECKING:
|
|
|
71
73
|
AsyncContractFunction,
|
|
72
74
|
)
|
|
73
75
|
from web3.main import AsyncWeb3 # noqa: F401
|
|
76
|
+
from web3.middleware.base import ( # noqa: F401
|
|
77
|
+
Middleware,
|
|
78
|
+
)
|
|
74
79
|
from web3.providers import ( # noqa: F401
|
|
75
80
|
AsyncBaseProvider,
|
|
76
81
|
BaseProvider,
|
|
77
82
|
)
|
|
78
83
|
from web3.types import ( # noqa: F401
|
|
79
|
-
AsyncMiddleware,
|
|
80
84
|
TxParams,
|
|
81
85
|
)
|
|
82
86
|
|
|
@@ -87,7 +91,7 @@ class AsyncENS(BaseENS):
|
|
|
87
91
|
like getting the address for a name.
|
|
88
92
|
|
|
89
93
|
Unless otherwise specified, all addresses are assumed to be a `str` in
|
|
90
|
-
`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
|
|
91
95
|
like: ``"0x314159265dD8dbb310642f98f50C066173C1259b"``
|
|
92
96
|
"""
|
|
93
97
|
|
|
@@ -96,9 +100,9 @@ class AsyncENS(BaseENS):
|
|
|
96
100
|
|
|
97
101
|
def __init__(
|
|
98
102
|
self,
|
|
99
|
-
provider: "AsyncBaseProvider" =
|
|
103
|
+
provider: "AsyncBaseProvider" = None,
|
|
100
104
|
addr: ChecksumAddress = None,
|
|
101
|
-
|
|
105
|
+
middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
|
|
102
106
|
) -> None:
|
|
103
107
|
"""
|
|
104
108
|
:param provider: a single provider used to connect to Ethereum
|
|
@@ -106,7 +110,8 @@ class AsyncENS(BaseENS):
|
|
|
106
110
|
:param hex-string addr: the address of the ENS registry on-chain.
|
|
107
111
|
If not provided, ENS.py will default to the mainnet ENS registry address.
|
|
108
112
|
"""
|
|
109
|
-
|
|
113
|
+
provider = provider or cast("AsyncBaseProvider", default)
|
|
114
|
+
self.w3 = init_async_web3(provider, middleware)
|
|
110
115
|
|
|
111
116
|
ens_addr = addr if addr else ENS_MAINNET_ADDR
|
|
112
117
|
self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr)
|
|
@@ -127,10 +132,8 @@ class AsyncENS(BaseENS):
|
|
|
127
132
|
provided, defaults to the mainnet ENS registry address.
|
|
128
133
|
"""
|
|
129
134
|
provider = w3.manager.provider
|
|
130
|
-
|
|
131
|
-
ns = cls(
|
|
132
|
-
cast("AsyncBaseProvider", provider), addr=addr, middlewares=middlewares
|
|
133
|
-
)
|
|
135
|
+
middleware = w3.middleware_onion.middleware
|
|
136
|
+
ns = cls(cast("AsyncBaseProvider", provider), addr=addr, middleware=middleware)
|
|
134
137
|
|
|
135
138
|
# inherit strict bytes checking from w3 instance
|
|
136
139
|
ns.strict_bytes_type_checking = w3.strict_bytes_type_checking
|
|
@@ -167,7 +170,7 @@ class AsyncENS(BaseENS):
|
|
|
167
170
|
async def setup_address(
|
|
168
171
|
self,
|
|
169
172
|
name: str,
|
|
170
|
-
address: Union[Address, ChecksumAddress, HexAddress] = cast(
|
|
173
|
+
address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
|
|
171
174
|
ChecksumAddress, default
|
|
172
175
|
),
|
|
173
176
|
coin_type: Optional[int] = None,
|
|
@@ -204,7 +207,7 @@ class AsyncENS(BaseENS):
|
|
|
204
207
|
elif is_binary_address(address):
|
|
205
208
|
address = to_checksum_address(cast(str, address))
|
|
206
209
|
elif not is_checksum_address(address):
|
|
207
|
-
raise
|
|
210
|
+
raise ENSValueError("You must supply the address in checksum format")
|
|
208
211
|
if await self.address(name) == address:
|
|
209
212
|
return None
|
|
210
213
|
if address is None:
|
|
@@ -282,7 +285,7 @@ class AsyncENS(BaseENS):
|
|
|
282
285
|
if is_binary_address(address):
|
|
283
286
|
address = to_checksum_address(address)
|
|
284
287
|
if not is_checksum_address(address):
|
|
285
|
-
raise
|
|
288
|
+
raise ENSValueError("You must supply the address in checksum format")
|
|
286
289
|
await self._assert_control(address, name)
|
|
287
290
|
if not resolved:
|
|
288
291
|
await self.setup_address(name, address, transact=transact)
|
|
@@ -305,7 +308,7 @@ class AsyncENS(BaseENS):
|
|
|
305
308
|
async def setup_owner(
|
|
306
309
|
self,
|
|
307
310
|
name: str,
|
|
308
|
-
new_owner: ChecksumAddress =
|
|
311
|
+
new_owner: ChecksumAddress = None,
|
|
309
312
|
transact: Optional["TxParams"] = None,
|
|
310
313
|
) -> Optional[ChecksumAddress]:
|
|
311
314
|
"""
|
|
@@ -332,6 +335,7 @@ class AsyncENS(BaseENS):
|
|
|
332
335
|
:raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
|
|
333
336
|
:returns: the new owner's address
|
|
334
337
|
"""
|
|
338
|
+
new_owner = new_owner or cast(ChecksumAddress, default)
|
|
335
339
|
if not transact:
|
|
336
340
|
transact = {}
|
|
337
341
|
transact = deepcopy(transact)
|
|
@@ -466,9 +470,13 @@ class AsyncENS(BaseENS):
|
|
|
466
470
|
resolver_addr = await self.address("resolver.eth")
|
|
467
471
|
namehash = raw_name_to_hash(name)
|
|
468
472
|
if await self.ens.caller.resolver(namehash) != resolver_addr:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
473
|
+
coro = cast(
|
|
474
|
+
Coroutine[Any, Any, HexBytes],
|
|
475
|
+
self.ens.functions.setResolver(namehash, resolver_addr).transact(
|
|
476
|
+
transact
|
|
477
|
+
),
|
|
478
|
+
)
|
|
479
|
+
await coro
|
|
472
480
|
return cast("AsyncContract", self._resolver_contract(address=resolver_addr))
|
|
473
481
|
|
|
474
482
|
async def _resolve(
|
|
@@ -550,11 +558,15 @@ class AsyncENS(BaseENS):
|
|
|
550
558
|
transact = deepcopy(transact)
|
|
551
559
|
transact["from"] = old_owner or owner
|
|
552
560
|
for label in reversed(unowned):
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
|
558
570
|
owned = f"{label}.{owned}"
|
|
559
571
|
|
|
560
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/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,
|
|
@@ -71,11 +72,13 @@ if TYPE_CHECKING:
|
|
|
71
72
|
Contract,
|
|
72
73
|
ContractFunction,
|
|
73
74
|
)
|
|
75
|
+
from web3.middleware.base import ( # noqa: F401
|
|
76
|
+
Middleware,
|
|
77
|
+
)
|
|
74
78
|
from web3.providers import ( # noqa: F401
|
|
75
79
|
BaseProvider,
|
|
76
80
|
)
|
|
77
81
|
from web3.types import ( # noqa: F401
|
|
78
|
-
Middleware,
|
|
79
82
|
TxParams,
|
|
80
83
|
)
|
|
81
84
|
|
|
@@ -86,7 +89,7 @@ class ENS(BaseENS):
|
|
|
86
89
|
like getting the address for a name.
|
|
87
90
|
|
|
88
91
|
Unless otherwise specified, all addresses are assumed to be a `str` in
|
|
89
|
-
`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
|
|
90
93
|
like: ``"0x314159265dD8dbb310642f98f50C066173C1259b"``
|
|
91
94
|
"""
|
|
92
95
|
|
|
@@ -95,9 +98,9 @@ class ENS(BaseENS):
|
|
|
95
98
|
|
|
96
99
|
def __init__(
|
|
97
100
|
self,
|
|
98
|
-
provider: "BaseProvider" =
|
|
101
|
+
provider: "BaseProvider" = None,
|
|
99
102
|
addr: ChecksumAddress = None,
|
|
100
|
-
|
|
103
|
+
middleware: Optional[Sequence[Tuple["Middleware", str]]] = None,
|
|
101
104
|
) -> None:
|
|
102
105
|
"""
|
|
103
106
|
:param provider: a single provider used to connect to Ethereum
|
|
@@ -106,7 +109,8 @@ class ENS(BaseENS):
|
|
|
106
109
|
If not provided, ENS.py will default to the mainnet ENS
|
|
107
110
|
registry address.
|
|
108
111
|
"""
|
|
109
|
-
|
|
112
|
+
provider = provider or cast("BaseProvider", default)
|
|
113
|
+
self.w3 = init_web3(provider, middleware)
|
|
110
114
|
|
|
111
115
|
ens_addr = addr if addr else ENS_MAINNET_ADDR
|
|
112
116
|
self.ens = self.w3.eth.contract(abi=abis.ENS, address=ens_addr)
|
|
@@ -127,8 +131,8 @@ class ENS(BaseENS):
|
|
|
127
131
|
provided, defaults to the mainnet ENS registry address.
|
|
128
132
|
"""
|
|
129
133
|
provider = w3.manager.provider
|
|
130
|
-
|
|
131
|
-
ns = cls(cast("BaseProvider", provider), addr=addr,
|
|
134
|
+
middleware = w3.middleware_onion.middleware
|
|
135
|
+
ns = cls(cast("BaseProvider", provider), addr=addr, middleware=middleware)
|
|
132
136
|
|
|
133
137
|
# inherit strict bytes checking from w3 instance
|
|
134
138
|
ns.strict_bytes_type_checking = w3.strict_bytes_type_checking
|
|
@@ -168,7 +172,7 @@ class ENS(BaseENS):
|
|
|
168
172
|
def setup_address(
|
|
169
173
|
self,
|
|
170
174
|
name: str,
|
|
171
|
-
address: Union[Address, ChecksumAddress, HexAddress] = cast(
|
|
175
|
+
address: Union[Address, ChecksumAddress, HexAddress] = cast( # noqa: B008
|
|
172
176
|
ChecksumAddress, default
|
|
173
177
|
),
|
|
174
178
|
coin_type: Optional[int] = None,
|
|
@@ -206,7 +210,7 @@ class ENS(BaseENS):
|
|
|
206
210
|
elif is_binary_address(address):
|
|
207
211
|
address = to_checksum_address(cast(str, address))
|
|
208
212
|
elif not is_checksum_address(address):
|
|
209
|
-
raise
|
|
213
|
+
raise ENSValueError("You must supply the address in checksum format")
|
|
210
214
|
if self.address(name) == address:
|
|
211
215
|
return None
|
|
212
216
|
if address is None:
|
|
@@ -282,7 +286,7 @@ class ENS(BaseENS):
|
|
|
282
286
|
if is_binary_address(address):
|
|
283
287
|
address = to_checksum_address(address)
|
|
284
288
|
if not is_checksum_address(address):
|
|
285
|
-
raise
|
|
289
|
+
raise ENSValueError("You must supply the address in checksum format")
|
|
286
290
|
self._assert_control(address, name)
|
|
287
291
|
if not resolved:
|
|
288
292
|
self.setup_address(name, address, transact=transact)
|
|
@@ -305,7 +309,7 @@ class ENS(BaseENS):
|
|
|
305
309
|
def setup_owner(
|
|
306
310
|
self,
|
|
307
311
|
name: str,
|
|
308
|
-
new_owner: ChecksumAddress =
|
|
312
|
+
new_owner: ChecksumAddress = None,
|
|
309
313
|
transact: Optional["TxParams"] = None,
|
|
310
314
|
) -> Optional[ChecksumAddress]:
|
|
311
315
|
"""
|
|
@@ -332,6 +336,7 @@ class ENS(BaseENS):
|
|
|
332
336
|
:raises UnauthorizedError: if ``'from'`` in `transact` does not own `name`
|
|
333
337
|
:returns: the new owner's address
|
|
334
338
|
"""
|
|
339
|
+
new_owner = new_owner or cast(ChecksumAddress, default)
|
|
335
340
|
if not transact:
|
|
336
341
|
transact = {}
|
|
337
342
|
|
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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
|
103
|
+
class ENSValidationError(ENSException):
|
|
117
104
|
"""
|
|
118
105
|
Raised if there is a validation error
|
|
119
106
|
"""
|