py-near 1.1.15__tar.gz → 1.1.16__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.
Files changed (29) hide show
  1. {py_near-1.1.15 → py_near-1.1.16}/PKG-INFO +2 -1
  2. {py_near-1.1.15 → py_near-1.1.16}/pyproject.toml +2 -2
  3. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/account.py +7 -2
  4. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/providers.py +35 -17
  5. {py_near-1.1.15 → py_near-1.1.16}/LICENSE +0 -0
  6. {py_near-1.1.15 → py_near-1.1.16}/README.md +0 -0
  7. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/__init__.py +0 -0
  8. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/constants.py +0 -0
  9. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/__init__.py +0 -0
  10. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/core.py +0 -0
  11. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/ft/__init__.py +0 -0
  12. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/ft/async_client.py +0 -0
  13. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/ft/exceptions.py +0 -0
  14. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/ft/models.py +0 -0
  15. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/fts.py +0 -0
  16. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/keypom/__init__.py +0 -0
  17. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/keypom/async_client.py +0 -0
  18. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/keypom/exceptions.py +0 -0
  19. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/keypom/models.py +0 -0
  20. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/staking/__init__.py +0 -0
  21. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/staking/async_client.py +0 -0
  22. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/staking/exceptions.py +0 -0
  23. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/dapps/staking/models.py +0 -0
  24. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/exceptions/__init__.py +0 -0
  25. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/exceptions/exceptions.py +0 -0
  26. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/exceptions/provider.py +0 -0
  27. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/models.py +0 -0
  28. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/transactions.py +0 -0
  29. {py_near-1.1.15 → py_near-1.1.16}/src/py_near/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-near
3
- Version: 1.1.15
3
+ Version: 1.1.16
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
@@ -11,6 +11,7 @@ Classifier: Programming Language :: Python :: 3.8
11
11
  Classifier: Programming Language :: Python :: 3.9
12
12
  Classifier: Programming Language :: Python :: 3.10
13
13
  Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
14
15
  Requires-Dist: aiohttp (>=3.7.4,<4.0.0)
15
16
  Requires-Dist: ed25519 (>=1.5,<2.0)
16
17
  Requires-Dist: py-near-primitives (>=0.2.3,<0.3.0)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "py-near"
3
- version = "1.1.15"
3
+ version = "1.1.16"
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.15"
25
+ version = "1.1.16"
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"
@@ -368,17 +368,22 @@ class Account(object):
368
368
  )
369
369
 
370
370
  async def view_function(
371
- self, contract_id: str, method_name: str, args: dict
371
+ self,
372
+ contract_id: str,
373
+ method_name: str,
374
+ args: dict,
375
+ block_id: Optional[int] = None,
372
376
  ) -> ViewFunctionResult:
373
377
  """
374
378
  Call view function on smart contract. View function is read only function, it can't change state
375
379
  :param contract_id: smart contract account id
376
380
  :param method_name: method name to call
377
381
  :param args: json args to call method
382
+ :param block_id: execution view transaction in block with given id
378
383
  :return: result of view function call
379
384
  """
380
385
  result = await self._provider.view_call(
381
- contract_id, method_name, json.dumps(args).encode("utf8")
386
+ contract_id, method_name, json.dumps(args).encode("utf8"), block_id=block_id
382
387
  )
383
388
  if "error" in result:
384
389
  raise ViewFunctionError(result["error"])
@@ -77,21 +77,31 @@ class JsonProvider(object):
77
77
  if rpc_addr in self._available_rpcs:
78
78
  if r.status == 200:
79
79
  logger.error(f"Remove async RPC : {rpc_addr}")
80
- logger.error(
81
- f"Remove rpc because of error {r.status}: {rpc_addr}"
82
- )
80
+ else:
81
+ logger.error(
82
+ f"Remove rpc because of error {r.status}: {rpc_addr}"
83
+ )
83
84
  except Exception as e:
84
85
  if rpc_addr in self._available_rpcs:
85
86
  logger.error(f"Remove rpc: {e}")
86
- continue
87
87
  self._available_rpcs = [
88
88
  r[0] for r in sorted(available_rpcs, key=lambda x: x[1])
89
89
  ]
90
90
 
91
91
  async def call_rpc_request(self, method, params, timeout=TIMEOUT_WAIT_RPC):
92
- if self._last_rpc_addr_check < datetime.datetime.now().timestamp() - 30:
92
+ if (
93
+ self._last_rpc_addr_check < datetime.datetime.now().timestamp() - 30
94
+ or not self._available_rpcs
95
+ ):
93
96
  self._last_rpc_addr_check = datetime.datetime.now().timestamp()
94
- asyncio.create_task(self.check_available_rpcs())
97
+ if self._available_rpcs:
98
+ asyncio.create_task(self.check_available_rpcs())
99
+ else:
100
+ logger.warning("No RPC available, rechecking")
101
+ await self.check_available_rpcs()
102
+
103
+ if not self._available_rpcs:
104
+ raise RpcNotAvailableError("No RPC available")
95
105
 
96
106
  j = {"method": method, "params": params, "id": "dontcare", "jsonrpc": "2.0"}
97
107
 
@@ -256,17 +266,25 @@ class JsonProvider(object):
256
266
  },
257
267
  )
258
268
 
259
- async def view_call(self, account_id, method_name, args, finality="optimistic"):
260
- return await self.json_rpc(
261
- "query",
262
- {
263
- "request_type": "call_function",
264
- "account_id": account_id,
265
- "method_name": method_name,
266
- "args_base64": base64.b64encode(args).decode("utf8"),
267
- "finality": finality,
268
- },
269
- )
269
+ async def view_call(
270
+ self,
271
+ account_id,
272
+ method_name,
273
+ args,
274
+ finality="optimistic",
275
+ block_id: Optional[int] = None,
276
+ ):
277
+ body = {
278
+ "request_type": "call_function",
279
+ "account_id": account_id,
280
+ "method_name": method_name,
281
+ "args_base64": base64.b64encode(args).decode("utf8"),
282
+ }
283
+ if block_id:
284
+ body["block_id"] = block_id
285
+ else:
286
+ body["finality"] = finality
287
+ return await self.json_rpc("query", body)
270
288
 
271
289
  async def get_block(self, block_id):
272
290
  return await self.json_rpc("block", [block_id])
File without changes
File without changes
File without changes
File without changes