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.
- ens/__init__.py +13 -2
- ens/_normalization.py +4 -4
- ens/async_ens.py +31 -21
- ens/base_ens.py +3 -1
- ens/contract_data.py +2 -2
- ens/ens.py +14 -11
- ens/exceptions.py +16 -29
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +33 -41
- web3/__init__.py +23 -12
- web3/_utils/abi.py +162 -274
- web3/_utils/async_transactions.py +34 -20
- web3/_utils/batching.py +217 -0
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching/__init__.py +12 -0
- web3/_utils/caching/caching_utils.py +433 -0
- web3/_utils/caching/request_caching_validation.py +287 -0
- web3/_utils/compat/__init__.py +2 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contract_sources/contract_data/ambiguous_function_contract.py +42 -0
- 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 +50 -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 +172 -220
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +6 -1
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +16 -12
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +78 -72
- web3/_utils/fee_utils.py +1 -3
- web3/_utils/filters.py +24 -22
- web3/_utils/formatters.py +2 -2
- web3/_utils/http.py +8 -2
- web3/_utils/http_session_manager.py +314 -0
- web3/_utils/math.py +14 -15
- web3/_utils/method_formatters.py +161 -34
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +3 -2
- web3/_utils/module_testing/eth_module.py +736 -583
- web3/_utils/module_testing/go_ethereum_debug_module.py +128 -0
- web3/_utils/module_testing/module_testing_utils.py +81 -24
- web3/_utils/module_testing/persistent_connection_provider.py +702 -220
- web3/_utils/module_testing/utils.py +114 -33
- web3/_utils/module_testing/web3_module.py +438 -17
- web3/_utils/normalizers.py +13 -11
- web3/_utils/rpc_abi.py +10 -22
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +32 -25
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +20 -17
- web3/beacon/__init__.py +5 -0
- web3/beacon/api_endpoints.py +3 -0
- web3/beacon/async_beacon.py +29 -6
- web3/beacon/beacon.py +24 -6
- web3/contract/__init__.py +7 -0
- web3/contract/async_contract.py +285 -82
- web3/contract/base_contract.py +556 -258
- web3/contract/contract.py +295 -84
- web3/contract/utils.py +251 -55
- web3/datastructures.py +56 -41
- web3/eth/__init__.py +7 -0
- web3/eth/async_eth.py +89 -69
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +43 -66
- web3/exceptions.py +158 -83
- web3/gas_strategies/time_based.py +8 -6
- web3/geth.py +53 -184
- web3/main.py +77 -43
- web3/manager.py +368 -101
- web3/method.py +43 -15
- web3/middleware/__init__.py +26 -8
- web3/middleware/attrdict.py +12 -22
- web3/middleware/base.py +55 -2
- web3/middleware/filter.py +45 -23
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +15 -6
- web3/middleware/stalecheck.py +2 -1
- web3/module.py +62 -26
- web3/providers/__init__.py +21 -0
- web3/providers/async_base.py +93 -38
- web3/providers/base.py +85 -40
- web3/providers/eth_tester/__init__.py +5 -0
- web3/providers/eth_tester/defaults.py +2 -55
- web3/providers/eth_tester/main.py +57 -35
- web3/providers/eth_tester/middleware.py +16 -17
- web3/providers/ipc.py +42 -18
- web3/providers/legacy_websocket.py +27 -2
- web3/providers/persistent/__init__.py +7 -0
- web3/providers/persistent/async_ipc.py +61 -121
- web3/providers/persistent/persistent.py +324 -17
- web3/providers/persistent/persistent_connection.py +54 -5
- web3/providers/persistent/request_processor.py +136 -56
- web3/providers/persistent/subscription_container.py +56 -0
- web3/providers/persistent/subscription_manager.py +233 -0
- web3/providers/persistent/websocket.py +29 -92
- web3/providers/rpc/__init__.py +5 -0
- web3/providers/rpc/async_rpc.py +73 -18
- web3/providers/rpc/rpc.py +73 -30
- web3/providers/rpc/utils.py +1 -13
- web3/scripts/install_pre_releases.py +33 -0
- web3/scripts/parse_pygeth_version.py +16 -0
- web3/testing.py +4 -4
- web3/tracing.py +9 -5
- web3/types.py +141 -74
- web3/utils/__init__.py +64 -5
- web3/utils/abi.py +790 -10
- web3/utils/address.py +8 -0
- web3/utils/async_exception_handling.py +20 -11
- web3/utils/caching.py +34 -4
- web3/utils/exception_handling.py +9 -12
- web3/utils/subscriptions.py +285 -0
- {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/LICENSE +1 -1
- web3-7.7.0.dist-info/METADATA +130 -0
- web3-7.7.0.dist-info/RECORD +171 -0
- {web3-7.0.0b1.dist-info → web3-7.7.0.dist-info}/WHEEL +1 -1
- {web3-7.0.0b1.dist-info → web3-7.7.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/caching.py +0 -155
- web3/_utils/contract_sources/contract_data/address_reflector.py +0 -29
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- web3/_utils/request.py +0 -265
- web3/pm.py +0 -602
- web3/tools/__init__.py +0 -4
- web3/tools/benchmark/__init__.py +0 -0
- web3/tools/benchmark/main.py +0 -185
- web3/tools/benchmark/node.py +0 -126
- web3/tools/benchmark/reporting.py +0 -39
- web3/tools/benchmark/utils.py +0 -69
- 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-7.0.0b1.dist-info/METADATA +0 -114
- web3-7.0.0b1.dist-info/RECORD +0 -280
- web3-7.0.0b1.dist-info/entry_points.txt +0 -2
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
web3/_utils/method_formatters.py
CHANGED
|
@@ -9,6 +9,7 @@ from typing import (
|
|
|
9
9
|
Iterable,
|
|
10
10
|
NoReturn,
|
|
11
11
|
Tuple,
|
|
12
|
+
TypeVar,
|
|
12
13
|
Union,
|
|
13
14
|
cast,
|
|
14
15
|
)
|
|
@@ -32,8 +33,6 @@ from eth_utils.curried import (
|
|
|
32
33
|
is_integer,
|
|
33
34
|
is_null,
|
|
34
35
|
is_string,
|
|
35
|
-
remove_0x_prefix,
|
|
36
|
-
text_if_str,
|
|
37
36
|
to_checksum_address,
|
|
38
37
|
to_list,
|
|
39
38
|
to_tuple,
|
|
@@ -52,10 +51,6 @@ from hexbytes import (
|
|
|
52
51
|
from web3._utils.abi import (
|
|
53
52
|
is_length,
|
|
54
53
|
)
|
|
55
|
-
from web3._utils.encoding import (
|
|
56
|
-
hexstr_if_str,
|
|
57
|
-
to_hex,
|
|
58
|
-
)
|
|
59
54
|
from web3._utils.error_formatters_utils import (
|
|
60
55
|
raise_contract_logic_error_on_revert,
|
|
61
56
|
raise_transaction_indexing_error_if_indexing,
|
|
@@ -99,6 +94,8 @@ from web3.datastructures import (
|
|
|
99
94
|
from web3.exceptions import (
|
|
100
95
|
BlockNotFound,
|
|
101
96
|
TransactionNotFound,
|
|
97
|
+
Web3TypeError,
|
|
98
|
+
Web3ValueError,
|
|
102
99
|
)
|
|
103
100
|
from web3.types import (
|
|
104
101
|
BlockIdentifier,
|
|
@@ -115,6 +112,8 @@ if TYPE_CHECKING:
|
|
|
115
112
|
from web3.eth import Eth # noqa: F401
|
|
116
113
|
from web3.module import Module # noqa: F401
|
|
117
114
|
|
|
115
|
+
TValue = TypeVar("TValue")
|
|
116
|
+
|
|
118
117
|
|
|
119
118
|
def bytes_to_ascii(value: bytes) -> str:
|
|
120
119
|
return codecs.decode(value, "ascii")
|
|
@@ -136,7 +135,7 @@ def to_hexbytes(
|
|
|
136
135
|
if isinstance(val, (str, int, bytes)):
|
|
137
136
|
result = HexBytes(val)
|
|
138
137
|
else:
|
|
139
|
-
raise
|
|
138
|
+
raise Web3TypeError(f"Cannot convert {val!r} to HexBytes")
|
|
140
139
|
|
|
141
140
|
extra_bytes = len(result) - num_bytes
|
|
142
141
|
if extra_bytes == 0 or (variable_length and extra_bytes < 0):
|
|
@@ -144,7 +143,7 @@ def to_hexbytes(
|
|
|
144
143
|
elif all(byte == 0 for byte in result[:extra_bytes]):
|
|
145
144
|
return HexBytes(result[extra_bytes:])
|
|
146
145
|
else:
|
|
147
|
-
raise
|
|
146
|
+
raise Web3ValueError(
|
|
148
147
|
f"The value {result!r} is {len(result)} bytes, but should be {num_bytes}"
|
|
149
148
|
)
|
|
150
149
|
|
|
@@ -177,9 +176,9 @@ def type_aware_apply_formatters_to_dict_keys_and_values(
|
|
|
177
176
|
"""
|
|
178
177
|
Preserve ``AttributeDict`` types if original ``value`` was an ``AttributeDict``.
|
|
179
178
|
"""
|
|
180
|
-
formatted_dict =
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
formatted_dict = {
|
|
180
|
+
key_formatters(k): value_formatters(v) for k, v in dict_like_object.items()
|
|
181
|
+
}
|
|
183
182
|
return (
|
|
184
183
|
AttributeDict.recursive(formatted_dict)
|
|
185
184
|
if is_attrdict(dict_like_object)
|
|
@@ -191,10 +190,28 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
|
|
|
191
190
|
return to_list(apply_formatter_to_array(formatter))
|
|
192
191
|
|
|
193
192
|
|
|
193
|
+
def storage_key_to_hexstr(value: Union[bytes, int, str]) -> HexStr:
|
|
194
|
+
if not isinstance(value, (bytes, int, str)):
|
|
195
|
+
raise Web3ValueError(
|
|
196
|
+
f"Storage key must be one of bytes, int, str, got {type(value)}"
|
|
197
|
+
)
|
|
198
|
+
if isinstance(value, str):
|
|
199
|
+
if value.startswith("0x") and len(value) == 66:
|
|
200
|
+
return HexStr(value)
|
|
201
|
+
elif len(value) == 64:
|
|
202
|
+
return HexStr(f"0x{value}")
|
|
203
|
+
elif isinstance(value, bytes):
|
|
204
|
+
if len(value) == 32:
|
|
205
|
+
return cast(HexStr, HexBytes(value).to_0x_hex())
|
|
206
|
+
elif isinstance(value, int):
|
|
207
|
+
return storage_key_to_hexstr(hex(value))
|
|
208
|
+
raise Web3ValueError(f"Storage key must be a 32-byte value, got {value!r}")
|
|
209
|
+
|
|
210
|
+
|
|
194
211
|
ACCESS_LIST_FORMATTER = type_aware_apply_formatters_to_dict(
|
|
195
212
|
{
|
|
196
213
|
"address": to_checksum_address,
|
|
197
|
-
"storageKeys": apply_list_to_array_formatter(
|
|
214
|
+
"storageKeys": apply_list_to_array_formatter(storage_key_to_hexstr),
|
|
198
215
|
}
|
|
199
216
|
)
|
|
200
217
|
|
|
@@ -233,6 +250,10 @@ TRANSACTION_RESULT_FORMATTERS = {
|
|
|
233
250
|
),
|
|
234
251
|
"input": HexBytes,
|
|
235
252
|
"data": HexBytes, # Nethermind, for example, returns both `input` and `data`
|
|
253
|
+
"maxFeePerBlobGas": to_integer_if_hex,
|
|
254
|
+
"blobVersionedHashes": apply_formatter_if(
|
|
255
|
+
is_not_null, apply_formatter_to_array(to_hexbytes(32))
|
|
256
|
+
),
|
|
236
257
|
}
|
|
237
258
|
|
|
238
259
|
|
|
@@ -281,6 +302,8 @@ RECEIPT_FORMATTERS = {
|
|
|
281
302
|
"to": apply_formatter_if(is_address, to_checksum_address),
|
|
282
303
|
"effectiveGasPrice": to_integer_if_hex,
|
|
283
304
|
"type": to_integer_if_hex,
|
|
305
|
+
"blobGasPrice": to_integer_if_hex,
|
|
306
|
+
"blobGasUsed": to_integer_if_hex,
|
|
284
307
|
}
|
|
285
308
|
|
|
286
309
|
|
|
@@ -404,8 +427,8 @@ ACCOUNT_PROOF_FORMATTERS = {
|
|
|
404
427
|
proof_formatter = type_aware_apply_formatters_to_dict(ACCOUNT_PROOF_FORMATTERS)
|
|
405
428
|
|
|
406
429
|
FILTER_PARAMS_FORMATTERS = {
|
|
407
|
-
"fromBlock":
|
|
408
|
-
"toBlock":
|
|
430
|
+
"fromBlock": to_hex_if_integer,
|
|
431
|
+
"toBlock": to_hex_if_integer,
|
|
409
432
|
}
|
|
410
433
|
|
|
411
434
|
|
|
@@ -419,7 +442,22 @@ filter_result_formatter = apply_one_of_formatters(
|
|
|
419
442
|
)
|
|
420
443
|
)
|
|
421
444
|
|
|
445
|
+
ACCESS_LIST_REQUEST_FORMATTER = type_aware_apply_formatters_to_dict(
|
|
446
|
+
{
|
|
447
|
+
"accessList": apply_formatter_if(
|
|
448
|
+
is_not_null,
|
|
449
|
+
apply_list_to_array_formatter(
|
|
450
|
+
apply_formatters_to_dict(
|
|
451
|
+
{
|
|
452
|
+
"storageKeys": apply_list_to_array_formatter(to_hex_if_bytes),
|
|
453
|
+
}
|
|
454
|
+
)
|
|
455
|
+
),
|
|
456
|
+
),
|
|
457
|
+
}
|
|
458
|
+
)
|
|
422
459
|
transaction_param_formatter = compose(
|
|
460
|
+
ACCESS_LIST_REQUEST_FORMATTER,
|
|
423
461
|
remove_key_if("to", lambda txn: txn["to"] in {"", b"", None}),
|
|
424
462
|
remove_key_if("gasPrice", lambda txn: txn["gasPrice"] in {"", b"", None}),
|
|
425
463
|
)
|
|
@@ -516,6 +554,7 @@ PYTHONIC_REQUEST_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
516
554
|
),
|
|
517
555
|
RPC.eth_getBalance: apply_formatter_at_index(to_hex_if_integer, 1),
|
|
518
556
|
RPC.eth_getBlockByNumber: apply_formatter_at_index(to_hex_if_integer, 0),
|
|
557
|
+
RPC.eth_getBlockReceipts: apply_formatter_at_index(to_hex_if_integer, 0),
|
|
519
558
|
RPC.eth_getBlockTransactionCountByNumber: apply_formatter_at_index(
|
|
520
559
|
to_hex_if_integer,
|
|
521
560
|
0,
|
|
@@ -559,16 +598,6 @@ PYTHONIC_REQUEST_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
559
598
|
RPC.eth_sendTransaction: apply_formatter_at_index(transaction_param_formatter, 0),
|
|
560
599
|
RPC.eth_signTransaction: apply_formatter_at_index(transaction_param_formatter, 0),
|
|
561
600
|
RPC.eth_getProof: apply_formatter_at_index(to_hex_if_integer, 2),
|
|
562
|
-
# personal
|
|
563
|
-
RPC.personal_importRawKey: apply_formatter_at_index(
|
|
564
|
-
compose(remove_0x_prefix, hexstr_if_str(to_hex)),
|
|
565
|
-
0,
|
|
566
|
-
),
|
|
567
|
-
RPC.personal_sign: apply_formatter_at_index(text_if_str(to_hex), 0),
|
|
568
|
-
RPC.personal_ecRecover: apply_formatter_at_index(text_if_str(to_hex), 0),
|
|
569
|
-
RPC.personal_sendTransaction: apply_formatter_at_index(
|
|
570
|
-
transaction_param_formatter, 0
|
|
571
|
-
),
|
|
572
601
|
# Snapshot and Revert
|
|
573
602
|
RPC.evm_revert: apply_formatter_at_index(integer_to_hex, 0),
|
|
574
603
|
# tracing
|
|
@@ -581,6 +610,102 @@ PYTHONIC_REQUEST_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
581
610
|
}
|
|
582
611
|
|
|
583
612
|
# --- Result Formatters --- #
|
|
613
|
+
# -- debug -- #
|
|
614
|
+
DEBUG_CALLTRACE_LOG_ENTRY_FORMATTERS = apply_formatter_if(
|
|
615
|
+
is_not_null,
|
|
616
|
+
type_aware_apply_formatters_to_dict(
|
|
617
|
+
{
|
|
618
|
+
"address": to_checksum_address,
|
|
619
|
+
"topics": apply_list_to_array_formatter(to_hexbytes(32)),
|
|
620
|
+
"data": HexBytes,
|
|
621
|
+
"position": to_integer_if_hex,
|
|
622
|
+
}
|
|
623
|
+
),
|
|
624
|
+
)
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
debug_calltrace_log_list_result_formatter: Callable[
|
|
628
|
+
[Formatters], Any
|
|
629
|
+
] = apply_formatter_to_array(DEBUG_CALLTRACE_LOG_ENTRY_FORMATTERS)
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
PRETRACE_INNER_FORMATTERS = {
|
|
633
|
+
"balance": to_integer_if_hex,
|
|
634
|
+
"nonce": to_integer_if_hex,
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
def has_pretrace_keys(val: Any) -> bool:
|
|
639
|
+
if isinstance(val, dict) or isinstance(val, AttributeDict):
|
|
640
|
+
return (
|
|
641
|
+
val.get("balance")
|
|
642
|
+
or val.get("nonce")
|
|
643
|
+
or val.get("code")
|
|
644
|
+
or val.get("storage")
|
|
645
|
+
)
|
|
646
|
+
return False
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
@curry
|
|
650
|
+
def pretrace_formatter(
|
|
651
|
+
resp: Union[AttributeDict[str, Any], Dict[str, Any]],
|
|
652
|
+
) -> Union[ReadableAttributeDict[str, Any], Dict[str, Any]]:
|
|
653
|
+
return type_aware_apply_formatters_to_dict_keys_and_values(
|
|
654
|
+
apply_formatter_if(is_address, to_checksum_address),
|
|
655
|
+
apply_formatter_if(
|
|
656
|
+
has_pretrace_keys,
|
|
657
|
+
type_aware_apply_formatters_to_dict(PRETRACE_INNER_FORMATTERS),
|
|
658
|
+
),
|
|
659
|
+
resp,
|
|
660
|
+
)
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
DEBUG_PRESTATE_DIFFMODE_FORMATTERS = {
|
|
664
|
+
"pre": pretrace_formatter,
|
|
665
|
+
"post": pretrace_formatter,
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
DEBUG_CALLTRACE_FORMATTERS = {
|
|
670
|
+
"from": to_checksum_address,
|
|
671
|
+
"to": to_checksum_address,
|
|
672
|
+
"value": to_integer_if_hex,
|
|
673
|
+
"gas": to_integer_if_hex,
|
|
674
|
+
"gasUsed": to_integer_if_hex,
|
|
675
|
+
"input": HexBytes,
|
|
676
|
+
"output": HexBytes,
|
|
677
|
+
"calls": lambda calls: debug_calltrace_list_result_formatter(calls),
|
|
678
|
+
"logs": debug_calltrace_log_list_result_formatter,
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
OPCODE_TRACE_FORMATTERS = {
|
|
683
|
+
"pc": to_integer_if_hex,
|
|
684
|
+
"gas": to_integer_if_hex,
|
|
685
|
+
"gasCost": to_integer_if_hex,
|
|
686
|
+
"refund": to_integer_if_hex,
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
DEBUG_TRACE_FORMATTERS = {
|
|
691
|
+
**DEBUG_CALLTRACE_FORMATTERS,
|
|
692
|
+
**OPCODE_TRACE_FORMATTERS,
|
|
693
|
+
**DEBUG_PRESTATE_DIFFMODE_FORMATTERS,
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
trace_result_formatters = type_aware_apply_formatters_to_dict(DEBUG_TRACE_FORMATTERS)
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
debug_calltrace_result_formatter = type_aware_apply_formatters_to_dict(
|
|
701
|
+
DEBUG_CALLTRACE_FORMATTERS
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
debug_calltrace_list_result_formatter: Callable[
|
|
706
|
+
[Formatters], Any
|
|
707
|
+
] = apply_formatter_to_array(debug_calltrace_result_formatter)
|
|
708
|
+
|
|
584
709
|
|
|
585
710
|
# -- tracing -- #
|
|
586
711
|
|
|
@@ -620,7 +745,7 @@ TRACE_RESULT_FORMATTERS = apply_formatter_if(
|
|
|
620
745
|
)
|
|
621
746
|
|
|
622
747
|
# result formatters for the trace field
|
|
623
|
-
TRACE_FORMATTERS = apply_formatter_if(
|
|
748
|
+
TRACE_FORMATTERS: Callable[[TValue], Union[Any, TValue]] = apply_formatter_if(
|
|
624
749
|
is_not_null,
|
|
625
750
|
type_aware_apply_formatters_to_dict(
|
|
626
751
|
{
|
|
@@ -711,9 +836,9 @@ def subscription_formatter(value: Any) -> Union[HexBytes, HexStr, Dict[str, Any]
|
|
|
711
836
|
PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
712
837
|
# Eth
|
|
713
838
|
RPC.eth_accounts: apply_list_to_array_formatter(to_checksum_address),
|
|
839
|
+
RPC.eth_blobBaseFee: to_integer_if_hex,
|
|
714
840
|
RPC.eth_blockNumber: to_integer_if_hex,
|
|
715
841
|
RPC.eth_chainId: to_integer_if_hex,
|
|
716
|
-
RPC.eth_coinbase: to_checksum_address,
|
|
717
842
|
RPC.eth_call: HexBytes,
|
|
718
843
|
RPC.eth_createAccessList: ACCESS_LIST_RESPONSE_FORMATTER,
|
|
719
844
|
RPC.eth_estimateGas: to_integer_if_hex,
|
|
@@ -723,6 +848,7 @@ PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
723
848
|
RPC.eth_getBalance: to_integer_if_hex,
|
|
724
849
|
RPC.eth_getBlockByHash: apply_formatter_if(is_not_null, block_formatter),
|
|
725
850
|
RPC.eth_getBlockByNumber: apply_formatter_if(is_not_null, block_formatter),
|
|
851
|
+
RPC.eth_getBlockReceipts: apply_formatter_to_array(receipt_formatter),
|
|
726
852
|
RPC.eth_getBlockTransactionCountByHash: to_integer_if_hex,
|
|
727
853
|
RPC.eth_getBlockTransactionCountByNumber: to_integer_if_hex,
|
|
728
854
|
RPC.eth_getCode: HexBytes,
|
|
@@ -752,7 +878,6 @@ PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
752
878
|
),
|
|
753
879
|
RPC.eth_getUncleCountByBlockHash: to_integer_if_hex,
|
|
754
880
|
RPC.eth_getUncleCountByBlockNumber: to_integer_if_hex,
|
|
755
|
-
RPC.eth_hashrate: to_integer_if_hex,
|
|
756
881
|
RPC.eth_protocolVersion: compose(
|
|
757
882
|
apply_formatter_if(is_0x_prefixed, to_integer_if_hex),
|
|
758
883
|
apply_formatter_if(is_integer, str),
|
|
@@ -763,13 +888,6 @@ PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
763
888
|
RPC.eth_signTransaction: apply_formatter_if(is_not_null, signed_tx_formatter),
|
|
764
889
|
RPC.eth_signTypedData: HexBytes,
|
|
765
890
|
RPC.eth_syncing: apply_formatter_if(is_not_false, syncing_formatter),
|
|
766
|
-
# personal
|
|
767
|
-
RPC.personal_importRawKey: to_checksum_address,
|
|
768
|
-
RPC.personal_listAccounts: apply_list_to_array_formatter(to_checksum_address),
|
|
769
|
-
RPC.personal_listWallets: apply_list_to_array_formatter(geth_wallets_formatter),
|
|
770
|
-
RPC.personal_newAccount: to_checksum_address,
|
|
771
|
-
RPC.personal_sendTransaction: to_hexbytes(32),
|
|
772
|
-
RPC.personal_signTypedData: HexBytes,
|
|
773
891
|
# Transaction Pool
|
|
774
892
|
RPC.txpool_content: transaction_pool_content_formatter,
|
|
775
893
|
RPC.txpool_inspect: transaction_pool_inspect_formatter,
|
|
@@ -777,6 +895,14 @@ PYTHONIC_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
|
777
895
|
RPC.evm_snapshot: hex_to_integer,
|
|
778
896
|
# Net
|
|
779
897
|
RPC.net_peerCount: to_integer_if_hex,
|
|
898
|
+
# Debug
|
|
899
|
+
RPC.debug_traceTransaction: apply_formatter_if(
|
|
900
|
+
is_not_null,
|
|
901
|
+
compose(
|
|
902
|
+
pretrace_formatter,
|
|
903
|
+
trace_result_formatters,
|
|
904
|
+
),
|
|
905
|
+
),
|
|
780
906
|
# tracing
|
|
781
907
|
RPC.trace_block: trace_list_result_formatter,
|
|
782
908
|
RPC.trace_call: common_tracing_result_formatter,
|
|
@@ -900,6 +1026,7 @@ def raise_transaction_not_found_with_index(
|
|
|
900
1026
|
NULL_RESULT_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
|
|
901
1027
|
RPC.eth_getBlockByHash: raise_block_not_found,
|
|
902
1028
|
RPC.eth_getBlockByNumber: raise_block_not_found,
|
|
1029
|
+
RPC.eth_getBlockReceipts: raise_block_not_found,
|
|
903
1030
|
RPC.eth_getBlockTransactionCountByHash: raise_block_not_found,
|
|
904
1031
|
RPC.eth_getBlockTransactionCountByNumber: raise_block_not_found,
|
|
905
1032
|
RPC.eth_getUncleCountByBlockHash: raise_block_not_found,
|
web3/_utils/module.py
CHANGED
|
@@ -13,6 +13,7 @@ from typing import (
|
|
|
13
13
|
)
|
|
14
14
|
|
|
15
15
|
from web3.exceptions import (
|
|
16
|
+
Web3AttributeError,
|
|
16
17
|
Web3ValidationError,
|
|
17
18
|
)
|
|
18
19
|
from web3.module import (
|
|
@@ -50,7 +51,7 @@ def attach_modules(
|
|
|
50
51
|
module_class = module_info[0] if module_info_is_list_like else module_info
|
|
51
52
|
|
|
52
53
|
if hasattr(parent_module, module_name):
|
|
53
|
-
raise
|
|
54
|
+
raise Web3AttributeError(
|
|
54
55
|
f"Cannot set {parent_module} module named '{module_name}'. "
|
|
55
56
|
" The web3 object already has an attribute with that name"
|
|
56
57
|
)
|
|
@@ -5,8 +5,9 @@ from .eth_module import (
|
|
|
5
5
|
from .go_ethereum_admin_module import (
|
|
6
6
|
GoEthereumAdminModuleTest,
|
|
7
7
|
)
|
|
8
|
-
from .
|
|
9
|
-
|
|
8
|
+
from .go_ethereum_debug_module import (
|
|
9
|
+
GoEthereumAsyncDebugModuleTest,
|
|
10
|
+
GoEthereumDebugModuleTest,
|
|
10
11
|
)
|
|
11
12
|
from .go_ethereum_txpool_module import (
|
|
12
13
|
GoEthereumAsyncTxPoolModuleTest,
|