web3 7.0.0b3__py3-none-any.whl → 7.0.0b5__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 +12 -9
- ens/contract_data.py +2 -2
- ens/ens.py +8 -5
- ens/exceptions.py +19 -27
- ens/specs/nf.json +1 -1
- ens/specs/normalization_spec.json +1 -1
- ens/utils.py +17 -10
- 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 +17 -17
- 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 +38 -36
- web3/_utils/fee_utils.py +2 -4
- web3/_utils/filters.py +23 -18
- web3/_utils/formatters.py +2 -2
- web3/_utils/math.py +3 -2
- web3/_utils/method_formatters.py +24 -28
- web3/_utils/module.py +2 -1
- web3/_utils/module_testing/__init__.py +0 -3
- web3/_utils/module_testing/eth_module.py +494 -432
- 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 +5 -19
- web3/_utils/threads.py +8 -7
- web3/_utils/transactions.py +14 -12
- web3/_utils/type_conversion.py +5 -1
- web3/_utils/validation.py +12 -10
- web3/contract/async_contract.py +23 -18
- web3/contract/base_contract.py +69 -74
- web3/contract/contract.py +25 -19
- web3/contract/utils.py +11 -6
- web3/datastructures.py +22 -12
- web3/eth/async_eth.py +38 -32
- web3/eth/base_eth.py +7 -3
- web3/eth/eth.py +20 -15
- web3/exceptions.py +83 -78
- web3/gas_strategies/time_based.py +2 -4
- web3/geth.py +1 -191
- web3/main.py +6 -6
- web3/manager.py +128 -68
- web3/method.py +13 -5
- web3/middleware/base.py +4 -2
- web3/middleware/filter.py +45 -23
- web3/middleware/formatting.py +6 -3
- web3/middleware/names.py +4 -1
- web3/middleware/signing.py +8 -4
- web3/middleware/stalecheck.py +2 -1
- web3/providers/eth_tester/defaults.py +1 -49
- web3/providers/eth_tester/main.py +41 -15
- web3/providers/eth_tester/middleware.py +13 -9
- web3/providers/ipc.py +7 -3
- web3/providers/persistent/async_ipc.py +6 -7
- web3/providers/persistent/persistent.py +11 -1
- web3/providers/persistent/request_processor.py +7 -7
- web3/providers/persistent/websocket.py +3 -3
- web3/providers/rpc/async_rpc.py +24 -7
- web3/providers/rpc/rpc.py +30 -17
- web3/providers/rpc/utils.py +1 -10
- web3/testing.py +4 -4
- web3/tools/benchmark/main.py +13 -9
- web3/tools/benchmark/node.py +2 -8
- web3/tools/benchmark/utils.py +1 -1
- web3/tracing.py +9 -5
- web3/types.py +20 -23
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/METADATA +13 -28
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/RECORD +81 -82
- web3/_utils/module_testing/go_ethereum_personal_module.py +0 -300
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/LICENSE +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/WHEEL +0 -0
- {web3-7.0.0b3.dist-info → web3-7.0.0b5.dist-info}/top_level.txt +0 -0
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
|
@@ -57,12 +57,14 @@ from web3.eth.base_eth import (
|
|
|
57
57
|
BaseEth,
|
|
58
58
|
)
|
|
59
59
|
from web3.exceptions import (
|
|
60
|
-
|
|
60
|
+
MethodNotSupported,
|
|
61
61
|
OffchainLookup,
|
|
62
62
|
TimeExhausted,
|
|
63
63
|
TooManyRequests,
|
|
64
64
|
TransactionIndexingInProgress,
|
|
65
65
|
TransactionNotFound,
|
|
66
|
+
Web3RPCError,
|
|
67
|
+
Web3ValueError,
|
|
66
68
|
)
|
|
67
69
|
from web3.method import (
|
|
68
70
|
Method,
|
|
@@ -107,9 +109,9 @@ class AsyncEth(BaseEth):
|
|
|
107
109
|
|
|
108
110
|
is_async = True
|
|
109
111
|
|
|
110
|
-
_default_contract_factory: Type[
|
|
111
|
-
AsyncContract
|
|
112
|
-
|
|
112
|
+
_default_contract_factory: Type[
|
|
113
|
+
Union[AsyncContract, AsyncContractCaller]
|
|
114
|
+
] = AsyncContract
|
|
113
115
|
|
|
114
116
|
# eth_accounts
|
|
115
117
|
|
|
@@ -193,10 +195,11 @@ class AsyncEth(BaseEth):
|
|
|
193
195
|
"""
|
|
194
196
|
try:
|
|
195
197
|
return await self._max_priority_fee()
|
|
196
|
-
except
|
|
198
|
+
except Web3RPCError:
|
|
197
199
|
warnings.warn(
|
|
198
200
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
199
|
-
"Calculating using eth_feeHistory."
|
|
201
|
+
"Calculating using eth_feeHistory.",
|
|
202
|
+
stacklevel=2,
|
|
200
203
|
)
|
|
201
204
|
return await async_fee_history_priority_fee(self)
|
|
202
205
|
|
|
@@ -283,7 +286,7 @@ class AsyncEth(BaseEth):
|
|
|
283
286
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
284
287
|
|
|
285
288
|
if not max_redirects or max_redirects < 4:
|
|
286
|
-
raise
|
|
289
|
+
raise Web3ValueError(
|
|
287
290
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
288
291
|
)
|
|
289
292
|
|
|
@@ -391,15 +394,15 @@ class AsyncEth(BaseEth):
|
|
|
391
394
|
# eth_getBlockTransactionCountByHash
|
|
392
395
|
# eth_getBlockTransactionCountByNumber
|
|
393
396
|
|
|
394
|
-
get_block_transaction_count: Method[
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
397
|
+
get_block_transaction_count: Method[
|
|
398
|
+
Callable[[BlockIdentifier], Awaitable[int]]
|
|
399
|
+
] = Method(
|
|
400
|
+
method_choice_depends_on_args=select_method_for_block_identifier(
|
|
401
|
+
if_predefined=RPC.eth_getBlockTransactionCountByNumber,
|
|
402
|
+
if_hash=RPC.eth_getBlockTransactionCountByHash,
|
|
403
|
+
if_number=RPC.eth_getBlockTransactionCountByNumber,
|
|
404
|
+
),
|
|
405
|
+
mungers=[default_root_munger],
|
|
403
406
|
)
|
|
404
407
|
|
|
405
408
|
# eth_sendTransaction
|
|
@@ -426,15 +429,15 @@ class AsyncEth(BaseEth):
|
|
|
426
429
|
# eth_getBlockByHash
|
|
427
430
|
# eth_getBlockByNumber
|
|
428
431
|
|
|
429
|
-
_get_block: Method[
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
432
|
+
_get_block: Method[
|
|
433
|
+
Callable[[BlockIdentifier, bool], Awaitable[BlockData]]
|
|
434
|
+
] = Method(
|
|
435
|
+
method_choice_depends_on_args=select_method_for_block_identifier(
|
|
436
|
+
if_predefined=RPC.eth_getBlockByNumber,
|
|
437
|
+
if_hash=RPC.eth_getBlockByHash,
|
|
438
|
+
if_number=RPC.eth_getBlockByNumber,
|
|
439
|
+
),
|
|
440
|
+
mungers=[BaseEth.get_block_munger],
|
|
438
441
|
)
|
|
439
442
|
|
|
440
443
|
async def get_block(
|
|
@@ -681,9 +684,9 @@ class AsyncEth(BaseEth):
|
|
|
681
684
|
|
|
682
685
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
683
686
|
|
|
684
|
-
_get_filter_changes: Method[
|
|
685
|
-
|
|
686
|
-
)
|
|
687
|
+
_get_filter_changes: Method[
|
|
688
|
+
Callable[[HexStr], Awaitable[List[LogReceipt]]]
|
|
689
|
+
] = Method(RPC.eth_getFilterChanges, mungers=[default_root_munger])
|
|
687
690
|
|
|
688
691
|
async def get_filter_changes(self, filter_id: HexStr) -> List[LogReceipt]:
|
|
689
692
|
return await self._get_filter_changes(filter_id)
|
|
@@ -734,7 +737,7 @@ class AsyncEth(BaseEth):
|
|
|
734
737
|
] = None,
|
|
735
738
|
) -> HexStr:
|
|
736
739
|
if not isinstance(self.w3.provider, PersistentConnectionProvider):
|
|
737
|
-
raise
|
|
740
|
+
raise MethodNotSupported(
|
|
738
741
|
"eth_subscribe is only supported with providers that support "
|
|
739
742
|
"persistent connections."
|
|
740
743
|
)
|
|
@@ -751,7 +754,7 @@ class AsyncEth(BaseEth):
|
|
|
751
754
|
|
|
752
755
|
async def unsubscribe(self, subscription_id: HexStr) -> bool:
|
|
753
756
|
if not isinstance(self.w3.provider, PersistentConnectionProvider):
|
|
754
|
-
raise
|
|
757
|
+
raise MethodNotSupported(
|
|
755
758
|
"eth_unsubscribe is only supported with providers that support "
|
|
756
759
|
"persistent connections."
|
|
757
760
|
)
|
|
@@ -761,12 +764,15 @@ class AsyncEth(BaseEth):
|
|
|
761
764
|
# -- contract methods -- #
|
|
762
765
|
|
|
763
766
|
@overload
|
|
764
|
-
|
|
767
|
+
# mypy error: Overloaded function signatures 1 and 2 overlap with incompatible return types # noqa: E501
|
|
768
|
+
def contract(self, address: None = None, **kwargs: Any) -> Type[AsyncContract]: # type: ignore[misc] # noqa: E501
|
|
769
|
+
...
|
|
765
770
|
|
|
766
771
|
@overload
|
|
767
772
|
def contract(
|
|
768
773
|
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
|
|
769
|
-
) -> AsyncContract:
|
|
774
|
+
) -> AsyncContract:
|
|
775
|
+
...
|
|
770
776
|
|
|
771
777
|
def contract(
|
|
772
778
|
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
|
@@ -57,12 +57,13 @@ from web3.eth.base_eth import (
|
|
|
57
57
|
BaseEth,
|
|
58
58
|
)
|
|
59
59
|
from web3.exceptions import (
|
|
60
|
-
MethodUnavailable,
|
|
61
60
|
OffchainLookup,
|
|
62
61
|
TimeExhausted,
|
|
63
62
|
TooManyRequests,
|
|
64
63
|
TransactionIndexingInProgress,
|
|
65
64
|
TransactionNotFound,
|
|
65
|
+
Web3RPCError,
|
|
66
|
+
Web3ValueError,
|
|
66
67
|
)
|
|
67
68
|
from web3.method import (
|
|
68
69
|
Method,
|
|
@@ -186,10 +187,11 @@ class Eth(BaseEth):
|
|
|
186
187
|
"""
|
|
187
188
|
try:
|
|
188
189
|
return self._max_priority_fee()
|
|
189
|
-
except
|
|
190
|
+
except Web3RPCError:
|
|
190
191
|
warnings.warn(
|
|
191
192
|
"There was an issue with the method eth_maxPriorityFeePerGas. "
|
|
192
|
-
"Calculating using eth_feeHistory."
|
|
193
|
+
"Calculating using eth_feeHistory.",
|
|
194
|
+
stacklevel=2,
|
|
193
195
|
)
|
|
194
196
|
return fee_history_priority_fee(self)
|
|
195
197
|
|
|
@@ -271,7 +273,7 @@ class Eth(BaseEth):
|
|
|
271
273
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
272
274
|
|
|
273
275
|
if not max_redirects or max_redirects < 4:
|
|
274
|
-
raise
|
|
276
|
+
raise Web3ValueError(
|
|
275
277
|
"ccip_read_max_redirects property on provider must be at least 4."
|
|
276
278
|
)
|
|
277
279
|
|
|
@@ -631,15 +633,15 @@ class Eth(BaseEth):
|
|
|
631
633
|
|
|
632
634
|
# eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
|
|
633
635
|
|
|
634
|
-
filter: Method[
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
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],
|
|
643
645
|
)
|
|
644
646
|
|
|
645
647
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
@@ -677,12 +679,15 @@ class Eth(BaseEth):
|
|
|
677
679
|
)
|
|
678
680
|
|
|
679
681
|
@overload
|
|
680
|
-
|
|
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
|
+
...
|
|
681
685
|
|
|
682
686
|
@overload
|
|
683
687
|
def contract(
|
|
684
688
|
self, address: Union[Address, ChecksumAddress, ENS], **kwargs: Any
|
|
685
|
-
) -> Contract:
|
|
689
|
+
) -> Contract:
|
|
690
|
+
...
|
|
686
691
|
|
|
687
692
|
def contract(
|
|
688
693
|
self,
|