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/eth/eth.py
CHANGED
|
@@ -2,6 +2,7 @@ from typing import (
|
|
|
2
2
|
TYPE_CHECKING,
|
|
3
3
|
Any,
|
|
4
4
|
Callable,
|
|
5
|
+
Dict,
|
|
5
6
|
List,
|
|
6
7
|
Optional,
|
|
7
8
|
Sequence,
|
|
@@ -29,6 +30,9 @@ from hexbytes import (
|
|
|
29
30
|
from web3._utils.blocks import (
|
|
30
31
|
select_method_for_block_identifier,
|
|
31
32
|
)
|
|
33
|
+
from web3._utils.compat import (
|
|
34
|
+
Unpack,
|
|
35
|
+
)
|
|
32
36
|
from web3._utils.fee_utils import (
|
|
33
37
|
fee_history_priority_fee,
|
|
34
38
|
)
|
|
@@ -56,12 +60,13 @@ from web3.eth.base_eth import (
|
|
|
56
60
|
BaseEth,
|
|
57
61
|
)
|
|
58
62
|
from web3.exceptions import (
|
|
59
|
-
MethodUnavailable,
|
|
60
63
|
OffchainLookup,
|
|
61
64
|
TimeExhausted,
|
|
62
65
|
TooManyRequests,
|
|
63
66
|
TransactionIndexingInProgress,
|
|
64
67
|
TransactionNotFound,
|
|
68
|
+
Web3RPCError,
|
|
69
|
+
Web3ValueError,
|
|
65
70
|
)
|
|
66
71
|
from web3.method import (
|
|
67
72
|
Method,
|
|
@@ -72,6 +77,7 @@ from web3.types import (
|
|
|
72
77
|
BlockData,
|
|
73
78
|
BlockIdentifier,
|
|
74
79
|
BlockParams,
|
|
80
|
+
BlockReceipts,
|
|
75
81
|
CreateAccessListResponse,
|
|
76
82
|
FeeHistory,
|
|
77
83
|
FilterParams,
|
|
@@ -113,16 +119,16 @@ class Eth(BaseEth):
|
|
|
113
119
|
def accounts(self) -> Tuple[ChecksumAddress]:
|
|
114
120
|
return self._accounts()
|
|
115
121
|
|
|
116
|
-
#
|
|
122
|
+
# eth_blobBaseFee
|
|
117
123
|
|
|
118
|
-
|
|
119
|
-
RPC.
|
|
124
|
+
_eth_blobBaseFee: Method[Callable[[], Wei]] = Method(
|
|
125
|
+
RPC.eth_blobBaseFee,
|
|
120
126
|
is_property=True,
|
|
121
127
|
)
|
|
122
128
|
|
|
123
129
|
@property
|
|
124
|
-
def
|
|
125
|
-
return self.
|
|
130
|
+
def blob_base_fee(self) -> Wei:
|
|
131
|
+
return self._eth_blobBaseFee()
|
|
126
132
|
|
|
127
133
|
# eth_blockNumber
|
|
128
134
|
|
|
@@ -146,17 +152,6 @@ class Eth(BaseEth):
|
|
|
146
152
|
def chain_id(self) -> int:
|
|
147
153
|
return self._chain_id()
|
|
148
154
|
|
|
149
|
-
# eth_coinbase
|
|
150
|
-
|
|
151
|
-
_coinbase: Method[Callable[[], ChecksumAddress]] = Method(
|
|
152
|
-
RPC.eth_coinbase,
|
|
153
|
-
is_property=True,
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
@property
|
|
157
|
-
def coinbase(self) -> ChecksumAddress:
|
|
158
|
-
return self._coinbase()
|
|
159
|
-
|
|
160
155
|
# eth_gasPrice
|
|
161
156
|
|
|
162
157
|
_gas_price: Method[Callable[[], Wei]] = Method(
|
|
@@ -184,24 +179,14 @@ class Eth(BaseEth):
|
|
|
184
179
|
"""
|
|
185
180
|
try:
|
|
186
181
|
return self._max_priority_fee()
|
|
187
|
-
except
|
|
182
|
+
except Web3RPCError:
|
|
188
183
|
warnings.warn(
|
|
189
184
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
190
|
-
"Calculating using eth_feeHistory."
|
|
185
|
+
"Calculating using eth_feeHistory.",
|
|
186
|
+
stacklevel=2,
|
|
191
187
|
)
|
|
192
188
|
return fee_history_priority_fee(self)
|
|
193
189
|
|
|
194
|
-
# eth_mining
|
|
195
|
-
|
|
196
|
-
_mining: Method[Callable[[], bool]] = Method(
|
|
197
|
-
RPC.eth_mining,
|
|
198
|
-
is_property=True,
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
@property
|
|
202
|
-
def mining(self) -> bool:
|
|
203
|
-
return self._mining()
|
|
204
|
-
|
|
205
190
|
# eth_syncing
|
|
206
191
|
|
|
207
192
|
_syncing: Method[Callable[[], Union[SyncStatus, bool]]] = Method(
|
|
@@ -269,7 +254,7 @@ class Eth(BaseEth):
|
|
|
269
254
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
270
255
|
|
|
271
256
|
if not max_redirects or max_redirects < 4:
|
|
272
|
-
raise
|
|
257
|
+
raise Web3ValueError(
|
|
273
258
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
274
259
|
)
|
|
275
260
|
|
|
@@ -278,7 +263,8 @@ class Eth(BaseEth):
|
|
|
278
263
|
return self._call(transaction, block_identifier, state_override)
|
|
279
264
|
except OffchainLookup as offchain_lookup:
|
|
280
265
|
durin_calldata = handle_offchain_lookup(
|
|
281
|
-
offchain_lookup.payload,
|
|
266
|
+
offchain_lookup.payload,
|
|
267
|
+
transaction,
|
|
282
268
|
)
|
|
283
269
|
transaction["data"] = durin_calldata
|
|
284
270
|
|
|
@@ -411,6 +397,16 @@ class Eth(BaseEth):
|
|
|
411
397
|
) -> BlockData:
|
|
412
398
|
return self._get_block(block_identifier, full_transactions)
|
|
413
399
|
|
|
400
|
+
# eth_getBlockReceipts
|
|
401
|
+
|
|
402
|
+
_get_block_receipts: Method[Callable[[BlockIdentifier], BlockReceipts]] = Method(
|
|
403
|
+
RPC.eth_getBlockReceipts,
|
|
404
|
+
mungers=[default_root_munger],
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
def get_block_receipts(self, block_identifier: BlockIdentifier) -> BlockReceipts:
|
|
408
|
+
return self._get_block_receipts(block_identifier)
|
|
409
|
+
|
|
414
410
|
# eth_getBalance
|
|
415
411
|
|
|
416
412
|
_get_balance: Method[
|
|
@@ -582,10 +578,8 @@ class Eth(BaseEth):
|
|
|
582
578
|
current_transaction = get_required_transaction(self.w3, transaction_hash)
|
|
583
579
|
return replace_transaction(self.w3, current_transaction, new_transaction)
|
|
584
580
|
|
|
585
|
-
# todo: Update Any to stricter kwarg checking with TxParams
|
|
586
|
-
# https://github.com/python/mypy/issues/4441
|
|
587
581
|
def modify_transaction(
|
|
588
|
-
self, transaction_hash: _Hash32, **transaction_params:
|
|
582
|
+
self, transaction_hash: _Hash32, **transaction_params: Unpack[TxParams]
|
|
589
583
|
) -> HexBytes:
|
|
590
584
|
assert_valid_transaction_params(cast(TxParams, transaction_params))
|
|
591
585
|
current_transaction = get_required_transaction(self.w3, transaction_hash)
|
|
@@ -611,7 +605,7 @@ class Eth(BaseEth):
|
|
|
611
605
|
# eth_signTypedData
|
|
612
606
|
|
|
613
607
|
sign_typed_data: Method[
|
|
614
|
-
Callable[[Union[Address, ChecksumAddress, ENS], str], HexStr]
|
|
608
|
+
Callable[[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], HexStr]
|
|
615
609
|
] = Method(
|
|
616
610
|
RPC.eth_signTypedData,
|
|
617
611
|
mungers=[default_root_munger],
|
|
@@ -619,15 +613,15 @@ class Eth(BaseEth):
|
|
|
619
613
|
|
|
620
614
|
# eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
|
|
621
615
|
|
|
622
|
-
filter: Method[
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
616
|
+
filter: Method[
|
|
617
|
+
Callable[[Optional[Union[str, FilterParams, HexStr]]], Filter]
|
|
618
|
+
] = Method(
|
|
619
|
+
method_choice_depends_on_args=select_filter_method(
|
|
620
|
+
if_new_block_filter=RPC.eth_newBlockFilter,
|
|
621
|
+
if_new_pending_transaction_filter=RPC.eth_newPendingTransactionFilter,
|
|
622
|
+
if_new_filter=RPC.eth_newFilter,
|
|
623
|
+
),
|
|
624
|
+
mungers=[BaseEth.filter_munger],
|
|
631
625
|
)
|
|
632
626
|
|
|
633
627
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
@@ -645,32 +639,15 @@ class Eth(BaseEth):
|
|
|
645
639
|
mungers=[default_root_munger],
|
|
646
640
|
)
|
|
647
641
|
|
|
648
|
-
# eth_submitHashrate
|
|
649
|
-
|
|
650
|
-
submit_hashrate: Method[Callable[[int, _Hash32], bool]] = Method(
|
|
651
|
-
RPC.eth_submitHashrate,
|
|
652
|
-
mungers=[default_root_munger],
|
|
653
|
-
)
|
|
654
|
-
|
|
655
|
-
# eth_getWork, eth_submitWork
|
|
656
|
-
|
|
657
|
-
get_work: Method[Callable[[], List[HexBytes]]] = Method(
|
|
658
|
-
RPC.eth_getWork,
|
|
659
|
-
is_property=True,
|
|
660
|
-
)
|
|
661
|
-
|
|
662
|
-
submit_work: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method(
|
|
663
|
-
RPC.eth_submitWork,
|
|
664
|
-
mungers=[default_root_munger],
|
|
665
|
-
)
|
|
666
|
-
|
|
667
642
|
@overload
|
|
668
|
-
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]:
|
|
643
|
+
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]:
|
|
644
|
+
...
|
|
669
645
|
|
|
670
646
|
@overload
|
|
671
647
|
def contract(
|
|
672
648
|
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
|
|
673
|
-
) -> Contract:
|
|
649
|
+
) -> Contract:
|
|
650
|
+
...
|
|
674
651
|
|
|
675
652
|
def contract(
|
|
676
653
|
self,
|
web3/exceptions.py
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import time
|
|
3
3
|
from typing import (
|
|
4
|
+
TYPE_CHECKING,
|
|
4
5
|
Any,
|
|
5
6
|
Dict,
|
|
6
7
|
Optional,
|
|
7
8
|
Union,
|
|
8
9
|
)
|
|
9
10
|
|
|
10
|
-
from eth_utils import (
|
|
11
|
-
ValidationError,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
11
|
from web3.types import (
|
|
15
12
|
BlockData,
|
|
13
|
+
RPCResponse,
|
|
16
14
|
)
|
|
17
15
|
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
import asyncio
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
class Web3Exception(Exception):
|
|
20
21
|
"""
|
|
@@ -30,6 +31,52 @@ class Web3Exception(Exception):
|
|
|
30
31
|
# deal with other exceptions
|
|
31
32
|
"""
|
|
32
33
|
|
|
34
|
+
user_message: Optional[str] = None
|
|
35
|
+
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
*args: Any,
|
|
39
|
+
user_message: Optional[str] = None,
|
|
40
|
+
):
|
|
41
|
+
super().__init__(*args)
|
|
42
|
+
|
|
43
|
+
# Assign properties of Web3Exception
|
|
44
|
+
self.user_message = user_message
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Web3AssertionError(Web3Exception, AssertionError):
|
|
48
|
+
"""
|
|
49
|
+
A web3.py exception wrapper for `AssertionError`, for better control over
|
|
50
|
+
exception handling.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Web3ValueError(Web3Exception, ValueError):
|
|
55
|
+
"""
|
|
56
|
+
A web3.py exception wrapper for `ValueError`, for better control over
|
|
57
|
+
exception handling.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Web3AttributeError(Web3Exception, AttributeError):
|
|
62
|
+
"""
|
|
63
|
+
A web3.py exception wrapper for `AttributeError`, for better control over
|
|
64
|
+
exception handling.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class Web3TypeError(Web3Exception, TypeError):
|
|
69
|
+
"""
|
|
70
|
+
A web3.py exception wrapper for `TypeError`, for better control over
|
|
71
|
+
exception handling.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class MethodNotSupported(Web3Exception):
|
|
76
|
+
"""
|
|
77
|
+
Raised when a method is not supported by the provider.
|
|
78
|
+
"""
|
|
79
|
+
|
|
33
80
|
|
|
34
81
|
class BadFunctionCallOutput(Web3Exception):
|
|
35
82
|
"""
|
|
@@ -38,24 +85,18 @@ class BadFunctionCallOutput(Web3Exception):
|
|
|
38
85
|
Most likely ABI mismatch.
|
|
39
86
|
"""
|
|
40
87
|
|
|
41
|
-
pass
|
|
42
|
-
|
|
43
88
|
|
|
44
|
-
class
|
|
89
|
+
class BlockNumberOutOfRange(Web3Exception):
|
|
45
90
|
"""
|
|
46
91
|
block_identifier passed does not match known block.
|
|
47
92
|
"""
|
|
48
93
|
|
|
49
|
-
pass
|
|
50
|
-
|
|
51
94
|
|
|
52
95
|
class ProviderConnectionError(Web3Exception):
|
|
53
96
|
"""
|
|
54
97
|
Raised when unable to connect to a provider
|
|
55
98
|
"""
|
|
56
99
|
|
|
57
|
-
pass
|
|
58
|
-
|
|
59
100
|
|
|
60
101
|
class CannotHandleRequest(Web3Exception):
|
|
61
102
|
"""
|
|
@@ -63,16 +104,12 @@ class CannotHandleRequest(Web3Exception):
|
|
|
63
104
|
that the manager should proceed to the next provider.
|
|
64
105
|
"""
|
|
65
106
|
|
|
66
|
-
pass
|
|
67
|
-
|
|
68
107
|
|
|
69
108
|
class TooManyRequests(Web3Exception):
|
|
70
109
|
"""
|
|
71
110
|
Raised by a provider to signal that too many requests have been made consecutively.
|
|
72
111
|
"""
|
|
73
112
|
|
|
74
|
-
pass
|
|
75
|
-
|
|
76
113
|
|
|
77
114
|
class MultipleFailedRequests(Web3Exception):
|
|
78
115
|
"""
|
|
@@ -80,16 +117,12 @@ class MultipleFailedRequests(Web3Exception):
|
|
|
80
117
|
(or similar) data have failed.
|
|
81
118
|
"""
|
|
82
119
|
|
|
83
|
-
pass
|
|
84
|
-
|
|
85
120
|
|
|
86
121
|
class InvalidAddress(Web3Exception):
|
|
87
122
|
"""
|
|
88
123
|
The supplied address does not have a valid checksum, as defined in EIP-55
|
|
89
124
|
"""
|
|
90
125
|
|
|
91
|
-
pass
|
|
92
|
-
|
|
93
126
|
|
|
94
127
|
class NameNotFound(Web3Exception):
|
|
95
128
|
"""
|
|
@@ -97,8 +130,6 @@ class NameNotFound(Web3Exception):
|
|
|
97
130
|
does not resolve to an address.
|
|
98
131
|
"""
|
|
99
132
|
|
|
100
|
-
pass
|
|
101
|
-
|
|
102
133
|
|
|
103
134
|
class StaleBlockchain(Web3Exception):
|
|
104
135
|
"""
|
|
@@ -128,17 +159,13 @@ class MismatchedABI(Web3Exception):
|
|
|
128
159
|
attempt is made to access a function/event that does not exist in the ABI.
|
|
129
160
|
"""
|
|
130
161
|
|
|
131
|
-
pass
|
|
132
162
|
|
|
133
|
-
|
|
134
|
-
class ABIEventFunctionNotFound(AttributeError, MismatchedABI):
|
|
163
|
+
class ABIEventNotFound(AttributeError, MismatchedABI):
|
|
135
164
|
"""
|
|
136
165
|
Raised when an attempt is made to access an event
|
|
137
166
|
that does not exist in the ABI.
|
|
138
167
|
"""
|
|
139
168
|
|
|
140
|
-
pass
|
|
141
|
-
|
|
142
169
|
|
|
143
170
|
class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
144
171
|
"""
|
|
@@ -146,56 +173,54 @@ class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
|
146
173
|
that does not exist in the ABI.
|
|
147
174
|
"""
|
|
148
175
|
|
|
149
|
-
pass
|
|
150
176
|
|
|
177
|
+
class ABIConstructorNotFound(Web3Exception):
|
|
178
|
+
"""
|
|
179
|
+
Raised when a constructor function doesn't exist in contract.
|
|
180
|
+
"""
|
|
151
181
|
|
|
152
|
-
|
|
182
|
+
|
|
183
|
+
class ABIFallbackNotFound(Web3Exception):
|
|
153
184
|
"""
|
|
154
|
-
Raised when fallback function doesn't exist in contract.
|
|
185
|
+
Raised when a fallback function doesn't exist in contract.
|
|
155
186
|
"""
|
|
156
187
|
|
|
157
|
-
|
|
188
|
+
|
|
189
|
+
class ABIReceiveNotFound(Web3Exception):
|
|
190
|
+
"""
|
|
191
|
+
Raised when a receive function doesn't exist in contract.
|
|
192
|
+
"""
|
|
158
193
|
|
|
159
194
|
|
|
160
|
-
class Web3ValidationError(Web3Exception
|
|
195
|
+
class Web3ValidationError(Web3Exception):
|
|
161
196
|
"""
|
|
162
197
|
Raised when a supplied value is invalid.
|
|
163
198
|
"""
|
|
164
199
|
|
|
165
|
-
pass
|
|
166
|
-
|
|
167
200
|
|
|
168
201
|
class ExtraDataLengthError(Web3ValidationError):
|
|
169
202
|
"""
|
|
170
203
|
Raised when an RPC call returns >32 bytes of extraData.
|
|
171
204
|
"""
|
|
172
205
|
|
|
173
|
-
pass
|
|
174
|
-
|
|
175
206
|
|
|
176
207
|
class NoABIFunctionsFound(Web3Exception):
|
|
177
208
|
"""
|
|
178
209
|
Raised when an ABI is present, but doesn't contain any functions.
|
|
179
210
|
"""
|
|
180
211
|
|
|
181
|
-
pass
|
|
182
|
-
|
|
183
212
|
|
|
184
213
|
class NoABIFound(Web3Exception):
|
|
185
214
|
"""
|
|
186
215
|
Raised when no ABI is present.
|
|
187
216
|
"""
|
|
188
217
|
|
|
189
|
-
pass
|
|
190
|
-
|
|
191
218
|
|
|
192
219
|
class NoABIEventsFound(Web3Exception):
|
|
193
220
|
"""
|
|
194
221
|
Raised when an ABI doesn't contain any events.
|
|
195
222
|
"""
|
|
196
223
|
|
|
197
|
-
pass
|
|
198
|
-
|
|
199
224
|
|
|
200
225
|
class InsufficientData(Web3Exception):
|
|
201
226
|
"""
|
|
@@ -203,8 +228,6 @@ class InsufficientData(Web3Exception):
|
|
|
203
228
|
complete a calculation
|
|
204
229
|
"""
|
|
205
230
|
|
|
206
|
-
pass
|
|
207
|
-
|
|
208
231
|
|
|
209
232
|
class TimeExhausted(Web3Exception):
|
|
210
233
|
"""
|
|
@@ -212,57 +235,24 @@ class TimeExhausted(Web3Exception):
|
|
|
212
235
|
result within a specified timeout.
|
|
213
236
|
"""
|
|
214
237
|
|
|
215
|
-
pass
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
class TransactionNotFound(Web3Exception):
|
|
219
|
-
"""
|
|
220
|
-
Raised when a tx hash used to lookup a tx in a jsonrpc call cannot be found.
|
|
221
|
-
"""
|
|
222
|
-
|
|
223
|
-
pass
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
class TransactionIndexingInProgress(Web3Exception):
|
|
227
|
-
"""
|
|
228
|
-
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
229
|
-
still being in progress.
|
|
230
|
-
"""
|
|
231
|
-
|
|
232
|
-
pass
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
class BlockNotFound(Web3Exception):
|
|
236
|
-
"""
|
|
237
|
-
Raised when the block id used to lookup a block in a jsonrpc call cannot be found.
|
|
238
|
-
"""
|
|
239
|
-
|
|
240
|
-
pass
|
|
241
|
-
|
|
242
238
|
|
|
243
239
|
class InfuraProjectIdNotFound(Web3Exception):
|
|
244
240
|
"""
|
|
245
241
|
Raised when there is no Infura Project Id set.
|
|
246
242
|
"""
|
|
247
243
|
|
|
248
|
-
pass
|
|
249
|
-
|
|
250
244
|
|
|
251
245
|
class LogTopicError(Web3Exception):
|
|
252
246
|
"""
|
|
253
247
|
Raised when the number of log topics is mismatched.
|
|
254
248
|
"""
|
|
255
249
|
|
|
256
|
-
pass
|
|
257
|
-
|
|
258
250
|
|
|
259
251
|
class InvalidEventABI(Web3Exception):
|
|
260
252
|
"""
|
|
261
253
|
Raised when the event ABI is invalid.
|
|
262
254
|
"""
|
|
263
255
|
|
|
264
|
-
pass
|
|
265
|
-
|
|
266
256
|
|
|
267
257
|
class ContractLogicError(Web3Exception):
|
|
268
258
|
"""
|
|
@@ -274,6 +264,7 @@ class ContractLogicError(Web3Exception):
|
|
|
274
264
|
message: Optional[str] = None,
|
|
275
265
|
data: Optional[Union[str, Dict[str, str]]] = None,
|
|
276
266
|
):
|
|
267
|
+
super().__init__(message, data)
|
|
277
268
|
self.message = message
|
|
278
269
|
self.data = data
|
|
279
270
|
|
|
@@ -283,16 +274,12 @@ class ContractCustomError(ContractLogicError):
|
|
|
283
274
|
Raised on a contract revert custom error
|
|
284
275
|
"""
|
|
285
276
|
|
|
286
|
-
pass
|
|
287
|
-
|
|
288
277
|
|
|
289
278
|
class ContractPanicError(ContractLogicError):
|
|
290
279
|
"""
|
|
291
280
|
Raised when a contract reverts with Panic, as of Solidity 0.8.0
|
|
292
281
|
"""
|
|
293
282
|
|
|
294
|
-
pass
|
|
295
|
-
|
|
296
283
|
|
|
297
284
|
class OffchainLookup(ContractLogicError):
|
|
298
285
|
"""
|
|
@@ -330,12 +317,100 @@ class BadResponseFormat(Web3Exception):
|
|
|
330
317
|
Raised when a JSON-RPC response comes back in an unexpected format
|
|
331
318
|
"""
|
|
332
319
|
|
|
333
|
-
|
|
320
|
+
|
|
321
|
+
class TaskNotRunning(Web3Exception):
|
|
322
|
+
"""
|
|
323
|
+
Used to signal between asyncio contexts that a task that is being awaited
|
|
324
|
+
is not currently running.
|
|
325
|
+
"""
|
|
326
|
+
|
|
327
|
+
def __init__(
|
|
328
|
+
self, task: "asyncio.Task[Any]", message: Optional[str] = None
|
|
329
|
+
) -> None:
|
|
330
|
+
self.task = task
|
|
331
|
+
if message is None:
|
|
332
|
+
message = f"Task {task} is not running."
|
|
333
|
+
self.message = message
|
|
334
|
+
super().__init__(message)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
class PersistentConnectionError(Web3Exception):
|
|
338
|
+
"""
|
|
339
|
+
Raised when a persistent connection encounters an error.
|
|
340
|
+
"""
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class ReadBufferLimitReached(PersistentConnectionError, Web3ValueError):
|
|
344
|
+
"""
|
|
345
|
+
Raised when the read buffer limit is reached while reading data from a persistent
|
|
346
|
+
connection.
|
|
347
|
+
"""
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
class PersistentConnectionClosedOK(PersistentConnectionError):
|
|
351
|
+
"""
|
|
352
|
+
Raised when a persistent connection is closed gracefully by the server.
|
|
353
|
+
"""
|
|
334
354
|
|
|
335
355
|
|
|
336
|
-
class
|
|
356
|
+
class SubscriptionProcessingFinished(Web3Exception):
|
|
357
|
+
"""
|
|
358
|
+
Raised to alert the subscription manager that the processing of subscriptions
|
|
359
|
+
has finished.
|
|
360
|
+
"""
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
class Web3RPCError(Web3Exception):
|
|
364
|
+
"""
|
|
365
|
+
Raised when a JSON-RPC response contains an error field.
|
|
366
|
+
"""
|
|
367
|
+
|
|
368
|
+
def __init__(
|
|
369
|
+
self,
|
|
370
|
+
message: str,
|
|
371
|
+
rpc_response: Optional[RPCResponse] = None,
|
|
372
|
+
user_message: Optional[str] = None,
|
|
373
|
+
) -> None:
|
|
374
|
+
if user_message is None:
|
|
375
|
+
user_message = (
|
|
376
|
+
"An RPC error was returned by the node. Check the message provided in "
|
|
377
|
+
"the error and any available logs for more information."
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
super().__init__(
|
|
381
|
+
message,
|
|
382
|
+
user_message=user_message,
|
|
383
|
+
)
|
|
384
|
+
self.message = message
|
|
385
|
+
self.rpc_response = rpc_response
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
class MethodUnavailable(Web3RPCError):
|
|
337
389
|
"""
|
|
338
390
|
Raised when the method is not available on the node
|
|
339
391
|
"""
|
|
340
392
|
|
|
341
|
-
|
|
393
|
+
|
|
394
|
+
class RequestTimedOut(Web3RPCError):
|
|
395
|
+
"""
|
|
396
|
+
Raised when a request to the node times out.
|
|
397
|
+
"""
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class TransactionNotFound(Web3RPCError):
|
|
401
|
+
"""
|
|
402
|
+
Raised when a tx hash used to look up a tx in a jsonrpc call cannot be found.
|
|
403
|
+
"""
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
class TransactionIndexingInProgress(Web3RPCError):
|
|
407
|
+
"""
|
|
408
|
+
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
409
|
+
still being in progress.
|
|
410
|
+
"""
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
class BlockNotFound(Web3RPCError):
|
|
414
|
+
"""
|
|
415
|
+
Raised when the block id used to look up a block in a jsonrpc call cannot be found.
|
|
416
|
+
"""
|
|
@@ -5,6 +5,7 @@ from typing import (
|
|
|
5
5
|
Iterable,
|
|
6
6
|
Sequence,
|
|
7
7
|
Tuple,
|
|
8
|
+
cast,
|
|
8
9
|
)
|
|
9
10
|
|
|
10
11
|
from eth_typing import (
|
|
@@ -35,6 +36,7 @@ from web3.exceptions import (
|
|
|
35
36
|
from web3.types import (
|
|
36
37
|
BlockNumber,
|
|
37
38
|
GasPriceStrategy,
|
|
39
|
+
TxData,
|
|
38
40
|
TxParams,
|
|
39
41
|
Wei,
|
|
40
42
|
)
|
|
@@ -84,8 +86,8 @@ def _get_raw_miner_data(
|
|
|
84
86
|
latest = w3.eth.get_block("latest", full_transactions=True)
|
|
85
87
|
|
|
86
88
|
for transaction in latest["transactions"]:
|
|
87
|
-
|
|
88
|
-
yield (latest["miner"], latest["hash"], transaction["gasPrice"])
|
|
89
|
+
transaction = cast(TxData, transaction)
|
|
90
|
+
yield (latest["miner"], latest["hash"], transaction["gasPrice"])
|
|
89
91
|
|
|
90
92
|
block = latest
|
|
91
93
|
|
|
@@ -97,8 +99,8 @@ def _get_raw_miner_data(
|
|
|
97
99
|
# block numbers to make caching the data easier to implement.
|
|
98
100
|
block = w3.eth.get_block(block["parentHash"], full_transactions=True)
|
|
99
101
|
for transaction in block["transactions"]:
|
|
100
|
-
|
|
101
|
-
yield (block["miner"], block["hash"], transaction["gasPrice"])
|
|
102
|
+
transaction = cast(TxData, transaction)
|
|
103
|
+
yield (block["miner"], block["hash"], transaction["gasPrice"])
|
|
102
104
|
|
|
103
105
|
|
|
104
106
|
def _aggregate_miner_data(
|
|
@@ -112,11 +114,11 @@ def _aggregate_miner_data(
|
|
|
112
114
|
# types ignored b/c mypy has trouble inferring gas_prices: Sequence[Wei]
|
|
113
115
|
price_percentile = percentile(gas_prices, percentile=20) # type: ignore
|
|
114
116
|
except InsufficientData:
|
|
115
|
-
price_percentile = min(gas_prices)
|
|
117
|
+
price_percentile = min(gas_prices)
|
|
116
118
|
yield MinerData(
|
|
117
119
|
miner,
|
|
118
120
|
len(set(block_hashes)),
|
|
119
|
-
min(gas_prices),
|
|
121
|
+
min(gas_prices),
|
|
120
122
|
price_percentile,
|
|
121
123
|
)
|
|
122
124
|
|