Skip to content

Commit

Permalink
Merge pull request #84 from Multi-Agent-io/development
Browse files Browse the repository at this point in the history
1.6.1 added Lifetime subscription support in get_days_left
  • Loading branch information
PaTara43 authored Feb 7, 2023
2 parents 7da9e85 + 9e0f4d5 commit e280188
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "robonomics-interface"
version = "1.6.0"
version = "1.6.1"
description = "Robonomics wrapper over https://github.com/polkascan/py-substrate-interface created to facilitate programming with Robonomics"
authors = ["Pavel Tarasov <p040399@outlook.com>"]
license = "Apache-2.0"
Expand Down
5 changes: 4 additions & 1 deletion robonomicsinterface/classes/rws.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def get_days_left(
:param addr: Possible subscription owner. If ``None`` - account address.
:param block_hash: Retrieves data as of passed block hash.
:return: Number of days left if subscription is active, ``False`` if no active subscription.
:return: Number of days left if subscription is active, ``False`` if no active subscription, -1 for a Lifetime
subscription.
"""

Expand All @@ -112,6 +113,8 @@ def get_days_left(
ledger: LedgerTyping = self._service_functions.chainstate_query("RWS", "Ledger", address, block_hash=block_hash)
if not ledger:
return False
if "Lifetime" in ledger["kind"]:
return -1
unix_time_sub_expire: int = ledger["issue_time"] + 86400 * 1000 * ledger["kind"]["Daily"]["days"]
days_left: float = (unix_time_sub_expire - time.time() * 1000) / 86400000
if days_left >= 0:
Expand Down

0 comments on commit e280188

Please sign in to comment.