File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
bittensor_cli/src/bittensor Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 18
18
# DEALINGS IN THE SOFTWARE.
19
19
20
20
from typing import Union
21
+ from bittensor_cli .src import UNITS
21
22
22
23
23
24
class Balance :
@@ -279,3 +280,21 @@ def from_rao(amount: int):
279
280
:return: A Balance object representing the given amount.
280
281
"""
281
282
return Balance (amount )
283
+
284
+ @staticmethod
285
+ def get_unit (netuid : int ):
286
+ units = UNITS
287
+ base = len (units )
288
+ if netuid < base :
289
+ return units [netuid ]
290
+ else :
291
+ result = ""
292
+ while netuid > 0 :
293
+ result = units [netuid % base ] + result
294
+ netuid //= base
295
+ return result
296
+
297
+ def set_unit (self , netuid : int ):
298
+ self .unit = Balance .get_unit (netuid )
299
+ self .rao_unit = Balance .get_unit (netuid )
300
+ return self
You can’t perform that action at this time.
0 commit comments