communex.balance
1DECIMALS = 9 2 3 4def from_nano(amount: int) -> float: 5 """ 6 Converts from nano to j 7 """ 8 9 return amount / (10**DECIMALS) 10 11 12def to_nano(amount: float) -> int: 13 """ 14 Converts from j to nano 15 """ 16 17 return int(amount * (10**DECIMALS)) 18 19 20def from_horus(amount: int, subnet_tempo: int = 100) -> float: 21 """ 22 Converts from horus to j 23 """ 24 25 return amount / (10**DECIMALS * subnet_tempo) 26 27 28def repr_j(amount: int): 29 """ 30 Given an amount in nano, returns a representation of it in tokens/J. 31 32 E.g. "103.2J". 33 """ 34 35 return f"{from_nano(amount)}J"
DECIMALS =
9
def
from_nano(amount: int) -> float:
5def from_nano(amount: int) -> float: 6 """ 7 Converts from nano to j 8 """ 9 10 return amount / (10**DECIMALS)
Converts from nano to j
def
to_nano(amount: float) -> int:
13def to_nano(amount: float) -> int: 14 """ 15 Converts from j to nano 16 """ 17 18 return int(amount * (10**DECIMALS))
Converts from j to nano
def
from_horus(amount: int, subnet_tempo: int = 100) -> float:
21def from_horus(amount: int, subnet_tempo: int = 100) -> float: 22 """ 23 Converts from horus to j 24 """ 25 26 return amount / (10**DECIMALS * subnet_tempo)
Converts from horus to j
def
repr_j(amount: int):
29def repr_j(amount: int): 30 """ 31 Given an amount in nano, returns a representation of it in tokens/J. 32 33 E.g. "103.2J". 34 """ 35 36 return f"{from_nano(amount)}J"
Given an amount in nano, returns a representation of it in tokens/J.
E.g. "103.2J".