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
@@ -4,9 +4,6 @@ import logging
4
4
  import os
5
5
  from typing import (
6
6
  Any,
7
- Dict,
8
- Optional,
9
- Union,
10
7
  )
11
8
 
12
9
  from eth_typing import (
@@ -15,13 +12,16 @@ from eth_typing import (
15
12
  from toolz import (
16
13
  merge,
17
14
  )
15
+ from websockets.asyncio.client import (
16
+ ClientConnection,
17
+ connect,
18
+ )
18
19
  from websockets.exceptions import (
19
20
  ConnectionClosedOK,
20
21
  WebSocketException,
21
22
  )
22
- from websockets.legacy.client import (
23
- WebSocketClientProtocol,
24
- connect,
23
+ from websockets.protocol import (
24
+ State,
25
25
  )
26
26
 
27
27
  from web3.exceptions import (
@@ -59,10 +59,10 @@ class WebSocketProvider(PersistentConnectionProvider):
59
59
 
60
60
  def __init__(
61
61
  self,
62
- endpoint_uri: Optional[Union[URI, str]] = None,
63
- websocket_kwargs: Optional[Dict[str, Any]] = None,
62
+ endpoint_uri: URI | str | None = None,
63
+ websocket_kwargs: dict[str, Any] | None = None,
64
64
  # uses binary frames by default
65
- use_text_frames: Optional[bool] = False,
65
+ use_text_frames: bool | None = False,
66
66
  # `PersistentConnectionProvider` kwargs can be passed through
67
67
  **kwargs: Any,
68
68
  ) -> None:
@@ -72,7 +72,7 @@ class WebSocketProvider(PersistentConnectionProvider):
72
72
  )
73
73
  super().__init__(**kwargs)
74
74
  self.use_text_frames = use_text_frames
75
- self._ws: Optional[WebSocketClientProtocol] = None
75
+ self._ws: ClientConnection | None = None
76
76
 
77
77
  if not any(
78
78
  self.endpoint_uri.startswith(prefix)
@@ -119,7 +119,7 @@ class WebSocketProvider(PersistentConnectionProvider):
119
119
  "Connection to websocket has not been initiated for the provider."
120
120
  )
121
121
 
122
- payload: Union[bytes, str] = request_data
122
+ payload: bytes | str = request_data
123
123
  if self.use_text_frames:
124
124
  payload = request_data.decode("utf-8")
125
125
 
@@ -134,9 +134,12 @@ class WebSocketProvider(PersistentConnectionProvider):
134
134
  async def _provider_specific_connect(self) -> None:
135
135
  self._ws = await connect(self.endpoint_uri, **self.websocket_kwargs)
136
136
 
137
+ def is_open(self) -> bool:
138
+ return self._ws.state == State.OPEN
139
+
137
140
  async def _provider_specific_disconnect(self) -> None:
138
141
  # this should remain idempotent
139
- if self._ws is not None and not self._ws.closed:
142
+ if self._ws is not None and self.is_open():
140
143
  await self._ws.close()
141
144
  self._ws = None
142
145
 
@@ -2,12 +2,7 @@ import asyncio
2
2
  import logging
3
3
  from typing import (
4
4
  Any,
5
- Dict,
6
5
  Iterable,
7
- List,
8
- Optional,
9
- Tuple,
10
- Union,
11
6
  cast,
12
7
  )
13
8
 
@@ -60,11 +55,10 @@ class AsyncHTTPProvider(AsyncJSONBaseProvider):
60
55
 
61
56
  def __init__(
62
57
  self,
63
- endpoint_uri: Optional[Union[URI, str]] = None,
64
- request_kwargs: Optional[Any] = None,
65
- exception_retry_configuration: Optional[
66
- Union[ExceptionRetryConfiguration, Empty]
67
- ] = empty,
58
+ endpoint_uri: URI | str | None = None,
59
+ request_kwargs: Any | None = None,
60
+ exception_retry_configuration: None
61
+ | (ExceptionRetryConfiguration | Empty) = empty,
68
62
  **kwargs: Any,
69
63
  ) -> None:
70
64
  self._request_session_manager = HTTPSessionManager()
@@ -99,18 +93,18 @@ class AsyncHTTPProvider(AsyncJSONBaseProvider):
99
93
 
100
94
  @exception_retry_configuration.setter
101
95
  def exception_retry_configuration(
102
- self, value: Union[ExceptionRetryConfiguration, Empty]
96
+ self, value: ExceptionRetryConfiguration | Empty
103
97
  ) -> None:
104
98
  self._exception_retry_configuration = value
105
99
 
106
100
  @to_dict
107
- def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:
101
+ def get_request_kwargs(self) -> Iterable[tuple[str, Any]]:
108
102
  if "headers" not in self._request_kwargs:
109
103
  yield "headers", self.get_request_headers()
110
104
  yield from self._request_kwargs.items()
111
105
 
112
106
  @combomethod
113
- def get_request_headers(cls) -> Dict[str, str]:
107
+ def get_request_headers(cls) -> dict[str, str]:
114
108
  if isinstance(cls, AsyncHTTPProvider):
115
109
  cls_name = cls.__class__.__name__
116
110
  else:
@@ -169,8 +163,8 @@ class AsyncHTTPProvider(AsyncJSONBaseProvider):
169
163
  return response
170
164
 
171
165
  async def make_batch_request(
172
- self, batch_requests: List[Tuple[RPCEndpoint, Any]]
173
- ) -> Union[List[RPCResponse], RPCResponse]:
166
+ self, batch_requests: list[tuple[RPCEndpoint, Any]]
167
+ ) -> list[RPCResponse] | RPCResponse:
174
168
  self.logger.debug("Making batch request HTTP - uri: `%s`", self.endpoint_uri)
175
169
  request_data = self.encode_batch_rpc_request(batch_requests)
176
170
  raw_response = await self._request_session_manager.async_make_post_request(
@@ -182,7 +176,7 @@ class AsyncHTTPProvider(AsyncJSONBaseProvider):
182
176
  # RPC errors return only one response with the error object
183
177
  return response
184
178
  return sort_batch_response_by_response_ids(
185
- cast(List[RPCResponse], sort_batch_response_by_response_ids(response))
179
+ cast(list[RPCResponse], sort_batch_response_by_response_ids(response))
186
180
  )
187
181
 
188
182
  async def disconnect(self) -> None:
web3/providers/rpc/rpc.py CHANGED
@@ -3,12 +3,7 @@ import time
3
3
  from typing import (
4
4
  TYPE_CHECKING,
5
5
  Any,
6
- Dict,
7
6
  Iterable,
8
- List,
9
- Optional,
10
- Tuple,
11
- Union,
12
7
  cast,
13
8
  )
14
9
 
@@ -63,18 +58,15 @@ class HTTPProvider(JSONBaseProvider):
63
58
 
64
59
  def __init__(
65
60
  self,
66
- endpoint_uri: Optional[Union[URI, str]] = None,
67
- request_kwargs: Optional[Any] = None,
68
- session: Optional[Any] = None,
69
- exception_retry_configuration: Optional[
70
- Union[ExceptionRetryConfiguration, Empty]
71
- ] = empty,
61
+ endpoint_uri: URI | str | None = None,
62
+ request_kwargs: Any | None = None,
63
+ session: Any | None = None,
64
+ exception_retry_configuration: None
65
+ | (ExceptionRetryConfiguration | Empty) = empty,
72
66
  **kwargs: Any,
73
67
  ) -> None:
74
68
  super().__init__(**kwargs)
75
- # Pass explicit session to manager so it's used for ALL requests,
76
- # regardless of which thread makes them
77
- self._request_session_manager = HTTPSessionManager(explicit_session=session)
69
+ self._request_session_manager = HTTPSessionManager()
78
70
 
79
71
  if endpoint_uri is None:
80
72
  self.endpoint_uri = (
@@ -86,6 +78,11 @@ class HTTPProvider(JSONBaseProvider):
86
78
  self._request_kwargs = request_kwargs or {}
87
79
  self._exception_retry_configuration = exception_retry_configuration
88
80
 
81
+ if session:
82
+ self._request_session_manager.cache_and_return_session(
83
+ self.endpoint_uri, session
84
+ )
85
+
89
86
  def __str__(self) -> str:
90
87
  return f"RPC connection {self.endpoint_uri}"
91
88
 
@@ -103,18 +100,18 @@ class HTTPProvider(JSONBaseProvider):
103
100
 
104
101
  @exception_retry_configuration.setter
105
102
  def exception_retry_configuration(
106
- self, value: Union[ExceptionRetryConfiguration, Empty]
103
+ self, value: ExceptionRetryConfiguration | Empty
107
104
  ) -> None:
108
105
  self._exception_retry_configuration = value
109
106
 
110
107
  @to_dict
111
- def get_request_kwargs(self) -> Iterable[Tuple[str, Any]]:
108
+ def get_request_kwargs(self) -> Iterable[tuple[str, Any]]:
112
109
  if "headers" not in self._request_kwargs:
113
110
  yield "headers", self.get_request_headers()
114
111
  yield from self._request_kwargs.items()
115
112
 
116
113
  @combomethod
117
- def get_request_headers(cls) -> Dict[str, str]:
114
+ def get_request_headers(cls) -> dict[str, str]:
118
115
  if isinstance(cls, HTTPProvider):
119
116
  cls_name = cls.__class__.__name__
120
117
  else:
@@ -174,8 +171,8 @@ class HTTPProvider(JSONBaseProvider):
174
171
  return response
175
172
 
176
173
  def make_batch_request(
177
- self, batch_requests: List[Tuple[RPCEndpoint, Any]]
178
- ) -> Union[List[RPCResponse], RPCResponse]:
174
+ self, batch_requests: list[tuple[RPCEndpoint, Any]]
175
+ ) -> list[RPCResponse] | RPCResponse:
179
176
  self.logger.debug("Making batch request HTTP, uri: `%s`", self.endpoint_uri)
180
177
  request_data = self.encode_batch_rpc_request(batch_requests)
181
178
  raw_response = self._request_session_manager.make_post_request(
@@ -187,5 +184,5 @@ class HTTPProvider(JSONBaseProvider):
187
184
  # RPC errors return only one response with the error object
188
185
  return response
189
186
  return sort_batch_response_by_response_ids(
190
- cast(List[RPCResponse], sort_batch_response_by_response_ids(response))
187
+ cast(list[RPCResponse], sort_batch_response_by_response_ids(response))
191
188
  )
@@ -1,6 +1,5 @@
1
1
  from typing import (
2
2
  Sequence,
3
- Type,
4
3
  )
5
4
 
6
5
  from pydantic import (
@@ -72,14 +71,14 @@ def check_if_retry_on_failure(
72
71
 
73
72
 
74
73
  class ExceptionRetryConfiguration(BaseModel):
75
- errors: Sequence[Type[BaseException]]
74
+ errors: Sequence[type[BaseException]]
76
75
  retries: int
77
76
  backoff_factor: float
78
77
  method_allowlist: Sequence[str]
79
78
 
80
79
  def __init__(
81
80
  self,
82
- errors: Sequence[Type[BaseException]] = None,
81
+ errors: Sequence[type[BaseException]] = None,
83
82
  retries: int = 5,
84
83
  backoff_factor: float = 0.125,
85
84
  method_allowlist: Sequence[str] = None,
@@ -5,9 +5,6 @@ import subprocess
5
5
  from tempfile import (
6
6
  TemporaryDirectory,
7
7
  )
8
- from typing import (
9
- Tuple,
10
- )
11
8
  import venv
12
9
 
13
10
 
@@ -33,7 +30,7 @@ def find_wheel(project_path: Path) -> Path:
33
30
 
34
31
 
35
32
  def install_wheel(
36
- venv_path: Path, wheel_path: Path, extras: Tuple[str, ...] = ()
33
+ venv_path: Path, wheel_path: Path, extras: tuple[str, ...] = ()
37
34
  ) -> None:
38
35
  if extras:
39
36
  extra_suffix = f"[{','.join(extras)}]"
web3/testing.py CHANGED
@@ -1,7 +1,3 @@
1
- from typing import (
2
- Optional,
3
- )
4
-
5
1
  from web3._utils.rpc_abi import (
6
2
  RPC,
7
3
  )
@@ -24,7 +20,7 @@ class Testing(Module):
24
20
  def reset(self) -> None:
25
21
  self.w3.manager.request_blocking(RPC.evm_reset, [])
26
22
 
27
- def revert(self, snapshot_idx: Optional[int] = None) -> None:
23
+ def revert(self, snapshot_idx: int | None = None) -> None:
28
24
  if snapshot_idx is None:
29
25
  revert_target = self.last_snapshot_idx
30
26
  else:
web3/tracing.py CHANGED
@@ -1,9 +1,5 @@
1
1
  from typing import (
2
2
  Callable,
3
- List,
4
- Optional,
5
- Tuple,
6
- Union,
7
3
  )
8
4
 
9
5
  from eth_typing import (
@@ -53,8 +49,8 @@ class Tracing(Module):
53
49
  self._default_block = value
54
50
 
55
51
  def trace_replay_transaction_munger(
56
- self, block_identifier: Union[_Hash32, BlockIdentifier], mode: TraceMode = None
57
- ) -> Tuple[Union[BlockIdentifier, _Hash32], TraceMode]:
52
+ self, block_identifier: _Hash32 | BlockIdentifier, mode: TraceMode = None
53
+ ) -> tuple[BlockIdentifier | _Hash32, TraceMode]:
58
54
  if mode is None:
59
55
  mode = ["trace"]
60
56
  return (block_identifier, mode)
@@ -64,21 +60,21 @@ class Tracing(Module):
64
60
  mungers=[trace_replay_transaction_munger],
65
61
  )
66
62
 
67
- trace_replay_block_transactions: Method[Callable[..., List[BlockTrace]]] = Method(
63
+ trace_replay_block_transactions: Method[Callable[..., list[BlockTrace]]] = Method(
68
64
  RPC.trace_replayBlockTransactions, mungers=[trace_replay_transaction_munger]
69
65
  )
70
66
 
71
- trace_block: Method[Callable[[BlockIdentifier], List[BlockTrace]]] = Method(
67
+ trace_block: Method[Callable[[BlockIdentifier], list[BlockTrace]]] = Method(
72
68
  RPC.trace_block,
73
69
  mungers=[default_root_munger],
74
70
  )
75
71
 
76
- trace_filter: Method[Callable[[TraceFilterParams], List[FilterTrace]]] = Method(
72
+ trace_filter: Method[Callable[[TraceFilterParams], list[FilterTrace]]] = Method(
77
73
  RPC.trace_filter,
78
74
  mungers=[default_root_munger],
79
75
  )
80
76
 
81
- trace_transaction: Method[Callable[[_Hash32], List[FilterTrace]]] = Method(
77
+ trace_transaction: Method[Callable[[_Hash32], list[FilterTrace]]] = Method(
82
78
  RPC.trace_transaction,
83
79
  mungers=[default_root_munger],
84
80
  )
@@ -87,8 +83,8 @@ class Tracing(Module):
87
83
  self,
88
84
  transaction: TxParams,
89
85
  mode: TraceMode = None,
90
- block_identifier: Optional[BlockIdentifier] = None,
91
- ) -> Tuple[TxParams, TraceMode, BlockIdentifier]:
86
+ block_identifier: BlockIdentifier | None = None,
87
+ ) -> tuple[TxParams, TraceMode, BlockIdentifier]:
92
88
  if mode is None:
93
89
  mode = ["trace"]
94
90
  if "from" not in transaction and is_checksum_address(
@@ -108,7 +104,7 @@ class Tracing(Module):
108
104
 
109
105
  def trace_transactions_munger(
110
106
  self, raw_transaction: HexStr, mode: TraceMode = None
111
- ) -> Tuple[HexStr, TraceMode]:
107
+ ) -> tuple[HexStr, TraceMode]:
112
108
  if mode is None:
113
109
  mode = ["trace"]
114
110
  return raw_transaction, mode
web3/types.py CHANGED
@@ -3,14 +3,10 @@ from typing import (
3
3
  Any,
4
4
  Callable,
5
5
  Coroutine,
6
- Dict,
7
- List,
8
6
  Literal,
9
7
  NewType,
10
8
  Optional,
11
9
  Sequence,
12
- Tuple,
13
- Type,
14
10
  TypedDict,
15
11
  TypeVar,
16
12
  Union,
@@ -58,7 +54,7 @@ BlockParams = Literal["latest", "earliest", "pending", "safe", "finalized"]
58
54
  BlockIdentifier = Union[BlockParams, BlockNumber, Hash32, HexStr, HexBytes, int]
59
55
  LatestBlockParam = Literal["latest"]
60
56
 
61
- ABIElementIdentifier = Union[str, Type[FallbackFn], Type[ReceiveFn]]
57
+ ABIElementIdentifier = Union[str, type[FallbackFn], type[ReceiveFn]]
62
58
 
63
59
  # bytes, hexbytes, or hexstr representing a 32 byte hash
64
60
  _Hash32 = Union[Hash32, HexBytes, HexStr]
@@ -82,7 +78,7 @@ RPCEndpoint = NewType("RPCEndpoint", str)
82
78
  Timestamp = NewType("Timestamp", int)
83
79
  Wei = NewType("Wei", int)
84
80
  Gwei = NewType("Gwei", int)
85
- Formatters = Dict[RPCEndpoint, Callable[..., Any]]
81
+ Formatters = dict[RPCEndpoint, Callable[..., Any]]
86
82
 
87
83
 
88
84
  class AccessListEntry(TypedDict):
@@ -95,7 +91,7 @@ AccessList = NewType("AccessList", Sequence[AccessListEntry])
95
91
 
96
92
  class EventData(TypedDict):
97
93
  address: ChecksumAddress
98
- args: Dict[str, Any]
94
+ args: dict[str, Any]
99
95
  blockHash: HexBytes
100
96
  blockNumber: int
101
97
  event: str
@@ -154,9 +150,9 @@ TxData = TypedDict(
154
150
 
155
151
  class SetCodeAuthorizationParams(TypedDict):
156
152
  chainId: int
157
- address: Union[Address, ChecksumAddress, str]
153
+ address: Address | ChecksumAddress | str
158
154
  nonce: Nonce
159
- yParity: int
155
+ y_parity: int
160
156
  r: int
161
157
  s: int
162
158
 
@@ -193,7 +189,7 @@ TxParams = TypedDict(
193
189
 
194
190
  class WithdrawalData(TypedDict):
195
191
  index: int
196
- validatorIndex: int
192
+ validator_index: int
197
193
  address: ChecksumAddress
198
194
  amount: Gwei
199
195
 
@@ -217,7 +213,7 @@ class BlockData(TypedDict, total=False):
217
213
  stateRoot: HexBytes
218
214
  timestamp: Timestamp
219
215
  totalDifficulty: int
220
- transactions: Union[Sequence[HexBytes], Sequence[TxData]]
216
+ transactions: Sequence[HexBytes] | Sequence[TxData]
221
217
  transactionsRoot: HexBytes
222
218
  uncles: Sequence[HexBytes]
223
219
  withdrawals: Sequence[WithdrawalData]
@@ -252,7 +248,7 @@ class BlockTypeSubscriptionResponse(SubscriptionResponse):
252
248
 
253
249
 
254
250
  class TransactionTypeSubscriptionResponse(SubscriptionResponse):
255
- result: Union[HexBytes, TxData]
251
+ result: HexBytes | TxData
256
252
 
257
253
 
258
254
  class LogsSubscriptionResponse(SubscriptionResponse):
@@ -267,7 +263,7 @@ class SyncProgress(TypedDict):
267
263
 
268
264
 
269
265
  class SyncingSubscriptionResponse(SubscriptionResponse):
270
- result: Union[Literal[False], SyncProgress]
266
+ result: Literal[False] | SyncProgress
271
267
 
272
268
 
273
269
  class GethSyncingStatus(TypedDict):
@@ -338,23 +334,23 @@ class CreateAccessListResponse(TypedDict):
338
334
 
339
335
  MakeRequestFn = Callable[[RPCEndpoint, Any], RPCResponse]
340
336
  MakeBatchRequestFn = Callable[
341
- [List[Tuple[RPCEndpoint, Any]]], Union[List[RPCResponse], RPCResponse]
337
+ [list[tuple[RPCEndpoint, Any]]], Union[list[RPCResponse], RPCResponse]
342
338
  ]
343
339
  AsyncMakeRequestFn = Callable[[RPCEndpoint, Any], Coroutine[Any, Any, RPCResponse]]
344
340
  AsyncMakeBatchRequestFn = Callable[
345
- [List[Tuple[RPCEndpoint, Any]]],
346
- Coroutine[Any, Any, Union[List[RPCResponse], RPCResponse]],
341
+ [list[tuple[RPCEndpoint, Any]]],
342
+ Coroutine[Any, Any, Union[list[RPCResponse], RPCResponse]],
347
343
  ]
348
344
 
349
345
 
350
346
  class FormattersDict(TypedDict, total=False):
351
- error_formatters: Optional[Formatters]
352
- request_formatters: Optional[Formatters]
353
- result_formatters: Optional[Formatters]
347
+ error_formatters: Formatters | None
348
+ request_formatters: Formatters | None
349
+ result_formatters: Formatters | None
354
350
 
355
351
 
356
352
  class FilterParams(TypedDict, total=False):
357
- address: Union[Address, ChecksumAddress, List[Address], List[ChecksumAddress]]
353
+ address: Address | ChecksumAddress | list[Address] | list[ChecksumAddress]
358
354
  blockHash: HexBytes
359
355
  fromBlock: BlockIdentifier
360
356
  toBlock: BlockIdentifier
@@ -362,21 +358,21 @@ class FilterParams(TypedDict, total=False):
362
358
 
363
359
 
364
360
  class FeeHistory(TypedDict):
365
- baseFeePerGas: List[Wei]
366
- gasUsedRatio: List[float]
361
+ baseFeePerGas: list[Wei]
362
+ gasUsedRatio: list[float]
367
363
  oldestBlock: BlockNumber
368
- reward: List[List[Wei]]
364
+ reward: list[list[Wei]]
369
365
 
370
366
 
371
367
  class StateOverrideParams(TypedDict, total=False):
372
- balance: Optional[Wei]
373
- nonce: Optional[int]
374
- code: Optional[Union[bytes, HexStr]]
375
- state: Optional[Dict[HexStr, HexStr]]
376
- stateDiff: Optional[Dict[HexStr, HexStr]]
368
+ balance: Wei | None
369
+ nonce: int | None
370
+ code: bytes | HexStr | None
371
+ state: dict[HexStr, HexStr] | None
372
+ stateDiff: dict[HexStr, HexStr] | None
377
373
 
378
374
 
379
- StateOverride = Dict[Union[str, Address, ChecksumAddress], StateOverrideParams]
375
+ StateOverride = dict[Union[str, Address, ChecksumAddress], StateOverrideParams]
380
376
 
381
377
 
382
378
  GasPriceStrategy = Union[
@@ -395,7 +391,7 @@ TxReceipt = TypedDict(
395
391
  "effectiveGasPrice": Wei,
396
392
  "gasUsed": int,
397
393
  "from": ChecksumAddress,
398
- "logs": List[LogReceipt],
394
+ "logs": list[LogReceipt],
399
395
  "logsBloom": HexBytes,
400
396
  "root": HexStr,
401
397
  "status": int,
@@ -406,7 +402,7 @@ TxReceipt = TypedDict(
406
402
  },
407
403
  )
408
404
 
409
- BlockReceipts = List[TxReceipt]
405
+ BlockReceipts = list[TxReceipt]
410
406
 
411
407
 
412
408
  class SignedTx(TypedDict, total=False):
@@ -443,16 +439,16 @@ class NodeInfo(TypedDict):
443
439
  ip: str
444
440
  listenAddr: str
445
441
  name: str
446
- ports: Dict[str, int]
447
- protocols: Dict[str, Protocol]
442
+ ports: dict[str, int]
443
+ protocols: dict[str, Protocol]
448
444
 
449
445
 
450
446
  class Peer(TypedDict, total=False):
451
447
  caps: Sequence[str]
452
448
  id: HexStr
453
449
  name: str
454
- network: Dict[str, str]
455
- protocols: Dict[str, Protocol]
450
+ network: dict[str, str]
451
+ protocols: dict[str, Protocol]
456
452
 
457
453
 
458
454
  class SyncStatus(TypedDict):
@@ -515,13 +511,13 @@ PendingTx = TypedDict(
515
511
 
516
512
 
517
513
  class TxPoolContent(TypedDict, total=False):
518
- pending: Dict[ChecksumAddress, Dict[Nonce, List[PendingTx]]]
519
- queued: Dict[ChecksumAddress, Dict[Nonce, List[PendingTx]]]
514
+ pending: dict[ChecksumAddress, dict[Nonce, list[PendingTx]]]
515
+ queued: dict[ChecksumAddress, dict[Nonce, list[PendingTx]]]
520
516
 
521
517
 
522
518
  class TxPoolInspect(TypedDict, total=False):
523
- pending: Dict[ChecksumAddress, Dict[Nonce, str]]
524
- queued: Dict[ChecksumAddress, Dict[Nonce, str]]
519
+ pending: dict[ChecksumAddress, dict[Nonce, str]]
520
+ queued: dict[ChecksumAddress, dict[Nonce, str]]
525
521
 
526
522
 
527
523
  class TxPoolStatus(TypedDict, total=False):
@@ -538,7 +534,7 @@ class TraceConfig(TypedDict, total=False):
538
534
  enableMemory: bool
539
535
  enableReturnData: bool
540
536
  tracer: str
541
- tracerConfig: Dict[str, Any]
537
+ tracerConfig: dict[str, Any]
542
538
  timeout: int
543
539
 
544
540
 
@@ -574,21 +570,21 @@ class TraceData(TypedDict, total=False):
574
570
  balance: int
575
571
  nonce: int
576
572
  code: str
577
- storage: Dict[str, str]
573
+ storage: dict[str, str]
578
574
 
579
575
 
580
576
  class DiffModeTrace(TypedDict):
581
- post: Dict[ChecksumAddress, TraceData]
582
- pre: Dict[ChecksumAddress, TraceData]
577
+ post: dict[ChecksumAddress, TraceData]
578
+ pre: dict[ChecksumAddress, TraceData]
583
579
 
584
580
 
585
- PrestateTrace = Dict[ChecksumAddress, TraceData]
581
+ PrestateTrace = dict[ChecksumAddress, TraceData]
586
582
 
587
583
 
588
584
  # 4byte tracer returns something like:
589
585
  # { '0x27dc297e-128' : 1 }
590
586
  # which is: { 4byte signature - calldata size : # of occurrences of key }
591
- FourByteTrace = Dict[str, int]
587
+ FourByteTrace = dict[str, int]
592
588
 
593
589
 
594
590
  class StructLog(TypedDict):
@@ -597,14 +593,14 @@ class StructLog(TypedDict):
597
593
  gas: int
598
594
  gasCost: int
599
595
  depth: int
600
- stack: List[HexStr]
596
+ stack: list[HexStr]
601
597
 
602
598
 
603
599
  class OpcodeTrace(TypedDict, total=False):
604
600
  gas: int
605
601
  failed: bool
606
602
  returnValue: str
607
- structLogs: List[StructLog]
603
+ structLogs: list[StructLog]
608
604
 
609
605
 
610
606
  class BlockStateCallV1(TypedDict):
@@ -637,7 +633,7 @@ class SimulateV1Result(BlockData):
637
633
 
638
634
 
639
635
  class GethWallet(TypedDict):
640
- accounts: Sequence[Dict[str, str]]
636
+ accounts: Sequence[dict[str, str]]
641
637
  status: str
642
638
  url: str
643
639
 
@@ -649,17 +645,17 @@ TContractEvent = TypeVar("TContractEvent", bound="BaseContractEvent")
649
645
 
650
646
 
651
647
  # Tracing types
652
- BlockTrace = NewType("BlockTrace", Dict[str, Any])
653
- FilterTrace = NewType("FilterTrace", Dict[str, Any])
648
+ BlockTrace = NewType("BlockTrace", dict[str, Any])
649
+ FilterTrace = NewType("FilterTrace", dict[str, Any])
654
650
  TraceMode = Sequence[Literal["trace", "vmTrace", "stateDiff"]]
655
651
 
656
652
 
657
653
  class TraceFilterParams(TypedDict, total=False):
658
654
  after: int
659
655
  count: int
660
- fromAddress: Sequence[Union[Address, ChecksumAddress, ENS]]
656
+ fromAddress: Sequence[Address | ChecksumAddress | ENS]
661
657
  fromBlock: BlockIdentifier
662
- toAddress: Sequence[Union[Address, ChecksumAddress, ENS]]
658
+ toAddress: Sequence[Address | ChecksumAddress | ENS]
663
659
  toBlock: BlockIdentifier
664
660
 
665
661
 
@@ -674,10 +670,7 @@ SubscriptionType = Literal[
674
670
 
675
671
 
676
672
  class LogsSubscriptionArg(TypedDict, total=False):
677
- address: Union[
678
- Address,
679
- ChecksumAddress,
680
- ENS,
681
- Sequence[Union[Address, ChecksumAddress, ENS]],
682
- ]
673
+ address: (
674
+ Address | ChecksumAddress | ENS | Sequence[Address | ChecksumAddress | ENS]
675
+ )
683
676
  topics: Sequence[TopicFilter]