Skip to content

Commit

Permalink
Balance update.
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Oct 2, 2024
1 parent ea5d010 commit 3e973b3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bittensor_cli/src/bittensor/balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# DEALINGS IN THE SOFTWARE.

from typing import Union
from bittensor_cli.src import UNITS


class Balance:
Expand Down Expand Up @@ -279,3 +280,21 @@ def from_rao(amount: int):
:return: A Balance object representing the given amount.
"""
return Balance(amount)

@staticmethod
def get_unit(netuid: int):
units = UNITS
base = len(units)
if netuid < base:
return units[netuid]
else:
result = ""
while netuid > 0:
result = units[netuid % base] + result
netuid //= base
return result

def set_unit(self, netuid: int):
self.unit = Balance.get_unit(netuid)
self.rao_unit = Balance.get_unit(netuid)
return self

0 comments on commit 3e973b3

Please sign in to comment.