web3 7.0.0b2__py3-none-any.whl → 7.0.0b4__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/_normalization.py +1 -3
- ens/async_ens.py +14 -11
- ens/contract_data.py +2 -2
- ens/ens.py +10 -7
- ens/exceptions.py +19 -27
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +24 -15
- web3/__init__.py +2 -7
- web3/_utils/abi.py +30 -29
- web3/_utils/async_transactions.py +7 -4
- web3/_utils/blocks.py +6 -2
- web3/_utils/caching.py +7 -3
- web3/_utils/compat/__init__.py +0 -3
- web3/_utils/contract_sources/compile_contracts.py +1 -1
- web3/_utils/contracts.py +12 -12
- web3/_utils/datatypes.py +5 -1
- web3/_utils/decorators.py +6 -1
- web3/_utils/empty.py +1 -1
- web3/_utils/encoding.py +15 -10
- web3/_utils/error_formatters_utils.py +5 -3
- web3/_utils/events.py +35 -24
- web3/_utils/fee_utils.py +2 -4
- web3/_utils/filters.py +17 -12
- web3/_utils/formatters.py +2 -2
- web3/_utils/math.py +14 -15
- web3/_utils/method_formatters.py +31 -5
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/eth_module.py +129 -75
- web3/_utils/module_testing/go_ethereum_personal_module.py +1 -1
- web3/_utils/module_testing/module_testing_utils.py +1 -3
- web3/_utils/module_testing/utils.py +14 -7
- web3/_utils/normalizers.py +3 -3
- web3/_utils/request.py +4 -4
- web3/_utils/rpc_abi.py +6 -1
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +18 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +12 -10
- web3/contract/async_contract.py +12 -7
- web3/contract/base_contract.py +51 -57
- web3/contract/contract.py +12 -6
- web3/contract/utils.py +11 -6
- web3/datastructures.py +22 -12
- web3/eth/async_eth.py +53 -30
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +31 -14
- web3/exceptions.py +41 -59
- web3/gas_strategies/time_based.py +2 -4
- web3/geth.py +1 -3
- web3/main.py +6 -2
- web3/manager.py +13 -12
- web3/method.py +13 -5
- web3/middleware/base.py +4 -2
- web3/middleware/filter.py +27 -17
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +6 -2
- web3/middleware/stalecheck.py +2 -1
- web3/providers/eth_tester/defaults.py +1 -1
- web3/providers/eth_tester/main.py +5 -4
- web3/providers/eth_tester/middleware.py +10 -1
- web3/providers/ipc.py +7 -3
- web3/providers/persistent/async_ipc.py +6 -7
- web3/providers/persistent/persistent.py +12 -2
- web3/providers/persistent/request_processor.py +10 -12
- web3/providers/persistent/websocket.py +3 -3
- web3/providers/rpc/async_rpc.py +23 -6
- web3/providers/rpc/rpc.py +27 -16
- web3/testing.py +4 -4
- web3/tools/benchmark/__init__.py +0 -0
- web3/tools/benchmark/main.py +189 -0
- web3/tools/benchmark/node.py +126 -0
- web3/tools/benchmark/reporting.py +39 -0
- web3/tools/benchmark/utils.py +69 -0
- web3/tracing.py +9 -5
- web3/types.py +23 -22
- web3/utils/caching.py +2 -4
- {web3-7.0.0b2.dist-info → web3-7.0.0b4.dist-info}/METADATA +13 -26
- {web3-7.0.0b2.dist-info → web3-7.0.0b4.dist-info}/RECORD +83 -78
- {web3-7.0.0b2.dist-info → web3-7.0.0b4.dist-info}/LICENSE +0 -0
- {web3-7.0.0b2.dist-info → web3-7.0.0b4.dist-info}/WHEEL +0 -0
- {web3-7.0.0b2.dist-info → web3-7.0.0b4.dist-info}/top_level.txt +0 -0
web3/contract/contract.py
CHANGED
|
@@ -81,7 +81,10 @@ from web3.exceptions import (
|
|
|
81
81
|
ABIFunctionNotFound,
|
|
82
82
|
NoABIFound,
|
|
83
83
|
NoABIFunctionsFound,
|
|
84
|
+
Web3AttributeError,
|
|
85
|
+
Web3TypeError,
|
|
84
86
|
Web3ValidationError,
|
|
87
|
+
Web3ValueError,
|
|
85
88
|
)
|
|
86
89
|
from web3.types import (
|
|
87
90
|
ABI,
|
|
@@ -111,7 +114,8 @@ class ContractEvent(BaseContractEvent):
|
|
|
111
114
|
toBlock: Optional[BlockIdentifier] = None,
|
|
112
115
|
block_hash: Optional[HexBytes] = None,
|
|
113
116
|
) -> Iterable[EventData]:
|
|
114
|
-
"""
|
|
117
|
+
"""
|
|
118
|
+
Get events for this contract instance using eth_getLogs API.
|
|
115
119
|
|
|
116
120
|
This is a stateless method, as opposed to create_filter.
|
|
117
121
|
It can be safely called against nodes which do not provide
|
|
@@ -438,11 +442,13 @@ class Contract(BaseContract):
|
|
|
438
442
|
events: ContractEvents = None
|
|
439
443
|
|
|
440
444
|
def __init__(self, address: Optional[ChecksumAddress] = None) -> None:
|
|
441
|
-
"""
|
|
442
|
-
|
|
445
|
+
"""
|
|
446
|
+
Create a new smart contract proxy object.
|
|
447
|
+
:param address: Contract address as 0x hex string
|
|
448
|
+
"""
|
|
443
449
|
_w3 = self.w3
|
|
444
450
|
if _w3 is None:
|
|
445
|
-
raise
|
|
451
|
+
raise Web3AttributeError(
|
|
446
452
|
"The `Contract` class has not been initialized. Please use the "
|
|
447
453
|
"`web3.contract` interface to create your contract class."
|
|
448
454
|
)
|
|
@@ -451,7 +457,7 @@ class Contract(BaseContract):
|
|
|
451
457
|
self.address = normalize_address(cast("ENS", _w3.ens), address)
|
|
452
458
|
|
|
453
459
|
if not self.address:
|
|
454
|
-
raise
|
|
460
|
+
raise Web3TypeError(
|
|
455
461
|
"The address argument is required to instantiate a contract."
|
|
456
462
|
)
|
|
457
463
|
|
|
@@ -528,7 +534,7 @@ class Contract(BaseContract):
|
|
|
528
534
|
:return: a contract constructor object
|
|
529
535
|
"""
|
|
530
536
|
if cls.bytecode is None:
|
|
531
|
-
raise
|
|
537
|
+
raise Web3ValueError(
|
|
532
538
|
"Cannot call constructor on a contract that does not have "
|
|
533
539
|
"'bytecode' associated with it"
|
|
534
540
|
)
|
web3/contract/utils.py
CHANGED
|
@@ -43,6 +43,7 @@ from web3._utils.transactions import (
|
|
|
43
43
|
)
|
|
44
44
|
from web3.exceptions import (
|
|
45
45
|
BadFunctionCallOutput,
|
|
46
|
+
Web3ValueError,
|
|
46
47
|
)
|
|
47
48
|
from web3.types import (
|
|
48
49
|
ABI,
|
|
@@ -185,7 +186,8 @@ def estimate_gas_for_function(
|
|
|
185
186
|
*args: Any,
|
|
186
187
|
**kwargs: Any,
|
|
187
188
|
) -> int:
|
|
188
|
-
"""
|
|
189
|
+
"""
|
|
190
|
+
Estimates gas cost a function call would take.
|
|
189
191
|
|
|
190
192
|
Don't call this directly, instead use :meth:`Contract.estimate_gas`
|
|
191
193
|
on your contract instance.
|
|
@@ -214,7 +216,8 @@ def build_transaction_for_function(
|
|
|
214
216
|
*args: Any,
|
|
215
217
|
**kwargs: Any,
|
|
216
218
|
) -> TxParams:
|
|
217
|
-
"""
|
|
219
|
+
"""
|
|
220
|
+
Builds a dictionary with the fields required to make the given transaction
|
|
218
221
|
|
|
219
222
|
Don't call this directly, instead use :meth:`Contract.build_transaction`
|
|
220
223
|
on your contract instance.
|
|
@@ -261,11 +264,11 @@ def get_function_by_identifier(
|
|
|
261
264
|
fns: Sequence[TContractFn], identifier: str
|
|
262
265
|
) -> TContractFn:
|
|
263
266
|
if len(fns) > 1:
|
|
264
|
-
raise
|
|
267
|
+
raise Web3ValueError(
|
|
265
268
|
f"Found multiple functions with matching {identifier}. " f"Found: {fns!r}"
|
|
266
269
|
)
|
|
267
270
|
elif len(fns) == 0:
|
|
268
|
-
raise
|
|
271
|
+
raise Web3ValueError(f"Could not find any function with matching {identifier}")
|
|
269
272
|
return fns[0]
|
|
270
273
|
|
|
271
274
|
|
|
@@ -394,7 +397,8 @@ async def async_estimate_gas_for_function(
|
|
|
394
397
|
*args: Any,
|
|
395
398
|
**kwargs: Any,
|
|
396
399
|
) -> int:
|
|
397
|
-
"""
|
|
400
|
+
"""
|
|
401
|
+
Estimates gas cost a function call would take.
|
|
398
402
|
|
|
399
403
|
Don't call this directly, instead use :meth:`Contract.estimate_gas`
|
|
400
404
|
on your contract instance.
|
|
@@ -425,7 +429,8 @@ async def async_build_transaction_for_function(
|
|
|
425
429
|
*args: Any,
|
|
426
430
|
**kwargs: Any,
|
|
427
431
|
) -> TxParams:
|
|
428
|
-
"""
|
|
432
|
+
"""
|
|
433
|
+
Builds a dictionary with the fields required to make the given transaction
|
|
429
434
|
|
|
430
435
|
Don't call this directly, instead use :meth:`Contract.build_transaction`
|
|
431
436
|
on your contract instance.
|
web3/datastructures.py
CHANGED
|
@@ -28,6 +28,11 @@ from eth_utils import (
|
|
|
28
28
|
from web3._utils.formatters import (
|
|
29
29
|
recursive_map,
|
|
30
30
|
)
|
|
31
|
+
from web3.exceptions import (
|
|
32
|
+
Web3AssertionError,
|
|
33
|
+
Web3TypeError,
|
|
34
|
+
Web3ValueError,
|
|
35
|
+
)
|
|
31
36
|
|
|
32
37
|
# Hashable must be immutable:
|
|
33
38
|
# "the implementation of hashable collections requires that a
|
|
@@ -85,7 +90,10 @@ class ReadableAttributeDict(Mapping[TKey, TValue]):
|
|
|
85
90
|
|
|
86
91
|
@classmethod
|
|
87
92
|
def recursive(cls, value: TValue) -> "ReadableAttributeDict[TKey, TValue]":
|
|
88
|
-
return
|
|
93
|
+
return cast(
|
|
94
|
+
"ReadableAttributeDict[TKey, TValue]",
|
|
95
|
+
recursive_map(cls._apply_if_mapping, value),
|
|
96
|
+
)
|
|
89
97
|
|
|
90
98
|
|
|
91
99
|
class MutableAttributeDict(
|
|
@@ -100,19 +108,21 @@ class MutableAttributeDict(
|
|
|
100
108
|
|
|
101
109
|
class AttributeDict(ReadableAttributeDict[TKey, TValue], Hashable):
|
|
102
110
|
"""
|
|
103
|
-
|
|
111
|
+
Provides superficial immutability, someone could hack around it
|
|
104
112
|
"""
|
|
105
113
|
|
|
106
114
|
def __setattr__(self, attr: str, val: TValue) -> None:
|
|
107
115
|
if attr == "__dict__":
|
|
108
116
|
super().__setattr__(attr, val)
|
|
109
117
|
else:
|
|
110
|
-
raise
|
|
118
|
+
raise Web3TypeError(
|
|
111
119
|
"This data is immutable -- create a copy instead of modifying"
|
|
112
120
|
)
|
|
113
121
|
|
|
114
122
|
def __delattr__(self, key: str) -> None:
|
|
115
|
-
raise
|
|
123
|
+
raise Web3TypeError(
|
|
124
|
+
"This data is immutable -- create a copy instead of modifying"
|
|
125
|
+
)
|
|
116
126
|
|
|
117
127
|
def __hash__(self) -> int:
|
|
118
128
|
return hash(tuple(sorted(tupleize_lists_nested(self).items())))
|
|
@@ -143,7 +153,7 @@ def tupleize_lists_nested(d: Mapping[TKey, TValue]) -> AttributeDict[TKey, TValu
|
|
|
143
153
|
elif isinstance(v, Mapping):
|
|
144
154
|
ret[k] = tupleize_lists_nested(v)
|
|
145
155
|
elif not isinstance(v, Hashable):
|
|
146
|
-
raise
|
|
156
|
+
raise Web3TypeError(f"Found unhashable type '{type(v).__name__}': {v}")
|
|
147
157
|
else:
|
|
148
158
|
ret[k] = v
|
|
149
159
|
return AttributeDict(ret)
|
|
@@ -176,9 +186,9 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
176
186
|
|
|
177
187
|
if name in self._queue:
|
|
178
188
|
if name is element:
|
|
179
|
-
raise
|
|
189
|
+
raise Web3ValueError("You can't add the same un-named instance twice")
|
|
180
190
|
else:
|
|
181
|
-
raise
|
|
191
|
+
raise Web3ValueError(
|
|
182
192
|
"You can't add the same name again, use replace instead"
|
|
183
193
|
)
|
|
184
194
|
|
|
@@ -195,7 +205,7 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
195
205
|
to calling :meth:`add` .
|
|
196
206
|
"""
|
|
197
207
|
if not is_integer(layer):
|
|
198
|
-
raise
|
|
208
|
+
raise Web3TypeError("The layer for insertion must be an int.")
|
|
199
209
|
elif layer != 0 and layer != len(self._queue):
|
|
200
210
|
raise NotImplementedError(
|
|
201
211
|
f"You can only insert to the beginning or end of a {type(self)}, "
|
|
@@ -215,7 +225,7 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
215
225
|
elif layer == len(self._queue):
|
|
216
226
|
return
|
|
217
227
|
else:
|
|
218
|
-
raise
|
|
228
|
+
raise Web3AssertionError(
|
|
219
229
|
"Impossible to reach: earlier validation raises an error"
|
|
220
230
|
)
|
|
221
231
|
|
|
@@ -226,7 +236,7 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
226
236
|
old_name = self._repr_if_not_hashable(old)
|
|
227
237
|
|
|
228
238
|
if old_name not in self._queue:
|
|
229
|
-
raise
|
|
239
|
+
raise Web3ValueError(
|
|
230
240
|
"You can't replace unless one already exists, use add instead"
|
|
231
241
|
)
|
|
232
242
|
|
|
@@ -248,7 +258,7 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
248
258
|
def remove(self, old: TKey) -> None:
|
|
249
259
|
old_name = self._repr_if_not_hashable(old)
|
|
250
260
|
if old_name not in self._queue:
|
|
251
|
-
raise
|
|
261
|
+
raise Web3ValueError("You can only remove something that has been added")
|
|
252
262
|
del self._queue[old_name]
|
|
253
263
|
|
|
254
264
|
@property
|
|
@@ -310,7 +320,7 @@ class NamedElementOnion(Mapping[TKey, TValue]):
|
|
|
310
320
|
|
|
311
321
|
def as_tuple_of_middleware(self) -> Tuple[TValue, ...]:
|
|
312
322
|
"""
|
|
313
|
-
|
|
323
|
+
Helps with type hinting since we return `Iterator[TKey]` type, though it's
|
|
314
324
|
actually a `Iterator[TValue]` type, for the `__iter__()` method. This is in
|
|
315
325
|
order to satisfy the `Mapping` interface.
|
|
316
326
|
"""
|
web3/eth/async_eth.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import (
|
|
|
4
4
|
Any,
|
|
5
5
|
Awaitable,
|
|
6
6
|
Callable,
|
|
7
|
+
Dict,
|
|
7
8
|
List,
|
|
8
9
|
Optional,
|
|
9
10
|
Tuple,
|
|
@@ -62,6 +63,7 @@ from web3.exceptions import (
|
|
|
62
63
|
TooManyRequests,
|
|
63
64
|
TransactionIndexingInProgress,
|
|
64
65
|
TransactionNotFound,
|
|
66
|
+
Web3ValueError,
|
|
65
67
|
)
|
|
66
68
|
from web3.method import (
|
|
67
69
|
Method,
|
|
@@ -75,6 +77,7 @@ from web3.types import (
|
|
|
75
77
|
BlockData,
|
|
76
78
|
BlockIdentifier,
|
|
77
79
|
BlockParams,
|
|
80
|
+
BlockReceipts,
|
|
78
81
|
CreateAccessListResponse,
|
|
79
82
|
FeeHistory,
|
|
80
83
|
FilterParams,
|
|
@@ -105,9 +108,9 @@ class AsyncEth(BaseEth):
|
|
|
105
108
|
|
|
106
109
|
is_async = True
|
|
107
110
|
|
|
108
|
-
_default_contract_factory: Type[
|
|
109
|
-
AsyncContract
|
|
110
|
-
|
|
111
|
+
_default_contract_factory: Type[
|
|
112
|
+
Union[AsyncContract, AsyncContractCaller]
|
|
113
|
+
] = AsyncContract
|
|
111
114
|
|
|
112
115
|
# eth_accounts
|
|
113
116
|
|
|
@@ -194,7 +197,8 @@ class AsyncEth(BaseEth):
|
|
|
194
197
|
except (ValueError, MethodUnavailable):
|
|
195
198
|
warnings.warn(
|
|
196
199
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
197
|
-
"Calculating using eth_feeHistory."
|
|
200
|
+
"Calculating using eth_feeHistory.",
|
|
201
|
+
stacklevel=2,
|
|
198
202
|
)
|
|
199
203
|
return await async_fee_history_priority_fee(self)
|
|
200
204
|
|
|
@@ -281,7 +285,7 @@ class AsyncEth(BaseEth):
|
|
|
281
285
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
282
286
|
|
|
283
287
|
if not max_redirects or max_redirects < 4:
|
|
284
|
-
raise
|
|
288
|
+
raise Web3ValueError(
|
|
285
289
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
286
290
|
)
|
|
287
291
|
|
|
@@ -389,15 +393,15 @@ class AsyncEth(BaseEth):
|
|
|
389
393
|
# eth_getBlockTransactionCountByHash
|
|
390
394
|
# eth_getBlockTransactionCountByNumber
|
|
391
395
|
|
|
392
|
-
get_block_transaction_count: Method[
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
get_block_transaction_count: Method[
|
|
397
|
+
Callable[[BlockIdentifier], Awaitable[int]]
|
|
398
|
+
] = Method(
|
|
399
|
+
method_choice_depends_on_args=select_method_for_block_identifier(
|
|
400
|
+
if_predefined=RPC.eth_getBlockTransactionCountByNumber,
|
|
401
|
+
if_hash=RPC.eth_getBlockTransactionCountByHash,
|
|
402
|
+
if_number=RPC.eth_getBlockTransactionCountByNumber,
|
|
403
|
+
),
|
|
404
|
+
mungers=[default_root_munger],
|
|
401
405
|
)
|
|
402
406
|
|
|
403
407
|
# eth_sendTransaction
|
|
@@ -424,15 +428,15 @@ class AsyncEth(BaseEth):
|
|
|
424
428
|
# eth_getBlockByHash
|
|
425
429
|
# eth_getBlockByNumber
|
|
426
430
|
|
|
427
|
-
_get_block: Method[
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
_get_block: Method[
|
|
432
|
+
Callable[[BlockIdentifier, bool], Awaitable[BlockData]]
|
|
433
|
+
] = Method(
|
|
434
|
+
method_choice_depends_on_args=select_method_for_block_identifier(
|
|
435
|
+
if_predefined=RPC.eth_getBlockByNumber,
|
|
436
|
+
if_hash=RPC.eth_getBlockByHash,
|
|
437
|
+
if_number=RPC.eth_getBlockByNumber,
|
|
438
|
+
),
|
|
439
|
+
mungers=[BaseEth.get_block_munger],
|
|
436
440
|
)
|
|
437
441
|
|
|
438
442
|
async def get_block(
|
|
@@ -440,6 +444,20 @@ class AsyncEth(BaseEth):
|
|
|
440
444
|
) -> BlockData:
|
|
441
445
|
return await self._get_block(block_identifier, full_transactions)
|
|
442
446
|
|
|
447
|
+
# eth_getBlockReceipts
|
|
448
|
+
|
|
449
|
+
_get_block_receipts: Method[
|
|
450
|
+
Callable[[BlockIdentifier], Awaitable[BlockReceipts]]
|
|
451
|
+
] = Method(
|
|
452
|
+
RPC.eth_getBlockReceipts,
|
|
453
|
+
mungers=[default_root_munger],
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
async def get_block_receipts(
|
|
457
|
+
self, block_identifier: BlockIdentifier
|
|
458
|
+
) -> BlockReceipts:
|
|
459
|
+
return await self._get_block_receipts(block_identifier)
|
|
460
|
+
|
|
443
461
|
# eth_getBalance
|
|
444
462
|
|
|
445
463
|
_get_balance: Method[
|
|
@@ -622,14 +640,16 @@ class AsyncEth(BaseEth):
|
|
|
622
640
|
# eth_signTypedData
|
|
623
641
|
|
|
624
642
|
_sign_typed_data: Method[
|
|
625
|
-
Callable[
|
|
643
|
+
Callable[
|
|
644
|
+
[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], Awaitable[HexStr]
|
|
645
|
+
]
|
|
626
646
|
] = Method(
|
|
627
647
|
RPC.eth_signTypedData,
|
|
628
648
|
mungers=[default_root_munger],
|
|
629
649
|
)
|
|
630
650
|
|
|
631
651
|
async def sign_typed_data(
|
|
632
|
-
self, account: Union[Address, ChecksumAddress, ENS], data: str
|
|
652
|
+
self, account: Union[Address, ChecksumAddress, ENS], data: Dict[str, Any]
|
|
633
653
|
) -> HexStr:
|
|
634
654
|
return await self._sign_typed_data(account, data)
|
|
635
655
|
|
|
@@ -663,9 +683,9 @@ class AsyncEth(BaseEth):
|
|
|
663
683
|
|
|
664
684
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
665
685
|
|
|
666
|
-
_get_filter_changes: Method[
|
|
667
|
-
|
|
668
|
-
)
|
|
686
|
+
_get_filter_changes: Method[
|
|
687
|
+
Callable[[HexStr], Awaitable[List[LogReceipt]]]
|
|
688
|
+
] = Method(RPC.eth_getFilterChanges, mungers=[default_root_munger])
|
|
669
689
|
|
|
670
690
|
async def get_filter_changes(self, filter_id: HexStr) -> List[LogReceipt]:
|
|
671
691
|
return await self._get_filter_changes(filter_id)
|
|
@@ -743,12 +763,15 @@ class AsyncEth(BaseEth):
|
|
|
743
763
|
# -- contract methods -- #
|
|
744
764
|
|
|
745
765
|
@overload
|
|
746
|
-
|
|
766
|
+
# mypy error: Overloaded function signatures 1 and 2 overlap with incompatible return types # noqa: E501
|
|
767
|
+
def contract(self, address: None = None, **kwargs: Any) -> Type[AsyncContract]: # type: ignore[misc] # noqa: E501
|
|
768
|
+
...
|
|
747
769
|
|
|
748
770
|
@overload
|
|
749
771
|
def contract(
|
|
750
772
|
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
|
|
751
|
-
) -> AsyncContract:
|
|
773
|
+
) -> AsyncContract:
|
|
774
|
+
...
|
|
752
775
|
|
|
753
776
|
def contract(
|
|
754
777
|
self,
|
web3/eth/base_eth.py
CHANGED
|
@@ -30,6 +30,10 @@ from web3._utils.empty import (
|
|
|
30
30
|
from web3._utils.encoding import (
|
|
31
31
|
to_hex,
|
|
32
32
|
)
|
|
33
|
+
from web3.exceptions import (
|
|
34
|
+
Web3TypeError,
|
|
35
|
+
Web3ValueError,
|
|
36
|
+
)
|
|
33
37
|
from web3.module import (
|
|
34
38
|
Module,
|
|
35
39
|
)
|
|
@@ -194,7 +198,7 @@ class BaseEth(Module):
|
|
|
194
198
|
filter_id: Optional[HexStr] = None,
|
|
195
199
|
) -> Union[List[FilterParams], List[HexStr], List[str]]:
|
|
196
200
|
if filter_id and filter_params:
|
|
197
|
-
raise
|
|
201
|
+
raise Web3TypeError(
|
|
198
202
|
"Ambiguous invocation: provide either a `filter_params` or a "
|
|
199
203
|
"`filter_id` argument. Both were supplied."
|
|
200
204
|
)
|
|
@@ -204,14 +208,14 @@ class BaseEth(Module):
|
|
|
204
208
|
if filter_params in {"latest", "pending"}:
|
|
205
209
|
return [filter_params]
|
|
206
210
|
else:
|
|
207
|
-
raise
|
|
211
|
+
raise Web3ValueError(
|
|
208
212
|
"The filter API only accepts the values of `pending` or "
|
|
209
213
|
"`latest` for string based filters"
|
|
210
214
|
)
|
|
211
215
|
elif filter_id and not filter_params:
|
|
212
216
|
return [filter_id]
|
|
213
217
|
else:
|
|
214
|
-
raise
|
|
218
|
+
raise Web3TypeError(
|
|
215
219
|
"Must provide either filter_params as a string or "
|
|
216
220
|
"a valid filter object, or a filter_id as a string "
|
|
217
221
|
"or hex."
|
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,
|
|
@@ -62,6 +63,7 @@ from web3.exceptions import (
|
|
|
62
63
|
TooManyRequests,
|
|
63
64
|
TransactionIndexingInProgress,
|
|
64
65
|
TransactionNotFound,
|
|
66
|
+
Web3ValueError,
|
|
65
67
|
)
|
|
66
68
|
from web3.method import (
|
|
67
69
|
Method,
|
|
@@ -72,6 +74,7 @@ from web3.types import (
|
|
|
72
74
|
BlockData,
|
|
73
75
|
BlockIdentifier,
|
|
74
76
|
BlockParams,
|
|
77
|
+
BlockReceipts,
|
|
75
78
|
CreateAccessListResponse,
|
|
76
79
|
FeeHistory,
|
|
77
80
|
FilterParams,
|
|
@@ -187,7 +190,8 @@ class Eth(BaseEth):
|
|
|
187
190
|
except (ValueError, MethodUnavailable):
|
|
188
191
|
warnings.warn(
|
|
189
192
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
190
|
-
"Calculating using eth_feeHistory."
|
|
193
|
+
"Calculating using eth_feeHistory.",
|
|
194
|
+
stacklevel=2,
|
|
191
195
|
)
|
|
192
196
|
return fee_history_priority_fee(self)
|
|
193
197
|
|
|
@@ -269,7 +273,7 @@ class Eth(BaseEth):
|
|
|
269
273
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
270
274
|
|
|
271
275
|
if not max_redirects or max_redirects < 4:
|
|
272
|
-
raise
|
|
276
|
+
raise Web3ValueError(
|
|
273
277
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
274
278
|
)
|
|
275
279
|
|
|
@@ -411,6 +415,16 @@ class Eth(BaseEth):
|
|
|
411
415
|
) -> BlockData:
|
|
412
416
|
return self._get_block(block_identifier, full_transactions)
|
|
413
417
|
|
|
418
|
+
# eth_getBlockReceipts
|
|
419
|
+
|
|
420
|
+
_get_block_receipts: Method[Callable[[BlockIdentifier], BlockReceipts]] = Method(
|
|
421
|
+
RPC.eth_getBlockReceipts,
|
|
422
|
+
mungers=[default_root_munger],
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
def get_block_receipts(self, block_identifier: BlockIdentifier) -> BlockReceipts:
|
|
426
|
+
return self._get_block_receipts(block_identifier)
|
|
427
|
+
|
|
414
428
|
# eth_getBalance
|
|
415
429
|
|
|
416
430
|
_get_balance: Method[
|
|
@@ -611,7 +625,7 @@ class Eth(BaseEth):
|
|
|
611
625
|
# eth_signTypedData
|
|
612
626
|
|
|
613
627
|
sign_typed_data: Method[
|
|
614
|
-
Callable[[Union[Address, ChecksumAddress, ENS], str], HexStr]
|
|
628
|
+
Callable[[Union[Address, ChecksumAddress, ENS], Dict[str, Any]], HexStr]
|
|
615
629
|
] = Method(
|
|
616
630
|
RPC.eth_signTypedData,
|
|
617
631
|
mungers=[default_root_munger],
|
|
@@ -619,15 +633,15 @@ class Eth(BaseEth):
|
|
|
619
633
|
|
|
620
634
|
# eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
|
|
621
635
|
|
|
622
|
-
filter: Method[
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
636
|
+
filter: Method[
|
|
637
|
+
Callable[[Optional[Union[str, FilterParams, HexStr]]], Filter]
|
|
638
|
+
] = Method(
|
|
639
|
+
method_choice_depends_on_args=select_filter_method(
|
|
640
|
+
if_new_block_filter=RPC.eth_newBlockFilter,
|
|
641
|
+
if_new_pending_transaction_filter=RPC.eth_newPendingTransactionFilter,
|
|
642
|
+
if_new_filter=RPC.eth_newFilter,
|
|
643
|
+
),
|
|
644
|
+
mungers=[BaseEth.filter_munger],
|
|
631
645
|
)
|
|
632
646
|
|
|
633
647
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
@@ -665,12 +679,15 @@ class Eth(BaseEth):
|
|
|
665
679
|
)
|
|
666
680
|
|
|
667
681
|
@overload
|
|
668
|
-
|
|
682
|
+
# type error: Overloaded function signatures 1 and 2 overlap with incompatible return types # noqa: E501
|
|
683
|
+
def contract(self, address: None = None, **kwargs: Any) -> Type[Contract]: # type: ignore[misc] # noqa: E501
|
|
684
|
+
...
|
|
669
685
|
|
|
670
686
|
@overload
|
|
671
687
|
def contract(
|
|
672
688
|
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
|
|
673
|
-
) -> Contract:
|
|
689
|
+
) -> Contract:
|
|
690
|
+
...
|
|
674
691
|
|
|
675
692
|
def contract(
|
|
676
693
|
self,
|