web3 7.0.0b7__py3-none-any.whl → 7.0.0b9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ens/async_ens.py +16 -7
- ens/base_ens.py +3 -1
- ens/exceptions.py +2 -7
- ens/utils.py +0 -17
- web3/_utils/abi.py +100 -257
- web3/_utils/compat/__init__.py +1 -0
- web3/_utils/contracts.py +116 -205
- web3/_utils/encoding.py +4 -5
- web3/_utils/events.py +28 -33
- web3/_utils/fee_utils.py +2 -2
- web3/_utils/filters.py +2 -5
- web3/_utils/http_session_manager.py +30 -7
- web3/_utils/method_formatters.py +21 -3
- web3/_utils/module_testing/eth_module.py +61 -39
- web3/_utils/module_testing/module_testing_utils.py +51 -10
- web3/_utils/module_testing/persistent_connection_provider.py +46 -16
- web3/_utils/module_testing/web3_module.py +8 -8
- web3/_utils/normalizers.py +10 -8
- web3/_utils/validation.py +5 -7
- web3/contract/async_contract.py +18 -17
- web3/contract/base_contract.py +116 -80
- web3/contract/contract.py +16 -17
- web3/contract/utils.py +86 -55
- web3/eth/async_eth.py +1 -2
- web3/eth/eth.py +1 -2
- web3/exceptions.py +28 -9
- web3/gas_strategies/time_based.py +4 -0
- web3/manager.py +68 -23
- web3/middleware/filter.py +3 -3
- web3/middleware/signing.py +6 -1
- web3/module.py +1 -1
- web3/providers/persistent/async_ipc.py +34 -79
- web3/providers/persistent/persistent.py +76 -7
- web3/providers/persistent/persistent_connection.py +47 -5
- web3/providers/persistent/websocket.py +19 -59
- web3/types.py +5 -45
- web3/utils/__init__.py +48 -4
- web3/utils/abi.py +575 -10
- web3/utils/caching.py +24 -0
- {web3-7.0.0b7.dist-info → web3-7.0.0b9.dist-info}/METADATA +14 -8
- {web3-7.0.0b7.dist-info → web3-7.0.0b9.dist-info}/RECORD +45 -50
- {web3-7.0.0b7.dist-info → web3-7.0.0b9.dist-info}/WHEEL +1 -1
- web3/tools/benchmark/__init__.py +0 -0
- web3/tools/benchmark/main.py +0 -190
- web3/tools/benchmark/node.py +0 -120
- web3/tools/benchmark/reporting.py +0 -39
- web3/tools/benchmark/utils.py +0 -69
- /web3/_utils/{function_identifiers.py → abi_element_identifiers.py} +0 -0
- {web3-7.0.0b7.dist-info → web3-7.0.0b9.dist-info}/LICENSE +0 -0
- {web3-7.0.0b7.dist-info → web3-7.0.0b9.dist-info}/top_level.txt +0 -0
|
@@ -5,11 +5,8 @@ import os
|
|
|
5
5
|
from typing import (
|
|
6
6
|
Any,
|
|
7
7
|
Dict,
|
|
8
|
-
List,
|
|
9
8
|
Optional,
|
|
10
|
-
Tuple,
|
|
11
9
|
Union,
|
|
12
|
-
cast,
|
|
13
10
|
)
|
|
14
11
|
|
|
15
12
|
from eth_typing import (
|
|
@@ -25,17 +22,12 @@ from websockets.client import (
|
|
|
25
22
|
connect,
|
|
26
23
|
)
|
|
27
24
|
from websockets.exceptions import (
|
|
25
|
+
ConnectionClosedOK,
|
|
28
26
|
WebSocketException,
|
|
29
27
|
)
|
|
30
28
|
|
|
31
|
-
from web3._utils.batching import (
|
|
32
|
-
BATCH_REQUEST_ID,
|
|
33
|
-
sort_batch_response_by_response_ids,
|
|
34
|
-
)
|
|
35
|
-
from web3._utils.caching import (
|
|
36
|
-
async_handle_request_caching,
|
|
37
|
-
)
|
|
38
29
|
from web3.exceptions import (
|
|
30
|
+
PersistentConnectionClosedOK,
|
|
39
31
|
ProviderConnectionError,
|
|
40
32
|
Web3ValidationError,
|
|
41
33
|
)
|
|
@@ -43,7 +35,6 @@ from web3.providers.persistent import (
|
|
|
43
35
|
PersistentConnectionProvider,
|
|
44
36
|
)
|
|
45
37
|
from web3.types import (
|
|
46
|
-
RPCEndpoint,
|
|
47
38
|
RPCResponse,
|
|
48
39
|
)
|
|
49
40
|
|
|
@@ -122,18 +113,7 @@ class WebSocketProvider(PersistentConnectionProvider):
|
|
|
122
113
|
) from e
|
|
123
114
|
return False
|
|
124
115
|
|
|
125
|
-
async def
|
|
126
|
-
self._ws = await connect(self.endpoint_uri, **self.websocket_kwargs)
|
|
127
|
-
|
|
128
|
-
async def _provider_specific_disconnect(self) -> None:
|
|
129
|
-
if self._ws is not None and not self._ws.closed:
|
|
130
|
-
await self._ws.close()
|
|
131
|
-
self._ws = None
|
|
132
|
-
|
|
133
|
-
@async_handle_request_caching
|
|
134
|
-
async def make_request(self, method: RPCEndpoint, params: Any) -> RPCResponse:
|
|
135
|
-
request_data = self.encode_rpc_request(method, params)
|
|
136
|
-
|
|
116
|
+
async def socket_send(self, request_data: bytes) -> None:
|
|
137
117
|
if self._ws is None:
|
|
138
118
|
raise ProviderConnectionError(
|
|
139
119
|
"Connection to websocket has not been initiated for the provider."
|
|
@@ -143,44 +123,24 @@ class WebSocketProvider(PersistentConnectionProvider):
|
|
|
143
123
|
self._ws.send(request_data), timeout=self.request_timeout
|
|
144
124
|
)
|
|
145
125
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return response
|
|
126
|
+
async def socket_recv(self) -> RPCResponse:
|
|
127
|
+
raw_response = await self._ws.recv()
|
|
128
|
+
return json.loads(raw_response)
|
|
150
129
|
|
|
151
|
-
|
|
152
|
-
self, requests: List[Tuple[RPCEndpoint, Any]]
|
|
153
|
-
) -> List[RPCResponse]:
|
|
154
|
-
request_data = self.encode_batch_rpc_request(requests)
|
|
130
|
+
# -- private methods -- #
|
|
155
131
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"Connection to websocket has not been initiated for the provider."
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
await asyncio.wait_for(
|
|
162
|
-
self._ws.send(request_data), timeout=self.request_timeout
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
response = cast(
|
|
166
|
-
List[RPCResponse],
|
|
167
|
-
await self._get_response_for_request_id(BATCH_REQUEST_ID),
|
|
168
|
-
)
|
|
169
|
-
return response
|
|
170
|
-
|
|
171
|
-
async def _provider_specific_message_listener(self) -> None:
|
|
172
|
-
async for raw_message in self._ws:
|
|
173
|
-
await asyncio.sleep(0)
|
|
132
|
+
async def _provider_specific_connect(self) -> None:
|
|
133
|
+
self._ws = await connect(self.endpoint_uri, **self.websocket_kwargs)
|
|
174
134
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
135
|
+
async def _provider_specific_disconnect(self) -> None:
|
|
136
|
+
if self._ws is not None and not self._ws.closed:
|
|
137
|
+
await self._ws.close()
|
|
138
|
+
self._ws = None
|
|
178
139
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
response, subscription=subscription
|
|
140
|
+
async def _provider_specific_socket_reader(self) -> RPCResponse:
|
|
141
|
+
try:
|
|
142
|
+
return await self.socket_recv()
|
|
143
|
+
except ConnectionClosedOK:
|
|
144
|
+
raise PersistentConnectionClosedOK(
|
|
145
|
+
user_message="WebSocket connection received `ConnectionClosedOK`."
|
|
186
146
|
)
|
web3/types.py
CHANGED
|
@@ -27,13 +27,13 @@ from hexbytes import (
|
|
|
27
27
|
HexBytes,
|
|
28
28
|
)
|
|
29
29
|
|
|
30
|
-
from web3._utils.
|
|
31
|
-
NotRequired,
|
|
32
|
-
)
|
|
33
|
-
from web3._utils.function_identifiers import (
|
|
30
|
+
from web3._utils.abi_element_identifiers import (
|
|
34
31
|
FallbackFn,
|
|
35
32
|
ReceiveFn,
|
|
36
33
|
)
|
|
34
|
+
from web3._utils.compat import (
|
|
35
|
+
NotRequired,
|
|
36
|
+
)
|
|
37
37
|
|
|
38
38
|
if TYPE_CHECKING:
|
|
39
39
|
from web3.contract.async_contract import AsyncContractFunction # noqa: F401
|
|
@@ -53,7 +53,7 @@ BlockParams = Literal["latest", "earliest", "pending", "safe", "finalized"]
|
|
|
53
53
|
BlockIdentifier = Union[BlockParams, BlockNumber, Hash32, HexStr, HexBytes, int]
|
|
54
54
|
LatestBlockParam = Literal["latest"]
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
ABIElementIdentifier = Union[str, Type[FallbackFn], Type[ReceiveFn]]
|
|
57
57
|
|
|
58
58
|
# bytes, hexbytes, or hexstr representing a 32 byte hash
|
|
59
59
|
_Hash32 = Union[Hash32, HexBytes, HexStr]
|
|
@@ -75,46 +75,6 @@ class AccessListEntry(TypedDict):
|
|
|
75
75
|
AccessList = NewType("AccessList", Sequence[AccessListEntry])
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
# todo: move these to eth_typing once web3 is type hinted
|
|
79
|
-
class ABIEventParams(TypedDict, total=False):
|
|
80
|
-
indexed: bool
|
|
81
|
-
name: str
|
|
82
|
-
type: str
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
class ABIEvent(TypedDict, total=False):
|
|
86
|
-
anonymous: bool
|
|
87
|
-
inputs: Sequence["ABIEventParams"]
|
|
88
|
-
name: str
|
|
89
|
-
type: Literal["event"]
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
class ABIFunctionComponents(TypedDict, total=False):
|
|
93
|
-
components: Sequence["ABIFunctionComponents"]
|
|
94
|
-
name: str
|
|
95
|
-
type: str
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class ABIFunctionParams(TypedDict, total=False):
|
|
99
|
-
components: Sequence["ABIFunctionComponents"]
|
|
100
|
-
name: str
|
|
101
|
-
type: str
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
class ABIFunction(TypedDict, total=False):
|
|
105
|
-
constant: bool
|
|
106
|
-
inputs: Sequence["ABIFunctionParams"]
|
|
107
|
-
name: str
|
|
108
|
-
outputs: Sequence["ABIFunctionParams"]
|
|
109
|
-
payable: bool
|
|
110
|
-
stateMutability: Literal["pure", "view", "nonpayable", "payable"]
|
|
111
|
-
type: Literal["function", "constructor", "fallback", "receive"]
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
ABIElement = Union[ABIFunction, ABIEvent]
|
|
115
|
-
ABI = Sequence[Union[ABIFunction, ABIEvent]]
|
|
116
|
-
|
|
117
|
-
|
|
118
78
|
class EventData(TypedDict):
|
|
119
79
|
address: ChecksumAddress
|
|
120
80
|
args: Dict[str, Any]
|
web3/utils/__init__.py
CHANGED
|
@@ -3,11 +3,35 @@ NOTE: This is a public utility module. Any changes to these utility methods woul
|
|
|
3
3
|
classify as breaking changes.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from .abi import (
|
|
6
|
+
from eth_utils.abi import (
|
|
7
|
+
abi_to_signature,
|
|
8
|
+
collapse_if_tuple,
|
|
9
|
+
event_abi_to_log_topic,
|
|
10
|
+
event_signature_to_log_topic,
|
|
11
|
+
filter_abi_by_name,
|
|
12
|
+
filter_abi_by_type,
|
|
13
|
+
function_abi_to_4byte_selector,
|
|
14
|
+
function_signature_to_4byte_selector,
|
|
7
15
|
get_abi_input_names,
|
|
16
|
+
get_abi_input_types,
|
|
8
17
|
get_abi_output_names,
|
|
18
|
+
get_abi_output_types,
|
|
19
|
+
get_aligned_abi_inputs,
|
|
20
|
+
get_all_event_abis,
|
|
21
|
+
get_all_function_abis,
|
|
22
|
+
get_normalized_abi_inputs,
|
|
23
|
+
)
|
|
24
|
+
from .abi import ( # NOQA
|
|
25
|
+
check_if_arguments_can_be_encoded,
|
|
26
|
+
get_abi_element_info,
|
|
27
|
+
get_abi_element,
|
|
28
|
+
get_event_abi,
|
|
29
|
+
get_event_log_topics,
|
|
30
|
+
log_topic_to_bytes,
|
|
31
|
+
)
|
|
32
|
+
from .address import (
|
|
33
|
+
get_create_address,
|
|
9
34
|
)
|
|
10
|
-
from .address import get_create_address
|
|
11
35
|
from .async_exception_handling import (
|
|
12
36
|
async_handle_offchain_lookup,
|
|
13
37
|
)
|
|
@@ -19,10 +43,30 @@ from .exception_handling import (
|
|
|
19
43
|
)
|
|
20
44
|
|
|
21
45
|
__all__ = [
|
|
22
|
-
"
|
|
23
|
-
"
|
|
46
|
+
"abi_to_signature",
|
|
47
|
+
"collapse_if_tuple",
|
|
48
|
+
"event_abi_to_log_topic",
|
|
49
|
+
"event_signature_to_log_topic",
|
|
50
|
+
"filter_abi_by_name",
|
|
51
|
+
"filter_abi_by_type",
|
|
52
|
+
"function_abi_to_4byte_selector",
|
|
53
|
+
"function_signature_to_4byte_selector",
|
|
24
54
|
"get_abi_input_names",
|
|
55
|
+
"get_abi_input_types",
|
|
25
56
|
"get_abi_output_names",
|
|
57
|
+
"get_abi_output_types",
|
|
58
|
+
"get_aligned_abi_inputs",
|
|
59
|
+
"get_all_event_abis",
|
|
60
|
+
"get_all_function_abis",
|
|
61
|
+
"get_normalized_abi_inputs",
|
|
62
|
+
"check_if_arguments_can_be_encoded",
|
|
63
|
+
"get_abi_element_info",
|
|
64
|
+
"get_abi_element",
|
|
65
|
+
"get_event_abi",
|
|
66
|
+
"get_event_log_topics",
|
|
67
|
+
"log_topic_to_bytes",
|
|
26
68
|
"get_create_address",
|
|
69
|
+
"async_handle_offchain_lookup",
|
|
70
|
+
"SimpleCache",
|
|
27
71
|
"handle_offchain_lookup",
|
|
28
72
|
]
|