py-near 1.1.49__py3-none-any.whl → 1.1.50__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.
py_near/models.py CHANGED
@@ -48,8 +48,10 @@ class ReceiptOutcome:
48
48
  tokens_burnt: str
49
49
  executor_id: str
50
50
  gas_burnt: int
51
+ receipt_id: str
51
52
 
52
53
  def __init__(self, data):
54
+ self.receipt_id = data['id']
53
55
  self.logs = data["outcome"]["logs"]
54
56
  self.metadata = data["outcome"]["metadata"]
55
57
  self.receipt_ids = data["outcome"]["receipt_ids"]
py_near/providers.py CHANGED
@@ -6,6 +6,7 @@ from collections import Counter
6
6
  from typing import Optional
7
7
 
8
8
  import httpx
9
+ from httpx import Limits
9
10
  from loguru import logger
10
11
 
11
12
  from py_near.constants import TIMEOUT_WAIT_RPC
@@ -60,29 +61,13 @@ class JsonProvider(object):
60
61
  self._last_rpc_addr_check = 0
61
62
  self.allow_broadcast = allow_broadcast
62
63
  self._timeout = timeout
63
- self._client: httpx.AsyncClient = httpx.AsyncClient()
64
+ self._client = httpx.AsyncClient(
65
+ limits=Limits(max_connections=1000, max_keepalive_connections=200)
66
+ )
64
67
 
65
68
  async def shutdown(self):
66
69
  pass
67
70
 
68
- async def check_available_rpcs(self):
69
- if (
70
- self._last_rpc_addr_check < datetime.datetime.now().timestamp() - 30
71
- or not self._available_rpcs
72
- ):
73
- self._last_rpc_addr_check = datetime.datetime.now().timestamp()
74
- asyncio.create_task(self._check_available_rpcs())
75
-
76
- for _ in range(5):
77
- if self._available_rpcs:
78
- break
79
- await self._check_available_rpcs()
80
- await asyncio.sleep(3)
81
-
82
- if not self._available_rpcs:
83
- self._available_rpcs = self._rpc_addresses.copy()
84
- logger.error("All RPCs are async, reset to default list")
85
-
86
71
  async def _check_available_rpcs(self):
87
72
  available_rpcs = []
88
73
  for rpc_addr in self._rpc_addresses:
@@ -132,7 +117,7 @@ class JsonProvider(object):
132
117
  except Exception as e:
133
118
  if rpc_addr in self._available_rpcs:
134
119
  logger.error(f"Remove rpc: {e}")
135
- logger.error(f"Rpc check error: {e}")
120
+ logger.exception(e)
136
121
  self._available_rpcs = available_rpcs
137
122
 
138
123
  @staticmethod
@@ -144,7 +129,6 @@ class JsonProvider(object):
144
129
  async def call_rpc_request(
145
130
  self, method, params, broadcast=False, threshold: int = 0
146
131
  ):
147
- await self.check_available_rpcs()
148
132
  j = {"method": method, "params": params, "id": "dontcare", "jsonrpc": "2.0"}
149
133
 
150
134
  async def f(rpc_call_addr):
@@ -325,7 +309,6 @@ class JsonProvider(object):
325
309
  return await self.wait_for_trx(trx_hash, receiver_id)
326
310
 
327
311
  async def get_status(self):
328
- await self.check_available_rpcs()
329
312
  for rpc_addr in self._available_rpcs.copy():
330
313
  try:
331
314
  data = {
@@ -340,9 +323,7 @@ class JsonProvider(object):
340
323
  if "@" in rpc_addr:
341
324
  auth_key = rpc_addr.split("//")[1].split("@")[0]
342
325
  rpc_addr = rpc_addr.replace(auth_key + "@", "")
343
- headers = {
344
- "Authorization": f"Bearer {auth_key}"
345
- }
326
+ headers = {"Authorization": f"Bearer {auth_key}"}
346
327
  r = await self._client.post(rpc_addr, json=data, headers=headers)
347
328
  if r.status_code == 200:
348
329
  return json.loads(r.text)["result"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-near
3
- Version: 1.1.49
3
+ Version: 1.1.50
4
4
  Summary: Pretty simple and fully asynchronous framework for working with NEAR blockchain
5
5
  Author: pvolnov
6
6
  Author-email: petr@herewallet.app
@@ -19,11 +19,11 @@ py_near/dapps/staking/models.py,sha256=zC5M_pc1oMqHq4GaYif1uwFbW6acD2BsiA9rbyiaU
19
19
  py_near/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  py_near/exceptions/exceptions.py,sha256=DEFipaAHm0y7oCuN2QKzHsiQvUTUQVl-Ce36Ag7n7hs,5509
21
21
  py_near/exceptions/provider.py,sha256=K-wexgjPJ8sw42JePwaP7R5dJEIn9DoFJRvVcURsx6s,7718
22
- py_near/models.py,sha256=GZQD1TKGWlwqsJsKRXrVNBjCdAIpk7GQypU-QOtAPFs,11533
23
- py_near/providers.py,sha256=1eg9MFIYIKA09bZyTdSZ2Umrh0kX1SUFEhY_tN8Cqz4,16722
22
+ py_near/models.py,sha256=85ynmLVJnzWvFKq-Z8iIO0waU-2iP-CSkaOGX4mYoL0,11590
23
+ py_near/providers.py,sha256=qSeBa_dL5PG262mEOfcnt_15D_OBf07szGCMVS7nfTc,16003
24
24
  py_near/transactions.py,sha256=QAXegv2JpKISk92NaChtIH6-QPHrcWbrwdKH_lH4TsU,3186
25
25
  py_near/utils.py,sha256=FirRH93ydH1cwjn0-sNrZeIn3BRD6QHedrP2VkAdJ6g,126
26
- py_near-1.1.49.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
27
- py_near-1.1.49.dist-info/METADATA,sha256=ERDv9zuuxRMfj4RzeF4Kvup_2QuTYueowDiP3tmc-EY,4693
28
- py_near-1.1.49.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- py_near-1.1.49.dist-info/RECORD,,
26
+ py_near-1.1.50.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
27
+ py_near-1.1.50.dist-info/METADATA,sha256=aGwb2Lr4zn6aI92kfAAAIXqk1h5sZmGXoP5BWOwCWeQ,4693
28
+ py_near-1.1.50.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
+ py_near-1.1.50.dist-info/RECORD,,