bittensor-cli 9.1.3__tar.gz → 9.1.4__tar.gz

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 (41) hide show
  1. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/PKG-INFO +2 -2
  2. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/cli.py +22 -18
  3. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/__init__.py +105 -58
  4. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/chain_data.py +3 -1
  5. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/subtensor_interface.py +13 -5
  6. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/utils.py +2 -3
  7. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/stake/add.py +19 -23
  8. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/stake/children_hotkeys.py +17 -14
  9. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/stake/list.py +93 -95
  10. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/stake/move.py +0 -3
  11. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/stake/remove.py +38 -33
  12. bittensor_cli-9.1.4/bittensor_cli/src/commands/subnets/__init__.py +0 -0
  13. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/subnets/subnets.py +13 -14
  14. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/sudo.py +1 -2
  15. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/wallets.py +4 -3
  16. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/version.py +1 -1
  17. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/PKG-INFO +2 -2
  18. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/requires.txt +1 -1
  19. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/pyproject.toml +2 -2
  20. bittensor_cli-9.1.3/bittensor_cli/src/commands/stake/__init__.py +0 -154
  21. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/README.md +0 -0
  22. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/__init__.py +0 -0
  23. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/doc_generation_helper.py +0 -0
  24. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/__init__.py +0 -0
  25. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/balances.py +0 -0
  26. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/extrinsics/__init__.py +0 -0
  27. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/extrinsics/registration.py +0 -0
  28. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/extrinsics/root.py +0 -0
  29. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/extrinsics/transfer.py +0 -0
  30. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/minigraph.py +0 -0
  31. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/bittensor/networking.py +0 -0
  32. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/__init__.py +0 -0
  33. {bittensor_cli-9.1.3/bittensor_cli/src/commands/subnets → bittensor_cli-9.1.4/bittensor_cli/src/commands/stake}/__init__.py +0 -0
  34. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/subnets/price.py +0 -0
  35. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/view.py +0 -0
  36. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli/src/commands/weights.py +0 -0
  37. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/SOURCES.txt +0 -0
  38. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/dependency_links.txt +0 -0
  39. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/entry_points.txt +0 -0
  40. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/bittensor_cli.egg-info/top_level.txt +0 -0
  41. {bittensor_cli-9.1.3 → bittensor_cli-9.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bittensor-cli
3
- Version: 9.1.3
3
+ Version: 9.1.4
4
4
  Summary: Bittensor CLI
5
5
  Author: bittensor.com
6
6
  Project-URL: homepage, https://github.com/opentensor/btcli
@@ -9,7 +9,7 @@ Requires-Python: <3.13,>=3.9
9
9
  Description-Content-Type: text/markdown
10
10
  Requires-Dist: wheel
11
11
  Requires-Dist: async-property==0.2.2
12
- Requires-Dist: async-substrate-interface>=1.0.5
12
+ Requires-Dist: async-substrate-interface>=1.0.7
13
13
  Requires-Dist: aiohttp~=3.10.2
14
14
  Requires-Dist: backoff~=2.2.1
15
15
  Requires-Dist: GitPython>=3.0.0
@@ -25,7 +25,7 @@ from bittensor_cli.src import (
25
25
  WalletOptions as WO,
26
26
  WalletValidationTypes as WV,
27
27
  Constants,
28
- COLOR_PALETTE,
28
+ COLORS,
29
29
  HYPERPARAMS,
30
30
  )
31
31
  from bittensor_cli.version import __version__, __version_as_int__
@@ -241,6 +241,7 @@ class Options:
241
241
  "--slippage",
242
242
  "--slippage-tolerance",
243
243
  "--tolerance",
244
+ "--rate-tolerance",
244
245
  help="Set the rate tolerance percentage for transactions (default: 0.05%).",
245
246
  callback=validate_rate_tolerance,
246
247
  )
