py-near 1.1.22__py3-none-any.whl → 1.1.25__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 +15 -2
- py_near/providers.py +36 -28
- {py_near-1.1.22.dist-info → py_near-1.1.25.dist-info}/METADATA +1 -1
- {py_near-1.1.22.dist-info → py_near-1.1.25.dist-info}/RECORD +6 -6
- {py_near-1.1.22.dist-info → py_near-1.1.25.dist-info}/LICENSE +0 -0
- {py_near-1.1.22.dist-info → py_near-1.1.25.dist-info}/WHEEL +0 -0
py_near/account.py
CHANGED
@@ -69,7 +69,11 @@ class Account(object):
|
|
69
69
|
|
70
70
|
for pk in private_keys:
|
71
71
|
if isinstance(pk, str):
|
72
|
-
|
72
|
+
try:
|
73
|
+
pk = base58.b58decode(pk.replace("ed25519:", ""))
|
74
|
+
except UnicodeEncodeError:
|
75
|
+
logger.error(f"Can't decode private key {pk[:10]}")
|
76
|
+
continue
|
73
77
|
private_key = ed25519.SigningKey(pk)
|
74
78
|
public_key = base58.b58encode(
|
75
79
|
private_key.get_verifying_key().to_bytes()
|
@@ -117,6 +121,12 @@ class Account(object):
|
|
117
121
|
raise ValueError("You must provide a private key or seed to call methods")
|
118
122
|
await self._update_last_block_hash()
|
119
123
|
|
124
|
+
while True:
|
125
|
+
if self._free_signers.empty():
|
126
|
+
logger.info("Free signer not found")
|
127
|
+
await asyncio.sleep(0.5)
|
128
|
+
continue
|
129
|
+
break
|
120
130
|
pk = await self._free_signers.get()
|
121
131
|
access_key = await self.get_access_key(pk)
|
122
132
|
|
@@ -146,7 +156,10 @@ class Account(object):
|
|
146
156
|
)
|
147
157
|
except JsonProviderError as e:
|
148
158
|
e.trx_hash = trx_hash
|
149
|
-
raise
|
159
|
+
raise
|
160
|
+
except Exception as e:
|
161
|
+
e.trx_hash = trx_hash
|
162
|
+
raise
|
150
163
|
finally:
|
151
164
|
await self._free_signers.put(pk)
|
152
165
|
|
py_near/providers.py
CHANGED
@@ -75,31 +75,35 @@ class JsonProvider(object):
|
|
75
75
|
available_rpcs = []
|
76
76
|
for rpc_addr in self._rpc_addresses:
|
77
77
|
try:
|
78
|
+
data = {
|
79
|
+
"jsonrpc": "2.0",
|
80
|
+
"method": "status",
|
81
|
+
"params": {"finality": "final"},
|
82
|
+
"id": 1,
|
83
|
+
}
|
78
84
|
async with aiohttp.ClientSession() as session:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
85
|
+
async with session.post(rpc_addr, json=data) as r:
|
86
|
+
if r.status == 200:
|
87
|
+
data = json.loads(await r.text())
|
88
|
+
if data["sync_info"]["syncing"]:
|
89
|
+
last_block_ts = datetime.datetime.fromisoformat(
|
90
|
+
data["sync_info"]["latest_block_time"]
|
91
|
+
)
|
92
|
+
diff = (
|
93
|
+
datetime.datetime.utcnow().timestamp()
|
94
|
+
- last_block_ts.timestamp()
|
95
|
+
)
|
96
|
+
is_syncing = diff > 60
|
97
|
+
else:
|
98
|
+
is_syncing = False
|
99
|
+
if is_syncing:
|
100
|
+
logger.error(f"Remove async RPC : {rpc_addr} ({diff})")
|
101
|
+
continue
|
102
|
+
available_rpcs.append(rpc_addr)
|
93
103
|
else:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
continue
|
98
|
-
available_rpcs.append(rpc_addr)
|
99
|
-
else:
|
100
|
-
logger.error(
|
101
|
-
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
102
|
-
)
|
104
|
+
logger.error(
|
105
|
+
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
106
|
+
)
|
103
107
|
except Exception as e:
|
104
108
|
if rpc_addr in self._available_rpcs:
|
105
109
|
logger.error(f"Remove rpc: {e}")
|
@@ -208,12 +212,16 @@ class JsonProvider(object):
|
|
208
212
|
await self.check_available_rpcs()
|
209
213
|
for rpc_addr in self._available_rpcs:
|
210
214
|
try:
|
215
|
+
data = {
|
216
|
+
"jsonrpc": "2.0",
|
217
|
+
"method": "status",
|
218
|
+
"params": {"finality": "final"},
|
219
|
+
"id": 1,
|
220
|
+
}
|
211
221
|
async with aiohttp.ClientSession() as session:
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
if r.status == 200:
|
216
|
-
return json.loads(await r.text())
|
222
|
+
async with session.post(rpc_addr, json=data) as r:
|
223
|
+
if r.status == 200:
|
224
|
+
return json.loads(await r.text())
|
217
225
|
except (
|
218
226
|
ClientResponseError,
|
219
227
|
ClientConnectorError,
|
@@ -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=sw5bqGUFFOkqc8COGB4GYUM9YzSgLO_jIUli4RTQEQo,16655
|
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
|
@@ -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=9i9laUNtQFGfiTGglXB95rp1g8Ph49d0dXKHxYnJHOo,12529
|
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.25.dist-info/LICENSE,sha256=I_GOA9xJ35FiL-KnYXZJdATkbO2KcV2dK2enRGVxzKM,1023
|
27
|
+
py_near-1.1.25.dist-info/METADATA,sha256=d1SofefxxzkkBmOEPhvgGghb51slREAebC8DwT4d1FY,4713
|
28
|
+
py_near-1.1.25.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
29
|
+
py_near-1.1.25.dist-info/RECORD,,
|
File without changes
|
File without changes
|