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
|
@@ -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.
|
|
23
|
-
|
|
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:
|
|
63
|
-
websocket_kwargs:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
142
|
+
if self._ws is not None and self.is_open():
|
|
140
143
|
await self._ws.close()
|
|
141
144
|
self._ws = None
|
|
142
145
|
|
web3/providers/rpc/async_rpc.py
CHANGED
|
@@ -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:
|
|
64
|
-
request_kwargs:
|
|
65
|
-
exception_retry_configuration:
|
|
66
|
-
|
|
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:
|
|
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[
|
|
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) ->
|
|
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:
|
|
173
|
-
) ->
|
|
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(
|
|
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,12 +58,11 @@ class HTTPProvider(JSONBaseProvider):
|
|
|
63
58
|
|
|
64
59
|
def __init__(
|
|
65
60
|
self,
|
|
66
|
-
endpoint_uri:
|
|
67
|
-
request_kwargs:
|
|
68
|
-
session:
|
|
69
|
-
exception_retry_configuration:
|
|
70
|
-
|
|
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)
|
|
@@ -106,18 +100,18 @@ class HTTPProvider(JSONBaseProvider):
|
|
|
106
100
|
|
|
107
101
|
@exception_retry_configuration.setter
|
|
108
102
|
def exception_retry_configuration(
|
|
109
|
-
self, value:
|
|
103
|
+
self, value: ExceptionRetryConfiguration | Empty
|
|
110
104
|
) -> None:
|
|
111
105
|
self._exception_retry_configuration = value
|
|
112
106
|
|
|
113
107
|
@to_dict
|
|
114
|
-
def get_request_kwargs(self) -> Iterable[
|
|
108
|
+
def get_request_kwargs(self) -> Iterable[tuple[str, Any]]:
|
|
115
109
|
if "headers" not in self._request_kwargs:
|
|
116
110
|
yield "headers", self.get_request_headers()
|
|
117
111
|
yield from self._request_kwargs.items()
|
|
118
112
|
|
|
119
113
|
@combomethod
|
|
120
|
-
def get_request_headers(cls) ->
|
|
114
|
+
def get_request_headers(cls) -> dict[str, str]:
|
|
121
115
|
if isinstance(cls, HTTPProvider):
|
|
122
116
|
cls_name = cls.__class__.__name__
|
|
123
117
|
else:
|
|
@@ -177,8 +171,8 @@ class HTTPProvider(JSONBaseProvider):
|
|
|
177
171
|
return response
|
|
178
172
|
|
|
179
173
|
def make_batch_request(
|
|
180
|
-
self, batch_requests:
|
|
181
|
-
) ->
|
|
174
|
+
self, batch_requests: list[tuple[RPCEndpoint, Any]]
|
|
175
|
+
) -> list[RPCResponse] | RPCResponse:
|
|
182
176
|
self.logger.debug("Making batch request HTTP, uri: `%s`", self.endpoint_uri)
|
|
183
177
|
request_data = self.encode_batch_rpc_request(batch_requests)
|
|
184
178
|
raw_response = self._request_session_manager.make_post_request(
|
|
@@ -190,5 +184,5 @@ class HTTPProvider(JSONBaseProvider):
|
|
|
190
184
|
# RPC errors return only one response with the error object
|
|
191
185
|
return response
|
|
192
186
|
return sort_batch_response_by_response_ids(
|
|
193
|
-
cast(
|
|
187
|
+
cast(list[RPCResponse], sort_batch_response_by_response_ids(response))
|
|
194
188
|
)
|
web3/providers/rpc/utils.py
CHANGED
|
@@ -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[
|
|
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[
|
|
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:
|
|
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:
|
|
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:
|
|
57
|
-
) ->
|
|
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[...,
|
|
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],
|
|
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],
|
|
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],
|
|
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:
|
|
91
|
-
) ->
|
|
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
|
-
) ->
|
|
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,
|
|
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 =
|
|
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:
|
|
94
|
+
args: dict[str, Any]
|
|
99
95
|
blockHash: HexBytes
|
|
100
96
|
blockNumber: int
|
|
101
97
|
event: str
|
|
@@ -154,7 +150,7 @@ TxData = TypedDict(
|
|
|
154
150
|
|
|
155
151
|
class SetCodeAuthorizationParams(TypedDict):
|
|
156
152
|
chainId: int
|
|
157
|
-
address:
|
|
153
|
+
address: Address | ChecksumAddress | str
|
|
158
154
|
nonce: Nonce
|
|
159
155
|
y_parity: int
|
|
160
156
|
r: int
|
|
@@ -217,7 +213,7 @@ class BlockData(TypedDict, total=False):
|
|
|
217
213
|
stateRoot: HexBytes
|
|
218
214
|
timestamp: Timestamp
|
|
219
215
|
totalDifficulty: int
|
|
220
|
-
transactions:
|
|
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:
|
|
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:
|
|
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
|
-
[
|
|
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
|
-
[
|
|
346
|
-
Coroutine[Any, Any, Union[
|
|
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:
|
|
352
|
-
request_formatters:
|
|
353
|
-
result_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:
|
|
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:
|
|
366
|
-
gasUsedRatio:
|
|
361
|
+
baseFeePerGas: list[Wei]
|
|
362
|
+
gasUsedRatio: list[float]
|
|
367
363
|
oldestBlock: BlockNumber
|
|
368
|
-
reward:
|
|
364
|
+
reward: list[list[Wei]]
|
|
369
365
|
|
|
370
366
|
|
|
371
367
|
class StateOverrideParams(TypedDict, total=False):
|
|
372
|
-
balance:
|
|
373
|
-
nonce:
|
|
374
|
-
code:
|
|
375
|
-
state:
|
|
376
|
-
stateDiff:
|
|
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 =
|
|
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":
|
|
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 =
|
|
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:
|
|
447
|
-
protocols:
|
|
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:
|
|
455
|
-
protocols:
|
|
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:
|
|
519
|
-
queued:
|
|
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:
|
|
524
|
-
queued:
|
|
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:
|
|
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:
|
|
573
|
+
storage: dict[str, str]
|
|
578
574
|
|
|
579
575
|
|
|
580
576
|
class DiffModeTrace(TypedDict):
|
|
581
|
-
post:
|
|
582
|
-
pre:
|
|
577
|
+
post: dict[ChecksumAddress, TraceData]
|
|
578
|
+
pre: dict[ChecksumAddress, TraceData]
|
|
583
579
|
|
|
584
580
|
|
|
585
|
-
PrestateTrace =
|
|
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 =
|
|
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:
|
|
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:
|
|
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[
|
|
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",
|
|
653
|
-
FilterTrace = NewType("FilterTrace",
|
|
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[
|
|
656
|
+
fromAddress: Sequence[Address | ChecksumAddress | ENS]
|
|
661
657
|
fromBlock: BlockIdentifier
|
|
662
|
-
toAddress: Sequence[
|
|
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:
|
|
678
|
-
Address
|
|
679
|
-
|
|
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]
|