py-near 1.1.42__tar.gz → 1.1.44__tar.gz
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-1.1.42 → py_near-1.1.44}/PKG-INFO +1 -1
- {py_near-1.1.42 → py_near-1.1.44}/pyproject.toml +2 -2
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/providers.py +52 -39
- {py_near-1.1.42 → py_near-1.1.44}/LICENSE +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/README.md +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/account.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/constants.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/__pycache__/core.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/__pycache__/fts.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/core.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/async_client.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/models.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/async_client.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/exceptions.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/models.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/fts.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/keypom/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/keypom/async_client.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/keypom/exceptions.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/keypom/models.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/async_client.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/models.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/async_client.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/exceptions.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/models.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__init__.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/provider.cpython-311.pyc +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/exceptions.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/provider.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/models.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/transactions.py +0 -0
- {py_near-1.1.42 → py_near-1.1.44}/src/py_near/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "py-near"
|
3
|
-
version = "1.1.
|
3
|
+
version = "1.1.44"
|
4
4
|
description="Pretty simple and fully asynchronous framework for working with NEAR blockchain"
|
5
5
|
authors = ["pvolnov <petr@herewallet.app>"]
|
6
6
|
readme = "README.md"
|
@@ -22,7 +22,7 @@ base58 = "^2.1.1"
|
|
22
22
|
|
23
23
|
[project]
|
24
24
|
name = "py-near"
|
25
|
-
version = "1.1.
|
25
|
+
version = "1.1.44"
|
26
26
|
description = "Pretty simple and fully asynchronous framework for working with NEAR blockchaink"
|
27
27
|
authors = [ {name = "pvolnov", email = "petr@herewallet.app"} ]
|
28
28
|
requires-python = ">=3.7"
|
@@ -81,7 +81,8 @@ class JsonProvider(object):
|
|
81
81
|
await asyncio.sleep(3)
|
82
82
|
|
83
83
|
if not self._available_rpcs:
|
84
|
-
|
84
|
+
self._available_rpcs = self._rpc_addresses.copy()
|
85
|
+
logger.error("All RPCs are async, reset to default list")
|
85
86
|
|
86
87
|
async def _check_available_rpcs(self):
|
87
88
|
available_rpcs = []
|
@@ -93,31 +94,40 @@ class JsonProvider(object):
|
|
93
94
|
"params": {"finality": "final"},
|
94
95
|
"id": 1,
|
95
96
|
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
)
|
107
|
-
|
97
|
+
auth_key = "py-near"
|
98
|
+
if "@" in rpc_addr:
|
99
|
+
auth_key = rpc_addr.split("//")[1].split("@")[0]
|
100
|
+
rpc_addr = rpc_addr.replace(auth_key + "@", "")
|
101
|
+
async with aiohttp.ClientSession() as session:
|
102
|
+
async with session.post(rpc_addr, json=data, headers={
|
103
|
+
"Referer": "https://tgapp.herewallet.app",
|
104
|
+
"Authorization": f"Bearer {auth_key}",
|
105
|
+
}) as r:
|
106
|
+
if r.status == 200:
|
107
|
+
data = json.loads(await r.text())["result"]
|
108
|
+
if data["sync_info"]["syncing"]:
|
109
|
+
last_block_ts = datetime.datetime.fromisoformat(
|
110
|
+
data["sync_info"]["latest_block_time"]
|
111
|
+
)
|
112
|
+
diff = (
|
113
|
+
datetime.datetime.utcnow().timestamp()
|
114
|
+
- last_block_ts.timestamp()
|
115
|
+
)
|
116
|
+
is_syncing = diff > 60
|
117
|
+
else:
|
118
|
+
is_syncing = False
|
119
|
+
if is_syncing:
|
120
|
+
logger.error(f"Remove async RPC : {rpc_addr} ({diff})")
|
121
|
+
continue
|
122
|
+
available_rpcs.append(rpc_addr)
|
108
123
|
else:
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
continue
|
113
|
-
available_rpcs.append(rpc_addr)
|
114
|
-
else:
|
115
|
-
logger.error(
|
116
|
-
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
117
|
-
)
|
124
|
+
logger.error(
|
125
|
+
f"Remove rpc because of error {r.status}: {rpc_addr}"
|
126
|
+
)
|
118
127
|
except Exception as e:
|
119
128
|
if rpc_addr in self._available_rpcs:
|
120
129
|
logger.error(f"Remove rpc: {e}")
|
130
|
+
logger.error(f"Rpc check error: {e}")
|
121
131
|
self._available_rpcs = available_rpcs
|
122
132
|
|
123
133
|
@staticmethod
|
@@ -137,23 +147,24 @@ class JsonProvider(object):
|
|
137
147
|
if "@" in rpc_call_addr:
|
138
148
|
auth_key = rpc_call_addr.split("//")[1].split("@")[0]
|
139
149
|
rpc_call_addr = rpc_call_addr.replace(auth_key + "@", "")
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
"
|
154
|
-
|
150
|
+
async with aiohttp.ClientSession() as session:
|
151
|
+
r = await session.post(
|
152
|
+
rpc_call_addr,
|
153
|
+
json=j,
|
154
|
+
timeout=self._timeout,
|
155
|
+
headers={
|
156
|
+
"Referer": "https://tgapp.herewallet.app",
|
157
|
+
"Authorization": f"Bearer {auth_key}",
|
158
|
+
}, # NEAR RPC requires Referer header
|
159
|
+
)
|
160
|
+
if r.status == 200:
|
161
|
+
return json.loads(await r.text())
|
162
|
+
return {
|
163
|
+
"error": {
|
164
|
+
"cause": {"name": "RPC_ERROR", "message": f"Status: {r.status}"},
|
165
|
+
"data": await r.text(),
|
166
|
+
}
|
155
167
|
}
|
156
|
-
}
|
157
168
|
|
158
169
|
if broadcast or threshold:
|
159
170
|
pending = [
|
@@ -161,6 +172,7 @@ class JsonProvider(object):
|
|
161
172
|
]
|
162
173
|
|
163
174
|
responses = []
|
175
|
+
correct_responses = []
|
164
176
|
while pending and len(pending):
|
165
177
|
done, pending = await asyncio.wait(
|
166
178
|
pending, return_when=asyncio.FIRST_COMPLETED
|
@@ -173,7 +185,7 @@ class JsonProvider(object):
|
|
173
185
|
responses.append(result)
|
174
186
|
except Exception as e:
|
175
187
|
logger.warning(e)
|
176
|
-
if responses:
|
188
|
+
if responses and threshold:
|
177
189
|
array = [hash(json.dumps(x)) for x in responses]
|
178
190
|
most_frequent_element = self.most_frequent_by_hash(array)
|
179
191
|
correct_responses = [
|
@@ -183,6 +195,7 @@ class JsonProvider(object):
|
|
183
195
|
for task in pending:
|
184
196
|
task.cancel()
|
185
197
|
return most_frequent_element
|
198
|
+
raise RpcEmptyResponse(f"Threshold not reached: {len(correct_responses)}/{threshold}")
|
186
199
|
else:
|
187
200
|
for rpc_addr in self._available_rpcs:
|
188
201
|
try:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/async_client.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/ft/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/__init__.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/async_client.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/dapps/staking/__pycache__/models.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/__init__.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.42 → py_near-1.1.44}/src/py_near/exceptions/__pycache__/provider.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|