web3 7.14.1__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.
Files changed (99) hide show
  1. ens/_normalization.py +23 -29
  2. ens/async_ens.py +30 -24
  3. ens/base_ens.py +2 -3
  4. ens/ens.py +18 -20
  5. ens/utils.py +6 -10
  6. web3/__init__.py +0 -4
  7. web3/_utils/abi.py +38 -40
  8. web3/_utils/async_transactions.py +6 -9
  9. web3/_utils/batching.py +11 -15
  10. web3/_utils/blocks.py +1 -2
  11. web3/_utils/caching/caching_utils.py +12 -17
  12. web3/_utils/caching/request_caching_validation.py +7 -9
  13. web3/_utils/compat/__init__.py +2 -2
  14. web3/_utils/contract_sources/compile_contracts.py +4 -6
  15. web3/_utils/contracts.py +25 -29
  16. web3/_utils/datatypes.py +6 -10
  17. web3/_utils/decorators.py +1 -3
  18. web3/_utils/encoding.py +10 -14
  19. web3/_utils/ens.py +4 -5
  20. web3/_utils/events.py +19 -24
  21. web3/_utils/filters.py +23 -29
  22. web3/_utils/formatters.py +8 -13
  23. web3/_utils/http_session_manager.py +11 -22
  24. web3/_utils/math.py +1 -2
  25. web3/_utils/method_formatters.py +41 -43
  26. web3/_utils/module.py +3 -6
  27. web3/_utils/module_testing/eth_module.py +7 -9
  28. web3/_utils/module_testing/go_ethereum_admin_module.py +1 -2
  29. web3/_utils/module_testing/module_testing_utils.py +9 -5
  30. web3/_utils/module_testing/persistent_connection_provider.py +3 -7
  31. web3/_utils/module_testing/utils.py +32 -21
  32. web3/_utils/normalizers.py +21 -24
  33. web3/_utils/rpc_abi.py +8 -11
  34. web3/_utils/threads.py +3 -4
  35. web3/_utils/transactions.py +3 -6
  36. web3/_utils/type_conversion.py +2 -6
  37. web3/_utils/utility_methods.py +5 -7
  38. web3/_utils/validation.py +6 -8
  39. web3/_utils/windows.py +1 -4
  40. web3/beacon/async_beacon.py +50 -54
  41. web3/beacon/beacon.py +50 -54
  42. web3/contract/async_contract.py +38 -46
  43. web3/contract/base_contract.py +70 -75
  44. web3/contract/contract.py +39 -43
  45. web3/contract/utils.py +47 -51
  46. web3/datastructures.py +10 -15
  47. web3/eth/async_eth.py +64 -70
  48. web3/eth/base_eth.py +40 -44
  49. web3/eth/eth.py +50 -66
  50. web3/exceptions.py +8 -13
  51. web3/gas_strategies/rpc.py +1 -7
  52. web3/gas_strategies/time_based.py +2 -3
  53. web3/geth.py +17 -17
  54. web3/main.py +43 -52
  55. web3/manager.py +32 -35
  56. web3/method.py +22 -29
  57. web3/middleware/base.py +5 -8
  58. web3/middleware/filter.py +41 -46
  59. web3/middleware/formatting.py +5 -6
  60. web3/middleware/names.py +1 -3
  61. web3/middleware/signing.py +3 -4
  62. web3/middleware/stalecheck.py +1 -2
  63. web3/middleware/validation.py +1 -2
  64. web3/module.py +11 -14
  65. web3/providers/__init__.py +0 -4
  66. web3/providers/async_base.py +21 -27
  67. web3/providers/auto.py +9 -20
  68. web3/providers/base.py +12 -17
  69. web3/providers/eth_tester/defaults.py +4 -8
  70. web3/providers/eth_tester/main.py +4 -8
  71. web3/providers/eth_tester/middleware.py +2 -4
  72. web3/providers/ipc.py +6 -10
  73. web3/providers/persistent/async_ipc.py +4 -7
  74. web3/providers/persistent/persistent.py +22 -25
  75. web3/providers/persistent/persistent_connection.py +2 -4
  76. web3/providers/persistent/request_processor.py +11 -32
  77. web3/providers/persistent/subscription_container.py +5 -8
  78. web3/providers/persistent/subscription_manager.py +13 -19
  79. web3/providers/persistent/websocket.py +15 -12
  80. web3/providers/rpc/async_rpc.py +10 -16
  81. web3/providers/rpc/rpc.py +17 -20
  82. web3/providers/rpc/utils.py +2 -3
  83. web3/scripts/release/test_package.py +1 -4
  84. web3/testing.py +1 -5
  85. web3/tracing.py +9 -13
  86. web3/types.py +51 -58
  87. web3/utils/abi.py +28 -33
  88. web3/utils/async_exception_handling.py +1 -2
  89. web3/utils/caching.py +6 -10
  90. web3/utils/exception_handling.py +1 -2
  91. web3/utils/subscriptions.py +30 -34
  92. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/METADATA +10 -9
  93. web3-8.0.0b1.dist-info/RECORD +170 -0
  94. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/WHEEL +1 -1
  95. ens/specs/.DS_Store +0 -0
  96. web3/providers/legacy_websocket.py +0 -159
  97. web3-7.14.1.dist-info/RECORD +0 -172
  98. {web3-7.14.1.dist-info → web3-8.0.0b1.dist-info}/licenses/LICENSE +0 -0
  99. {web3-7.14.1.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: Type[
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[Tuple[ChecksumAddress]]]] = Method(
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) -> Tuple[ChecksumAddress]:
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[Union[SyncStatus, bool]]]] = Method(
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) -> Union[SyncStatus, bool]:
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, Union[BlockParams, BlockNumber], Optional[List[float]]],
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: Union[BlockParams, BlockNumber],
233
- reward_percentiles: Optional[List[float]] = None,
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
- Optional[BlockIdentifier],
245
- Optional[StateOverride],
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: Optional[BlockIdentifier] = None,
255
- state_override: Optional[StateOverride] = None,
256
- ccip_read_enabled: Optional[bool] = None,
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: Optional[BlockIdentifier] = None,
276
- state_override: Optional[StateOverride] = None,
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, Optional[BlockIdentifier]],
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: Optional[BlockIdentifier] = None,
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, Optional[BlockIdentifier], Optional[StateOverride]],
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: Optional[BlockIdentifier] = None,
342
- state_override: Optional[StateOverride] = None,
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[[Union[HexStr, bytes]], Awaitable[HexBytes]]
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: Union[HexStr, bytes]) -> HexBytes:
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, block_identifier: BlockIdentifier, full_transactions: bool = False
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
- [Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]],
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: Union[Address, ChecksumAddress, ENS],
485
- block_identifier: Optional[BlockIdentifier] = None,
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
- [Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]],
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: Union[Address, ChecksumAddress, ENS],
501
- block_identifier: Optional[BlockIdentifier] = None,
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[List[LogReceipt]]]] = Method(
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
- ) -> List[LogReceipt]:
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
- [Union[Address, ChecksumAddress, ENS], Optional[BlockIdentifier]],
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: Union[Address, ChecksumAddress, ENS],
532
- block_identifier: Optional[BlockIdentifier] = None,
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: Optional[float] = 120,
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
- [Union[Address, ChecksumAddress, ENS], int, Optional[BlockIdentifier]],
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: Union[Address, ChecksumAddress, ENS],
583
+ account: Address | ChecksumAddress | ENS,
590
584
  position: int,
