diff --git a/pyproject.toml b/pyproject.toml index 949c793..d7a1be6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "Apache-2.0" diff --git a/robonomicsinterface/classes/rws.py b/robonomicsinterface/classes/rws.py index 1af4d22..9575cb6 100644 --- a/robonomicsinterface/classes/rws.py +++ b/robonomicsinterface/classes/rws.py @@ -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. """ @@ -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: