py-near 1.1.33__py3-none-any.whl → 1.1.35__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
@@ -23,7 +23,7 @@ from py_near.exceptions.provider import (
|
|
23
23
|
InvalidTransactionError,
|
24
24
|
RPCTimeoutError,
|
25
25
|
UnknownAccessKeyError,
|
26
|
-
ERROR_CODE_TO_EXCEPTION,
|
26
|
+
ERROR_CODE_TO_EXCEPTION, InvalidNonce,
|
27
27
|
)
|
28
28
|
from py_near.models import TransactionResult
|
29
29
|
|
@@ -120,6 +120,30 @@ 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
|
+
tasks = [
|
138
|
+
asyncio.create_task(f(rpc_addr)) for rpc_addr in self._available_rpcs
|
139
|
+
]
|
140
|
+
for t in tasks:
|
141
|
+
try:
|
142
|
+
res = await t
|
143
|
+
return res
|
144
|
+
except Exception as e:
|
145
|
+
logger.error(f"Rpc error: {e}")
|
146
|
+
continue
|
123
147
|
for rpc_addr in self._available_rpcs:
|
124
148
|
try:
|
125
149
|
async with aiohttp.ClientSession() as session:
|
@@ -133,8 +157,7 @@ class JsonProvider(object):
|
|
133
157
|
)
|
134
158
|
r.raise_for_status()
|
135
159
|
res = json.loads(await r.text())
|
136
|
-
|
137
|
-
return res
|
160
|
+
return res
|
138
161
|
except (
|
139
162
|
RPCTimeoutError,
|
140
163
|
ClientResponseError,
|
@@ -203,12 +226,19 @@ class JsonProvider(object):
|
|
203
226
|
:param timeout: rpc request timeout
|
204
227
|
:return:
|
205
228
|
"""
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
229
|
+
try:
|
230
|
+
return await self.json_rpc(
|
231
|
+
"send_tx",
|
232
|
+
{"signed_tx_base64": signed_tx, "wait_until": "INCLUDED_FINAL"},
|
233
|
+
timeout=timeout,
|
234
|
+
broadcast=self.allow_broadcast,
|
235
|
+
)
|
236
|
+
except InvalidNonce:
|
237
|
+
logger.warning("Invalid nonce during broadcast included transaction")
|
238
|
+
return None
|
239
|
+
except RPCTimeoutError:
|
240
|
+
raise RPCTimeoutError("Transaction not included")
|
241
|
+
|
212
242
|
|
213
243
|
async def wait_for_trx(self, trx_hash, receiver_id) -> TransactionResult:
|
214
244
|
for _ in range(6):
|
@@ -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=
|
23
|
+
py_near/providers.py,sha256=TbkVFzW0SUdb_8UAe51b4j99MdBNfcl5yhLUif1tK7w,15124
|
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.
|
27
|
-
py_near-1.1.
|
28
|
-
py_near-1.1.
|
29
|
-
py_near-1.1.
|
26
|
+
py_near-1.1.35.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
|
27
|
+
py_near-1.1.35.dist-info/METADATA,sha256=jBst8XdqvnEzgB3RRf5fU_g025Jurf10JNyZIOmw7-w,4713
|
28
|
+
py_near-1.1.35.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
29
|
+
py_near-1.1.35.dist-info/RECORD,,
|
File without changes
|
File without changes
|