591
- block_identifier: Optional[BlockIdentifier] = None,
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: Union[Address, ChecksumAddress, ENS],
631
- data: Union[int, bytes] = None,
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
- [Union[Address, ChecksumAddress, ENS], Dict[str, Any]], Awaitable[HexStr]
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: Union[Address, ChecksumAddress, ENS], data: Dict[str, Any]
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[[Optional[Union[str, FilterParams, HexStr]]], Awaitable[AsyncFilter]]
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[List[LogReceipt]]]
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) -> List[LogReceipt]:
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[List[LogReceipt]]]] = Method(
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) -> List[LogReceipt]:
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: Optional[
727
- Union[
728
- LogsSubscriptionArg, # logs, optional filter params
729
- bool, # newPendingTransactions, full_transactions
730
- ]
731
- ] = None,
732
- handler: Optional[EthSubscriptionHandler] = None,
733
- handler_context: Optional[Dict[str, Any]] = None,
734
- label: Optional[str] = None,
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) -> Type[AsyncContract]:
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: Union[Address, ChecksumAddress, ENS], **kwargs: Any
775
+ self, address: Address | ChecksumAddress | ENS, **kwargs: Any
782
776
  ) -> AsyncContract:
783
777
  ...
784
778
 
785
779
  def contract(
786
780
  self,
787
- address: Optional[Union[Address, ChecksumAddress, ENS]] = None,
781
+ address: Address | ChecksumAddress | ENS | None = None,
788
782
  **kwargs: Any,
789
- ) -> Union[Type[AsyncContract], AsyncContract]:
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: Type[Union[AsyncContract, AsyncContractCaller]],
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: Union[ChecksumAddress, Empty] = empty
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) -> Union[ChecksumAddress, Empty]:
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: Union[ChecksumAddress, Empty]) -> None:
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) -> Tuple[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: Optional[TxParams] = None
90
- ) -> Optional[Wei]:
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: Optional[GasPriceStrategy]
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: Optional[BlockIdentifier] = None,
104
- state_override: Optional[StateOverride] = None,
105
- ) -> Union[
106
- Tuple[TxParams, BlockIdentifier],
107
- Tuple[TxParams, BlockIdentifier, StateOverride],
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: Optional[BlockIdentifier] = None,
126
- state_override: Optional[StateOverride] = None,
127
- ) -> Union[
128
- Tuple[TxParams, BlockIdentifier],
129
- Tuple[TxParams, BlockIdentifier, StateOverride],
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
- ) -> Tuple[BlockIdentifier, bool]:
133
+ ) -> tuple[BlockIdentifier, bool]:
138
134
  return (block_identifier, full_transactions)