@@ -341,8 +342,8 @@ def get_optional_netuid(netuid: Optional[int], all_netuids: bool) -> Optional[in
341
342
  return None
342
343
  elif netuid is None and all_netuids is False:
343
344
  answer = Prompt.ask(
344
- f"Enter the [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]netuid"
345
- f"[/{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}] to use. Leave blank for all netuids",
345
+ f"Enter the [{COLORS.G.SUBHEAD_MAIN}]netuid"
346
+ f"[/{COLORS.G.SUBHEAD_MAIN}] to use. Leave blank for all netuids",
346
347
  default=None,
347
348
  show_default=False,
348
349
  )
@@ -950,7 +951,8 @@ class CLIManager:
950
951
  elif self.config["network"]:
951
952
  self.subtensor = SubtensorInterface(self.config["network"])
952
953
  console.print(
953
- f"Using the specified network [{COLOR_PALETTE['GENERAL']['LINKS']}]{self.config['network']}[/{COLOR_PALETTE['GENERAL']['LINKS']}] from config"
954
+ f"Using the specified network [{COLORS.G.LINKS}]{self.config['network']}"
955
+ f"[/{COLORS.G.LINKS}] from config"
954
956
  )
955
957
  else:
956
958
  self.subtensor = SubtensorInterface(defaults.subtensor.network)
@@ -1523,7 +1525,7 @@ class CLIManager:
1523
1525
  else:
1524
1526
  wallet_name = Prompt.ask(
1525
1527
  "Enter the [blue]wallet name[/blue]"
1526
- + f" [{COLOR_PALETTE['GENERAL']['HINT']} italic](Hint: You can set this with `btcli config set --wallet-name`)",
1528
+ + f" [{COLORS.G.HINT} italic](Hint: You can set this with `btcli config set --wallet-name`)",
1527
1529
  default=defaults.wallet.name,
1528
1530
  )
1529
1531
 
@@ -2049,7 +2051,7 @@ class CLIManager:
2049
2051
 
2050
2052
  if not wallet_name:
2051
2053
  wallet_name = Prompt.ask(
2052
- f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
2054
+ f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2053
2055
  default=defaults.wallet.name,
2054
2056
  )
2055
2057
 
@@ -2106,7 +2108,7 @@ class CLIManager:
2106
2108
 
2107
2109
  if not wallet_name:
2108
2110
  wallet_name = Prompt.ask(
2109
- f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
2111
+ f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2110
2112
  default=defaults.wallet.name,
2111
2113
  )
2112
2114
  wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)
@@ -2223,13 +2225,13 @@ class CLIManager:
2223
2225
 
2224
2226
  if not wallet_name:
2225
2227
  wallet_name = Prompt.ask(
2226
- f"Enter the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]wallet name",
2228
+ f"Enter the [{COLORS.G.CK}]wallet name",
2227
2229
  default=defaults.wallet.name,
2228
2230
  )
2229
2231
 
2230
2232
  if not wallet_hotkey:
2231
2233
  wallet_hotkey = Prompt.ask(
2232
- f"Enter the name of the [{COLOR_PALETTE['GENERAL']['HOTKEY']}]new hotkey",
2234
+ f"Enter the name of the [{COLORS.G.HK}]new hotkey",
2233
2235
  default=defaults.wallet.hotkey,
2234
2236
  )
2235
2237
 
@@ -2285,7 +2287,7 @@ class CLIManager:
2285
2287
 
2286
2288
  if not wallet_name:
2287
2289
  wallet_name = Prompt.ask(
2288
- f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
2290
+ f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2289
2291
  default=defaults.wallet.name,
2290
2292
  )
2291
2293
 
@@ -2359,12 +2361,12 @@ class CLIManager:
2359
2361
 
2360
2362
  if not wallet_name:
2361
2363
  wallet_name = Prompt.ask(
2362
- f"Enter the name of the [{COLOR_PALETTE['GENERAL']['COLDKEY']}]new wallet (coldkey)",
2364
+ f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2363
2365
  default=defaults.wallet.name,
2364
2366
  )
2365
2367
  if not wallet_hotkey:
2366
2368
  wallet_hotkey = Prompt.ask(
2367
- f"Enter the the name of the [{COLOR_PALETTE['GENERAL']['HOTKEY']}]new hotkey",
2369
+ f"Enter the the name of the [{COLORS.G.HK}]new hotkey",
2368
2370
  default=defaults.wallet.hotkey,
2369
2371
  )
2370
2372
 
@@ -2742,9 +2744,10 @@ class CLIManager:
2742
2744
  self.verbosity_handler(quiet, verbose)
2743
2745
  if use_hotkey is None:
