web3 7.14.0__py3-none-any.whl → 8.0.0b1__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 +23 -29
- ens/async_ens.py +30 -24
- ens/base_ens.py +2 -3
- ens/ens.py +18 -20
- ens/utils.py +6 -10
- web3/__init__.py +0 -4
- web3/_utils/abi.py +38 -40
- web3/_utils/async_transactions.py +6 -9
- web3/_utils/batching.py +11 -15
- web3/_utils/blocks.py +1 -2
- web3/_utils/caching/caching_utils.py +12 -17
- web3/_utils/caching/request_caching_validation.py +7 -9
- web3/_utils/compat/__init__.py +2 -2
- web3/_utils/contract_sources/compile_contracts.py +4 -6
- web3/_utils/contracts.py +25 -29
- web3/_utils/datatypes.py +6 -10
- web3/_utils/decorators.py +1 -3
- web3/_utils/encoding.py +10 -14
- web3/_utils/ens.py +4 -5
- web3/_utils/events.py +19 -24
- web3/_utils/filters.py +23 -29
- web3/_utils/formatters.py +8 -13
- web3/_utils/http_session_manager.py +11 -15
- web3/_utils/math.py +1 -2
- web3/_utils/method_formatters.py +41 -43
- web3/_utils/module.py +3 -6
- web3/_utils/module_testing/eth_module.py +7 -9
- web3/_utils/module_testing/go_ethereum_admin_module.py +1 -2
- web3/_utils/module_testing/module_testing_utils.py +9 -5
- web3/_utils/module_testing/persistent_connection_provider.py +3 -7
- web3/_utils/module_testing/utils.py +32 -21
- web3/_utils/normalizers.py +21 -24
- web3/_utils/rpc_abi.py +8 -11
- web3/_utils/threads.py +3 -4
- web3/_utils/transactions.py +3 -6
- web3/_utils/type_conversion.py +2 -6
- web3/_utils/utility_methods.py +5 -7
- web3/_utils/validation.py +6 -8
- web3/_utils/windows.py +1 -4
- web3/beacon/async_beacon.py +51 -55
- web3/beacon/beacon.py +50 -54
- web3/contract/async_contract.py +38 -46
- web3/contract/base_contract.py +70 -75
- web3/contract/contract.py +39 -43
- web3/contract/utils.py +47 -51
- web3/datastructures.py +10 -15
- web3/eth/async_eth.py +64 -70
- web3/eth/base_eth.py +40 -44
- web3/eth/eth.py +50 -66
- web3/exceptions.py +8 -13
- web3/gas_strategies/rpc.py +1 -7
- web3/gas_strategies/time_based.py +2 -3
- web3/geth.py +17 -17
- web3/main.py +43 -52
- web3/manager.py +32 -35
- web3/method.py +22 -29
- web3/middleware/base.py +5 -8
- web3/middleware/filter.py +41 -46
- web3/middleware/formatting.py +5 -6
- web3/middleware/names.py +1 -3
- web3/middleware/signing.py +3 -4
- web3/middleware/stalecheck.py +1 -2
- web3/middleware/validation.py +1 -2
- web3/module.py +11 -14
- web3/providers/__init__.py +0 -4
- web3/providers/async_base.py +21 -27
- web3/providers/auto.py +9 -20
- web3/providers/base.py +12 -17
- web3/providers/eth_tester/defaults.py +4 -8
- web3/providers/eth_tester/main.py +4 -8
- web3/providers/eth_tester/middleware.py +2 -4
- web3/providers/ipc.py +6 -10
- web3/providers/persistent/async_ipc.py +4 -7
- web3/providers/persistent/persistent.py +22 -25
- web3/providers/persistent/persistent_connection.py +2 -4
- web3/providers/persistent/request_processor.py +11 -32
- web3/providers/persistent/subscription_container.py +5 -8
- web3/providers/persistent/subscription_manager.py +13 -19
- web3/providers/persistent/websocket.py +15 -12
- web3/providers/rpc/async_rpc.py +10 -16
- web3/providers/rpc/rpc.py +11 -17
- web3/providers/rpc/utils.py +2 -3
- web3/scripts/release/test_package.py +1 -4
- web3/testing.py +1 -5
- web3/tracing.py +9 -13
- web3/types.py +49 -56
- web3/utils/abi.py +28 -33
- web3/utils/async_exception_handling.py +1 -2
- web3/utils/caching.py +6 -10
- web3/utils/exception_handling.py +1 -2
- web3/utils/subscriptions.py +30 -34
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/METADATA +13 -12
- web3-8.0.0b1.dist-info/RECORD +170 -0
- web3/providers/legacy_websocket.py +0 -159
- web3-7.14.0.dist-info/RECORD +0 -171
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/WHEEL +0 -0
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/licenses/LICENSE +0 -0
- {web3-7.14.0.dist-info → web3-8.0.0b1.dist-info}/top_level.txt +0 -0
web3/eth/async_eth.py
CHANGED
|
@@ -4,13 +4,7 @@ from typing import (
|
|
|
4
4
|
Any,
|
|
5
5
|
Awaitable,
|
|
6
6
|
Callable,
|
|
7
|
-
Dict,
|
|
8
|
-
List,
|
|
9
|
-
Optional,
|
|
10
7
|
Sequence,
|
|
11
|
-
Tuple,
|
|
12
|
-
Type,
|
|
13
|
-
Union,
|
|
14
8
|
cast,
|
|
15
9
|
overload,
|
|
16
10
|
)
|
|
@@ -123,19 +117,17 @@ class AsyncEth(BaseEth):
|
|
|
123
117
|
|
|
124
118
|
is_async = True
|
|
125
119
|
|
|
126
|
-
_default_contract_factory:
|
|
127
|
-
Union[AsyncContract, AsyncContractCaller]
|
|
128
|
-
] = AsyncContract
|
|
120
|
+
_default_contract_factory: type[AsyncContract | AsyncContractCaller] = AsyncContract
|
|
129
121
|
|
|
130
122
|
# eth_accounts
|
|
131
123
|
|
|
132
|
-
_accounts: Method[Callable[[], Awaitable[
|
|
124
|
+
_accounts: Method[Callable[[], Awaitable[tuple[ChecksumAddress]]]] = Method(
|
|
133
125
|
RPC.eth_accounts,
|
|
134
126
|
is_property=True,
|
|
135
127
|
)
|
|
136
128
|
|
|
137
129
|
@property
|
|
138
|
-
async def accounts(self) ->
|
|
130
|
+
async def accounts(self) -> tuple[ChecksumAddress]:
|
|
139
131
|
return await self._accounts()
|
|
140
132
|
|
|
141
133
|
# eth_blobBaseFee
|
|
@@ -208,20 +200,20 @@ class AsyncEth(BaseEth):
|
|
|
208
200
|
|
|
209
201
|
# eth_syncing
|
|
210
202
|
|
|
211
|
-
_syncing: Method[Callable[[], Awaitable[
|
|
203
|
+
_syncing: Method[Callable[[], Awaitable[SyncStatus | bool]]] = Method(
|
|
212
204
|
RPC.eth_syncing,
|
|
213
205
|
is_property=True,
|
|
214
206
|
)
|
|
215
207
|
|
|
216
208
|
@property
|
|
217
|
-
async def syncing(self) ->
|
|
209
|
+
async def syncing(self) -> SyncStatus | bool:
|
|
218
210
|
return await self._syncing()
|
|
219
211
|
|
|
220
212
|
# eth_feeHistory
|
|
221
213
|
|
|
222
214
|
_fee_history: Method[
|
|
223
215
|
Callable[
|
|
224
|
-
[int,
|
|
216
|
+
[int, BlockParams | BlockNumber, list[float] | None],
|
|
225
217
|
Awaitable[FeeHistory],
|
|
226
218
|
]
|
|
227
219
|
] = Method(RPC.eth_feeHistory, mungers=[default_root_munger])
|
|
@@ -229,8 +221,8 @@ class AsyncEth(BaseEth):
|
|
|
229
221
|
async def fee_history(
|
|
230
222
|
self,
|
|
231
223
|
block_count: int,
|
|
232
|
-
newest_block:
|
|
233
|
-
reward_percentiles:
|
|
224
|
+
newest_block: BlockParams | BlockNumber,
|
|
225
|
+
reward_percentiles: list[float] | None = None,
|
|
234
226
|
) -> FeeHistory:
|
|
235
227
|
reward_percentiles = reward_percentiles or []
|
|
236
228
|
return await self._fee_history(block_count, newest_block, reward_percentiles)
|
|
@@ -241,8 +233,8 @@ class AsyncEth(BaseEth):
|
|
|
241
233
|
Callable[
|
|
242
234
|
[
|
|
243
235
|
TxParams,
|
|
244
|
-
|
|
245
|
-
|
|
236
|
+
BlockIdentifier | None,
|
|
237
|
+
StateOverride | None,
|
|
246
238
|
],
|
|
247
239
|
Awaitable[HexBytes],
|
|
248
240
|
]
|
|
@@ -251,9 +243,9 @@ class AsyncEth(BaseEth):
|
|
|
251
243
|
async def call(
|
|
252
244
|
self,
|
|
253
245
|
transaction: TxParams,
|
|
254
|
-
block_identifier:
|
|
255
|
-
state_override:
|
|
256
|
-
ccip_read_enabled:
|
|
246
|
+
block_identifier: BlockIdentifier | None = None,
|
|
247
|
+
state_override: StateOverride | None = None,
|
|
248
|
+
ccip_read_enabled: bool | None = None,
|
|
257
249
|
) -> HexBytes:
|
|
258
250
|
ccip_read_enabled_on_provider = self.w3.provider.global_ccip_read_enabled
|
|
259
251
|
if (
|
|
@@ -272,8 +264,8 @@ class AsyncEth(BaseEth):
|
|
|
272
264
|
async def _durin_call(
|
|
273
265
|
self,
|
|
274
266
|
transaction: TxParams,
|
|
275
|
-
block_identifier:
|
|
276
|
-
state_override:
|
|
267
|
+
block_identifier: BlockIdentifier | None = None,
|
|
268
|
+
state_override: StateOverride | None = None,
|
|
277
269
|
) -> HexBytes:
|
|
278
270
|
max_redirects = self.w3.provider.ccip_read_max_redirects
|
|
279
271
|
|
|
@@ -314,7 +306,7 @@ class AsyncEth(BaseEth):
|
|
|
314
306
|
|
|
315
307
|
_create_access_list: Method[
|
|
316
308
|
Callable[
|
|
317
|
-
[TxParams,
|
|
309
|
+
[TxParams, BlockIdentifier | None],
|
|
318
310
|
Awaitable[CreateAccessListResponse],
|
|
319
311
|
]
|
|
320
312
|
] = Method(RPC.eth_createAccessList, mungers=[BaseEth.create_access_list_munger])
|
|
@@ -322,7 +314,7 @@ class AsyncEth(BaseEth):
|
|
|
322
314
|
async def create_access_list(
|
|
323
315
|
self,
|
|
324
316
|
transaction: TxParams,
|
|
325
|
-
block_identifier:
|
|
317
|
+
block_identifier: BlockIdentifier | None = None,
|
|
326
318
|
) -> CreateAccessListResponse:
|
|
327
319
|
return await self._create_access_list(transaction, block_identifier)
|
|
328
320
|
|
|
@@ -330,7 +322,7 @@ class AsyncEth(BaseEth):
|
|
|
330
322
|
|
|
331
323
|
_estimate_gas: Method[
|
|
332
324
|
Callable[
|
|
333
|
-
[TxParams,
|
|
325
|
+
[TxParams, BlockIdentifier | None, StateOverride | None],
|
|
334
326
|
Awaitable[int],
|
|
335
327
|
]
|
|
336
328
|
] = Method(RPC.eth_estimateGas, mungers=[BaseEth.estimate_gas_munger])
|
|
@@ -338,8 +330,8 @@ class AsyncEth(BaseEth):
|
|
|
338
330
|
async def estimate_gas(
|
|
339
331
|
self,
|
|
340
332
|
transaction: TxParams,
|
|
341
|
-
block_identifier:
|
|
342
|
-
state_override:
|
|
333
|
+
block_identifier: BlockIdentifier | None = None,
|
|
334
|
+
state_override: StateOverride | None = None,
|
|
343
335
|
) -> int:
|
|
344
336
|
return await self._estimate_gas(transaction, block_identifier, state_override)
|
|
345
337
|
|
|
@@ -425,13 +417,13 @@ class AsyncEth(BaseEth):
|
|
|
425
417
|
# eth_sendRawTransaction
|
|
426
418
|
|
|
427
419
|
_send_raw_transaction: Method[
|
|
428
|
-
Callable[[
|
|
420
|
+
Callable[[HexStr | bytes], Awaitable[HexBytes]]
|
|
429
421
|
] = Method(
|
|
430
422
|
RPC.eth_sendRawTransaction,
|
|
431
423
|
mungers=[default_root_munger],
|
|
432
424
|
)
|
|
433
425
|
|
|
434
|
-
async def send_raw_transaction(self, transaction:
|
|
426
|
+
async def send_raw_transaction(self, transaction: HexStr | bytes) -> HexBytes:
|
|
435
427
|
return await self._send_raw_transaction(transaction)
|
|
436
428
|
|
|
437
429
|
# eth_getBlockByHash
|
|
@@ -449,7 +441,9 @@ class AsyncEth(BaseEth):
|
|
|
449
441
|
)
|
|
450
442
|
|
|
451
443
|
async def get_block(
|
|
452
|
-
self,
|
|
444
|
+
self,
|
|
445
|
+
block_identifier: BlockIdentifier,
|
|
446
|
+
full_transactions: bool = False,
|
|
453
447
|
) -> BlockData:
|
|
454
448
|
return await self._get_block(block_identifier, full_transactions)
|
|
455
449
|
|
|
@@ -471,7 +465,7 @@ class AsyncEth(BaseEth):
|
|
|
471
465
|
|
|
472
466
|
_get_balance: Method[
|
|
473
467
|
Callable[
|
|
474
|
-
[
|
|
468
|
+
[Address | ChecksumAddress | ENS, BlockIdentifier | None],
|
|
475
469
|
Awaitable[Wei],
|
|
476
470
|
]
|
|
477
471
|
] = Method(
|
|
@@ -481,8 +475,8 @@ class AsyncEth(BaseEth):
|
|
|
481
475
|
|
|
482
476
|
async def get_balance(
|
|
483
477
|
self,
|
|
484
|
-
account:
|
|
485
|
-
block_identifier:
|
|
478
|
+
account: Address | ChecksumAddress | ENS,
|
|
479
|
+
block_identifier: BlockIdentifier | None = None,
|
|
486
480
|
) -> Wei:
|
|
487
481
|
return await self._get_balance(account, block_identifier)
|
|
488
482
|
|
|
@@ -490,35 +484,35 @@ class AsyncEth(BaseEth):
|
|
|
490
484
|
|
|
491
485
|
_get_code: Method[
|
|
492
486
|
Callable[
|
|
493
|
-
[
|
|
487
|
+
[Address | ChecksumAddress | ENS, BlockIdentifier | None],
|
|
494
488
|
Awaitable[HexBytes],
|
|
495
489
|
]
|
|
496
490
|
] = Method(RPC.eth_getCode, mungers=[BaseEth.block_id_munger])
|
|
497
491
|
|
|
498
492
|
async def get_code(
|
|
499
493
|
self,
|
|
500
|
-
account:
|
|
501
|
-
block_identifier:
|
|
494
|
+
account: Address | ChecksumAddress | ENS,
|
|
495
|
+
block_identifier: BlockIdentifier | None = None,
|
|
502
496
|
) -> HexBytes:
|
|
503
497
|
return await self._get_code(account, block_identifier)
|
|
504
498
|
|
|
505
499
|
# eth_getLogs
|
|
506
500
|
|
|
507
|
-
_get_logs: Method[Callable[[FilterParams], Awaitable[
|
|
501
|
+
_get_logs: Method[Callable[[FilterParams], Awaitable[list[LogReceipt]]]] = Method(
|
|
508
502
|
RPC.eth_getLogs, mungers=[default_root_munger]
|
|
509
503
|
)
|
|
510
504
|
|
|
511
505
|
async def get_logs(
|
|
512
506
|
self,
|
|
513
507
|
filter_params: FilterParams,
|
|
514
|
-
) ->
|
|
508
|
+
) -> list[LogReceipt]:
|
|
515
509
|
return await self._get_logs(filter_params)
|
|
516
510
|
|
|
517
511
|
# eth_getTransactionCount
|
|
518
512
|
|
|
519
513
|
_get_transaction_count: Method[
|
|
520
514
|
Callable[
|
|
521
|
-
[
|
|
515
|
+
[Address | ChecksumAddress | ENS, BlockIdentifier | None],
|
|
522
516
|
Awaitable[Nonce],
|
|
523
517
|
]
|
|
524
518
|
] = Method(
|
|
@@ -528,8 +522,8 @@ class AsyncEth(BaseEth):
|
|
|
528
522
|
|
|
529
523
|
async def get_transaction_count(
|
|
530
524
|
self,
|
|
531
|
-
account:
|
|
532
|
-
block_identifier:
|
|
525
|
+
account: Address | ChecksumAddress | ENS,
|
|
526
|
+
block_identifier: BlockIdentifier | None = None,
|
|
533
527
|
) -> Nonce:
|
|
534
528
|
return await self._get_transaction_count(account, block_identifier)
|
|
535
529
|
|
|
@@ -545,7 +539,7 @@ class AsyncEth(BaseEth):
|
|
|
545
539
|
async def wait_for_transaction_receipt(
|
|
546
540
|
self,
|
|
547
541
|
transaction_hash: _Hash32,
|
|
548
|
-
timeout:
|
|
542
|
+
timeout: float | None = 120,
|
|
549
543
|
poll_latency: float = 0.1,
|
|
550
544
|
) -> TxReceipt:
|
|
551
545
|
async def _wait_for_tx_receipt_with_timeout(
|
|
@@ -576,7 +570,7 @@ class AsyncEth(BaseEth):
|
|
|
576
570
|
|
|
577
571
|
_get_storage_at: Method[
|
|
578
572
|
Callable[
|
|
579
|
-
[
|
|
573
|
+
[Address | ChecksumAddress | ENS, int, BlockIdentifier | None],
|
|
580
574
|
Awaitable[HexBytes],
|
|
581
575
|
]
|
|
582
576
|
] = Method(
|
|
@@ -586,9 +580,9 @@ class AsyncEth(BaseEth):
|
|
|
586
580
|
|
|
587
581
|
async def get_storage_at(
|
|
588
582
|
self,
|
|
589
|
-
account:
|
|
583
|
+
account: Address | ChecksumAddress | ENS,
|
|
590
584
|
position: int,
|
|
591
|
-
block_identifier:
|
|
585
|
+
block_identifier: BlockIdentifier | None = None,
|
|
592
586
|
) -> HexBytes:
|
|
593
587
|
return await self._get_storage_at(account, position, block_identifier)
|
|
594
588
|
|
|
@@ -627,8 +621,8 @@ class AsyncEth(BaseEth):
|
|
|
627
621
|
|
|
628
622
|
async def sign(
|
|
629
623
|
self,
|
|
630
|
-
account:
|
|
631
|
-
data:
|
|
624
|
+
account: Address | ChecksumAddress | ENS,
|
|
625
|
+
data: int | bytes = None,
|
|
632
626
|
hexstr: HexStr = None,
|
|
633
627
|
text: str = None,
|
|
634
628
|
) -> HexStr:
|
|
@@ -648,7 +642,8 @@ class AsyncEth(BaseEth):
|
|
|
648
642
|
|
|
649
643
|
_sign_typed_data: Method[
|
|
650
644
|
Callable[
|
|
651
|
-
[
|
|
645
|
+
[Address | ChecksumAddress | ENS, dict[str, Any]],
|
|
646
|
+
Awaitable[HexStr],
|
|
652
647
|
]
|
|
653
648
|
] = Method(
|
|
654
649
|
RPC.eth_signTypedData,
|
|
@@ -656,7 +651,7 @@ class AsyncEth(BaseEth):
|
|
|
656
651
|
)
|
|
657
652
|
|
|
658
653
|
async def sign_typed_data(
|
|
659
|
-
self, account:
|
|
654
|
+
self, account: Address | ChecksumAddress | ENS, data: dict[str, Any]
|
|
660
655
|
) -> HexStr:
|
|
661
656
|
return await self._sign_typed_data(account, data)
|
|
662
657
|
|
|
@@ -679,7 +674,7 @@ class AsyncEth(BaseEth):
|
|
|
679
674
|
# eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter
|
|
680
675
|
|
|
681
676
|
filter: Method[
|
|
682
|
-
Callable[[
|
|
677
|
+
Callable[[str | FilterParams | HexStr | None], Awaitable[AsyncFilter]]
|
|
683
678
|
] = Method(
|
|
684
679
|
method_choice_depends_on_args=select_filter_method(
|
|
685
680
|
if_new_block_filter=RPC.eth_newBlockFilter,
|
|
@@ -692,17 +687,17 @@ class AsyncEth(BaseEth):
|
|
|
692
687
|
# eth_getFilterChanges, eth_getFilterLogs, eth_uninstallFilter
|
|
693
688
|
|
|
694
689
|
_get_filter_changes: Method[
|
|
695
|
-
Callable[[HexStr], Awaitable[
|
|
690
|
+
Callable[[HexStr], Awaitable[list[LogReceipt]]]
|
|
696
691
|
] = Method(RPC.eth_getFilterChanges, mungers=[default_root_munger])
|
|
697
692
|
|
|
698
|
-
async def get_filter_changes(self, filter_id: HexStr) ->
|
|
693
|
+
async def get_filter_changes(self, filter_id: HexStr) -> list[LogReceipt]:
|
|
699
694
|
return await self._get_filter_changes(filter_id)
|
|
700
695
|
|
|
701
|
-
_get_filter_logs: Method[Callable[[HexStr], Awaitable[
|
|
696
|
+
_get_filter_logs: Method[Callable[[HexStr], Awaitable[list[LogReceipt]]]] = Method(
|
|
702
697
|
RPC.eth_getFilterLogs, mungers=[default_root_munger]
|
|
703
698
|
)
|
|
704
699
|
|
|
705
|
-
async def get_filter_logs(self, filter_id: HexStr) ->
|
|
700
|
+
async def get_filter_logs(self, filter_id: HexStr) -> list[LogReceipt]:
|
|
706
701
|
return await self._get_filter_logs(filter_id)
|
|
707
702
|
|
|
708
703
|
_uninstall_filter: Method[Callable[[HexStr], Awaitable[bool]]] = Method(
|
|
@@ -723,16 +718,15 @@ class AsyncEth(BaseEth):
|
|
|
723
718
|
async def subscribe(
|
|
724
719
|
self,
|
|
725
720
|
subscription_type: SubscriptionType,
|
|
726
|
-
subscription_arg:
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
parallelize: Optional[bool] = None,
|
|
721
|
+
subscription_arg: None
|
|
722
|
+
| (
|
|
723
|
+
LogsSubscriptionArg # logs, optional filter params
|
|
724
|
+
| bool # newPendingTransactions, full_transactions
|
|
725
|
+
) = None,
|
|
726
|
+
handler: EthSubscriptionHandler | None = None,
|
|
727
|
+
handler_context: dict[str, Any] | None = None,
|
|
728
|
+
label: str | None = None,
|
|
729
|
+
parallelize: bool | None = None,
|
|
736
730
|
) -> HexStr:
|
|
737
731
|
if not isinstance(self.w3.provider, PersistentConnectionProvider):
|
|
738
732
|
raise MethodNotSupported(
|
|
@@ -773,20 +767,20 @@ class AsyncEth(BaseEth):
|
|
|
773
767
|
# -- contract methods -- #
|
|
774
768
|
|
|
775
769
|
@overload
|
|
776
|
-
def contract(self, address: None = None, **kwargs: Any) ->
|
|
770
|
+
def contract(self, address: None = None, **kwargs: Any) -> type[AsyncContract]:
|
|
777
771
|
...
|
|
778
772
|
|
|
779
773
|
@overload
|
|
780
774
|
def contract(
|
|
781
|
-
self, address:
|
|
775
|
+
self, address: Address | ChecksumAddress | ENS, **kwargs: Any
|
|
782
776
|
) -> AsyncContract:
|
|
783
777
|
...
|
|
784
778
|
|
|
785
779
|
def contract(
|
|
786
780
|
self,
|
|
787
|
-
address:
|
|
781
|
+
address: Address | ChecksumAddress | ENS | None = None,
|
|
788
782
|
**kwargs: Any,
|
|
789
|
-
) ->
|
|
783
|
+
) -> type[AsyncContract] | AsyncContract:
|
|
790
784
|
ContractFactoryClass = kwargs.pop(
|
|
791
785
|
"ContractFactoryClass", self._default_contract_factory
|
|
792
786
|
)
|
|
@@ -800,6 +794,6 @@ class AsyncEth(BaseEth):
|
|
|
800
794
|
|
|
801
795
|
def set_contract_factory(
|
|
802
796
|
self,
|
|
803
|
-
contract_factory:
|
|
797
|
+
contract_factory: type[AsyncContract | AsyncContractCaller],
|
|
804
798
|
) -> None:
|
|
805
799
|
self._default_contract_factory = contract_factory
|
web3/eth/base_eth.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
from typing import (
|
|
2
2
|
Any,
|
|
3
|
-
List,
|
|
4
3
|
NoReturn,
|
|
5
|
-
Optional,
|
|
6
|
-
Tuple,
|
|
7
|
-
Union,
|
|
8
4
|
)
|
|
9
5
|
|
|
10
6
|
from eth_account import (
|
|
@@ -49,7 +45,7 @@ from web3.types import (
|
|
|
49
45
|
|
|
50
46
|
|
|
51
47
|
class BaseEth(Module):
|
|
52
|
-
_default_account:
|
|
48
|
+
_default_account: ChecksumAddress | Empty = empty
|
|
53
49
|
_default_block: BlockIdentifier = "latest"
|
|
54
50
|
_default_contract_factory: Any = None
|
|
55
51
|
_gas_price_strategy = None
|
|
@@ -72,40 +68,40 @@ class BaseEth(Module):
|
|
|
72
68
|
self._default_block = value
|
|
73
69
|
|
|
74
70
|
@property
|
|
75
|
-
def default_account(self) ->
|
|
71
|
+
def default_account(self) -> ChecksumAddress | Empty:
|
|
76
72
|
return self._default_account
|
|
77
73
|
|
|
78
74
|
@default_account.setter
|
|
79
|
-
def default_account(self, account:
|
|
75
|
+
def default_account(self, account: ChecksumAddress | Empty) -> None:
|
|
80
76
|
self._default_account = account
|
|
81
77
|
|
|
82
|
-
def send_transaction_munger(self, transaction: TxParams) ->
|
|
78
|
+
def send_transaction_munger(self, transaction: TxParams) -> tuple[TxParams]:
|
|
83
79
|
if "from" not in transaction and is_checksum_address(self.default_account):
|
|
84
80
|
transaction = assoc(transaction, "from", self.default_account)
|
|
85
81
|
|
|
86
82
|
return (transaction,)
|
|
87
83
|
|
|
88
84
|
def generate_gas_price(
|
|
89
|
-
self, transaction_params:
|
|
90
|
-
) ->
|
|
85
|
+
self, transaction_params: TxParams | None = None
|
|
86
|
+
) -> Wei | None:
|
|
91
87
|
if self._gas_price_strategy:
|
|
92
88
|
return self._gas_price_strategy(self.w3, transaction_params)
|
|
93
89
|
return None
|
|
94
90
|
|
|
95
91
|
def set_gas_price_strategy(
|
|
96
|
-
self, gas_price_strategy:
|
|
92
|
+
self, gas_price_strategy: GasPriceStrategy | None
|
|
97
93
|
) -> None:
|
|
98
94
|
self._gas_price_strategy = gas_price_strategy
|
|
99
95
|
|
|
100
96
|
def _eth_call_and_estimate_gas_munger(
|
|
101
97
|
self,
|
|
102
98
|
transaction: TxParams,
|
|
103
|
-
block_identifier:
|
|
104
|
-
state_override:
|
|
105
|
-
) ->
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
block_identifier: BlockIdentifier | None = None,
|
|
100
|
+
state_override: StateOverride | None = None,
|
|
101
|
+
) -> (
|
|
102
|
+
tuple[TxParams, BlockIdentifier]
|
|
103
|
+
| tuple[TxParams, BlockIdentifier, StateOverride]
|
|
104
|
+
):
|
|
109
105
|
# TODO: move to middleware
|
|
110
106
|
if "from" not in transaction and is_checksum_address(self.default_account):
|
|
111
107
|
transaction = assoc(transaction, "from", self.default_account)
|
|
@@ -122,36 +118,36 @@ class BaseEth(Module):
|
|
|
122
118
|
def estimate_gas_munger(
|
|
123
119
|
self,
|
|
124
120
|
transaction: TxParams,
|
|
125
|
-
block_identifier:
|
|
126
|
-
state_override:
|
|
127
|
-
) ->
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
block_identifier: BlockIdentifier | None = None,
|
|
122
|
+
state_override: StateOverride | None = None,
|
|
123
|
+
) -> (
|
|
124
|
+
tuple[TxParams, BlockIdentifier]
|
|
125
|
+
| tuple[TxParams, BlockIdentifier, StateOverride]
|
|
126
|
+
):
|
|
131
127
|
return self._eth_call_and_estimate_gas_munger(
|
|
132
128
|
transaction, block_identifier, state_override
|
|
133
129
|
)
|
|
134
130
|
|
|
135
131
|
def get_block_munger(
|
|
136
132
|
self, block_identifier: BlockIdentifier, full_transactions: bool = False
|
|
137
|
-
) ->
|
|
133
|
+
) -> tuple[BlockIdentifier, bool]:
|
|
138
134
|
return (block_identifier, full_transactions)
|
|
139
135
|
|
|
140
136
|
def block_id_munger(
|
|
141
137
|
self,
|
|
142
|
-
account:
|
|
143
|
-
block_identifier:
|
|
144
|
-
) ->
|
|
138
|
+
account: Address | ChecksumAddress | ENS,
|
|
139
|
+
block_identifier: BlockIdentifier | None = None,
|
|
140
|
+
) -> tuple[Address | ChecksumAddress | ENS, BlockIdentifier]:
|
|
145
141
|
if block_identifier is None:
|
|
146
142
|
block_identifier = self.default_block
|
|
147
143
|
return (account, block_identifier)
|
|
148
144
|
|
|
149
145
|
def get_storage_at_munger(
|
|
150
146
|
self,
|
|
151
|
-
account:
|
|
147
|
+
account: Address | ChecksumAddress | ENS,
|
|
152
148
|
position: int,
|
|
153
|
-
block_identifier:
|
|
154
|
-
) ->
|
|
149
|
+
block_identifier: BlockIdentifier | None = None,
|
|
150
|
+
) -> tuple[Address | ChecksumAddress | ENS, int, BlockIdentifier]:
|
|
155
151
|
if block_identifier is None:
|
|
156
152
|
block_identifier = self.default_block
|
|
157
153
|
return (account, position, block_identifier)
|
|
@@ -159,19 +155,19 @@ class BaseEth(Module):
|
|
|
159
155
|
def call_munger(
|
|
160
156
|
self,
|
|
161
157
|
transaction: TxParams,
|
|
162
|
-
block_identifier:
|
|
163
|
-
state_override:
|
|
164
|
-
) ->
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
block_identifier: BlockIdentifier | None = None,
|
|
159
|
+
state_override: StateOverride | None = None,
|
|
160
|
+
) -> (
|
|
161
|
+
tuple[TxParams, BlockIdentifier]
|
|
162
|
+
| tuple[TxParams, BlockIdentifier, StateOverride]
|
|
163
|
+
):
|
|
168
164
|
return self._eth_call_and_estimate_gas_munger(
|
|
169
165
|
transaction, block_identifier, state_override
|
|
170
166
|
)
|
|
171
167
|
|
|
172
168
|
def create_access_list_munger(
|
|
173
|
-
self, transaction: TxParams, block_identifier:
|
|
174
|
-
) ->
|
|
169
|
+
self, transaction: TxParams, block_identifier: BlockIdentifier | None = None
|
|
170
|
+
) -> tuple[TxParams, BlockIdentifier]:
|
|
175
171
|
# TODO: move to middleware
|
|
176
172
|
if "from" not in transaction and is_checksum_address(self.default_account):
|
|
177
173
|
transaction = assoc(transaction, "from", self.default_account)
|
|
@@ -184,19 +180,19 @@ class BaseEth(Module):
|
|
|
184
180
|
|
|
185
181
|
def sign_munger(
|
|
186
182
|
self,
|
|
187
|
-
account:
|
|
188
|
-
data:
|
|
183
|
+
account: Address | ChecksumAddress | ENS,
|
|
184
|
+
data: int | bytes = None,
|
|
189
185
|
hexstr: HexStr = None,
|
|
190
186
|
text: str = None,
|
|
191
|
-
) ->
|
|
187
|
+
) -> tuple[Address | ChecksumAddress | ENS, HexStr]:
|
|
192
188
|
message_hex = to_hex(data, hexstr=hexstr, text=text)
|
|
193
189
|
return (account, message_hex)
|
|
194
190
|
|
|
195
191
|
def filter_munger(
|
|
196
192
|
self,
|
|
197
|
-
filter_params:
|
|
198
|
-
filter_id:
|
|
199
|
-
) ->
|
|
193
|
+
filter_params: str | FilterParams | None = None,
|
|
194
|
+
filter_id: HexStr | None = None,
|
|
195
|
+
) -> list[FilterParams] | list[HexStr] | list[str]:
|
|
200
196
|
if filter_id and filter_params:
|
|
201
197
|
raise Web3TypeError(
|
|
202
198
|
"Ambiguous invocation: provide either a `filter_params` or a "
|