web3 7.13.0__py3-none-any.whl → 7.14.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/async_ens.py +9 -5
- ens/base_ens.py +1 -1
- ens/utils.py +2 -1
- web3/_utils/abi.py +5 -5
- web3/_utils/async_transactions.py +12 -9
- web3/_utils/batching.py +1 -1
- web3/_utils/caching/caching_utils.py +2 -2
- web3/_utils/contracts.py +5 -5
- web3/_utils/ens.py +1 -1
- web3/_utils/events.py +1 -1
- web3/_utils/module_testing/eth_module.py +133 -125
- web3/_utils/module_testing/go_ethereum_admin_module.py +7 -6
- web3/_utils/module_testing/go_ethereum_debug_module.py +5 -4
- web3/_utils/module_testing/go_ethereum_txpool_module.py +6 -3
- web3/_utils/module_testing/module_testing_utils.py +1 -1
- web3/_utils/module_testing/net_module.py +4 -3
- web3/_utils/module_testing/persistent_connection_provider.py +132 -20
- web3/_utils/module_testing/utils.py +7 -6
- web3/_utils/module_testing/web3_module.py +15 -11
- web3/_utils/normalizers.py +3 -3
- web3/_utils/transactions.py +2 -1
- web3/contract/async_contract.py +13 -13
- web3/contract/base_contract.py +11 -12
- web3/contract/utils.py +7 -7
- web3/eth/async_eth.py +1 -1
- web3/gas_strategies/time_based.py +1 -1
- web3/main.py +24 -11
- web3/manager.py +9 -8
- web3/middleware/__init__.py +1 -1
- web3/middleware/base.py +5 -5
- web3/middleware/buffered_gas_estimate.py +1 -1
- web3/middleware/filter.py +10 -9
- web3/middleware/formatting.py +4 -4
- web3/middleware/gas_price_strategy.py +1 -1
- web3/middleware/names.py +4 -4
- web3/middleware/signing.py +3 -3
- web3/middleware/stalecheck.py +2 -2
- web3/middleware/validation.py +2 -2
- web3/module.py +3 -3
- web3/providers/async_base.py +2 -2
- web3/providers/base.py +2 -2
- web3/providers/eth_tester/defaults.py +2 -2
- web3/providers/eth_tester/main.py +1 -1
- web3/providers/eth_tester/middleware.py +2 -2
- web3/providers/persistent/persistent.py +4 -4
- web3/providers/persistent/persistent_connection.py +1 -1
- web3/providers/persistent/subscription_manager.py +1 -1
- web3/providers/persistent/utils.py +1 -1
- web3/types.py +16 -3
- web3/utils/subscriptions.py +3 -2
- {web3-7.13.0.dist-info → web3-7.14.0.dist-info}/METADATA +1 -1
- {web3-7.13.0.dist-info → web3-7.14.0.dist-info}/RECORD +55 -55
- {web3-7.13.0.dist-info → web3-7.14.0.dist-info}/WHEEL +0 -0
- {web3-7.13.0.dist-info → web3-7.14.0.dist-info}/licenses/LICENSE +0 -0
- {web3-7.13.0.dist-info → web3-7.14.0.dist-info}/top_level.txt +0 -0
web3/contract/async_contract.py
CHANGED
|
@@ -103,7 +103,7 @@ if TYPE_CHECKING:
|
|
|
103
103
|
|
|
104
104
|
class AsyncContractEvent(BaseContractEvent):
|
|
105
105
|
# mypy types
|
|
106
|
-
w3: "AsyncWeb3"
|
|
106
|
+
w3: "AsyncWeb3[Any]"
|
|
107
107
|
|
|
108
108
|
@combomethod
|
|
109
109
|
async def get_logs(
|
|
@@ -238,14 +238,14 @@ class AsyncContractEvent(BaseContractEvent):
|
|
|
238
238
|
|
|
239
239
|
class AsyncContractEvents(BaseContractEvents[AsyncContractEvent]):
|
|
240
240
|
def __init__(
|
|
241
|
-
self, abi: ABI, w3: "AsyncWeb3", address: Optional[ChecksumAddress] = None
|
|
241
|
+
self, abi: ABI, w3: "AsyncWeb3[Any]", address: Optional[ChecksumAddress] = None
|
|
242
242
|
) -> None:
|
|
243
243
|
super().__init__(abi, w3, AsyncContractEvent, address)
|
|
244
244
|
|
|
245
245
|
|
|
246
246
|
class AsyncContractFunction(BaseContractFunction):
|
|
247
247
|
# mypy types
|
|
248
|
-
w3: "AsyncWeb3"
|
|
248
|
+
w3: "AsyncWeb3[Any]"
|
|
249
249
|
|
|
250
250
|
async def call(
|
|
251
251
|
self,
|
|
@@ -357,7 +357,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
357
357
|
@staticmethod
|
|
358
358
|
def get_fallback_function(
|
|
359
359
|
abi: ABI,
|
|
360
|
-
async_w3: "AsyncWeb3",
|
|
360
|
+
async_w3: "AsyncWeb3[Any]",
|
|
361
361
|
address: Optional[ChecksumAddress] = None,
|
|
362
362
|
) -> "AsyncContractFunction":
|
|
363
363
|
if abi and fallback_func_abi_exists(abi):
|
|
@@ -373,7 +373,7 @@ class AsyncContractFunction(BaseContractFunction):
|
|
|
373
373
|
@staticmethod
|
|
374
374
|
def get_receive_function(
|
|
375
375
|
abi: ABI,
|
|
376
|
-
async_w3: "AsyncWeb3",
|
|
376
|
+
async_w3: "AsyncWeb3[Any]",
|
|
377
377
|
address: Optional[ChecksumAddress] = None,
|
|
378
378
|
) -> "AsyncContractFunction":
|
|
379
379
|
if abi and receive_func_abi_exists(abi):
|
|
@@ -391,7 +391,7 @@ class AsyncContractFunctions(BaseContractFunctions[AsyncContractFunction]):
|
|
|
391
391
|
def __init__(
|
|
392
392
|
self,
|
|
393
393
|
abi: ABI,
|
|
394
|
-
w3: "AsyncWeb3",
|
|
394
|
+
w3: "AsyncWeb3[Any]",
|
|
395
395
|
address: Optional[ChecksumAddress] = None,
|
|
396
396
|
decode_tuples: Optional[bool] = False,
|
|
397
397
|
) -> None:
|
|
@@ -403,7 +403,7 @@ class AsyncContract(BaseContract):
|
|
|
403
403
|
caller: "AsyncContractCaller" = None
|
|
404
404
|
|
|
405
405
|
# mypy types
|
|
406
|
-
w3: "AsyncWeb3"
|
|
406
|
+
w3: "AsyncWeb3[Any]"
|
|
407
407
|
|
|
408
408
|
#: Instance of :class:`ContractEvents` presenting available Event ABIs
|
|
409
409
|
events: AsyncContractEvents = None
|
|
@@ -447,7 +447,7 @@ class AsyncContract(BaseContract):
|
|
|
447
447
|
|
|
448
448
|
@classmethod
|
|
449
449
|
def factory(
|
|
450
|
-
cls, w3: "AsyncWeb3", class_name: Optional[str] = None, **kwargs: Any
|
|
450
|
+
cls, w3: "AsyncWeb3[Any]", class_name: Optional[str] = None, **kwargs: Any
|
|
451
451
|
) -> Type[Self]:
|
|
452
452
|
kwargs["w3"] = w3
|
|
453
453
|
|
|
@@ -519,7 +519,7 @@ class AsyncContract(BaseContract):
|
|
|
519
519
|
def find_functions_by_identifier(
|
|
520
520
|
cls,
|
|
521
521
|
contract_abi: ABI,
|
|
522
|
-
w3: "AsyncWeb3",
|
|
522
|
+
w3: "AsyncWeb3[Any]",
|
|
523
523
|
address: ChecksumAddress,
|
|
524
524
|
callable_check: Callable[..., Any],
|
|
525
525
|
) -> List["AsyncContractFunction"]:
|
|
@@ -540,7 +540,7 @@ class AsyncContract(BaseContract):
|
|
|
540
540
|
def find_events_by_identifier(
|
|
541
541
|
cls,
|
|
542
542
|
contract_abi: ABI,
|
|
543
|
-
w3: "AsyncWeb3",
|
|
543
|
+
w3: "AsyncWeb3[Any]",
|
|
544
544
|
address: ChecksumAddress,
|
|
545
545
|
callable_check: Callable[..., Any],
|
|
546
546
|
) -> List["AsyncContractEvent"]:
|
|
@@ -557,12 +557,12 @@ class AsyncContract(BaseContract):
|
|
|
557
557
|
|
|
558
558
|
class AsyncContractCaller(BaseContractCaller):
|
|
559
559
|
# mypy types
|
|
560
|
-
w3: "AsyncWeb3"
|
|
560
|
+
w3: "AsyncWeb3[Any]"
|
|
561
561
|
|
|
562
562
|
def __init__(
|
|
563
563
|
self,
|
|
564
564
|
abi: ABI,
|
|
565
|
-
w3: "AsyncWeb3",
|
|
565
|
+
w3: "AsyncWeb3[Any]",
|
|
566
566
|
address: ChecksumAddress,
|
|
567
567
|
transaction: Optional[TxParams] = None,
|
|
568
568
|
block_identifier: BlockIdentifier = None,
|
|
@@ -613,7 +613,7 @@ class AsyncContractCaller(BaseContractCaller):
|
|
|
613
613
|
|
|
614
614
|
class AsyncContractConstructor(BaseContractConstructor):
|
|
615
615
|
# mypy types
|
|
616
|
-
w3: "AsyncWeb3"
|
|
616
|
+
w3: "AsyncWeb3[Any]"
|
|
617
617
|
|
|
618
618
|
@combomethod
|
|
619
619
|
async def transact(self, transaction: Optional[TxParams] = None) -> HexBytes:
|
web3/contract/base_contract.py
CHANGED
|
@@ -169,7 +169,7 @@ class BaseContractEvent:
|
|
|
169
169
|
name: str = None
|
|
170
170
|
abi_element_identifier: ABIElementIdentifier = None
|
|
171
171
|
signature: str = None
|
|
172
|
-
w3: Union["Web3", "AsyncWeb3"] = None
|
|
172
|
+
w3: Union["Web3", "AsyncWeb3[Any]"] = None
|
|
173
173
|
contract_abi: ABI = None
|
|
174
174
|
abi: ABIEvent = None
|
|
175
175
|
argument_names: Tuple[str, ...] = tuple()
|
|
@@ -477,7 +477,7 @@ class BaseContractEvents(Generic[TContractEvent]):
|
|
|
477
477
|
def __init__(
|
|
478
478
|
self,
|
|
479
479
|
abi: ABI,
|
|
480
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
480
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
481
481
|
contract_event_type: Type[TContractEvent],
|
|
482
482
|
address: Optional[ChecksumAddress] = None,
|
|
483
483
|
) -> None:
|
|
@@ -569,7 +569,7 @@ class BaseContractFunction:
|
|
|
569
569
|
name: str = None
|
|
570
570
|
signature: str = None
|
|
571
571
|
abi_element_identifier: ABIElementIdentifier = None
|
|
572
|
-
w3: Union["Web3", "AsyncWeb3"] = None
|
|
572
|
+
w3: Union["Web3", "AsyncWeb3[Any]"] = None
|
|
573
573
|
contract_abi: ABI = None
|
|
574
574
|
abi: ABIFunction = None
|
|
575
575
|
transaction: TxParams = None
|
|
@@ -894,7 +894,7 @@ class BaseContractFunctions(Generic[TContractFn]):
|
|
|
894
894
|
def __init__(
|
|
895
895
|
self,
|
|
896
896
|
abi: ABI,
|
|
897
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
897
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
898
898
|
contract_function_class: Type[TContractFn],
|
|
899
899
|
address: Optional[ChecksumAddress] = None,
|
|
900
900
|
decode_tuples: Optional[bool] = False,
|
|
@@ -1000,8 +1000,7 @@ class BaseContract:
|
|
|
1000
1000
|
* Deploy a new smart contract using :py:meth:`Contract.constructor.transact()`
|
|
1001
1001
|
"""
|
|
1002
1002
|
|
|
1003
|
-
|
|
1004
|
-
w3: Union["Web3", "AsyncWeb3"] = None
|
|
1003
|
+
w3: Union["Web3", "AsyncWeb3[Any]"] = None
|
|
1005
1004
|
|
|
1006
1005
|
# instance level properties
|
|
1007
1006
|
address: ChecksumAddress = None
|
|
@@ -1286,7 +1285,7 @@ class BaseContract:
|
|
|
1286
1285
|
def find_functions_by_identifier(
|
|
1287
1286
|
cls,
|
|
1288
1287
|
contract_abi: ABI,
|
|
1289
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1288
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1290
1289
|
address: ChecksumAddress,
|
|
1291
1290
|
callable_check: Callable[..., Any],
|
|
1292
1291
|
) -> List[Any]:
|
|
@@ -1306,7 +1305,7 @@ class BaseContract:
|
|
|
1306
1305
|
def find_events_by_identifier(
|
|
1307
1306
|
cls,
|
|
1308
1307
|
contract_abi: ABI,
|
|
1309
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1308
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1310
1309
|
address: ChecksumAddress,
|
|
1311
1310
|
callable_check: Callable[..., Any],
|
|
1312
1311
|
) -> List[Any]:
|
|
@@ -1325,7 +1324,7 @@ class BaseContract:
|
|
|
1325
1324
|
@staticmethod
|
|
1326
1325
|
def get_fallback_function(
|
|
1327
1326
|
abi: ABI,
|
|
1328
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1327
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1329
1328
|
function_type: Type["BaseContractFunction"],
|
|
1330
1329
|
address: Optional[ChecksumAddress] = None,
|
|
1331
1330
|
) -> "BaseContractFunction":
|
|
@@ -1345,7 +1344,7 @@ class BaseContract:
|
|
|
1345
1344
|
@staticmethod
|
|
1346
1345
|
def get_receive_function(
|
|
1347
1346
|
abi: ABI,
|
|
1348
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1347
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1349
1348
|
function_type: Type["BaseContractFunction"],
|
|
1350
1349
|
address: Optional[ChecksumAddress] = None,
|
|
1351
1350
|
) -> "BaseContractFunction":
|
|
@@ -1469,7 +1468,7 @@ class BaseContractCaller:
|
|
|
1469
1468
|
def __init__(
|
|
1470
1469
|
self,
|
|
1471
1470
|
abi: ABI,
|
|
1472
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1471
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1473
1472
|
address: ChecksumAddress,
|
|
1474
1473
|
decode_tuples: Optional[bool] = False,
|
|
1475
1474
|
) -> None:
|
|
@@ -1542,7 +1541,7 @@ class BaseContractConstructor:
|
|
|
1542
1541
|
|
|
1543
1542
|
def __init__(
|
|
1544
1543
|
self,
|
|
1545
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
1544
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
1546
1545
|
abi: ABI,
|
|
1547
1546
|
bytecode: HexStr,
|
|
1548
1547
|
*args: Any,
|
web3/contract/utils.py
CHANGED
|
@@ -85,7 +85,7 @@ ACCEPTABLE_EMPTY_STRINGS = ["0x", b"0x", "", b""]
|
|
|
85
85
|
|
|
86
86
|
@curry
|
|
87
87
|
def format_contract_call_return_data_curried(
|
|
88
|
-
async_w3: Union["AsyncWeb3", "Web3"],
|
|
88
|
+
async_w3: Union["AsyncWeb3[Any]", "Web3"],
|
|
89
89
|
decode_tuples: bool,
|
|
90
90
|
fn_abi: ABICallable,
|
|
91
91
|
abi_element_identifier: ABIElementIdentifier,
|
|
@@ -332,7 +332,7 @@ def build_transaction_for_function(
|
|
|
332
332
|
|
|
333
333
|
def find_functions_by_identifier(
|
|
334
334
|
contract_abi: ABI,
|
|
335
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
335
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
336
336
|
address: ChecksumAddress,
|
|
337
337
|
callable_check: Callable[..., Any],
|
|
338
338
|
function_type: Type[TContractFn],
|
|
@@ -376,7 +376,7 @@ def get_function_by_identifier(
|
|
|
376
376
|
|
|
377
377
|
def find_events_by_identifier(
|
|
378
378
|
contract_abi: ABI,
|
|
379
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
379
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
380
380
|
address: ChecksumAddress,
|
|
381
381
|
callable_check: Callable[..., Any],
|
|
382
382
|
event_type: Type[TContractEvent],
|
|
@@ -418,7 +418,7 @@ def get_event_by_identifier(
|
|
|
418
418
|
|
|
419
419
|
|
|
420
420
|
async def async_call_contract_function(
|
|
421
|
-
async_w3: "AsyncWeb3",
|
|
421
|
+
async_w3: "AsyncWeb3[Any]",
|
|
422
422
|
address: ChecksumAddress,
|
|
423
423
|
normalizers: Tuple[Callable[..., Any], ...],
|
|
424
424
|
abi_element_identifier: ABIElementIdentifier,
|
|
@@ -534,7 +534,7 @@ async def async_call_contract_function(
|
|
|
534
534
|
|
|
535
535
|
async def async_transact_with_contract_function(
|
|
536
536
|
address: ChecksumAddress,
|
|
537
|
-
async_w3: "AsyncWeb3",
|
|
537
|
+
async_w3: "AsyncWeb3[Any]",
|
|
538
538
|
abi_element_identifier: Optional[ABIElementIdentifier] = None,
|
|
539
539
|
transaction: Optional[TxParams] = None,
|
|
540
540
|
contract_abi: Optional[ABI] = None,
|
|
@@ -563,7 +563,7 @@ async def async_transact_with_contract_function(
|
|
|
563
563
|
|
|
564
564
|
async def async_estimate_gas_for_function(
|
|
565
565
|
address: ChecksumAddress,
|
|
566
|
-
async_w3: "AsyncWeb3",
|
|
566
|
+
async_w3: "AsyncWeb3[Any]",
|
|
567
567
|
abi_element_identifier: Optional[ABIElementIdentifier] = None,
|
|
568
568
|
transaction: Optional[TxParams] = None,
|
|
569
569
|
contract_abi: Optional[ABI] = None,
|
|
@@ -597,7 +597,7 @@ async def async_estimate_gas_for_function(
|
|
|
597
597
|
|
|
598
598
|
async def async_build_transaction_for_function(
|
|
599
599
|
address: ChecksumAddress,
|
|
600
|
-
async_w3: "AsyncWeb3",
|
|
600
|
+
async_w3: "AsyncWeb3[Any]",
|
|
601
601
|
abi_element_identifier: Optional[ABIElementIdentifier] = None,
|
|
602
602
|
transaction: Optional[TxParams] = None,
|
|
603
603
|
contract_abi: Optional[ABI] = None,
|
web3/eth/async_eth.py
CHANGED
|
@@ -104,7 +104,7 @@ def _get_raw_miner_data(
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
def _aggregate_miner_data(
|
|
107
|
-
raw_data: Iterable[Tuple[ChecksumAddress, HexBytes, Wei]]
|
|
107
|
+
raw_data: Iterable[Tuple[ChecksumAddress, HexBytes, Wei]],
|
|
108
108
|
) -> Iterable[MinerData]:
|
|
109
109
|
data_by_miner = groupby(0, raw_data)
|
|
110
110
|
|
web3/main.py
CHANGED
|
@@ -37,10 +37,12 @@ from typing import (
|
|
|
37
37
|
Callable,
|
|
38
38
|
Dict,
|
|
39
39
|
Generator,
|
|
40
|
+
Generic,
|
|
40
41
|
List,
|
|
41
42
|
Optional,
|
|
42
43
|
Sequence,
|
|
43
44
|
Type,
|
|
45
|
+
TypeVar,
|
|
44
46
|
Union,
|
|
45
47
|
cast,
|
|
46
48
|
)
|
|
@@ -210,28 +212,36 @@ class BaseWeb3:
|
|
|
210
212
|
@staticmethod
|
|
211
213
|
@wraps(to_bytes)
|
|
212
214
|
def to_bytes(
|
|
213
|
-
primitive: Primitives = None,
|
|
215
|
+
primitive: Optional[Primitives] = None,
|
|
216
|
+
hexstr: Optional[HexStr] = None,
|
|
217
|
+
text: Optional[str] = None,
|
|
214
218
|
) -> bytes:
|
|
215
219
|
return to_bytes(primitive, hexstr, text)
|
|
216
220
|
|
|
217
221
|
@staticmethod
|
|
218
222
|
@wraps(to_int)
|
|
219
223
|
def to_int(
|
|
220
|
-
primitive: Primitives = None,
|
|
224
|
+
primitive: Optional[Primitives] = None,
|
|
225
|
+
hexstr: Optional[HexStr] = None,
|
|
226
|
+
text: Optional[str] = None,
|
|
221
227
|
) -> int:
|
|
222
228
|
return to_int(primitive, hexstr, text)
|
|
223
229
|
|
|
224
230
|
@staticmethod
|
|
225
231
|
@wraps(to_hex)
|
|
226
232
|
def to_hex(
|
|
227
|
-
primitive: Primitives = None,
|
|
233
|
+
primitive: Optional[Primitives] = None,
|
|
234
|
+
hexstr: Optional[HexStr] = None,
|
|
235
|
+
text: Optional[str] = None,
|
|
228
236
|
) -> HexStr:
|
|
229
237
|
return to_hex(primitive, hexstr, text)
|
|
230
238
|
|
|
231
239
|
@staticmethod
|
|
232
240
|
@wraps(to_text)
|
|
233
241
|
def to_text(
|
|
234
|
-
primitive: Primitives = None,
|
|
242
|
+
primitive: Optional[Primitives] = None,
|
|
243
|
+
hexstr: Optional[HexStr] = None,
|
|
244
|
+
text: Optional[str] = None,
|
|
235
245
|
) -> str:
|
|
236
246
|
return to_text(primitive, hexstr, text)
|
|
237
247
|
|
|
@@ -340,7 +350,7 @@ class BaseWeb3:
|
|
|
340
350
|
return cls.keccak(hexstr=hex_string)
|
|
341
351
|
|
|
342
352
|
def attach_modules(
|
|
343
|
-
self, modules:
|
|
353
|
+
self, modules: Dict[str, Union[Type[Module], Sequence[Any]]]
|
|
344
354
|
) -> None:
|
|
345
355
|
"""
|
|
346
356
|
Attach modules to the `Web3` instance.
|
|
@@ -359,7 +369,7 @@ class BaseWeb3:
|
|
|
359
369
|
|
|
360
370
|
|
|
361
371
|
def _validate_provider(
|
|
362
|
-
w3: Union["Web3", "AsyncWeb3"],
|
|
372
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
363
373
|
provider: Optional[Union[BaseProvider, AsyncBaseProvider]],
|
|
364
374
|
) -> None:
|
|
365
375
|
if provider is not None:
|
|
@@ -447,7 +457,10 @@ class Web3(BaseWeb3):
|
|
|
447
457
|
# -- async -- #
|
|
448
458
|
|
|
449
459
|
|
|
450
|
-
|
|
460
|
+
AsyncProviderT = TypeVar("AsyncProviderT", bound=AsyncBaseProvider)
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
class AsyncWeb3(BaseWeb3, Generic[AsyncProviderT]):
|
|
451
464
|
# mypy Types
|
|
452
465
|
eth: AsyncEth
|
|
453
466
|
net: AsyncNet
|
|
@@ -460,7 +473,7 @@ class AsyncWeb3(BaseWeb3):
|
|
|
460
473
|
|
|
461
474
|
def __init__(
|
|
462
475
|
self,
|
|
463
|
-
provider: Optional[
|
|
476
|
+
provider: Optional[AsyncProviderT] = None,
|
|
464
477
|
middleware: Optional[Sequence[Any]] = None,
|
|
465
478
|
modules: Optional[Dict[str, Union[Type[Module], Sequence[Any]]]] = None,
|
|
466
479
|
external_modules: Optional[
|
|
@@ -486,11 +499,11 @@ class AsyncWeb3(BaseWeb3):
|
|
|
486
499
|
return await self.provider.is_connected(show_traceback)
|
|
487
500
|
|
|
488
501
|
@property
|
|
489
|
-
def provider(self) ->
|
|
490
|
-
return cast(
|
|
502
|
+
def provider(self) -> AsyncProviderT:
|
|
503
|
+
return cast(AsyncProviderT, self.manager.provider)
|
|
491
504
|
|
|
492
505
|
@provider.setter
|
|
493
|
-
def provider(self, provider:
|
|
506
|
+
def provider(self, provider: AsyncProviderT) -> None:
|
|
494
507
|
self.manager.provider = provider
|
|
495
508
|
|
|
496
509
|
@property
|
web3/manager.py
CHANGED
|
@@ -105,7 +105,7 @@ class RequestManager:
|
|
|
105
105
|
|
|
106
106
|
def __init__(
|
|
107
107
|
self,
|
|
108
|
-
w3: Union["AsyncWeb3", "Web3"],
|
|
108
|
+
w3: Union["AsyncWeb3[Any]", "Web3"],
|
|
109
109
|
provider: Optional[Union["BaseProvider", "AsyncBaseProvider"]] = None,
|
|
110
110
|
middleware: Optional[Sequence[Tuple[Middleware, str]]] = None,
|
|
111
111
|
) -> None:
|
|
@@ -167,7 +167,8 @@ class RequestManager:
|
|
|
167
167
|
) -> RPCResponse:
|
|
168
168
|
provider = cast("AsyncBaseProvider", self.provider)
|
|
169
169
|
request_func = await provider.request_func(
|
|
170
|
-
cast("AsyncWeb3", self.w3),
|
|
170
|
+
cast("AsyncWeb3[Any]", self.w3),
|
|
171
|
+
cast("MiddlewareOnion", self.middleware_onion),
|
|
171
172
|
)
|
|
172
173
|
self.logger.debug("Making request. Method: %s", method)
|
|
173
174
|
return await request_func(method, params)
|
|
@@ -299,7 +300,7 @@ class RequestManager:
|
|
|
299
300
|
"""
|
|
300
301
|
provider = cast(AsyncJSONBaseProvider, self.provider)
|
|
301
302
|
request_func = await provider.batch_request_func(
|
|
302
|
-
cast("AsyncWeb3", self.w3),
|
|
303
|
+
cast("AsyncWeb3[Any]", self.w3),
|
|
303
304
|
cast("MiddlewareOnion", self.middleware_onion),
|
|
304
305
|
)
|
|
305
306
|
# since we add items to the batch without awaiting, we unpack the coroutines
|
|
@@ -336,7 +337,7 @@ class RequestManager:
|
|
|
336
337
|
"can send batch requests."
|
|
337
338
|
)
|
|
338
339
|
send_func = await self._provider.send_batch_func(
|
|
339
|
-
cast("AsyncWeb3", self.w3),
|
|
340
|
+
cast("AsyncWeb3[Any]", self.w3),
|
|
340
341
|
cast("MiddlewareOnion", self.middleware_onion),
|
|
341
342
|
)
|
|
342
343
|
self.logger.debug(
|
|
@@ -355,7 +356,7 @@ class RequestManager:
|
|
|
355
356
|
"can receive batch requests."
|
|
356
357
|
)
|
|
357
358
|
recv_func = await self._provider.recv_batch_func(
|
|
358
|
-
cast("AsyncWeb3", self.w3),
|
|
359
|
+
cast("AsyncWeb3[Any]", self.w3),
|
|
359
360
|
cast("MiddlewareOnion", self.middleware_onion),
|
|
360
361
|
)
|
|
361
362
|
self.logger.debug(
|
|
@@ -457,7 +458,7 @@ class RequestManager:
|
|
|
457
458
|
|
|
458
459
|
async def send(self, method: RPCEndpoint, params: Any) -> RPCRequest:
|
|
459
460
|
provider = cast(PersistentConnectionProvider, self._provider)
|
|
460
|
-
async_w3 = cast("AsyncWeb3", self.w3)
|
|
461
|
+
async_w3 = cast("AsyncWeb3[Any]", self.w3)
|
|
461
462
|
middleware_onion = cast("MiddlewareOnion", self.middleware_onion)
|
|
462
463
|
send_func = await provider.send_func(
|
|
463
464
|
async_w3,
|
|
@@ -475,7 +476,7 @@ class RequestManager:
|
|
|
475
476
|
|
|
476
477
|
async def recv_for_request(self, rpc_request: RPCRequest) -> RPCResponse:
|
|
477
478
|
provider = cast(PersistentConnectionProvider, self._provider)
|
|
478
|
-
async_w3 = cast("AsyncWeb3", self.w3)
|
|
479
|
+
async_w3 = cast("AsyncWeb3[Any]", self.w3)
|
|
479
480
|
middleware_onion = cast("MiddlewareOnion", self.middleware_onion)
|
|
480
481
|
recv_func = await provider.recv_func(
|
|
481
482
|
async_w3,
|
|
@@ -523,7 +524,7 @@ class RequestManager:
|
|
|
523
524
|
"Only providers that maintain an open, persistent connection "
|
|
524
525
|
"can listen to streams."
|
|
525
526
|
)
|
|
526
|
-
async_w3 = cast("AsyncWeb3", self.w3)
|
|
527
|
+
async_w3 = cast("AsyncWeb3[Any]", self.w3)
|
|
527
528
|
|
|
528
529
|
if self._provider._message_listener_task is None:
|
|
529
530
|
raise ProviderConnectionError(
|
web3/middleware/__init__.py
CHANGED
|
@@ -78,7 +78,7 @@ def combine_middleware(
|
|
|
78
78
|
|
|
79
79
|
async def async_combine_middleware(
|
|
80
80
|
middleware: Sequence[Middleware],
|
|
81
|
-
async_w3: "AsyncWeb3",
|
|
81
|
+
async_w3: "AsyncWeb3[Any]",
|
|
82
82
|
provider_request_fn: AsyncMakeRequestFn,
|
|
83
83
|
) -> Callable[..., Coroutine[Any, Any, "RPCResponse"]]:
|
|
84
84
|
"""
|
web3/middleware/base.py
CHANGED
|
@@ -35,9 +35,9 @@ class Web3Middleware:
|
|
|
35
35
|
but instead inherited from.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
|
-
_w3: Union["AsyncWeb3", "Web3"]
|
|
38
|
+
_w3: Union["AsyncWeb3[Any]", "Web3"]
|
|
39
39
|
|
|
40
|
-
def __init__(self, w3: Union["AsyncWeb3", "Web3"]) -> None:
|
|
40
|
+
def __init__(self, w3: Union["AsyncWeb3[Any]", "Web3"]) -> None:
|
|
41
41
|
self._w3 = w3
|
|
42
42
|
|
|
43
43
|
def __hash__(self) -> int:
|
|
@@ -61,7 +61,7 @@ class Web3Middleware:
|
|
|
61
61
|
self, make_batch_request: "MakeBatchRequestFn"
|
|
62
62
|
) -> "MakeBatchRequestFn":
|
|
63
63
|
def middleware(
|
|
64
|
-
requests_info: List[Tuple["RPCEndpoint", Any]]
|
|
64
|
+
requests_info: List[Tuple["RPCEndpoint", Any]],
|
|
65
65
|
) -> Union[List["RPCResponse"], "RPCResponse"]:
|
|
66
66
|
req_processed = [
|
|
67
67
|
self.request_processor(method, params)
|
|
@@ -106,7 +106,7 @@ class Web3Middleware:
|
|
|
106
106
|
self, make_batch_request: "AsyncMakeBatchRequestFn"
|
|
107
107
|
) -> "AsyncMakeBatchRequestFn":
|
|
108
108
|
async def middleware(
|
|
109
|
-
requests_info: List[Tuple["RPCEndpoint", Any]]
|
|
109
|
+
requests_info: List[Tuple["RPCEndpoint", Any]],
|
|
110
110
|
) -> Union[List["RPCResponse"], "RPCResponse"]:
|
|
111
111
|
req_processed = [
|
|
112
112
|
await self.async_request_processor(method, params)
|
|
@@ -145,7 +145,7 @@ class Web3MiddlewareBuilder(Web3Middleware):
|
|
|
145
145
|
@staticmethod
|
|
146
146
|
@abstractmethod
|
|
147
147
|
def build(
|
|
148
|
-
w3: Union["AsyncWeb3", "Web3"],
|
|
148
|
+
w3: Union["AsyncWeb3[Any]", "Web3"],
|
|
149
149
|
*args: Any,
|
|
150
150
|
**kwargs: Any,
|
|
151
151
|
) -> Web3Middleware:
|
|
@@ -52,7 +52,7 @@ class BufferedGasEstimateMiddleware(Web3Middleware):
|
|
|
52
52
|
transaction = params[0]
|
|
53
53
|
if "gas" not in transaction:
|
|
54
54
|
gas_estimate = await async_get_buffered_gas_estimate(
|
|
55
|
-
cast("AsyncWeb3", self._w3), transaction
|
|
55
|
+
cast("AsyncWeb3[Any]", self._w3), transaction
|
|
56
56
|
)
|
|
57
57
|
transaction = assoc(transaction, "gas", hex(gas_estimate))
|
|
58
58
|
params = (transaction,)
|
web3/middleware/filter.py
CHANGED
|
@@ -357,7 +357,8 @@ def block_hashes_in_range(
|
|
|
357
357
|
|
|
358
358
|
|
|
359
359
|
async def async_iter_latest_block(
|
|
360
|
-
w3: "AsyncWeb3",
|
|
360
|
+
w3: "AsyncWeb3[Any]",
|
|
361
|
+
to_block: Optional[Union[BlockNumber, LatestBlockParam]] = None,
|
|
361
362
|
) -> AsyncIterable[BlockNumber]:
|
|
362
363
|
"""
|
|
363
364
|
Returns a generator that dispenses the latest block, if
|
|
@@ -394,7 +395,7 @@ async def async_iter_latest_block(
|
|
|
394
395
|
|
|
395
396
|
|
|
396
397
|
async def async_iter_latest_block_ranges(
|
|
397
|
-
w3: "AsyncWeb3",
|
|
398
|
+
w3: "AsyncWeb3[Any]",
|
|
398
399
|
from_block: BlockNumber,
|
|
399
400
|
to_block: Optional[Union[BlockNumber, LatestBlockParam]] = None,
|
|
400
401
|
) -> AsyncIterable[Tuple[Optional[BlockNumber], Optional[BlockNumber]]]:
|
|
@@ -425,7 +426,7 @@ async def async_iter_latest_block_ranges(
|
|
|
425
426
|
|
|
426
427
|
|
|
427
428
|
async def async_get_logs_multipart(
|
|
428
|
-
w3: "AsyncWeb3",
|
|
429
|
+
w3: "AsyncWeb3[Any]",
|
|
429
430
|
start_block: BlockNumber,
|
|
430
431
|
stop_block: BlockNumber,
|
|
431
432
|
address: Union[Address, ChecksumAddress, List[Union[Address, ChecksumAddress]]],
|
|
@@ -458,7 +459,7 @@ class AsyncRequestLogs:
|
|
|
458
459
|
|
|
459
460
|
def __init__(
|
|
460
461
|
self,
|
|
461
|
-
w3: "AsyncWeb3",
|
|
462
|
+
w3: "AsyncWeb3[Any]",
|
|
462
463
|
from_block: Optional[Union[BlockNumber, LatestBlockParam]] = None,
|
|
463
464
|
to_block: Optional[Union[BlockNumber, LatestBlockParam]] = None,
|
|
464
465
|
address: Optional[
|
|
@@ -544,7 +545,7 @@ class AsyncRequestLogs:
|
|
|
544
545
|
|
|
545
546
|
|
|
546
547
|
class AsyncRequestBlocks:
|
|
547
|
-
def __init__(self, w3: "AsyncWeb3") -> None:
|
|
548
|
+
def __init__(self, w3: "AsyncWeb3[Any]") -> None:
|
|
548
549
|
self.w3 = w3
|
|
549
550
|
|
|
550
551
|
def __await__(self) -> Generator[Any, None, "AsyncRequestBlocks"]:
|
|
@@ -569,7 +570,7 @@ class AsyncRequestBlocks:
|
|
|
569
570
|
|
|
570
571
|
|
|
571
572
|
async def async_block_hashes_in_range(
|
|
572
|
-
w3: "AsyncWeb3", block_range: Tuple[BlockNumber, BlockNumber]
|
|
573
|
+
w3: "AsyncWeb3[Any]", block_range: Tuple[BlockNumber, BlockNumber]
|
|
573
574
|
) -> List[Union[None, Hash32]]:
|
|
574
575
|
from_block, to_block = block_range
|
|
575
576
|
if from_block is None or to_block is None:
|
|
@@ -594,7 +595,7 @@ def _simulate_rpc_response_with_result(filter_id: str) -> "RPCResponse":
|
|
|
594
595
|
|
|
595
596
|
|
|
596
597
|
class LocalFilterMiddleware(Web3Middleware):
|
|
597
|
-
def __init__(self, w3: Union["Web3", "AsyncWeb3"]):
|
|
598
|
+
def __init__(self, w3: Union["Web3", "AsyncWeb3[Any]"]):
|
|
598
599
|
self.filters: Dict[str, SyncFilter] = {}
|
|
599
600
|
self.async_filters: Dict[str, AsyncFilter] = {}
|
|
600
601
|
self.filter_id_counter = itertools.count()
|
|
@@ -660,12 +661,12 @@ class LocalFilterMiddleware(Web3Middleware):
|
|
|
660
661
|
|
|
661
662
|
if method == RPC.eth_newFilter:
|
|
662
663
|
_filter = await AsyncRequestLogs(
|
|
663
|
-
cast("AsyncWeb3", self._w3),
|
|
664
|
+
cast("AsyncWeb3[Any]", self._w3),
|
|
664
665
|
**apply_key_map(FILTER_PARAMS_KEY_MAP, params[0])
|
|
665
666
|
)
|
|
666
667
|
|
|
667
668
|
elif method == RPC.eth_newBlockFilter:
|
|
668
|
-
_filter = await AsyncRequestBlocks(cast("AsyncWeb3", self._w3))
|
|
669
|
+
_filter = await AsyncRequestBlocks(cast("AsyncWeb3[Any]", self._w3))
|
|
669
670
|
|
|
670
671
|
else:
|
|
671
672
|
raise NotImplementedError(method)
|
web3/middleware/formatting.py
CHANGED
|
@@ -100,7 +100,7 @@ def _apply_response_formatters(
|
|
|
100
100
|
|
|
101
101
|
SYNC_FORMATTERS_BUILDER = Callable[["Web3", RPCEndpoint], FormattersDict]
|
|
102
102
|
ASYNC_FORMATTERS_BUILDER = Callable[
|
|
103
|
-
["AsyncWeb3", RPCEndpoint], Coroutine[Any, Any, FormattersDict]
|
|
103
|
+
["AsyncWeb3[Any]", RPCEndpoint], Coroutine[Any, Any, FormattersDict]
|
|
104
104
|
]
|
|
105
105
|
|
|
106
106
|
|
|
@@ -114,7 +114,7 @@ class FormattingMiddlewareBuilder(Web3MiddlewareBuilder):
|
|
|
114
114
|
@staticmethod
|
|
115
115
|
@curry
|
|
116
116
|
def build(
|
|
117
|
-
w3: Union["
|
|
117
|
+
w3: Union["Web3", "AsyncWeb3[Any]"],
|
|
118
118
|
# formatters option:
|
|
119
119
|
request_formatters: Optional[Formatters] = None,
|
|
120
120
|
result_formatters: Optional[Formatters] = None,
|
|
@@ -186,7 +186,7 @@ class FormattingMiddlewareBuilder(Web3MiddlewareBuilder):
|
|
|
186
186
|
formatters = merge(
|
|
187
187
|
FORMATTER_DEFAULTS,
|
|
188
188
|
await self.async_formatters_builder(
|
|
189
|
-
cast("AsyncWeb3", self._w3), method
|
|
189
|
+
cast("AsyncWeb3[Any]", self._w3), method
|
|
190
190
|
),
|
|
191
191
|
)
|
|
192
192
|
self.request_formatters = formatters.pop("request_formatters")
|
|
@@ -204,7 +204,7 @@ class FormattingMiddlewareBuilder(Web3MiddlewareBuilder):
|
|
|
204
204
|
formatters = merge(
|
|
205
205
|
FORMATTER_DEFAULTS,
|
|
206
206
|
await self.async_formatters_builder(
|
|
207
|
-
cast("AsyncWeb3", self._w3), method
|
|
207
|
+
cast("AsyncWeb3[Any]", self._w3), method
|
|
208
208
|
),
|
|
209
209
|
)
|
|
210
210
|
self.result_formatters = formatters["result_formatters"]
|
|
@@ -106,7 +106,7 @@ class GasPriceStrategyMiddleware(Web3Middleware):
|
|
|
106
106
|
async def async_request_processor(self, method: RPCEndpoint, params: Any) -> Any:
|
|
107
107
|
if method == "eth_sendTransaction":
|
|
108
108
|
transaction = params[0]
|
|
109
|
-
w3 = cast("AsyncWeb3", self._w3)
|
|
109
|
+
w3 = cast("AsyncWeb3[Any]", self._w3)
|
|
110
110
|
generated_gas_price = w3.eth.generate_gas_price(transaction)
|
|
111
111
|
latest_block = await w3.eth.get_block("latest")
|
|
112
112
|
transaction = validate_transaction_params(
|