2744
2746
  use_hotkey = Confirm.ask(
2745
- f"Would you like to sign the transaction using your [{COLOR_PALETTE['GENERAL']['HOTKEY']}]hotkey[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]?"
2746
- f"\n[Type [{COLOR_PALETTE['GENERAL']['HOTKEY']}]y[/{COLOR_PALETTE['GENERAL']['HOTKEY']}] for [{COLOR_PALETTE['GENERAL']['HOTKEY']}]hotkey[/{COLOR_PALETTE['GENERAL']['HOTKEY']}]"
2747
- f" and [{COLOR_PALETTE['GENERAL']['COLDKEY']}]n[/{COLOR_PALETTE['GENERAL']['COLDKEY']}] for [{COLOR_PALETTE['GENERAL']['COLDKEY']}]coldkey[/{COLOR_PALETTE['GENERAL']['COLDKEY']}]] (default is [{COLOR_PALETTE['GENERAL']['COLDKEY']}]coldkey[/{COLOR_PALETTE['GENERAL']['COLDKEY']}])",
2747
+ f"Would you like to sign the transaction using your [{COLORS.G.HK}]hotkey[/{COLORS.G.HK}]?"
2748
+ f"\n[Type [{COLORS.G.HK}]y[/{COLORS.G.HK}] for [{COLORS.G.HK}]hotkey[/{COLORS.G.HK}]"
2749
+ f" and [{COLORS.G.CK}]n[/{COLORS.G.CK}] for [{COLORS.G.CK}]coldkey[/{COLORS.G.CK}]] "
2750
+ f"(default is [{COLORS.G.CK}]coldkey[/{COLORS.G.CK}])",
2748
2751
  default=False,
2749
2752
  )
2750
2753
 
@@ -3035,11 +3038,11 @@ class CLIManager:
3035
3038
  raise typer.Exit()
3036
3039
  if netuid is not None:
3037
3040
  amount = FloatPrompt.ask(
3038
- f"Amount to [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]stake (TAO τ)"
3041
+ f"Amount to [{COLORS.G.SUBHEAD_MAIN}]stake (TAO τ)"
3039
3042
  )
3040
3043
  else:
3041
3044
  amount = FloatPrompt.ask(
3042
- f"Amount to [{COLOR_PALETTE['GENERAL']['SUBHEADING_MAIN']}]stake to each netuid (TAO τ)"
3045
+ f"Amount to [{COLORS.G.SUBHEAD_MAIN}]stake to each netuid (TAO τ)"
3043
3046
  )
3044
3047
 
3045
3048
  if amount <= 0:
@@ -4112,7 +4115,8 @@ class CLIManager:
4112
4115
  if not param_value:
4113
4116
  if HYPERPARAMS.get(param_name):
4114
4117
  param_value = Prompt.ask(
4115
- f"Enter the new value for [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{param_name}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}] in the VALUE column format"
4118
+ f"Enter the new value for [{COLORS.G.SUBHEAD}]{param_name}[/{COLORS.G.SUBHEAD}] "
4119
+ f"in the VALUE column format"
4116
4120
  )
4117
4121
  else:
4118
4122
  param_value = None
@@ -721,64 +721,111 @@ HELP_PANELS = {
721
721
  },
722
722
  }
723
723
 
724
- COLOR_PALETTE = {
725
- "GENERAL": {
726
- "HEADER": "#4196D6", # Light Blue
727
- "LINKS": "#8CB9E9", # Sky Blue
728
- "HINT": "#A2E5B8", # Mint Green
729
- "COLDKEY": "#9EF5E4", # Aqua
730
- "HOTKEY": "#ECC39D", # Light Orange/Peach
731
- "SUBHEADING_MAIN": "#7ECFEC", # Light Cyan
732
- "SUBHEADING": "#AFEFFF", # Pale Blue
733
- "SUBHEADING_EXTRA_1": "#96A3C5", # Grayish Blue
734
- "SUBHEADING_EXTRA_2": "#6D7BAF", # Slate Blue
735
- "CONFIRMATION_Y_N_Q": "#EE8DF8", # Light Purple/Pink
736
- "SYMBOL": "#E7CC51", # Gold
737
- "BALANCE": "#4F91C6", # Medium Blue
738
- "COST": "#53B5A0", # Teal
739
- "SUCCESS": "#53B5A0", # Teal
740
- "NETUID": "#CBA880", # Tan
741
- "NETUID_EXTRA": "#DDD5A9", # Light Khaki
742
- "TEMPO": "#67A3A5", # Grayish Teal
743
- },
744
- "STAKE": {
745
- "STAKE_AMOUNT": "#53B5A0", # Teal
746
- "STAKE_ALPHA": "#53B5A0", # Teal
747
- "STAKE_SWAP": "#67A3A5", # Grayish Teal
748
- "TAO": "#4F91C6", # Medium Blue
749
- "SLIPPAGE_TEXT": "#C25E7C", # Rose
750
- "SLIPPAGE_PERCENT": "#E7B195", # Light Coral
751
- "NOT_REGISTERED": "#EB6A6C", # Salmon Red
752
- "EXTRA_1": "#D781BB", # Pink
753
- },
754
- "POOLS": {
755
- "TAO": "#4F91C6", # Medium Blue
756
- "ALPHA_IN": "#D09FE9", # Light Purple
757
- "ALPHA_OUT": "#AB7CC8", # Medium Purple
758
- "RATE": "#F8D384", # Light Orange
759
- "TAO_EQUIV": "#8CB9E9", # Sky Blue
760
- "EMISSION": "#F8D384", # Light Orange
761
- "EXTRA_1": "#CAA8FB", # Lavender
762
- "EXTRA_2": "#806DAF", # Dark Purple
763
- },
764
- "GREY": {
765
- "GREY_100": "#F8F9FA", # Almost White
766
- "GREY_200": "#F1F3F4", # Very Light Grey
767
- "GREY_300": "#DBDDE1", # Light Grey
768
- "GREY_400": "#BDC1C6", # Medium Light Grey
769
- "GREY_500": "#5F6368", # Medium Grey
770
- "GREY_600": "#2E3134", # Medium Dark Grey
771
- "GREY_700": "#282A2D", # Dark Grey
772
- "GREY_800": "#17181B", # Very Dark Grey
773
- "GREY_900": "#0E1013", # Almost Black
774
- "BLACK": "#000000", # Pure Black
775
- },
776
- "SUDO": {
777
- "HYPERPARAMETER": "#4F91C6", # Medium Blue
778
- "VALUE": "#D09FE9", # Light Purple
779
- "NORMALIZED": "#AB7CC8", # Medium Purple
780
- },
781
- }
724
+
725
+ class Gettable:
726
+ def __getitem__(self, item):
727
+ return getattr(self, item)
728
+
729
+
730
+ class ColorPalette(Gettable):
731
+ def __init__(self):
732
+ self.GENERAL = self.General()
733
+ self.STAKE = self.Stake()
734
+ self.POOLS = self.Pools()
735
+ self.GREY = self.Grey()
736
+ self.SUDO = self.Sudo()
737
+ # aliases
738
+ self.G = self.GENERAL
739
+ self.S = self.STAKE
740
+ self.P = self.POOLS
741
+ self.GR = self.GREY
742
+ self.SU = self.SUDO
743
+
744
+ class General(Gettable):
745
+ HEADER = "#4196D6" # Light Blue
746
+ LINKS = "#8CB9E9" # Sky Blue
747
+ HINT = "#A2E5B8" # Mint Green
748
+ COLDKEY = "#9EF5E4" # Aqua
749
+ HOTKEY = "#ECC39D" # Light Orange/Peach
750
+ SUBHEADING_MAIN = "#7ECFEC" # Light Cyan
751
+ SUBHEADING = "#AFEFFF" # Pale Blue
752
+ SUBHEADING_EXTRA_1 = "#96A3C5" # Grayish Blue
753
+ SUBHEADING_EXTRA_2 = "#6D7BAF" # Slate Blue
754
+ CONFIRMATION_Y_N_Q = "#EE8DF8" # Light Purple/Pink
755
+ SYMBOL = "#E7CC51" # Gold
756
+ BALANCE = "#4F91C6" # Medium Blue
757
+ COST = "#53B5A0" # Teal
758
+ SUCCESS = "#53B5A0" # Teal
759
+ NETUID = "#CBA880" # Tan
760
+ NETUID_EXTRA = "#DDD5A9" # Light Khaki
761
+ TEMPO = "#67A3A5" # Grayish Teal
762
+ # aliases
763
+ CK = COLDKEY
764
+ HK = HOTKEY
765
+ SUBHEAD_MAIN = SUBHEADING_MAIN
766
+ SUBHEAD = SUBHEADING
767
+ SUBHEAD_EX_1 = SUBHEADING_EXTRA_1
768
+ SUBHEAD_EX_2 = SUBHEADING_EXTRA_2
769
+ SYM = SYMBOL
770
+ BAL = BALANCE
771
+
772
+ class Stake(Gettable):
773
+ STAKE_AMOUNT = "#53B5A0" # Teal
774
+ STAKE_ALPHA = "#53B5A0" # Teal
775
+ STAKE_SWAP = "#67A3A5" # Grayish Teal
776
+ TAO = "#4F91C6" # Medium Blue
777
+ SLIPPAGE_TEXT = "#C25E7C" # Rose
778
+ SLIPPAGE_PERCENT = "#E7B195" # Light Coral
779
+ NOT_REGISTERED = "#EB6A6C" # Salmon Red
780
+ EXTRA_1 = "#D781BB" # Pink
781
+ # aliases
782
+ AMOUNT = STAKE_AMOUNT
783
+ ALPHA = STAKE_ALPHA
784
+ SWAP = STAKE_SWAP
785
+
786
+ class Pools(Gettable):
787
+ TAO = "#4F91C6" # Medium Blue
788
+ ALPHA_IN = "#D09FE9" # Light Purple
789
+ ALPHA_OUT = "#AB7CC8" # Medium Purple
790
+ RATE = "#F8D384" # Light Orange
791
+ TAO_EQUIV = "#8CB9E9" # Sky Blue
792
+ EMISSION = "#F8D384" # Light Orange
793
+ EXTRA_1 = "#CAA8FB" # Lavender
794
+ EXTRA_2 = "#806DAF" # Dark Purple
795
+
796
+ class Grey(Gettable):
797
+ GREY_100 = "#F8F9FA" # Almost White
798
+ GREY_200 = "#F1F3F4" # Very Light Grey
799
+ GREY_300 = "#DBDDE1" # Light Grey
800
+ GREY_400 = "#BDC1C6" # Medium Light Grey
801
+ GREY_500 = "#5F6368" # Medium Grey
802
+ GREY_600 = "#2E3134" # Medium Dark Grey
803
+ GREY_700 = "#282A2D" # Dark Grey
804
+ GREY_800 = "#17181B" # Very Dark Grey
805
+ GREY_900 = "#0E1013" # Almost Black
806
+ BLACK = "#000000" # Pure Black
807
+ # aliases
808
+ G_100 = GREY_100
809
+ G_200 = GREY_200
810
+ G_300 = GREY_300
811
+ G_400 = GREY_400
812
+ G_500 = GREY_500
813
+ G_600 = GREY_600
814
+ G_700 = GREY_700
815
+ G_800 = GREY_800
816
+ G_900 = GREY_900
817
+
818
+ class Sudo(Gettable):
819
+ HYPERPARAMETER = "#4F91C6" # Medium Blue
820
+ VALUE = "#D09FE9" # Light Purple
821
+ NORMALIZED = "#AB7CC8" # Medium Purple
822
+ # aliases
823
+ HYPERPARAM = HYPERPARAMETER
824
+ NORMAL = NORMALIZED
825
+
826
+
827
+ COLOR_PALETTE = ColorPalette()
828
+ COLORS = COLOR_PALETTE
782
829
 
