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
web3/eth/eth.py
CHANGED
|
@@ -30,6 +30,9 @@ from hexbytes import (
|
|
|
30
30
|
from web3._utils.blocks import (
|
|
31
31
|
select_method_for_block_identifier,
|
|
32
32
|
)
|
|
33
|
+
from web3._utils.compat import (
|
|
34
|
+
Unpack,
|
|
35
|
+
)
|
|
33
36
|
from web3._utils.fee_utils import (
|
|
34
37
|
fee_history_priority_fee,
|
|
35
38
|
)
|
|
@@ -57,12 +60,13 @@ from web3.eth.base_eth import (
|
|
|
57
60
|
BaseEth,
|
|
58
61
|
)
|
|
59
62
|
from web3.exceptions import (
|
|
60
|
-
MethodUnavailable,
|
|
61
63
|
OffchainLookup,
|
|
62
64
|
TimeExhausted,
|
|
63
65
|
TooManyRequests,
|
|
64
66
|
TransactionIndexingInProgress,
|
|
65
67
|
TransactionNotFound,
|
|
68
|
+
Web3RPCError,
|
|
69
|
+
Web3ValueError,
|
|
66
70
|
)
|
|
67
71
|
from web3.method import (
|
|
68
72
|
Method,
|
|
@@ -73,7 +77,7 @@ from web3.types import (
|
|
|
73
77
|
BlockData,
|
|
74
78
|
BlockIdentifier,
|
|
75
79
|
BlockParams,
|
|
76
|
-
|
|
80
|
+
BlockReceipts,
|
|
77
81
|
CreateAccessListResponse,
|
|
78
82
|
FeeHistory,
|
|
79
83
|
FilterParams,
|
|
@@ -81,6 +85,7 @@ from web3.types import (
|
|
|
81
85
|
MerkleProof,
|
|
82
86
|
Nonce,
|
|
83
87
|
SignedTx,
|
|
88
|
+
StateOverride,
|
|
84
89
|
SyncStatus,
|
|
85
90
|
TxData,
|
|
86
91
|
TxParams,
|
|
@@ -114,17 +119,6 @@ class Eth(BaseEth):
|
|
|
114
119
|
def accounts(self) -> Tuple[ChecksumAddress]:
|
|
115
120
|
return self._accounts()
|
|
116
121
|
|
|
117
|
-
# eth_hashrate
|
|
118
|
-
|
|
119
|
-
_hashrate: Method[Callable[[], int]] = Method(
|
|
120
|
-
RPC.eth_hashrate,
|
|
121
|
-
is_property=True,
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
@property
|
|
125
|
-
def hashrate(self) -> int:
|
|
126
|
-
return self._hashrate()
|
|
127
|
-
|
|
128
122
|
# eth_blockNumber
|
|
129
123
|
|
|
130
124
|
get_block_number: Method[Callable[[], BlockNumber]] = Method(
|
|
@@ -147,17 +141,6 @@ class Eth(BaseEth):
|
|
|
147
141
|
def chain_id(self) -> int:
|
|
148
142
|
return self._chain_id()
|
|
149
143
|
|
|
150
|
-
# eth_coinbase
|
|
151
|
-
|
|
152
|
-
_coinbase: Method[Callable[[], ChecksumAddress]] = Method(
|
|
153
|
-
RPC.eth_coinbase,
|
|
154
|
-
is_property=True,
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
@property
|
|
158
|
-
def coinbase(self) -> ChecksumAddress:
|
|
159
|
-
return self._coinbase()
|
|
160
|
-
|
|
161
144
|
# eth_gasPrice
|
|
162
145
|
|
|
163
146
|
_gas_price: Method[Callable[[], Wei]] = Method(
|
|
@@ -185,24 +168,14 @@ class Eth(BaseEth):
|
|
|
185
168
|
"""
|
|
186
169
|
try:
|
|
187
170
|
return self._max_priority_fee()
|
|
188
|
-
except
|
|
171
|
+
except Web3RPCError:
|
|
189
172
|
warnings.warn(
|
|
190
173
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
191
|
-
"Calculating using eth_feeHistory."
|
|
174
|
+
"Calculating using eth_feeHistory.",
|
|
175
|
+
stacklevel=2,
|
|
192
176
|
)
|
|
193
177
|
return fee_history_priority_fee(self)
|
|
194
178
|
|
|
195
|
-
# eth_mining
|
|
196
|
-
|
|
197
|
-
_mining: Method[Callable[[], bool]] = Method(
|
|
198
|
-
RPC.eth_mining,
|
|
199
|
-
is_property=True,
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
@property
|
|
203
|
-
def mining(self) -> bool:
|
|
204
|
-
return self._mining()
|
|
205
|
-
|
|
206
179
|
# eth_syncing
|
|
207
180
|
|
|
208
181
|
_syncing: Method[Callable[[], Union[SyncStatus, bool]]] = Method(
|
|
@@ -235,7 +208,7 @@ class Eth(BaseEth):
|
|
|
235
208
|
|
|
236
209
|
_call: Method[
|
|
237
210
|
Callable[
|
|
238
|
-
[TxParams, Optional[BlockIdentifier], Optional[
|
|
211
|
+
[TxParams, Optional[BlockIdentifier], Optional[StateOverride]],
|
|
239
212
|
HexBytes,
|
|
240
213
|
]
|
|
241
214
|
] = Method(RPC.eth_call, mungers=[BaseEth.call_munger])
|
|
@@ -244,7 +217,7 @@ class Eth(BaseEth):
|
|
|
244
217
|
self,
|
|
245
218
|
transaction: TxParams,
|
|
246
219
|
block_identifier: Optional[BlockIdentifier] = None,
|
|
247
|
-
state_override: Optional[
|
|
220
|
+
state_override: Optional[StateOverride] = None,
|
|
248
221
|
ccip_read_enabled: Optional[bool] = None,
|
|
249
222
|
) -> HexBytes:
|
|
250
223
|
ccip_read_enabled_on_provider = self.w3.provider.global_ccip_read_enabled
|
|
@@ -265,12 +238,12 @@ class Eth(BaseEth):
|
|
|
265
238
|
self,
|
|
266
239
|
transaction: TxParams,
|
|
267
240
|
block_identifier: Optional[BlockIdentifier] = None,
|
|
268
|
-
state_override: Optional[
|
|
241
|
+
state_override: Optional[StateOverride] = None,
|
|
269
242
|
) -> HexBytes:
|
|
270
243
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
271
244
|
|
|
272
245
|
if not max_redirects or max_redirects < 4:
|
|
273
|
-
raise
|
|
246
|
+
raise Web3ValueError(
|
|
274
247
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
275
248
|
)
|
|
276
249
|
|
|
@@ -279,7 +252,8 @@ class Eth(BaseEth):
|
|
|
279
252
|
return self._call(transaction, block_identifier, state_override)
|
|
280
253
|
except OffchainLookup as offchain_lookup:
|
|
281
254
|
durin_calldata = handle_offchain_lookup(
|
|
282
|
-
offchain_lookup.payload,
|
|
255
|
+
offchain_lookup.payload,
|
|
256
|
+
transaction,
|
|
283
257
|
)
|
|
284
258
|
transaction["data"] = durin_calldata
|
|
285
259
|
|
|
@@ -304,14 +278,14 @@ class Eth(BaseEth):
|
|
|
304
278
|
# eth_estimateGas
|
|
305
279
|
|
|
306
280
|
_estimate_gas: Method[
|
|
307
|
-
Callable[[TxParams, Optional[BlockIdentifier], Optional[
|
|
281
|
+
Callable[[TxParams, Optional[BlockIdentifier], Optional[StateOverride]], int]
|
|
308
282
|
] = Method(RPC.eth_estimateGas, mungers=[BaseEth.estimate_gas_munger])
|
|
309
283
|
|
|
310
284
|
def estimate_gas(
|
|
311
285
|
self,
|
|
312
286
|
transaction: TxParams,
|
|
313
287
|
block_identifier: Optional[BlockIdentifier] = None,
|
|
314
|
-
state_override: Optional[
|
|
288
|
+
state_override: Optional[StateOverride] = None,
|
|
315
289
|
) -> int:
|
|
316
290
|
return self._estimate_gas(transaction, block_identifier, state_override)
|
|
317
291
|
|
|
@@ -412,6 +386,16 @@ class Eth(BaseEth):
|
|
|
412
386
|
) -> BlockData:
|
|
413
387
|
return self._get_block(block_identifier, full_transactions)
|
|
414
388
|
|
|
389
|
+
# eth_getBlockReceipts
|
|
390
|
+
|
|
391
|
+
_get_block_receipts: Method[Callable[[BlockIdentifier], BlockReceipts]] = Method(
|
|
392
|
+
RPC.eth_getBlockReceipts,
|
|
393
|
+
mungers=[default_root_munger],
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
def get_block_receipts(self, block_identifier: BlockIdentifier) -> BlockReceipts:
|
|
397
|
+
return self._get_block_receipts(block_identifier)
|
|
398
|
+
|
|
415
399
|
# eth_getBalance
|
|
416
400
|
|
|
417
401
|
_get_balance: Method[
|
|
@@ -583,10 +567,8 @@ class Eth(BaseEth):
|
|
|
583
567
|
current_transaction = get_required_transaction(self.w3, transaction_hash)
|
|
584
568
|
return replace_transaction(self.w3, current_transaction, new_transaction)
|
|
585
569
|
|
|
586
|
-
# todo: Update Any to stricter kwarg checking with TxParams
|
|
587
|
-
# https://github.com/python/mypy/issues/4441
|
|
588
570
|
def modify_transaction(
|
|
589
|
-
self, transaction_hash: _Hash32, **transaction_params:
|
|
571
|
+
self, transaction_hash: _Hash32, **transaction_params: Unpack[TxParams]
|
|
590
572
|
) -> HexBytes:
|
|
591
573
|
assert_valid_transaction_params(cast(TxParams, transaction_params))
|
|
592
574
|
current_transaction = get_required_transaction(self.w3, transaction_hash)
|
|
@@ -646,28 +628,8 @@ class Eth(BaseEth):
|
|
|
646
628
|
mungers=[default_root_munger],
|
|
647
629
|
)
|
|
648
630
|
|
|
649
|
-
# eth_submitHashrate
|
|
650
|
-
|
|
651
|
-
submit_hashrate: Method[Callable[[int, _Hash32], bool]] = Method(
|
|
652
|
-
RPC.eth_submitHashrate,
|
|
653
|
-
mungers=[default_root_munger],
|
|
654
|
-
)
|
|
655
|
-
|
|
656
|
-
# eth_getWork, eth_submitWork
|
|
657
|
-
|
|
658
|
-
get_work: Method[Callable[[], List[HexBytes]]] = Method(
|
|
659
|
-
RPC.eth_getWork,
|
|
660
|
-
is_property=True,
|
|
661
|
-
)
|
|
662
|
-
|
|
663
|
-
submit_work: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method(
|
|
664
|
-
RPC.eth_submitWork,
|
|
665
|
-
mungers=[default_root_munger],
|
|
666
|
-
)
|
|
667
|
-
|
|
668
631
|
@overload
|
|
669
|
-
|
|
670
|
-
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]: # type: ignore[misc] # noqa: E501
|
|
632
|
+
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]:
|
|
671
633
|
...
|
|
672
634
|
|
|
673
635
|
@overload
|
web3/exceptions.py
CHANGED
|
@@ -8,12 +8,9 @@ from typing import (
|
|
|
8
8
|
Union,
|
|
9
9
|
)
|
|
10
10
|
|
|
11
|
-
from eth_utils import (
|
|
12
|
-
ValidationError,
|
|
13
|
-
)
|
|
14
|
-
|
|
15
11
|
from web3.types import (
|
|
16
12
|
BlockData,
|
|
13
|
+
RPCResponse,
|
|
17
14
|
)
|
|
18
15
|
|
|
19
16
|
if TYPE_CHECKING:
|
|
@@ -34,6 +31,8 @@ class Web3Exception(Exception):
|
|
|
34
31
|
# deal with other exceptions
|
|
35
32
|
"""
|
|
36
33
|
|
|
34
|
+
user_message: Optional[str] = None
|
|
35
|
+
|
|
37
36
|
def __init__(
|
|
38
37
|
self,
|
|
39
38
|
*args: Any,
|
|
@@ -45,6 +44,40 @@ class Web3Exception(Exception):
|
|
|
45
44
|
self.user_message = user_message
|
|
46
45
|
|
|
47
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
|
+
|
|
80
|
+
|
|
48
81
|
class BadFunctionCallOutput(Web3Exception):
|
|
49
82
|
"""
|
|
50
83
|
We failed to decode ABI output.
|
|
@@ -52,24 +85,18 @@ class BadFunctionCallOutput(Web3Exception):
|
|
|
52
85
|
Most likely ABI mismatch.
|
|
53
86
|
"""
|
|
54
87
|
|
|
55
|
-
pass
|
|
56
|
-
|
|
57
88
|
|
|
58
|
-
class
|
|
89
|
+
class BlockNumberOutOfRange(Web3Exception):
|
|
59
90
|
"""
|
|
60
91
|
block_identifier passed does not match known block.
|
|
61
92
|
"""
|
|
62
93
|
|
|
63
|
-
pass
|
|
64
|
-
|
|
65
94
|
|
|
66
95
|
class ProviderConnectionError(Web3Exception):
|
|
67
96
|
"""
|
|
68
97
|
Raised when unable to connect to a provider
|
|
69
98
|
"""
|
|
70
99
|
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
100
|
|
|
74
101
|
class CannotHandleRequest(Web3Exception):
|
|
75
102
|
"""
|
|
@@ -77,16 +104,12 @@ class CannotHandleRequest(Web3Exception):
|
|
|
77
104
|
that the manager should proceed to the next provider.
|
|
78
105
|
"""
|
|
79
106
|
|
|
80
|
-
pass
|
|
81
|
-
|
|
82
107
|
|
|
83
108
|
class TooManyRequests(Web3Exception):
|
|
84
109
|
"""
|
|
85
110
|
Raised by a provider to signal that too many requests have been made consecutively.
|
|
86
111
|
"""
|
|
87
112
|
|
|
88
|
-
pass
|
|
89
|
-
|
|
90
113
|
|
|
91
114
|
class MultipleFailedRequests(Web3Exception):
|
|
92
115
|
"""
|
|
@@ -94,16 +117,12 @@ class MultipleFailedRequests(Web3Exception):
|
|
|
94
117
|
(or similar) data have failed.
|
|
95
118
|
"""
|
|
96
119
|
|
|
97
|
-
pass
|
|
98
|
-
|
|
99
120
|
|
|
100
121
|
class InvalidAddress(Web3Exception):
|
|
101
122
|
"""
|
|
102
123
|
The supplied address does not have a valid checksum, as defined in EIP-55
|
|
103
124
|
"""
|
|
104
125
|
|
|
105
|
-
pass
|
|
106
|
-
|
|
107
126
|
|
|
108
127
|
class NameNotFound(Web3Exception):
|
|
109
128
|
"""
|
|
@@ -111,8 +130,6 @@ class NameNotFound(Web3Exception):
|
|
|
111
130
|
does not resolve to an address.
|
|
112
131
|
"""
|
|
113
132
|
|
|
114
|
-
pass
|
|
115
|
-
|
|
116
133
|
|
|
117
134
|
class StaleBlockchain(Web3Exception):
|
|
118
135
|
"""
|
|
@@ -142,17 +159,13 @@ class MismatchedABI(Web3Exception):
|
|
|
142
159
|
attempt is made to access a function/event that does not exist in the ABI.
|
|
143
160
|
"""
|
|
144
161
|
|
|
145
|
-
pass
|
|
146
|
-
|
|
147
162
|
|
|
148
|
-
class
|
|
163
|
+
class ABIEventNotFound(AttributeError, MismatchedABI):
|
|
149
164
|
"""
|
|
150
165
|
Raised when an attempt is made to access an event
|
|
151
166
|
that does not exist in the ABI.
|
|
152
167
|
"""
|
|
153
168
|
|
|
154
|
-
pass
|
|
155
|
-
|
|
156
169
|
|
|
157
170
|
class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
158
171
|
"""
|
|
@@ -160,56 +173,54 @@ class ABIFunctionNotFound(AttributeError, MismatchedABI):
|
|
|
160
173
|
that does not exist in the ABI.
|
|
161
174
|
"""
|
|
162
175
|
|
|
163
|
-
|
|
176
|
+
|
|
177
|
+
class ABIConstructorNotFound(Web3Exception):
|
|
178
|
+
"""
|
|
179
|
+
Raised when a constructor function doesn't exist in contract.
|
|
180
|
+
"""
|
|
164
181
|
|
|
165
182
|
|
|
166
|
-
class
|
|
183
|
+
class ABIFallbackNotFound(Web3Exception):
|
|
167
184
|
"""
|
|
168
|
-
Raised when fallback function doesn't exist in contract.
|
|
185
|
+
Raised when a fallback function doesn't exist in contract.
|
|
169
186
|
"""
|
|
170
187
|
|
|
171
|
-
pass
|
|
172
188
|
|
|
189
|
+
class ABIReceiveNotFound(Web3Exception):
|
|
190
|
+
"""
|
|
191
|
+
Raised when a receive function doesn't exist in contract.
|
|
192
|
+
"""
|
|
173
193
|
|
|
174
|
-
|
|
194
|
+
|
|
195
|
+
class Web3ValidationError(Web3Exception):
|
|
175
196
|
"""
|
|
176
197
|
Raised when a supplied value is invalid.
|
|
177
198
|
"""
|
|
178
199
|
|
|
179
|
-
pass
|
|
180
|
-
|
|
181
200
|
|
|
182
201
|
class ExtraDataLengthError(Web3ValidationError):
|
|
183
202
|
"""
|
|
184
203
|
Raised when an RPC call returns >32 bytes of extraData.
|
|
185
204
|
"""
|
|
186
205
|
|
|
187
|
-
pass
|
|
188
|
-
|
|
189
206
|
|
|
190
207
|
class NoABIFunctionsFound(Web3Exception):
|
|
191
208
|
"""
|
|
192
209
|
Raised when an ABI is present, but doesn't contain any functions.
|
|
193
210
|
"""
|
|
194
211
|
|
|
195
|
-
pass
|
|
196
|
-
|
|
197
212
|
|
|
198
213
|
class NoABIFound(Web3Exception):
|
|
199
214
|
"""
|
|
200
215
|
Raised when no ABI is present.
|
|
201
216
|
"""
|
|
202
217
|
|
|
203
|
-
pass
|
|
204
|
-
|
|
205
218
|
|
|
206
219
|
class NoABIEventsFound(Web3Exception):
|
|
207
220
|
"""
|
|
208
221
|
Raised when an ABI doesn't contain any events.
|
|
209
222
|
"""
|
|
210
223
|
|
|
211
|
-
pass
|
|
212
|
-
|
|
213
224
|
|
|
214
225
|
class InsufficientData(Web3Exception):
|
|
215
226
|
"""
|
|
@@ -217,8 +228,6 @@ class InsufficientData(Web3Exception):
|
|
|
217
228
|
complete a calculation
|
|
218
229
|
"""
|
|
219
230
|
|
|
220
|
-
pass
|
|
221
|
-
|
|
222
231
|
|
|
223
232
|
class TimeExhausted(Web3Exception):
|
|
224
233
|
"""
|
|
@@ -226,57 +235,24 @@ class TimeExhausted(Web3Exception):
|
|
|
226
235
|
result within a specified timeout.
|
|
227
236
|
"""
|
|
228
237
|
|
|
229
|
-
pass
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
class TransactionNotFound(Web3Exception):
|
|
233
|
-
"""
|
|
234
|
-
Raised when a tx hash used to lookup a tx in a jsonrpc call cannot be found.
|
|
235
|
-
"""
|
|
236
|
-
|
|
237
|
-
pass
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
class TransactionIndexingInProgress(Web3Exception):
|
|
241
|
-
"""
|
|
242
|
-
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
243
|
-
still being in progress.
|
|
244
|
-
"""
|
|
245
|
-
|
|
246
|
-
pass
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
class BlockNotFound(Web3Exception):
|
|
250
|
-
"""
|
|
251
|
-
Raised when the block id used to lookup a block in a jsonrpc call cannot be found.
|
|
252
|
-
"""
|
|
253
|
-
|
|
254
|
-
pass
|
|
255
|
-
|
|
256
238
|
|
|
257
239
|
class InfuraProjectIdNotFound(Web3Exception):
|
|
258
240
|
"""
|
|
259
241
|
Raised when there is no Infura Project Id set.
|
|
260
242
|
"""
|
|
261
243
|
|
|
262
|
-
pass
|
|
263
|
-
|
|
264
244
|
|
|
265
245
|
class LogTopicError(Web3Exception):
|
|
266
246
|
"""
|
|
267
247
|
Raised when the number of log topics is mismatched.
|
|
268
248
|
"""
|
|
269
249
|
|
|
270
|
-
pass
|
|
271
|
-
|
|
272
250
|
|
|
273
251
|
class InvalidEventABI(Web3Exception):
|
|
274
252
|
"""
|
|
275
253
|
Raised when the event ABI is invalid.
|
|
276
254
|
"""
|
|
277
255
|
|
|
278
|
-
pass
|
|
279
|
-
|
|
280
256
|
|
|
281
257
|
class ContractLogicError(Web3Exception):
|
|
282
258
|
"""
|
|
@@ -298,16 +274,12 @@ class ContractCustomError(ContractLogicError):
|
|
|
298
274
|
Raised on a contract revert custom error
|
|
299
275
|
"""
|
|
300
276
|
|
|
301
|
-
pass
|
|
302
|
-
|
|
303
277
|
|
|
304
278
|
class ContractPanicError(ContractLogicError):
|
|
305
279
|
"""
|
|
306
280
|
Raised when a contract reverts with Panic, as of Solidity 0.8.0
|
|
307
281
|
"""
|
|
308
282
|
|
|
309
|
-
pass
|
|
310
|
-
|
|
311
283
|
|
|
312
284
|
class OffchainLookup(ContractLogicError):
|
|
313
285
|
"""
|
|
@@ -362,9 +334,63 @@ class TaskNotRunning(Web3Exception):
|
|
|
362
334
|
super().__init__(message)
|
|
363
335
|
|
|
364
336
|
|
|
365
|
-
class
|
|
337
|
+
class PersistentConnectionClosedOK(Web3Exception):
|
|
338
|
+
"""
|
|
339
|
+
Raised when a persistent connection is closed gracefully by the server.
|
|
340
|
+
"""
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
class Web3RPCError(Web3Exception):
|
|
344
|
+
"""
|
|
345
|
+
Raised when a JSON-RPC response contains an error field.
|
|
346
|
+
"""
|
|
347
|
+
|
|
348
|
+
def __init__(
|
|
349
|
+
self,
|
|
350
|
+
message: str,
|
|
351
|
+
rpc_response: Optional[RPCResponse] = None,
|
|
352
|
+
user_message: Optional[str] = None,
|
|
353
|
+
) -> None:
|
|
354
|
+
if user_message is None:
|
|
355
|
+
user_message = (
|
|
356
|
+
"An RPC error was returned by the node. Check the message provided in "
|
|
357
|
+
"the error and any available logs for more information."
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
super().__init__(
|
|
361
|
+
message,
|
|
362
|
+
user_message=user_message,
|
|
363
|
+
)
|
|
364
|
+
self.message = message
|
|
365
|
+
self.rpc_response = rpc_response
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
class MethodUnavailable(Web3RPCError):
|
|
366
369
|
"""
|
|
367
370
|
Raised when the method is not available on the node
|
|
368
371
|
"""
|
|
369
372
|
|
|
370
|
-
|
|
373
|
+
|
|
374
|
+
class RequestTimedOut(Web3RPCError):
|
|
375
|
+
"""
|
|
376
|
+
Raised when a request to the node times out.
|
|
377
|
+
"""
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
class TransactionNotFound(Web3RPCError):
|
|
381
|
+
"""
|
|
382
|
+
Raised when a tx hash used to look up a tx in a jsonrpc call cannot be found.
|
|
383
|
+
"""
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
class TransactionIndexingInProgress(Web3RPCError):
|
|
387
|
+
"""
|
|
388
|
+
Raised when a transaction receipt is not yet available due to transaction indexing
|
|
389
|
+
still being in progress.
|
|
390
|
+
"""
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
class BlockNotFound(Web3RPCError):
|
|
394
|
+
"""
|
|
395
|
+
Raised when the block id used to look up a block in a jsonrpc call cannot be found.
|
|
396
|
+
"""
|
|
@@ -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
|
|