bittensor-cli 8.4.2__py3-none-any.whl → 9.0.0rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. bittensor_cli/__init__.py +2 -2
  2. bittensor_cli/cli.py +1503 -1372
  3. bittensor_cli/src/__init__.py +625 -197
  4. bittensor_cli/src/bittensor/balances.py +41 -8
  5. bittensor_cli/src/bittensor/chain_data.py +557 -428
  6. bittensor_cli/src/bittensor/extrinsics/registration.py +161 -47
  7. bittensor_cli/src/bittensor/extrinsics/root.py +14 -8
  8. bittensor_cli/src/bittensor/extrinsics/transfer.py +14 -21
  9. bittensor_cli/src/bittensor/minigraph.py +46 -8
  10. bittensor_cli/src/bittensor/subtensor_interface.py +572 -253
  11. bittensor_cli/src/bittensor/utils.py +326 -75
  12. bittensor_cli/src/commands/stake/__init__.py +154 -0
  13. bittensor_cli/src/commands/stake/children_hotkeys.py +123 -91
  14. bittensor_cli/src/commands/stake/move.py +1000 -0
  15. bittensor_cli/src/commands/stake/stake.py +1637 -1264
  16. bittensor_cli/src/commands/subnets/__init__.py +0 -0
  17. bittensor_cli/src/commands/subnets/price.py +867 -0
  18. bittensor_cli/src/commands/subnets/subnets.py +2043 -0
  19. bittensor_cli/src/commands/sudo.py +529 -26
  20. bittensor_cli/src/commands/wallets.py +231 -535
  21. bittensor_cli/src/commands/weights.py +15 -11
  22. {bittensor_cli-8.4.2.dist-info → bittensor_cli-9.0.0rc1.dist-info}/METADATA +7 -4
  23. bittensor_cli-9.0.0rc1.dist-info/RECORD +32 -0
  24. bittensor_cli/src/bittensor/async_substrate_interface.py +0 -2748
  25. bittensor_cli/src/commands/root.py +0 -1752
  26. bittensor_cli/src/commands/subnets.py +0 -897
  27. bittensor_cli-8.4.2.dist-info/RECORD +0 -31
  28. {bittensor_cli-8.4.2.dist-info → bittensor_cli-9.0.0rc1.dist-info}/WHEEL +0 -0
  29. {bittensor_cli-8.4.2.dist-info → bittensor_cli-9.0.0rc1.dist-info}/entry_points.txt +0 -0
  30. {bittensor_cli-8.4.2.dist-info → bittensor_cli-9.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -18,6 +18,7 @@
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:
@@ -72,7 +73,10 @@ class Balance:
72
73
  """
73
74
  Returns the Balance object as a string in the format "symbolvalue", where the value is in tao.
74
75
  """
75
- return f"{self.unit}{float(self.tao):,.9f}"
76
+ if self.unit == UNITS[0]:
77
+ return f"{self.unit} {float(self.tao):,.4f}"
78
+ else:
79
+ return f"{float(self.tao):,.4f} {self.unit}\u200e"
76
80
 
77
81
  def __rich__(self):
78
82
  return "[green]{}[/green][green]{}[/green][green].[/green][dim green]{}[/dim green]".format(
@@ -225,12 +229,6 @@ class Balance:
225
229
  except (ValueError, TypeError):
226
230
  raise NotImplementedError("Unsupported type")
227
231
 
228
- def __int__(self) -> int:
229
- return self.rao
230
-
231
- def __float__(self) -> float:
232
- return self.tao
233
-
234
232
  def __nonzero__(self) -> bool:
235
233
  return bool(self.rao)
236
234
 
@@ -278,4 +276,39 @@ class Balance:
278
276
 
279
277
  :return: A Balance object representing the given amount.
280
278
  """
281
- return Balance(amount)
279
+ return Balance(int(amount))
280
+
281
+ @staticmethod
282
+ def get_unit(netuid: int):
283
+ units = UNITS
284
+ base = len(units)
285
+ if netuid < base:
286
+ return units[netuid]
287
+ else:
288
+ result = ""
289
+ while netuid > 0:
290
+ result = units[netuid % base] + result
291
+ netuid //= base
292
+ return result
293
+
294
+ def set_unit(self, netuid: int):
295
+ self.unit = Balance.get_unit(netuid)
296
+ self.rao_unit = Balance.get_unit(netuid)
297
+ return self
298
+
299
+
300
+ def fixed_to_float(fixed: dict) -> float:
301
+ # Currently this is stored as a U64F64
302
+ # which is 64 bits of integer and 64 bits of fractional
303
+ # uint_bits = 64
304
+ frac_bits = 64
305
+
306
+ data: int = fixed["bits"]
307
+
308
+ # Shift bits to extract integer part (assuming 64 bits for integer part)
309
+ integer_part = data >> frac_bits
310
+ fractional_part = data & (2**frac_bits - 1)
311
+
312
+ frac_float = fractional_part / (2**frac_bits)
313
+
314
+ return integer_part + frac_float