783
830
 
784
831
  SUBNETS = {
@@ -745,7 +745,9 @@ class DynamicInfo(InfoBase):
745
745
  def alpha_to_tao(self, alpha: Balance) -> Balance:
746
746
  return Balance.from_tao(alpha.tao * self.price.tao)
747
747
 
748
- def tao_to_alpha_with_slippage(self, tao: Balance) -> tuple[Balance, Balance]:
748
+ def tao_to_alpha_with_slippage(
749
+ self, tao: Balance
750
+ ) -> tuple[Balance, Balance, float]:
749
751
  """
750
752
  Returns an estimate of how much Alpha would a staker receive if they stake their tao using the current pool state.
751
753
  Args:
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import os
2
3
  from typing import Optional, Any, Union, TypedDict, Iterable
3
4
 
4
5
  import aiohttp
@@ -9,7 +10,10 @@ from async_substrate_interface.errors import SubstrateRequestException
9
10
  import typer
10
11
 
11
12
 
12
- from async_substrate_interface.async_substrate import AsyncSubstrateInterface
13
+ from async_substrate_interface.async_substrate import (
14
+ DiskCachedAsyncSubstrateInterface,
15
+ AsyncSubstrateInterface,
16
+ )
13
17
  from bittensor_cli.src.bittensor.chain_data import (
14
18
  DelegateInfo,
15
19
  StakeInfo,
@@ -34,6 +38,12 @@ from bittensor_cli.src.bittensor.utils import (
34
38
  u16_normalized_float,
35
39
  )
36
40
 
41
+ SubstrateClass = (
42
+ DiskCachedAsyncSubstrateInterface
43
+ if os.getenv("DISK_CACHE", "0") == "1"
44
+ else AsyncSubstrateInterface
45
+ )
46
+
37
47
 
38
48
  class ParamWithTypes(TypedDict):
39
49
  name: str # Name of the parameter.
@@ -98,7 +108,7 @@ class SubtensorInterface:
98
108
  self.chain_endpoint = Constants.network_map[defaults.subtensor.network]
99
109
  self.network = defaults.subtensor.network
100
110
 
101
- self.substrate = AsyncSubstrateInterface(
111
+ self.substrate = SubstrateClass(
102
112
  url=self.chain_endpoint,
103
113
  ss58_format=SS58_FORMAT,
104
114
  type_registry=TYPE_REGISTRY,
@@ -207,7 +217,7 @@ class SubtensorInterface:
207
217
 
208
218
  if result is None:
209
219
  return []
210
- stakes = StakeInfo.list_from_any(result)
220
+ stakes: list[StakeInfo] = StakeInfo.list_from_any(result)
211
221
  return [stake for stake in stakes if stake.stake > 0]
212
222
 
213
223
  async def get_stake_for_coldkey_and_hotkey(
@@ -352,14 +362,12 @@ class SubtensorInterface:
352
362
  self,
353
363
  *ss58_addresses,
354
364
  block_hash: Optional[str] = None,
355
- reuse_block: bool = False,
356
365
  ) -> dict[str, tuple[Balance, Balance]]:
357
366
  """
358
367
  Returns the total stake held on a coldkey.
359
368
 
360
369
  :param ss58_addresses: The SS58 address(es) of the coldkey(s)
361
370
  :param block_hash: The hash of the block number to retrieve the stake from.
362
- :param reuse_block: Whether to reuse the last-used block hash when retrieving info.
363
371
 
364
372
  :return: {address: Balance objects}
365
373
  """
@@ -5,7 +5,6 @@ import os
5
5
  import sqlite3
6
6
  import platform
7
7
  import webbrowser
8
- import sys
9
8
  from pathlib import Path
10
9
  from typing import TYPE_CHECKING, Any, Collection, Optional, Union, Callable
11
10
  from urllib.parse import urlparse
@@ -73,8 +72,8 @@ class WalletLike:
73
72
  return self._coldkeypub
74
73
 
75
74
 
76
- def print_console(message: str, colour: str, title: str, console: Console):
77
- console.print(
75
+ def print_console(message: str, colour: str, title: str, console_: Console):
76
+ console_.print(
78
77
  f"[bold {colour}][{title}]:[/bold {colour}] [{colour}]{message}[/{colour}]\n"
79
78
  )
80
79
 
@@ -46,9 +46,7 @@ async def stake_add(
46
46
  netuid: the netuid to stake to (None indicates all subnets)
47
47
  stake_all: whether to stake all available balance
48
48
  amount: specified amount of balance to stake
49
- delegate: whether to delegate stake, currently unused
50
49
  prompt: whether to prompt the user
51
- max_stake: maximum amount to stake (used in combination with stake_all), currently unused
52
50
  all_hotkeys: whether to stake all hotkeys
53
51
  include_hotkeys: list of hotkeys to include in staking process (if not specifying `--all`)
54
52
  exclude_hotkeys: list of hotkeys to exclude in staking (if specifying `--all`)
@@ -61,18 +59,16 @@ async def stake_add(
61
59
  """
62
60
 
63
61
  async def safe_stake_extrinsic(
64
- netuid: int,
65
- amount: Balance,
62
+ netuid_: int,
63
+ amount_: Balance,
66
64
  current_stake: Balance,
67
- hotkey_ss58: str,
65
+ hotkey_ss58_: str,
68
66
  price_limit: Balance,
69
- wallet: Wallet,
70
- subtensor: "SubtensorInterface",
71
67
  status=None,
72
68
  ) -> None:
73
69
  err_out = partial(print_error, status=status)
74
70
  failure_prelude = (
75
- f":cross_mark: [red]Failed[/red] to stake {amount} on Netuid {netuid}"
71
+ f":cross_mark: [red]Failed[/red] to stake {amount_} on Netuid {netuid_}"
76
72
  )
77
73
  current_balance = await subtensor.get_balance(wallet.coldkeypub.ss58_address)
78
74
  next_nonce = await subtensor.substrate.get_account_next_index(
@@ -82,9 +78,9 @@ async def stake_add(
82
78
  call_module="SubtensorModule",
83
79
  call_function="add_stake_limit",
84
80
  call_params={
85
- "hotkey": hotkey_ss58,
86
- "netuid": netuid,
87
- "amount_staked": amount.rao,
81
+ "hotkey": hotkey_ss58_,
82
+ "netuid": netuid_,
83
+ "amount_staked": amount_.rao,
88
84
  "limit_price": price_limit,
89
85
  "allow_partial": allow_partial_stake,
90
86
  },
@@ -119,30 +115,30 @@ async def stake_add(
119
115
  new_balance, new_stake = await asyncio.gather(
120
116
  subtensor.get_balance(wallet.coldkeypub.ss58_address, block_hash),
121
117
  subtensor.get_stake(
122
- hotkey_ss58=hotkey_ss58,
118
+ hotkey_ss58=hotkey_ss58_,
123
119
  coldkey_ss58=wallet.coldkeypub.ss58_address,
124
- netuid=netuid,
120
+ netuid=netuid_,
125
121
  block_hash=block_hash,
126
122
  ),
127
123
  )
128
124
  console.print(
129
- f":white_heavy_check_mark: [dark_sea_green3]Finalized. Stake added to netuid: {netuid}[/dark_sea_green3]"
125
+ f":white_heavy_check_mark: [dark_sea_green3]Finalized. Stake added to netuid: {netuid_}[/dark_sea_green3]"
130
126
  )
131
127
  console.print(
132
128
  f"Balance:\n [blue]{current_balance}[/blue] :arrow_right: [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{new_balance}"
133
129
  )
134
130
 
135
131
  amount_staked = current_balance - new_balance
136
- if allow_partial_stake and (amount_staked != amount):
132
+ if allow_partial_stake and (amount_staked != amount_):
137
133
  console.print(
138
134
  "Partial stake transaction. Staked:\n"
139
135
  f" [{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}]{amount_staked}[/{COLOR_PALETTE['STAKE']['STAKE_AMOUNT']}] "
140
136
  f"instead of "
141
- f"[blue]{amount}[/blue]"
137
+ f"[blue]{amount_}[/blue]"
142
138
  )
143
139
 
144
140
  console.print(
145
- f"Subnet: [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{netuid}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}] "
141
+ f"Subnet: [{COLOR_PALETTE['GENERAL']['SUBHEADING']}]{netuid_}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}] "
146
142
  f"Stake:\n"
147
143
  f" [blue]{current_stake}[/blue] "
148
144
  f":arrow_right: "
@@ -361,13 +357,11 @@ async def stake_add(
361
357
  else:
362
358
  stake_coroutines.append(
363
359
  safe_stake_extrinsic(
364
- netuid=ni,
365
- amount=am,
360
+ netuid_=ni,
361
+ amount_=am,
366
362
  current_stake=curr,
367
- hotkey_ss58=staking_address,
363
+ hotkey_ss58_=staking_address,
368
364
  price_limit=price_with_tolerance,
369
- wallet=wallet,
370
- subtensor=subtensor,
371
365
  )
372
366
  )
373
367
  else:
@@ -590,7 +584,9 @@ The columns are as follows:
590
584
  console.print(base_description + (safe_staking_description if safe_staking else ""))
591
585
 
592
586
 
593
- def _calculate_slippage(subnet_info, amount: Balance) -> tuple[Balance, str, float]:
587
+ def _calculate_slippage(
588
+ subnet_info, amount: Balance
589
+ ) -> tuple[Balance, str, float, str]:
594
590
  """Calculate slippage when adding stake.
595
591
 
596
592
  Args:
@@ -313,9 +313,12 @@ async def get_children(
313
313
  """
314
314
  Get the take value for a given subtensor, hotkey, and netuid.
315
315
 
316
- @param child: The hotkey to retrieve the take value for.
316
+ Arguments:
317
+ child: The hotkey to retrieve the take value for.
318
+ netuid__: the netuid to retrieve the take value for.
317
319
 
318
- @return: The take value as a float. If the take value is not available, it returns 0.
320
+ Returns:
321
+ The take value as a float. If the take value is not available, it returns 0.
319
322
 
320
323
  """
321
324
  child_hotkey = child[1]
@@ -383,7 +386,7 @@ async def get_children(
383
386
  f"The total stake of parent hotkey '{parent_hotkey}'{insert_text}is {parent_total}."
384
387
  )
385
388
 
386
- for index, (netuid_, children_) in enumerate(netuid_children_):
389
+ for index, (child_netuid, children_) in enumerate(netuid_children_):
387
390
  # calculate totals
388
391
  total_proportion_per_netuid = 0
389
392
  total_stake_weight_per_netuid = 0
@@ -393,7 +396,7 @@ async def get_children(
393
396
 
394
397
  children_info = []
395
398
  child_takes = await asyncio.gather(
396
- *[get_take(c, netuid_) for c in children_]
399
+ *[get_take(c, child_netuid) for c in children_]
397
400
  )
398
401
  for child, child_take in zip(children_, child_takes):
399
402
  proportion = child[0]
@@ -408,7 +411,7 @@ async def get_children(
408
411
  (
409
412
  converted_proportion,
410
413
  child_hotkey,
411
- hotkey_stake_dict[child_hotkey][netuid_],
414
+ hotkey_stake_dict[child_hotkey][child_netuid],
412
415
  child_take,
413
416
  )
414
417
  )
@@ -420,7 +423,7 @@ async def get_children(
420
423
  for proportion_, hotkey, stake, child_take in children_info:
421
424
  proportion_percent = proportion_ * 100 # Proportion in percent
422
425
  proportion_tao = (
423
- hotkey_stake[netuid_].tao * proportion_
426
+ hotkey_stake[child_netuid].tao * proportion_
424
427
  ) # Proportion in TAO
425
428
 
426
429
  total_proportion_per_netuid += proportion_percent
@@ -433,7 +436,7 @@ async def get_children(
433
436
 
434
437
  hotkey = Text(hotkey, style="italic red" if proportion_ == 0 else "")
435
438
  table.add_row(
436
- str(netuid_),
439
+ str(child_netuid),
437
440
  hotkey,
438
441
  proportion_str,
439
442
  take_str,
@@ -661,28 +664,28 @@ async def childkey_take(
661
664
  table.add_column("Netuid", justify="center", style="cyan")
662
665
  table.add_column("Take (%)", justify="right", style="magenta")
663
666
 
664
- for netuid, take_value in takes:
665
- table.add_row(str(netuid), f"{take_value:.2f}%")
667
+ for take_netuid, take_value in takes:
668
+ table.add_row(str(take_netuid), f"{take_value:.2f}%")
666
669
 
667
670
  console.print(table)
668
671
 
669
- async def display_chk_take(ss58, netuid):
672
+ async def display_chk_take(ss58, take_netuid):
670
673
  """Print single key take for hotkey and netuid"""
671
674
  chk_take = await get_childkey_take(
672
- subtensor=subtensor, netuid=netuid, hotkey=ss58
675
+ subtensor=subtensor, netuid=take_netuid, hotkey=ss58
673
676
  )
674
677
  if chk_take is None:
675
678
  chk_take = 0
676
679
  chk_take = u16_to_float(chk_take)
677
680
  console.print(
678
- f"Child take for {ss58} is: {chk_take * 100:.2f}% on netuid {netuid}."
681
+ f"Child take for {ss58} is: {chk_take * 100:.2f}% on netuid {take_netuid}."
679
682
  )
680
683
 
681
684
  async def chk_all_subnets(ss58):
682
685
  """Aggregate data for childkey take from all subnets"""
683
- netuids = await subtensor.get_all_subnet_netuids()
686
+ all_netuids = await subtensor.get_all_subnet_netuids()
684
687
  takes = []
685
- for subnet in netuids:
688
+ for subnet in all_netuids:
686
689
  if subnet == 0:
687
690
  continue
688
691
  curr_take = await get_childkey_take(