py-near 1.1.33__py3-none-any.whl → 1.1.34__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/providers.py CHANGED
@@ -120,6 +120,31 @@ class JsonProvider(object):
120
120
  await self.check_available_rpcs()
121
121
  j = {"method": method, "params": params, "id": "dontcare", "jsonrpc": "2.0"}
122
122
  res = {}
123
+ if broadcast:
124
+ async def f(rpc_call_addr):
125
+ async with aiohttp.ClientSession() as session:
126
+ r = await session.post(
127
+ rpc_call_addr,
128
+ json=j,
129
+ timeout=timeout,
130
+ headers={
131
+ "Referer": "https://tgapp.herewallet.app/"
132
+ }, # NEAR RPC requires Referer header
133
+ )
134
+ r.raise_for_status()
135
+ res = json.loads(await r.text())
136
+ return res
137
+
138
+ tasks = [
139
+ asyncio.create_task(f(rpc_addr)) for rpc_addr in self._available_rpcs
140
+ ]
141
+ for t in tasks:
142
+ try:
143
+ res = await t
144
+ return res
145
+ except Exception as e:
146
+ logger.error(f"Rpc error: {e}")
147
+ continue
123
148
  for rpc_addr in self._available_rpcs:
124
149
  try:
125
150
  async with aiohttp.ClientSession() as session:
@@ -133,8 +158,7 @@ class JsonProvider(object):
133
158
  )
134
159
  r.raise_for_status()
135
160
  res = json.loads(await r.text())
136
- if not broadcast:
137
- return res
161
+ return res
138
162
  except (
139
163
  RPCTimeoutError,
140
164
  ClientResponseError,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-near
3
- Version: 1.1.33
3
+ Version: 1.1.34
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
@@ -20,10 +20,10 @@ py_near/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
20
20
  py_near/exceptions/exceptions.py,sha256=DEFipaAHm0y7oCuN2QKzHsiQvUTUQVl-Ce36Ag7n7hs,5509
21
21
  py_near/exceptions/provider.py,sha256=K-wexgjPJ8sw42JePwaP7R5dJEIn9DoFJRvVcURsx6s,7718
22
22
  py_near/models.py,sha256=GZQD1TKGWlwqsJsKRXrVNBjCdAIpk7GQypU-QOtAPFs,11533
23
- py_near/providers.py,sha256=E1FTza1IokXrFtOCPABW9UsXkgzqoTuxZfRWhCeixhk,13933
23
+ py_near/providers.py,sha256=1L5px_dDxrZxi0dNkOWA9MOq2VyUS11NluNJ21miQg0,14844
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.33.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
27
- py_near-1.1.33.dist-info/METADATA,sha256=STbfqsZrVA2yc5v-A2tiaLr8wfNQzAxB75yjYekvaek,4713
28
- py_near-1.1.33.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- py_near-1.1.33.dist-info/RECORD,,
26
+ py_near-1.1.34.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
27
+ py_near-1.1.34.dist-info/METADATA,sha256=kMX_ux6KsC7yfbLplg9qt1nJUMAok8JBtlCzznIHxsw,4713
28
+ py_near-1.1.34.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
+ py_near-1.1.34.dist-info/RECORD,,