helius-python 0.5.0__py3-none-any.whl → 0.5.2__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.
@@ -132,6 +132,10 @@ class WebSocketClient:
132
132
  base_url="wss://mainnet.helius-rpc.com",
133
133
  api_key: str | None = None,
134
134
  proxy: str | None = None,
135
+ open_timeout: float | None = 10,
136
+ ping_interval: float | None = 20,
137
+ ping_timeout: float | None = 20,
138
+ close_timeout: float | None = 10,
135
139
  ):
136
140
 
137
141
  base_url = base_url
@@ -144,7 +148,14 @@ class WebSocketClient:
144
148
  if not api_key:
145
149
  raise ValueError("No API key provided.")
146
150
  uri = httpx.URL(base_url).copy_with(path="/", params={"api-key": api_key})
147
- self._websocket = connect(str(uri), proxy=proxy)
151
+ self._websocket = connect(
152
+ str(uri),
153
+ proxy=proxy,
154
+ open_timeout=open_timeout,
155
+ ping_interval=ping_interval,
156
+ ping_timeout=ping_timeout,
157
+ close_timeout=close_timeout,
158
+ )
148
159
 
149
160
  def close(self):
150
161
  self._websocket.close()
@@ -163,6 +174,27 @@ class WebSocketClient:
163
174
  response = self._websocket.recv()
164
175
  return json.loads(response)
165
176
 
177
+ def receive(self) -> tuple[dict | None, Notification, int]:
178
+ response = json.loads(self._websocket.recv())
179
+ model = self.MODELS[response["method"]]
180
+ result = response["params"]["result"]
181
+ subscription = response["params"]["subscription"]
182
+ if isinstance(result, dict):
183
+ context = result.get("context")
184
+ value = result.get("value")
185
+ else:
186
+ context, value = None, None
187
+ if value is not None:
188
+ notification = model.model_validate(value)
189
+ else:
190
+ notification = model.model_validate(result)
191
+ return context, notification, subscription
192
+
193
+ def listen(self):
194
+ while True:
195
+ context, notification, subscription = self.receive()
196
+ yield context, notification, subscription
197
+
166
198
  def _unsubscribe(self, subscription_type, subscription) -> bool:
167
199
  request = (
168
200
  JsonRpcRequest(method=f"{subscription_type}Unsubscribe")
@@ -376,24 +408,3 @@ class WebSocketClient:
376
408
 
377
409
  def vote_unsubscribe(self, subscription) -> bool:
378
410
  return self._unsubscribe("vote", subscription)
379
-
380
- def receive(self) -> tuple[dict | None, Notification, int]:
381
- response = json.loads(self._websocket.recv())
382
- model = self.MODELS[response["method"]]
383
- result = response["params"]["result"]
384
- subscription = response["params"]["subscription"]
385
- if isinstance(result, dict):
386
- context = result.get("context")
387
- value = result.get("value")
388
- else:
389
- context, value = None, None
390
- if value is not None:
391
- notification = model.model_validate(value)
392
- else:
393
- notification = model.model_validate(result)
394
- return context, notification, subscription
395
-
396
- def listen(self):
397
- while True:
398
- context, notification, subscription = self.receive()
399
- yield context, notification, subscription
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: helius-python
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Typed Python client for the Helius API
5
5
  Project-URL: Homepage, https://github.com/markosnarinian/helius-python
6
6
  Project-URL: Issues, https://github.com/markosnarinian/helius-python/issues
@@ -1,7 +1,7 @@
1
1
  helius/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  helius/admin/__init__.py,sha256=HboRJXZNzuDAc6r3kj2QZtEcu2U3EWJHv81dYDJGjaA,262
3
3
  helius/admin/admin.py,sha256=dcmOgeu10Q43QZC8K-a25vp2JNAb4hs5gu3YWaovV4Y,2541
4
- helius/laserstream/websockets.py,sha256=cndqxXO9_I4aSjAeSkz3Q3u80jrFR0JMfXw09vzbgvQ,12448
4
+ helius/laserstream/websockets.py,sha256=zk3vpSORateUpi0s6Jq-MSBA384G9tp8bvJ_f5liHts,12809
5
5
  helius/rpc/__init__.py,sha256=sW31r7_8PRn-bQePJSbIK8NvlkMor0b59E4rnvvUT9I,992
6
6
  helius/rpc/client.py,sha256=zgubEGlSHAs-bHRSL0AP-X5c4l4oKJzoeriBM4DJnwk,37498
7
7
  helius/rpc/models.py,sha256=_o9B9VBgNBkYGGeglEgWxkffwS1thym2KfAfPekm590,7682
@@ -9,7 +9,7 @@ helius/utils/__init__.py,sha256=szG5WTfKl1dfqsZb2efmeZr5zJBKlEBgNCWYGCo7VbU,87
9
9
  helius/utils/json_rpc_request.py,sha256=hm7WkPo0CnwMnuHE4qR-d93wGArZRPRm-B3uueykL3E,1479
10
10
  helius/webhooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  helius/webhooks/webhooks.py,sha256=IXCF7sDS6QpcY5r03WTmXNpOqoltii3pSHPita0f83o,19803
12
- helius_python-0.5.0.dist-info/METADATA,sha256=k69sDfATDw_3K3qINHmRc3eEVCG7VoZX8aJlDPUdx7I,37939
13
- helius_python-0.5.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
14
- helius_python-0.5.0.dist-info/licenses/LICENSE,sha256=bZc2EDmq_GsWH77uK8LBn1kqqrOPcp2f9p-ys9bYa1E,1072
15
- helius_python-0.5.0.dist-info/RECORD,,
12
+ helius_python-0.5.2.dist-info/METADATA,sha256=13MGhAUwyrVv9XYfaslwOYqQcWCYiH5H0yEBVfSxGPs,37939
13
+ helius_python-0.5.2.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
14
+ helius_python-0.5.2.dist-info/licenses/LICENSE,sha256=bZc2EDmq_GsWH77uK8LBn1kqqrOPcp2f9p-ys9bYa1E,1072
15
+ helius_python-0.5.2.dist-info/RECORD,,