139
135
 
140
136
  def block_id_munger(
141
137
  self,
142
- account: Union[Address, ChecksumAddress, ENS],
143
- block_identifier: Optional[BlockIdentifier] = None,
144
- ) -> Tuple[Union[Address, ChecksumAddress, ENS], BlockIdentifier]:
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: Union[Address, ChecksumAddress, ENS],
147
+ account: Address | ChecksumAddress | ENS,
152
148
  position: int,
153
- block_identifier: Optional[BlockIdentifier] = None,
154
- ) -> Tuple[Union[Address, ChecksumAddress, ENS], int, BlockIdentifier]:
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: Optional[BlockIdentifier] = None,
163
- state_override: Optional[StateOverride] = None,
164
- ) -> Union[
165
- Tuple[TxParams, BlockIdentifier],
166
- Tuple[TxParams, BlockIdentifier, StateOverride],
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: Optional[BlockIdentifier] = None
174
- ) -> Tuple[TxParams, BlockIdentifier]:
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: Union[Address, ChecksumAddress, ENS],
188
- data: Union[int, bytes] = None,
183
+ account: Address | ChecksumAddress | ENS,
184
+ data: int | bytes = None,
189
185
  hexstr: HexStr = None,
190
186
  text: str = None,
191
- ) -> Tuple[Union[Address, ChecksumAddress, ENS], HexStr]:
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: Optional[Union[str, FilterParams]] = None,
198
- filter_id: Optional[HexStr] = None,
199
- ) -> Union[List[FilterParams], List[HexStr], List[str]]:
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 "