py-near 1.1.48__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/account.py +9 -0
- py_near/models.py +2 -0
- py_near/providers.py +6 -25
- {py_near-1.1.48.dist-info → py_near-1.1.50.dist-info}/METADATA +1 -1
- {py_near-1.1.48.dist-info → py_near-1.1.50.dist-info}/RECORD +7 -7
- {py_near-1.1.48.dist-info → py_near-1.1.50.dist-info}/LICENSE +0 -0
- {py_near-1.1.48.dist-info → py_near-1.1.50.dist-info}/WHEEL +0 -0
py_near/account.py
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
import asyncio
|
2
2
|
import collections
|
3
3
|
import json
|
4
|
+
import sys
|
4
5
|
from typing import List, Union, Dict, Optional
|
5
6
|
|
7
|
+
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
|
8
|
+
from collections.abc import MutableSet, MutableMapping
|
9
|
+
|
10
|
+
collections.MutableSet = collections.abc.MutableSet
|
11
|
+
collections.MutableMapping = collections.abc.MutableMapping
|
12
|
+
else:
|
13
|
+
from collections import MutableSet
|
14
|
+
|
6
15
|
import base58
|
7
16
|
import ed25519
|
8
17
|
from loguru import logger
|
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
|
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.
|
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,5 +1,5 @@
|
|
1
1
|
py_near/__init__.py,sha256=t5fAxjaU8dN8xpQR2vz0ZGhfTkdVy2RCbkhJhZFglk4,50
|
2
|
-
py_near/account.py,sha256=
|
2
|
+
py_near/account.py,sha256=77jCtVaGXK_ejQ0SyRYRgJ4Ez1DaWByfAX94Uuph-aw,18107
|
3
3
|
py_near/constants.py,sha256=inaWIuwmF1EB5JSB0ynnZY5rKY_QsxhF9KuCOhPsM6k,164
|
4
4
|
py_near/dapps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
py_near/dapps/core.py,sha256=LtN9aW2gw2mvEdhzQcQJIidtjv-XL1xjb0LK8DzqtqE,231
|
@@ -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=
|
23
|
-
py_near/providers.py,sha256=
|
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.
|
27
|
-
py_near-1.1.
|
28
|
-
py_near-1.1.
|
29
|
-
py_near-1.1.
|
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,,
|
File without changes
|
File without changes
|