web3 6.20.3__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.3.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.3.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.3.dist-info/METADATA +0 -104
- web3-6.20.3.dist-info/RECORD +0 -283
- web3-6.20.3.dist-info/entry_points.txt +0 -2
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
- {web3-6.20.3.dist-info → web3-7.0.0.dist-info}/WHEEL +0 -0
ethpm/validation/package.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
from typing import (
|
|
3
|
-
Any,
|
|
4
|
-
Dict,
|
|
5
|
-
)
|
|
6
|
-
|
|
7
|
-
from eth_utils import (
|
|
8
|
-
is_text,
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
from ethpm._utils.ipfs import (
|
|
12
|
-
is_ipfs_uri,
|
|
13
|
-
)
|
|
14
|
-
from ethpm.constants import (
|
|
15
|
-
PACKAGE_NAME_REGEX,
|
|
16
|
-
)
|
|
17
|
-
from ethpm.exceptions import (
|
|
18
|
-
EthPMValidationError,
|
|
19
|
-
InsufficientAssetsError,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def validate_minimal_contract_factory_data(contract_data: Dict[str, str]) -> None:
|
|
24
|
-
"""
|
|
25
|
-
Validate that contract data in a package contains at least an "abi" and
|
|
26
|
-
"deploymentBytecode" necessary to generate a deployable contract factory.
|
|
27
|
-
"""
|
|
28
|
-
if not all(key in contract_data.keys() for key in ("abi", "deploymentBytecode")):
|
|
29
|
-
raise InsufficientAssetsError(
|
|
30
|
-
"Minimum required contract data to generate a deployable "
|
|
31
|
-
"contract factory (abi & deploymentBytecode) not found."
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def validate_package_version(version: Any) -> None:
|
|
36
|
-
"""
|
|
37
|
-
Validates that a package version is of text type.
|
|
38
|
-
"""
|
|
39
|
-
if not is_text(version):
|
|
40
|
-
raise EthPMValidationError(
|
|
41
|
-
f"Expected a version of text type, instead received {type(version)}."
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def validate_package_name(pkg_name: str) -> None:
|
|
46
|
-
"""
|
|
47
|
-
Raise an exception if the value is not a valid package name
|
|
48
|
-
as defined in the EthPM-Spec.
|
|
49
|
-
"""
|
|
50
|
-
if not bool(re.match(PACKAGE_NAME_REGEX, pkg_name)):
|
|
51
|
-
raise EthPMValidationError(f"{pkg_name} is not a valid package name.")
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def validate_manifest_version(version: str) -> None:
|
|
55
|
-
"""
|
|
56
|
-
Raise an exception if the version is not "ethpm/3".
|
|
57
|
-
"""
|
|
58
|
-
if not version == "ethpm/3":
|
|
59
|
-
raise EthPMValidationError(
|
|
60
|
-
f"Py-EthPM does not support the provided specification version: {version}"
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
def validate_build_dependency(key: str, uri: str) -> None:
|
|
65
|
-
"""
|
|
66
|
-
Raise an exception if the key in dependencies is not a valid package name,
|
|
67
|
-
or if the value is not a valid IPFS URI.
|
|
68
|
-
"""
|
|
69
|
-
validate_package_name(key)
|
|
70
|
-
# validate is supported content-addressed uri
|
|
71
|
-
if not is_ipfs_uri(uri):
|
|
72
|
-
raise EthPMValidationError(f"URI: {uri} is not a valid IPFS URI.")
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
CONTRACT_NAME_REGEX = re.compile("^[a-zA-Z][-a-zA-Z0-9_]{0,255}$")
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def validate_contract_name(name: str) -> None:
|
|
79
|
-
if not CONTRACT_NAME_REGEX.match(name):
|
|
80
|
-
raise EthPMValidationError(f"Contract name: {name} is not valid.")
|
ethpm/validation/uri.py
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
from typing import (
|
|
3
|
-
TYPE_CHECKING,
|
|
4
|
-
List,
|
|
5
|
-
)
|
|
6
|
-
from urllib import (
|
|
7
|
-
parse,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
from eth_utils import (
|
|
11
|
-
is_checksum_address,
|
|
12
|
-
to_bytes,
|
|
13
|
-
to_int,
|
|
14
|
-
to_text,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
from ethpm._utils.chains import (
|
|
18
|
-
is_supported_chain_id,
|
|
19
|
-
)
|
|
20
|
-
from ethpm._utils.ipfs import (
|
|
21
|
-
is_ipfs_uri,
|
|
22
|
-
)
|
|
23
|
-
from ethpm._utils.registry import (
|
|
24
|
-
is_ens_domain,
|
|
25
|
-
)
|
|
26
|
-
from ethpm.constants import (
|
|
27
|
-
REGISTRY_URI_SCHEMES,
|
|
28
|
-
)
|
|
29
|
-
from ethpm.exceptions import (
|
|
30
|
-
EthPMValidationError,
|
|
31
|
-
)
|
|
32
|
-
from ethpm.validation.misc import (
|
|
33
|
-
validate_escaped_string,
|
|
34
|
-
)
|
|
35
|
-
from ethpm.validation.package import (
|
|
36
|
-
validate_package_name,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
if TYPE_CHECKING:
|
|
40
|
-
from web3 import Web3 # noqa: F401
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def validate_ipfs_uri(uri: str) -> None:
|
|
44
|
-
"""
|
|
45
|
-
Raise an exception if the provided URI is not a valid IPFS URI.
|
|
46
|
-
"""
|
|
47
|
-
if not is_ipfs_uri(uri):
|
|
48
|
-
raise EthPMValidationError(f"URI: {uri} is not a valid IPFS URI.")
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def validate_registry_uri(uri: str) -> None:
|
|
52
|
-
"""
|
|
53
|
-
Raise an exception if the URI does not conform to the registry URI scheme.
|
|
54
|
-
"""
|
|
55
|
-
parsed = parse.urlparse(uri)
|
|
56
|
-
scheme, authority, pkg_path = (
|
|
57
|
-
parsed.scheme,
|
|
58
|
-
parsed.netloc,
|
|
59
|
-
parsed.path,
|
|
60
|
-
)
|
|
61
|
-
pkg_id = pkg_path.strip("/")
|
|
62
|
-
|
|
63
|
-
if "@" in pkg_id:
|
|
64
|
-
if len(pkg_id.split("@")) != 2:
|
|
65
|
-
raise EthPMValidationError("Registry URI: {pkg_id} is not properly escaped")
|
|
66
|
-
pkg_name, pkg_version = pkg_id.split("@")
|
|
67
|
-
else:
|
|
68
|
-
pkg_name, pkg_version = (pkg_id, None)
|
|
69
|
-
|
|
70
|
-
validate_registry_uri_scheme(scheme)
|
|
71
|
-
validate_registry_uri_authority(authority)
|
|
72
|
-
if pkg_name:
|
|
73
|
-
validate_package_name(pkg_name)
|
|
74
|
-
if not pkg_name and pkg_version:
|
|
75
|
-
raise EthPMValidationError(
|
|
76
|
-
"Registry URIs cannot provide a version without a package name."
|
|
77
|
-
)
|
|
78
|
-
if pkg_version:
|
|
79
|
-
validate_escaped_string(pkg_version)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def validate_registry_uri_authority(auth: str) -> None:
|
|
83
|
-
"""
|
|
84
|
-
Raise an exception if the authority is not a valid ENS domain
|
|
85
|
-
or a valid checksummed contract address.
|
|
86
|
-
"""
|
|
87
|
-
if ":" in auth:
|
|
88
|
-
if len(auth.split(":")) != 2:
|
|
89
|
-
raise EthPMValidationError(
|
|
90
|
-
f"{auth} is not a valid registry URI authority. "
|
|
91
|
-
"Please try again with a valid registry URI."
|
|
92
|
-
)
|
|
93
|
-
address, chain_id = auth.split(":")
|
|
94
|
-
else:
|
|
95
|
-
address, chain_id = auth, "1"
|
|
96
|
-
|
|
97
|
-
if is_ens_domain(address) is False and not is_checksum_address(address):
|
|
98
|
-
raise EthPMValidationError(
|
|
99
|
-
f"{address} is not a valid registry address. "
|
|
100
|
-
"Please try again with a valid registry URI."
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
if not is_supported_chain_id(to_int(text=chain_id)):
|
|
104
|
-
raise EthPMValidationError(
|
|
105
|
-
f"Chain ID: {chain_id} is not supported. Supported chain ids include: "
|
|
106
|
-
"1 (mainnet), 5 (goerli), and 11155111 (sepolia)."
|
|
107
|
-
"Please try again with a valid registry URI."
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def validate_registry_uri_scheme(scheme: str) -> None:
|
|
112
|
-
"""
|
|
113
|
-
Raise an exception if the scheme is not a valid registry URI scheme:
|
|
114
|
-
- 'erc1319'
|
|
115
|
-
- 'ethpm'
|
|
116
|
-
"""
|
|
117
|
-
if scheme not in REGISTRY_URI_SCHEMES:
|
|
118
|
-
raise EthPMValidationError(
|
|
119
|
-
f"{scheme} is not a valid registry URI scheme. "
|
|
120
|
-
f"Valid schemes include: {REGISTRY_URI_SCHEMES}"
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def validate_single_matching_uri(all_blockchain_uris: List[str], w3: "Web3") -> str:
|
|
125
|
-
"""
|
|
126
|
-
Return a single block URI after validating that it is the *only* URI in
|
|
127
|
-
all_blockchain_uris that matches the w3 instance.
|
|
128
|
-
"""
|
|
129
|
-
from ethpm.uri import (
|
|
130
|
-
check_if_chain_matches_chain_uri,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
matching_uris = [
|
|
134
|
-
uri for uri in all_blockchain_uris if check_if_chain_matches_chain_uri(w3, uri)
|
|
135
|
-
]
|
|
136
|
-
|
|
137
|
-
if not matching_uris:
|
|
138
|
-
raise EthPMValidationError("Package has no matching URIs on chain.")
|
|
139
|
-
elif len(matching_uris) != 1:
|
|
140
|
-
raise EthPMValidationError(
|
|
141
|
-
f"Package has too many ({len(matching_uris)}) "
|
|
142
|
-
"matching URIs: {matching_uris}."
|
|
143
|
-
)
|
|
144
|
-
return matching_uris[0]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
def validate_blob_uri_contents(contents: bytes, blob_uri: str) -> None:
|
|
148
|
-
"""
|
|
149
|
-
Raises an exception if the sha1 hash of the contents does not match the
|
|
150
|
-
hash found in the blob_uri. Formula for how git calculates the hash
|
|
151
|
-
found here: http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html
|
|
152
|
-
"""
|
|
153
|
-
blob_path = parse.urlparse(blob_uri).path
|
|
154
|
-
blob_hash = blob_path.split("/")[-1]
|
|
155
|
-
contents_str = to_text(contents)
|
|
156
|
-
content_length = len(contents_str)
|
|
157
|
-
hashable_contents = "blob " + str(content_length) + "\0" + contents_str
|
|
158
|
-
hash_object = hashlib.sha1(to_bytes(text=hashable_contents))
|
|
159
|
-
if hash_object.hexdigest() != blob_hash:
|
|
160
|
-
raise EthPMValidationError(
|
|
161
|
-
f"Hash of contents fetched from {blob_uri} do not "
|
|
162
|
-
f"match its hash: {blob_hash}."
|
|
163
|
-
)
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Generated by `compile_contract_sources.py` script.
|
|
3
|
-
Compiled with Solidity v0.8.17.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
# source: web3/_utils/contract_sources/AddressReflector.sol:AddressReflector
|
|
7
|
-
ADDRESS_REFLECTOR_BYTECODE = "0x608060405234801561001057600080fd5b50610430806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea264697066735822122035083763a0f4c4f5a71055f0da2f3d4f78e64159a8f3bc215c430daec7ac5e2064736f6c63430008110033" # noqa: E501
|
|
8
|
-
ADDRESS_REFLECTOR_RUNTIME = "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630b816c161461003b578063c04d11fc1461006b575b600080fd5b61005560048036038101906100509190610121565b61009b565b604051610062919061015d565b60405180910390f35b610085600480360381019061008091906102d1565b6100a5565b60405161009291906103d8565b60405180910390f35b6000819050919050565b6060819050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100ee826100c3565b9050919050565b6100fe816100e3565b811461010957600080fd5b50565b60008135905061011b816100f5565b92915050565b600060208284031215610137576101366100b9565b5b60006101458482850161010c565b91505092915050565b610157816100e3565b82525050565b6000602082019050610172600083018461014e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6101c68261017d565b810181811067ffffffffffffffff821117156101e5576101e461018e565b5b80604052505050565b60006101f86100af565b905061020482826101bd565b919050565b600067ffffffffffffffff8211156102245761022361018e565b5b602082029050602081019050919050565b600080fd5b600061024d61024884610209565b6101ee565b905080838252602082019050602084028301858111156102705761026f610235565b5b835b818110156102995780610285888261010c565b845260208401935050602081019050610272565b5050509392505050565b600082601f8301126102b8576102b7610178565b5b81356102c884826020860161023a565b91505092915050565b6000602082840312156102e7576102e66100b9565b5b600082013567ffffffffffffffff811115610305576103046100be565b5b610311848285016102a3565b91505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b61034f816100e3565b82525050565b60006103618383610346565b60208301905092915050565b6000602082019050919050565b60006103858261031a565b61038f8185610325565b935061039a83610336565b8060005b838110156103cb5781516103b28882610355565b97506103bd8361036d565b92505060018101905061039e565b5085935050505092915050565b600060208201905081810360008301526103f2818461037a565b90509291505056fea264697066735822122035083763a0f4c4f5a71055f0da2f3d4f78e64159a8f3bc215c430daec7ac5e2064736f6c63430008110033" # noqa: E501
|
|
9
|
-
ADDRESS_REFLECTOR_ABI = [
|
|
10
|
-
{
|
|
11
|
-
"inputs": [{"internalType": "address", "name": "arg", "type": "address"}],
|
|
12
|
-
"name": "reflect",
|
|
13
|
-
"outputs": [{"internalType": "address", "name": "", "type": "address"}],
|
|
14
|
-
"stateMutability": "pure",
|
|
15
|
-
"type": "function",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
"inputs": [{"internalType": "address[]", "name": "arg", "type": "address[]"}],
|
|
19
|
-
"name": "reflect",
|
|
20
|
-
"outputs": [{"internalType": "address[]", "name": "", "type": "address[]"}],
|
|
21
|
-
"stateMutability": "pure",
|
|
22
|
-
"type": "function",
|
|
23
|
-
},
|
|
24
|
-
]
|
|
25
|
-
ADDRESS_REFLECTOR_DATA = {
|
|
26
|
-
"bytecode": ADDRESS_REFLECTOR_BYTECODE,
|
|
27
|
-
"bytecode_runtime": ADDRESS_REFLECTOR_RUNTIME,
|
|
28
|
-
"abi": ADDRESS_REFLECTOR_ABI,
|
|
29
|
-
}
|
web3/_utils/miner.py
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
from typing import (
|
|
2
|
-
Callable,
|
|
3
|
-
)
|
|
4
|
-
|
|
5
|
-
from eth_typing import (
|
|
6
|
-
ChecksumAddress,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
from web3._utils.rpc_abi import (
|
|
10
|
-
RPC,
|
|
11
|
-
)
|
|
12
|
-
from web3.method import (
|
|
13
|
-
DeprecatedMethod,
|
|
14
|
-
Method,
|
|
15
|
-
default_root_munger,
|
|
16
|
-
)
|
|
17
|
-
from web3.types import (
|
|
18
|
-
BlockNumber,
|
|
19
|
-
Wei,
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
#
|
|
23
|
-
# The Geth client deprecated the miner namespace.
|
|
24
|
-
#
|
|
25
|
-
|
|
26
|
-
_make_dag: Method[Callable[[BlockNumber], bool]] = Method(
|
|
27
|
-
RPC.miner_makeDag,
|
|
28
|
-
mungers=[default_root_munger],
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
make_dag = DeprecatedMethod(_make_dag, msg="All mining methods have been deprecated")
|
|
32
|
-
|
|
33
|
-
_set_extra: Method[Callable[[str], bool]] = Method(
|
|
34
|
-
RPC.miner_setExtra,
|
|
35
|
-
mungers=[default_root_munger],
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
set_extra = DeprecatedMethod(_set_extra, msg="All mining methods have been deprecated")
|
|
39
|
-
|
|
40
|
-
_set_etherbase: Method[Callable[[ChecksumAddress], bool]] = Method(
|
|
41
|
-
RPC.miner_setEtherbase,
|
|
42
|
-
mungers=[default_root_munger],
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
set_etherbase = DeprecatedMethod(
|
|
46
|
-
_set_etherbase, msg="All mining methods have been deprecated"
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
_set_gas_price: Method[Callable[[Wei], bool]] = Method(
|
|
50
|
-
RPC.miner_setGasPrice,
|
|
51
|
-
mungers=[default_root_munger],
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
set_gas_price = DeprecatedMethod(
|
|
55
|
-
_set_gas_price, msg="All mining methods have been deprecated"
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
_start: Method[Callable[[int], bool]] = Method(
|
|
59
|
-
RPC.miner_start,
|
|
60
|
-
mungers=[default_root_munger],
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
start = DeprecatedMethod(_start, msg="All mining methods have been deprecated")
|
|
64
|
-
|
|
65
|
-
_stop: Method[Callable[[], bool]] = Method(
|
|
66
|
-
RPC.miner_stop,
|
|
67
|
-
is_property=True,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
stop = DeprecatedMethod(_stop, msg="All mining methods have been deprecated")
|
|
71
|
-
|
|
72
|
-
_start_auto_dag: Method[Callable[[], bool]] = Method(
|
|
73
|
-
RPC.miner_startAutoDag,
|
|
74
|
-
is_property=True,
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
start_auto_dag = DeprecatedMethod(
|
|
78
|
-
_start_auto_dag, msg="All mining methods have been deprecated"
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
_stop_auto_dag: Method[Callable[[], bool]] = Method(
|
|
82
|
-
RPC.miner_stopAutoDag,
|
|
83
|
-
is_property=True,
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
stop_auto_dag = DeprecatedMethod(
|
|
87
|
-
_stop_auto_dag, msg="All mining methods have been deprecated"
|
|
88
|
-
)
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import pytest
|
|
3
|
-
from typing import (
|
|
4
|
-
TYPE_CHECKING,
|
|
5
|
-
cast,
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
from eth_typing import (
|
|
9
|
-
ChecksumAddress,
|
|
10
|
-
)
|
|
11
|
-
from eth_utils import (
|
|
12
|
-
is_checksum_address,
|
|
13
|
-
is_list_like,
|
|
14
|
-
is_same_address,
|
|
15
|
-
is_string,
|
|
16
|
-
)
|
|
17
|
-
from hexbytes import (
|
|
18
|
-
HexBytes,
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
from web3 import (
|
|
22
|
-
constants,
|
|
23
|
-
)
|
|
24
|
-
from web3.datastructures import (
|
|
25
|
-
AttributeDict,
|
|
26
|
-
)
|
|
27
|
-
from web3.types import (
|
|
28
|
-
TxParams,
|
|
29
|
-
Wei,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
if TYPE_CHECKING:
|
|
33
|
-
from web3 import ( # noqa: F401
|
|
34
|
-
AsyncWeb3,
|
|
35
|
-
Web3,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
PRIVATE_KEY_HEX = "0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f933673458f"
|
|
39
|
-
SECOND_PRIVATE_KEY_HEX = (
|
|
40
|
-
"0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f9336712345"
|
|
41
|
-
)
|
|
42
|
-
THIRD_PRIVATE_KEY_HEX = (
|
|
43
|
-
"0x56ebb41875ceedd42e395f730e03b5c44989393c9f0484ee6bc05f9336754321"
|
|
44
|
-
)
|
|
45
|
-
PASSWORD = "web3-testing"
|
|
46
|
-
ADDRESS = "0x844B417c0C58B02c2224306047B9fb0D3264fE8c"
|
|
47
|
-
SECOND_ADDRESS = "0xB96b6B21053e67BA59907E252D990C71742c41B8"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
PRIVATE_KEY_FOR_UNLOCK = (
|
|
51
|
-
"0x392f63a79b1ff8774845f3fa69de4a13800a59e7083f5187f1558f0797ad0f01"
|
|
52
|
-
)
|
|
53
|
-
ACCOUNT_FOR_UNLOCK = "0x12efDc31B1a8FA1A1e756DFD8A1601055C971E13"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class GoEthereumPersonalModuleTest:
|
|
57
|
-
def test_personal_import_raw_key(self, w3: "Web3") -> None:
|
|
58
|
-
with pytest.warns(DeprecationWarning):
|
|
59
|
-
actual = w3.geth.personal.import_raw_key(PRIVATE_KEY_HEX, PASSWORD)
|
|
60
|
-
assert actual == ADDRESS
|
|
61
|
-
|
|
62
|
-
def test_personal_list_accounts(self, w3: "Web3") -> None:
|
|
63
|
-
with pytest.warns(DeprecationWarning):
|
|
64
|
-
accounts = w3.geth.personal.list_accounts()
|
|
65
|
-
assert is_list_like(accounts)
|
|
66
|
-
assert len(accounts) > 0
|
|
67
|
-
assert all((is_checksum_address(item) for item in accounts))
|
|
68
|
-
|
|
69
|
-
def test_personal_list_wallets(self, w3: "Web3") -> None:
|
|
70
|
-
with pytest.warns(DeprecationWarning):
|
|
71
|
-
wallets = w3.geth.personal.list_wallets()
|
|
72
|
-
assert is_list_like(wallets)
|
|
73
|
-
assert len(wallets) > 0
|
|
74
|
-
assert is_checksum_address(wallets[0]["accounts"][0]["address"])
|
|
75
|
-
assert is_string(wallets[0]["accounts"][0]["url"])
|
|
76
|
-
assert is_string(wallets[0]["status"])
|
|
77
|
-
assert is_string(wallets[0]["url"])
|
|
78
|
-
|
|
79
|
-
def test_personal_lock_account(
|
|
80
|
-
self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress
|
|
81
|
-
) -> None:
|
|
82
|
-
with pytest.warns(DeprecationWarning):
|
|
83
|
-
w3.geth.personal.lock_account(unlockable_account_dual_type)
|
|
84
|
-
|
|
85
|
-
def test_personal_unlock_account_success(
|
|
86
|
-
self,
|
|
87
|
-
w3: "Web3",
|
|
88
|
-
unlockable_account_dual_type: ChecksumAddress,
|
|
89
|
-
unlockable_account_pw: str,
|
|
90
|
-
) -> None:
|
|
91
|
-
with pytest.warns(DeprecationWarning):
|
|
92
|
-
result = w3.geth.personal.unlock_account(
|
|
93
|
-
unlockable_account_dual_type, unlockable_account_pw
|
|
94
|
-
)
|
|
95
|
-
assert result is True
|
|
96
|
-
|
|
97
|
-
def test_personal_unlock_account_failure(
|
|
98
|
-
self, w3: "Web3", unlockable_account_dual_type: ChecksumAddress
|
|
99
|
-
) -> None:
|
|
100
|
-
with pytest.raises(ValueError):
|
|
101
|
-
w3.geth.personal.unlock_account(
|
|
102
|
-
unlockable_account_dual_type, "bad-password"
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
def test_personal_new_account(self, w3: "Web3") -> None:
|
|
106
|
-
with pytest.warns(DeprecationWarning):
|
|
107
|
-
new_account = w3.geth.personal.new_account(PASSWORD)
|
|
108
|
-
assert is_checksum_address(new_account)
|
|
109
|
-
|
|
110
|
-
def test_personal_send_transaction(
|
|
111
|
-
self,
|
|
112
|
-
w3: "Web3",
|
|
113
|
-
unlockable_account_dual_type: ChecksumAddress,
|
|
114
|
-
unlockable_account_pw: str,
|
|
115
|
-
) -> None:
|
|
116
|
-
assert (
|
|
117
|
-
w3.eth.get_balance(unlockable_account_dual_type) > constants.WEI_PER_ETHER
|
|
118
|
-
)
|
|
119
|
-
txn_params: TxParams = {
|
|
120
|
-
"from": unlockable_account_dual_type,
|
|
121
|
-
"to": unlockable_account_dual_type,
|
|
122
|
-
"gas": 21000,
|
|
123
|
-
"value": Wei(1),
|
|
124
|
-
"gasPrice": w3.to_wei(1, "gwei"),
|
|
125
|
-
}
|
|
126
|
-
with pytest.warns(DeprecationWarning):
|
|
127
|
-
txn_hash = w3.geth.personal.send_transaction(
|
|
128
|
-
txn_params, unlockable_account_pw
|
|
129
|
-
)
|
|
130
|
-
assert txn_hash
|
|
131
|
-
transaction = w3.eth.get_transaction(txn_hash)
|
|
132
|
-
|
|
133
|
-
assert is_same_address(
|
|
134
|
-
transaction["from"], cast(ChecksumAddress, txn_params["from"])
|
|
135
|
-
)
|
|
136
|
-
assert is_same_address(
|
|
137
|
-
transaction["to"], cast(ChecksumAddress, txn_params["to"])
|
|
138
|
-
)
|
|
139
|
-
assert transaction["gas"] == txn_params["gas"]
|
|
140
|
-
assert transaction["value"] == txn_params["value"]
|
|
141
|
-
assert transaction["gasPrice"] == txn_params["gasPrice"]
|
|
142
|
-
|
|
143
|
-
def test_personal_sign_and_ecrecover(
|
|
144
|
-
self,
|
|
145
|
-
w3: "Web3",
|
|
146
|
-
unlockable_account_dual_type: ChecksumAddress,
|
|
147
|
-
unlockable_account_pw: str,
|
|
148
|
-
) -> None:
|
|
149
|
-
message = "test-web3-geth-personal-sign"
|
|
150
|
-
with pytest.warns(DeprecationWarning):
|
|
151
|
-
signature = w3.geth.personal.sign(
|
|
152
|
-
message, unlockable_account_dual_type, unlockable_account_pw
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
with pytest.warns(DeprecationWarning):
|
|
156
|
-
signer = w3.geth.personal.ec_recover(message, signature)
|
|
157
|
-
assert is_same_address(signer, unlockable_account_dual_type)
|
|
158
|
-
|
|
159
|
-
@pytest.mark.xfail(
|
|
160
|
-
reason="personal_sign_typed_data JSON RPC call has not been released in geth"
|
|
161
|
-
)
|
|
162
|
-
def test_personal_sign_typed_data(
|
|
163
|
-
self,
|
|
164
|
-
w3: "Web3",
|
|
165
|
-
unlockable_account_dual_type: ChecksumAddress,
|
|
166
|
-
unlockable_account_pw: str,
|
|
167
|
-
) -> None:
|
|
168
|
-
typed_message = """
|
|
169
|
-
{
|
|
170
|
-
"types": {
|
|
171
|
-
"EIP712Domain": [
|
|
172
|
-
{"name": "name", "type": "string"},
|
|
173
|
-
{"name": "version", "type": "string"},
|
|
174
|
-
{"name": "chainId", "type": "uint256"},
|
|
175
|
-
{"name": "verifyingContract", "type": "address"}
|
|
176
|
-
],
|
|
177
|
-
"Person": [
|
|
178
|
-
{"name": "name", "type": "string"},
|
|
179
|
-
{"name": "wallet", "type": "address"}
|
|
180
|
-
],
|
|
181
|
-
"Mail": [
|
|
182
|
-
{"name": "from", "type": "Person"},
|
|
183
|
-
{"name": "to", "type": "Person"},
|
|
184
|
-
{"name": "contents", "type": "string"}
|
|
185
|
-
]
|
|
186
|
-
},
|
|
187
|
-
"primaryType": "Mail",
|
|
188
|
-
"domain": {
|
|
189
|
-
"name": "Ether Mail",
|
|
190
|
-
"version": "1",
|
|
191
|
-
"chainId": "0x01",
|
|
192
|
-
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
|
|
193
|
-
},
|
|
194
|
-
"message": {
|
|
195
|
-
"from": {
|
|
196
|
-
"name": "Cow",
|
|
197
|
-
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
|
|
198
|
-
},
|
|
199
|
-
"to": {
|
|
200
|
-
"name": "Bob",
|
|
201
|
-
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
|
|
202
|
-
},
|
|
203
|
-
"contents": "Hello, Bob!"
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
"""
|
|
207
|
-
with pytest.warns(DeprecationWarning):
|
|
208
|
-
signature = HexBytes(
|
|
209
|
-
w3.geth.personal.sign_typed_data(
|
|
210
|
-
json.loads(typed_message),
|
|
211
|
-
unlockable_account_dual_type,
|
|
212
|
-
unlockable_account_pw,
|
|
213
|
-
)
|
|
214
|
-
)
|
|
215
|
-
|
|
216
|
-
expected_signature = HexBytes(
|
|
217
|
-
"0xc8b56aaeefd10ab4005c2455daf28d9082af661ac347cd"
|
|
218
|
-
"b612d5b5e11f339f2055be831bf57a6e6cb5f6d93448fa35"
|
|
219
|
-
"c1bd56fe1d745ffa101e74697108668c401c"
|
|
220
|
-
)
|
|
221
|
-
assert signature == expected_signature
|
|
222
|
-
assert len(signature) == 32 + 32 + 1
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
class GoEthereumAsyncPersonalModuleTest:
|
|
226
|
-
@pytest.mark.asyncio
|
|
227
|
-
async def test_async_sign_and_ec_recover(
|
|
228
|
-
self,
|
|
229
|
-
async_w3: "AsyncWeb3",
|
|
230
|
-
async_unlockable_account_dual_type: ChecksumAddress,
|
|
231
|
-
unlockable_account_pw: str,
|
|
232
|
-
) -> None:
|
|
233
|
-
message = "This is a test"
|
|
234
|
-
with pytest.warns(DeprecationWarning):
|
|
235
|
-
signature = await async_w3.geth.personal.sign(
|
|
236
|
-
message, async_unlockable_account_dual_type, unlockable_account_pw
|
|
237
|
-
)
|
|
238
|
-
address = await async_w3.geth.personal.ec_recover(message, signature)
|
|
239
|
-
assert is_same_address(async_unlockable_account_dual_type, address)
|
|
240
|
-
|
|
241
|
-
@pytest.mark.asyncio
|
|
242
|
-
async def test_async_import_key(self, async_w3: "AsyncWeb3") -> None:
|
|
243
|
-
with pytest.warns(DeprecationWarning):
|
|
244
|
-
address = await async_w3.geth.personal.import_raw_key(
|
|
245
|
-
THIRD_PRIVATE_KEY_HEX, "Testing"
|
|
246
|
-
)
|
|
247
|
-
assert address is not None
|
|
248
|
-
|
|
249
|
-
@pytest.mark.asyncio
|
|
250
|
-
async def test_async_list_accounts(self, async_w3: "AsyncWeb3") -> None:
|
|
251
|
-
with pytest.warns(DeprecationWarning):
|
|
252
|
-
accounts = await async_w3.geth.personal.list_accounts()
|
|
253
|
-
assert len(accounts) > 0
|
|
254
|
-
|
|
255
|
-
@pytest.mark.asyncio
|
|
256
|
-
async def test_async_list_wallets(self, async_w3: "AsyncWeb3") -> None:
|
|
257
|
-
with pytest.warns(DeprecationWarning):
|
|
258
|
-
wallets = await async_w3.geth.personal.list_wallets()
|
|
259
|
-
assert isinstance(wallets[0], AttributeDict)
|
|
260
|
-
|
|
261
|
-
@pytest.mark.asyncio
|
|
262
|
-
async def test_async_new_account(self, async_w3: "AsyncWeb3") -> None:
|
|
263
|
-
passphrase = "Create New Account"
|
|
264
|
-
with pytest.warns(DeprecationWarning):
|
|
265
|
-
account = await async_w3.geth.personal.new_account(passphrase)
|
|
266
|
-
assert is_checksum_address(account)
|
|
267
|
-
|
|
268
|
-
@pytest.mark.asyncio
|
|
269
|
-
async def test_async_unlock_lock_account(
|
|
270
|
-
self,
|
|
271
|
-
async_w3: "AsyncWeb3",
|
|
272
|
-
async_unlockable_account_dual_type: ChecksumAddress,
|
|
273
|
-
unlockable_account_pw: str,
|
|
274
|
-
) -> None:
|
|
275
|
-
with pytest.warns(DeprecationWarning):
|
|
276
|
-
unlocked = await async_w3.geth.personal.unlock_account(
|
|
277
|
-
async_unlockable_account_dual_type, unlockable_account_pw
|
|
278
|
-
)
|
|
279
|
-
assert unlocked is True
|
|
280
|
-
|
|
281
|
-
with pytest.warns(DeprecationWarning):
|
|
282
|
-
locked = await async_w3.geth.personal.lock_account(
|
|
283
|
-
async_unlockable_account_dual_type
|
|
284
|
-
)
|
|
285
|
-
assert locked is True
|
|
286
|
-
|
|
287
|
-
@pytest.mark.asyncio
|
|
288
|
-
async def test_async_send_transaction(
|
|
289
|
-
self,
|
|
290
|
-
async_w3: "AsyncWeb3",
|
|
291
|
-
async_unlockable_account_dual_type: ChecksumAddress,
|
|
292
|
-
unlockable_account_pw: str,
|
|
293
|
-
) -> None:
|
|
294
|
-
tx_params = TxParams()
|
|
295
|
-
tx_params["to"] = async_unlockable_account_dual_type
|
|
296
|
-
tx_params["from"] = async_unlockable_account_dual_type
|
|
297
|
-
tx_params["value"] = Wei(123)
|
|
298
|
-
with pytest.warns(DeprecationWarning):
|
|
299
|
-
response = await async_w3.geth.personal.send_transaction(
|
|
300
|
-
tx_params, unlockable_account_pw
|
|
301
|
-
)
|
|
302
|
-
assert response is not None
|
|
303
|
-
|
|
304
|
-
@pytest.mark.xfail(
|
|
305
|
-
reason="personal_signTypedData JSON RPC call has not been released in geth"
|
|
306
|
-
)
|
|
307
|
-
@pytest.mark.asyncio
|
|
308
|
-
async def test_async_sign_typed_data(
|
|
309
|
-
self,
|
|
310
|
-
async_w3: "AsyncWeb3",
|
|
311
|
-
async_unlockable_account_dual_type: ChecksumAddress,
|
|
312
|
-
unlockable_account_pw: str,
|
|
313
|
-
) -> None:
|
|
314
|
-
message = {"message": "This is a test"}
|
|
315
|
-
with pytest.warns(DeprecationWarning):
|
|
316
|
-
signature = await async_w3.geth.personal.sign_typed_data(
|
|
317
|
-
message, async_unlockable_account_dual_type, unlockable_account_pw
|
|
318
|
-
)
|
|
319
|
-
with pytest.warns(DeprecationWarning):
|
|
320
|
-
address = await async_w3.geth.personal.ec_recover(
|
|
321
|
-
json.dumps(message), signature
|
|
322
|
-
)
|
|
323
|
-
assert is_same_address(async_unlockable_account_dual_type, address)
|