web3 6.19.0__py3-none-any.whl → 6.20.1__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.
web3/__init__.py CHANGED
@@ -1,6 +1,15 @@
1
1
  from eth_account import Account # noqa: E402
2
2
  import sys
3
3
 
4
+ from web3.providers import (
5
+ AsyncBaseProvider,
6
+ AutoProvider,
7
+ BaseProvider,
8
+ JSONBaseProvider,
9
+ PersistentConnectionProvider,
10
+ )
11
+
12
+
4
13
  if sys.version_info.major == 3 and sys.version_info.minor < 8:
5
14
  import pkg_resources
6
15
 
@@ -19,6 +28,7 @@ from web3.providers.async_rpc import ( # noqa: E402
19
28
  AsyncHTTPProvider,
20
29
  )
21
30
  from web3.providers.eth_tester import ( # noqa: E402
31
+ AsyncEthereumTesterProvider,
22
32
  EthereumTesterProvider,
23
33
  )
24
34
  from web3.providers.ipc import ( # noqa: E402
@@ -35,13 +45,21 @@ from web3.providers.websocket import ( # noqa: E402
35
45
 
36
46
  __all__ = [
37
47
  "__version__",
48
+ "Account",
49
+ # web3:
38
50
  "AsyncWeb3",
39
51
  "Web3",
52
+ # providers:
53
+ "AsyncBaseProvider",
54
+ "AsyncEthereumTesterProvider",
55
+ "AsyncHTTPProvider",
56
+ "AutoProvider",
57
+ "BaseProvider",
58
+ "EthereumTesterProvider",
40
59
  "HTTPProvider",
41
60
  "IPCProvider",
61
+ "JSONBaseProvider",
62
+ "PersistentConnectionProvider",
42
63
  "WebsocketProvider",
43
64
  "WebsocketProviderV2",
44
- "EthereumTesterProvider",
45
- "Account",
46
- "AsyncHTTPProvider",
47
65
  ]
@@ -1,6 +1,3 @@
1
- from collections import (
2
- deque,
3
- )
4
1
  import pytest
5
2
  import time
6
3
  from typing import (
@@ -9,6 +6,7 @@ from typing import (
9
6
  Collection,
10
7
  Dict,
11
8
  Generator,
9
+ Optional,
12
10
  Sequence,
13
11
  Union,
14
12
  )
@@ -35,6 +33,7 @@ from web3._utils.compat import (
35
33
  )
36
34
  from web3._utils.request import (
37
35
  async_cache_and_return_session,
36
+ asyncio,
38
37
  cache_and_return_session,
39
38
  )
40
39
  from web3.types import (
@@ -188,9 +187,13 @@ class WebsocketMessageStreamMock:
188
187
  closed: bool = False
189
188
 
190
189
  def __init__(
191
- self, messages: Collection[bytes] = None, raise_exception: Exception = None
190
+ self,
191
+ messages: Optional[Collection[bytes]] = None,
192
+ raise_exception: Optional[Exception] = None,
192
193
  ) -> None:
193
- self.messages = deque(messages) if messages else deque()
194
+ self.queue = asyncio.Queue() # type: ignore # py38 issue
195
+ for msg in messages or []:
196
+ self.queue.put_nowait(msg)
194
197
  self.raise_exception = raise_exception
195
198
 
196
199
  def __await__(self) -> Generator[Any, Any, "Self"]:
@@ -203,13 +206,13 @@ class WebsocketMessageStreamMock:
203
206
  return self
204
207
 
205
208
  async def __anext__(self) -> bytes:
209
+ return await self.recv()
210
+
211
+ async def recv(self) -> bytes:
206
212
  if self.raise_exception:
207
213
  raise self.raise_exception
208
214
 
209
- elif len(self.messages) == 0:
210
- raise StopAsyncIteration
211
-
212
- return self.messages.popleft()
215
+ return await self.queue.get()
213
216
 
214
217
  @staticmethod
215
218
  async def pong() -> Literal[False]:
@@ -8,6 +8,10 @@ from .base import (
8
8
  BaseProvider,
9
9
  JSONBaseProvider,
10
10
  )
11
+ from .eth_tester import (
12
+ AsyncEthereumTesterProvider,
13
+ EthereumTesterProvider,
14
+ )
11
15
  from .ipc import (
12
16
  IPCProvider,
13
17
  )
@@ -24,3 +28,18 @@ from .persistent import (
24
28
  from .auto import (
25
29
  AutoProvider,
26
30
  )
31
+
32
+ __all__ = [
33
+ "AsyncBaseProvider",
34
+ "AsyncEthereumTesterProvider",
35
+ "AsyncHTTPProvider",
36
+ "AutoProvider",
37
+ "BaseProvider",
38
+ "EthereumTesterProvider",
39
+ "HTTPProvider",
40
+ "IPCProvider",
41
+ "JSONBaseProvider",
42
+ "PersistentConnectionProvider",
43
+ "WebsocketProvider",
44
+ "WebsocketProviderV2",
45
+ ]
@@ -9,6 +9,7 @@ from typing import (
9
9
 
10
10
  from websockets import (
11
11
  ConnectionClosed,
12
+ ConnectionClosedOK,
12
13
  WebSocketClientProtocol,
13
14
  WebSocketException,
14
15
  )
@@ -142,6 +143,12 @@ class PersistentConnectionProvider(AsyncJSONBaseProvider, ABC):
142
143
  await asyncio.sleep(0)
143
144
  try:
144
145
  await self._provider_specific_message_listener()
146
+ except ConnectionClosedOK:
147
+ # RequestManager._ws_message_stream() will rethrow this exception and
148
+ # cause WebsocketConnection to stop the process_subscriptions() loop,
149
+ # or raise ConnectionClosedOK when recv() is called.
150
+ # see: https://github.com/ethereum/web3.py/pull/3424
151
+ raise
145
152
  except Exception as e:
146
153
  if not self.silence_listener_task_exceptions:
147
154
  raise e
@@ -184,10 +191,6 @@ class PersistentConnectionProvider(AsyncJSONBaseProvider, ABC):
184
191
  request_cache_key = generate_cache_key(request_id)
185
192
 
186
193
  while True:
187
- # check if an exception was recorded in the listener task and raise it
188
- # in the main loop if so
189
- self._handle_listener_task_exceptions()
190
-
191
194
  if request_cache_key in self._request_processor._request_response_cache:
192
195
  self.logger.debug(
193
196
  f"Popping response for id {request_id} from cache."
@@ -197,6 +200,9 @@ class PersistentConnectionProvider(AsyncJSONBaseProvider, ABC):
197
200
  )
198
201
  return popped_response
199
202
  else:
203
+ # check if an exception was recorded in the listener task and raise
204
+ # it in the main loop if so
205
+ self._handle_listener_task_exceptions()
200
206
  await asyncio.sleep(0)
201
207
 
202
208
  try:
@@ -136,9 +136,8 @@ class WebsocketProviderV2(PersistentConnectionProvider):
136
136
  return response
137
137
 
138
138
  async def _provider_specific_message_listener(self) -> None:
139
- async for raw_message in self._ws:
140
- await asyncio.sleep(0)
141
-
139
+ while True:
140
+ raw_message = await self._ws.recv()
142
141
  response = json.loads(raw_message)
143
142
  subscription = response.get("method") == "eth_subscription"
144
143
  await self._request_processor.cache_raw_response(
web3/types.py CHANGED
@@ -112,7 +112,33 @@ class ABIFunction(TypedDict, total=False):
112
112
  type: Literal["function", "constructor", "fallback", "receive"]
113
113
 
114
114
 
115
- ABIElement = Union[ABIFunction, ABIEvent]
115
+ class ABIComponent(TypedDict):
116
+ """
117
+ TypedDict representing an `ABIElement` component.
118
+ """
119
+
120
+ name: str
121
+ """Name of the component."""
122
+ type: str
123
+ """Type of the component."""
124
+ components: NotRequired[Sequence["ABIComponent"]]
125
+ """List of nested `ABI` components for ABI types."""
126
+
127
+
128
+ class ABIError(TypedDict):
129
+ """
130
+ TypedDict representing the `ABI` for an error.
131
+ """
132
+
133
+ type: Literal["error"]
134
+ """Type of the error."""
135
+ name: str
136
+ """Name of the error."""
137
+ inputs: NotRequired[Sequence["ABIComponent"]]
138
+ """Error input components."""
139
+
140
+
141
+ ABIElement = Union[ABIFunction, ABIEvent, ABIError]
116
142
  ABI = Sequence[Union[ABIFunction, ABIEvent]]
117
143
 
118
144
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: web3
3
- Version: 6.19.0
3
+ Version: 6.20.1
4
4
  Summary: web3.py
5
5
  Home-page: https://github.com/ethereum/web3.py
6
6
  Author: The Ethereum Foundation
@@ -114,7 +114,7 @@ ethpm/validation/manifest.py,sha256=fH4mnpfDZYuBRUWQtx5i0b4CBIErZ-AW7dVeHpYgrH4,
114
114
  ethpm/validation/misc.py,sha256=9E_GMyhfd_VX3yRXZ0mVlsE0xTFTx9n0fVN1KkNORb4,1072
115
115
  ethpm/validation/package.py,sha256=CowvdeSNUL7TWaGkuhr2AU_-oatyJ2fBVQwLUFchGH8,2317
116
116
  ethpm/validation/uri.py,sha256=JtNfDghEU-8yDoETIbEZnamlpFGF1fAQ-tdJQhqn7mg,4873
117
- web3/__init__.py,sha256=tieKn-7-iyxdwx_tI7eUGWBpSkawfI2_3pCnwh8PRP4,972
117
+ web3/__init__.py,sha256=mrHPtxA8F4eAAItRN97nLZmLbeBGd7IHCcJa2jtlGbk,1342
118
118
  web3/constants.py,sha256=eQLRQVMFPbgpOjjkPTMHkY-syncJuO-sPX5UrCSRjzQ,564
119
119
  web3/datastructures.py,sha256=5SuX36p-hGuiK3RwnG8yVsgROvkqzHdDKfTGSzghSy0,9234
120
120
  web3/exceptions.py,sha256=3c0uRBiKvRJCSQUALYDCjjsjcyqx_XJM4_oQBXKrBrs,7390
@@ -129,7 +129,7 @@ web3/pm.py,sha256=wE-W7zLrphOZfiAe2I95yHIbov8I1-hcVwbx7ymYCAk,21608
129
129
  web3/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
130
  web3/testing.py,sha256=X7rKGcuEbRCvwXlWuJOfzZvXHboIEeoK-bIWnF_zn1A,951
131
131
  web3/tracing.py,sha256=OBRKLfoSSstzUrk-oqkrbPYPTNGTaPX7-VO5iEt1FwY,2968
132
- web3/types.py,sha256=XgjIkEmknBBgW5yUPrW9BEkTjTY8RsKreP_j0cA5ap0,13034
132
+ web3/types.py,sha256=2A9RjWbG2UVeaG9MSO8sQi5BTRVtGY8epcxxn7o1vPA,13633
133
133
  web3/_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
134
134
  web3/_utils/abi.py,sha256=OOnpQSGVAPgbgCXcxGypmhMMj1tq27HXyqPYrTqkchU,30587
135
135
  web3/_utils/async_caching.py,sha256=2XnaKCHBTTDK6B2R_YZvjJqIRUpbMDIU1uYrq-Lcyp8,486
@@ -195,7 +195,7 @@ web3/_utils/module_testing/eth_module.py,sha256=JQ0XAF5GlvpHn3oeAi2DfltJdCZwHk7J
195
195
  web3/_utils/module_testing/go_ethereum_admin_module.py,sha256=_c-6SyzZkfAJ-7ySXUpw9FEr4cg-ShRdAGSAHWanCtY,3406
196
196
  web3/_utils/module_testing/go_ethereum_personal_module.py,sha256=KzYEcAs_6Ud_gbu6YMOC6HijTdNFiz-qogMCViedmY0,11536
197
197
  web3/_utils/module_testing/go_ethereum_txpool_module.py,sha256=5f8XL8-2x3keyGRaITxMQYl9oQzjgqGn8zobB-j9BPs,1176
198
- web3/_utils/module_testing/module_testing_utils.py,sha256=_BV5xITzHC6HkOL3GD6bCJ-vhEsPQt2iSpY9S_SWXYo,6290
198
+ web3/_utils/module_testing/module_testing_utils.py,sha256=_nqhDGaL9JwWrcLJlmnfUTHxzVJ7QPP9YSlpFbMY6jA,6383
199
199
  web3/_utils/module_testing/net_module.py,sha256=ifUTC-5fTcQbwpm0X09OdD5RSPnn00T8klFeYe8tTm4,1272
200
200
  web3/_utils/module_testing/persistent_connection_provider.py,sha256=2NFjp0ZShOt_D5gmcfrc2ua57mRyeFSZpkqtPgCNUgM,16620
201
201
  web3/_utils/module_testing/web3_module.py,sha256=Y4lYglg_kbrpfwGfjekv52h4B7DaWa3uS15KGrCKL7c,9613
@@ -237,13 +237,13 @@ web3/middleware/signing.py,sha256=ozgePUa-wJRLC2IXWqND45WSh_MFJSrdh8LsiZNDIC8,66
237
237
  web3/middleware/simulate_unmined_transaction.py,sha256=yWanxvM48UoIe3zD5JivMGzxfjXGUrMTG7PIL_o1nWk,1014
238
238
  web3/middleware/stalecheck.py,sha256=vFuNDkwpij0dBTYCefxdM9GRp5LedPR_oH9Shg6V10M,3739
239
239
  web3/middleware/validation.py,sha256=NHAJyXdpMR5Ec0pw_TzWdNkPJ0M4tSf6xW67Bt30CgY,4578
240
- web3/providers/__init__.py,sha256=sd6YwCYSwxBRj56OqAK4tX13sbF1k3mesThUM2MYLtg,417
240
+ web3/providers/__init__.py,sha256=YL93wkBt-uknmuWWXIcO8SvucDUgfcT3pbLTDH-ggu0,827
241
241
  web3/providers/async_base.py,sha256=ezQPXP8nXYzDQ4rt64Bd_HFhjB7oCX38hwQSGXHQ5pY,4423
242
242
  web3/providers/async_rpc.py,sha256=1tf72qPH8A3IW2ZJus9nORL-PfPgRtmj1YRFASVWyuM,2879
243
243
  web3/providers/auto.py,sha256=-dS_-2nhg2jOA432P0w3Ul3NUIso8rTl4uGUGo0XBw0,3447
244
244
  web3/providers/base.py,sha256=qASmfdhXhD2FSk2Uk8z-8NxVL4i42uJNoUlwRDzQpgI,4187
245
245
  web3/providers/ipc.py,sha256=xFWT6cY9emTnFMuIQFrmQ0DJMQSMoQtaztD7MTTVniI,6374
246
- web3/providers/persistent.py,sha256=L9Cgs3RxcUmplo3-mnDl9U0VlzMWfXZSVMWtWMjS0bY,8376
246
+ web3/providers/persistent.py,sha256=eSZy825cAV2beVNytcrmCMsjgoAzsa3G-nW00pI8F0M,8782
247
247
  web3/providers/rpc.py,sha256=w3XA8lhufp_tcGCqocRwi2DDt8j3fj0hoZGk0dfF0u0,2686
248
248
  web3/providers/eth_tester/__init__.py,sha256=J6wazY3hQySsUfpFgwCXbEMo-CGEZjRo11RCg4UXKmA,83
249
249
  web3/providers/eth_tester/defaults.py,sha256=Ri_WPJT8aumxwiZXwedkJ16H_gBkLsKqanlDLfeFqM8,14803
@@ -253,7 +253,7 @@ web3/providers/websocket/__init__.py,sha256=W5xi6NxUVaskom7k03vd2HCXSH8hXAob2ry-
253
253
  web3/providers/websocket/request_processor.py,sha256=kir6bkAWy6CQdBpNrk_8CB8GPsjXM42SXx7IYlAngqE,11653
254
254
  web3/providers/websocket/websocket.py,sha256=-U2-CGtqpysxZoFHsa-rBeZKjSRejqQSeb5Z12SzKwk,3929
255
255
  web3/providers/websocket/websocket_connection.py,sha256=_W3i_nF9NNRdSwFGwLsDCNXrrhlhV-NvmywX8vbuWvY,1104
256
- web3/providers/websocket/websocket_v2.py,sha256=HX-p1CATh2eA02H0vbKh33XQdahoiSp5RH8uUoXzndY,4402
256
+ web3/providers/websocket/websocket_v2.py,sha256=oVyNeUH7r-RFMy7whLFVRGKhhAC2GIvI6-q5NjlHmjQ,4391
257
257
  web3/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
258
258
  web3/scripts/release/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
259
259
  web3/scripts/release/test_package.py,sha256=DH0AryllcF4zfpWSd0NLPSQGHNoC-Qng5WYYbS5_4c8,1534
@@ -275,9 +275,9 @@ web3/utils/address.py,sha256=KC_IpEbixSCuMhaW6V2QCyyJTYKYGS9c8QtI9_aH7zQ,967
275
275
  web3/utils/async_exception_handling.py,sha256=gfLuzP7Y5rc21jZVjWEYAOZUMJkJd9CmsL297UKReow,3096
276
276
  web3/utils/caching.py,sha256=PgfuXiVgPYQuS0S89-jkNOJ3L2uTRt2MkVBvzMkaAXI,1770
277
277
  web3/utils/exception_handling.py,sha256=12xkzIqMAOx0Jcm6PYL98PmWlLPKFll0p9YoLGS_ZNg,3052
278
- web3-6.19.0.dist-info/LICENSE,sha256=ulnXiEqqFp9VyWe8yMFdtDi70RMBJk3mpY3FKujv6l8,1090
279
- web3-6.19.0.dist-info/METADATA,sha256=x0ZZ5THuZWBU5i5JndaNJpnoYMemRUafzsdYa5bVOaA,4522
280
- web3-6.19.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
281
- web3-6.19.0.dist-info/entry_points.txt,sha256=2qjzGxFUlYBzoP68fcB3AJyMRunWI70uBoxNp17Brb0,64
282
- web3-6.19.0.dist-info/top_level.txt,sha256=5lRZg30BFUrz8eUK60C7OAjNT3FI4YsGmA-vZ0WIOik,15
283
- web3-6.19.0.dist-info/RECORD,,
278
+ web3-6.20.1.dist-info/LICENSE,sha256=ulnXiEqqFp9VyWe8yMFdtDi70RMBJk3mpY3FKujv6l8,1090
279
+ web3-6.20.1.dist-info/METADATA,sha256=K93RrvWgbsuK4K0iLwy9GN6DQ93oRcGPJaDW2ma7fgk,4522
280
+ web3-6.20.1.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
281
+ web3-6.20.1.dist-info/entry_points.txt,sha256=2qjzGxFUlYBzoP68fcB3AJyMRunWI70uBoxNp17Brb0,64
282
+ web3-6.20.1.dist-info/top_level.txt,sha256=5lRZg30BFUrz8eUK60C7OAjNT3FI4YsGmA-vZ0WIOik,15
283
+ web3-6.20.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (71.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
File without changes