bittensor-cli 9.21.1__tar.gz → 9.21.2__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 (68) hide show
  1. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/PKG-INFO +3 -8
  2. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/cli.py +1 -112
  3. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/__init__.py +0 -11
  4. bittensor_cli-9.21.2/bittensor_cli/src/bittensor/extrinsics/registration.py +286 -0
  5. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/extrinsics/root.py +47 -136
  6. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/extrinsics/serving.py +23 -2
  7. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/minigraph.py +62 -89
  8. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/subtensor_interface.py +7 -3
  9. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/utils.py +2 -82
  10. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/move.py +52 -4
  11. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/subnets/subnets.py +8 -8
  12. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/sudo.py +8 -24
  13. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/wallets.py +0 -32
  14. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/weights.py +12 -38
  15. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/pyproject.toml +3 -11
  16. bittensor_cli-9.21.1/bittensor_cli/src/bittensor/extrinsics/registration.py +0 -1646
  17. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/README.md +0 -0
  18. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/__init__.py +0 -0
  19. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/doc_generation_helper.py +0 -0
  20. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/__init__.py +0 -0
  21. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/balances.py +0 -0
  22. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/chain_data.py +0 -0
  23. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/extrinsics/__init__.py +0 -0
  24. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/extrinsics/mev_shield.py +0 -0
  25. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/extrinsics/transfer.py +0 -0
  26. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/networking.py +0 -0
  27. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/main-filters.j2 +0 -0
  28. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/main-header.j2 +0 -0
  29. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/neuron-details.j2 +0 -0
  30. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/price-multi.j2 +0 -0
  31. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/price-single.j2 +0 -0
  32. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/subnet-details-header.j2 +0 -0
  33. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/subnet-details.j2 +0 -0
  34. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/subnet-metrics.j2 +0 -0
  35. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/subnets-table.j2 +0 -0
  36. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/table.j2 +0 -0
  37. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/view.css +0 -0
  38. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/view.j2 +0 -0
  39. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/bittensor/templates/view.js +0 -0
  40. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/__init__.py +0 -0
  41. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/axon/__init__.py +0 -0
  42. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/axon/axon.py +0 -0
  43. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/__init__.py +0 -0
  44. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/contribute.py +0 -0
  45. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/contributors.py +0 -0
  46. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/create.py +0 -0
  47. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/dissolve.py +0 -0
  48. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/refund.py +0 -0
  49. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/update.py +0 -0
  50. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/utils.py +0 -0
  51. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/crowd/view.py +0 -0
  52. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/liquidity/__init__.py +0 -0
  53. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/liquidity/liquidity.py +0 -0
  54. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/liquidity/utils.py +0 -0
  55. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/proxy.py +0 -0
  56. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/__init__.py +0 -0
  57. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/add.py +0 -0
  58. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/auto_staking.py +0 -0
  59. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/children_hotkeys.py +0 -0
  60. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/claim.py +0 -0
  61. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/list.py +0 -0
  62. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/remove.py +0 -0
  63. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/stake/wizard.py +0 -0
  64. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/subnets/__init__.py +0 -0
  65. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/subnets/mechanisms.py +0 -0
  66. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/subnets/price.py +0 -0
  67. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/src/commands/view.py +0 -0
  68. {bittensor_cli-9.21.1 → bittensor_cli-9.21.2}/bittensor_cli/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bittensor-cli
3
- Version: 9.21.1
3
+ Version: 9.21.2
4
4
  Summary: Bittensor CLI
5
5
  Author: bittensor.com
6
6
  Requires-Python: >=3.10
@@ -18,16 +18,13 @@ Classifier: Topic :: Scientific/Engineering
18
18
  Classifier: Topic :: Scientific/Engineering :: Mathematics
19
19
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Classifier: Topic :: Utilities
21
- Requires-Dist: wheel
22
- Requires-Dist: async-substrate-interface>=2.0.3,<3.0.0
21
+ Requires-Dist: wheel>0.46.1
22
+ Requires-Dist: async-substrate-interface>=2.0.4,<3.0.0
23
23
  Requires-Dist: aiohttp~=3.13
24
- Requires-Dist: backoff~=2.2.1
25
24
  Requires-Dist: bittensor-drand>=1.3.0
26
25
  Requires-Dist: GitPython>=3.0.0
27
26
  Requires-Dist: netaddr~=1.3.0
28
- Requires-Dist: numpy>=2.0.1,<3.0.0
29
27
  Requires-Dist: Jinja2
30
- Requires-Dist: pycryptodome>=3.0.0,<4.0.0
31
28
  Requires-Dist: PyYAML~=6.0
32
29
  Requires-Dist: rich>=13.7,<15.0
33
30
  Requires-Dist: cyscale>=0.3.3,<1.0.0
@@ -37,10 +34,8 @@ Requires-Dist: bittensor-wallet==4.0.1
37
34
  Requires-Dist: packaging
38
35
  Requires-Dist: plotille>=5.0.0
39
36
  Requires-Dist: plotly>=6.0.0
40
- Requires-Dist: torch>=1.13.1,<3.0 ; extra == "cuda"
41
37
  Project-URL: Repository, https://github.com/opentensor/btcli
42
38
  Project-URL: homepage, https://github.com/opentensor/btcli
43
- Provides-Extra: cuda
44
39
 
45
40
  <div align="center">
46
41
 
@@ -16,7 +16,6 @@ from dataclasses import fields
16
16
  from pathlib import Path
17
17
  from typing import Coroutine, Optional, Union
18
18
 
19
- import numpy as np
20
19
  import rich
21
20
  import typer
22
21
  from async_substrate_interface.errors import (
@@ -124,8 +123,6 @@ except ImportError:
124
123
  logger = logging.getLogger("btcli")
125
124
  _epilog = "Made with [bold red]:heart:[/bold red] by The Openτensor Foundaτion"
126
125
 
127
- np.set_printoptions(precision=8, suppress=True, floatmode="fixed")
128
-
129
126
 
130
127
  def arg__(arg_name: str) -> str:
131
128
  """
@@ -383,6 +380,7 @@ class Options:
383
380
  None,
384
381
  "--tolerance",
385
382
  "--rate-tolerance",
383
+ "--limit",
386
384
  help="Set the rate tolerance percentage for transactions (default: 0.05 for 5%).",
387
385
  callback=validate_rate_tolerance,
388
386
  )
@@ -1061,9 +1059,6 @@ class CLIManager:
1061
1059
  rich_help_panel=HELP_PANELS["WALLET"]["INFORMATION"],
1062
1060
  hidden=True,
1063
1061
  )(self.wallet_inspect)
1064
- self.wallet_app.command(
1065
- "faucet", rich_help_panel=HELP_PANELS["WALLET"]["OPERATIONS"]
1066
- )(self.wallet_faucet)
1067
1062
  self.wallet_app.command(
1068
1063
  "set-identity", rich_help_panel=HELP_PANELS["WALLET"]["IDENTITY"]
1069
1064
  )(self.wallet_set_id)
@@ -3042,112 +3037,6 @@ class CLIManager:
3042
3037
  )
3043
3038
  )
3044
3039
 
3045
- def wallet_faucet(
3046
- self,
3047
- wallet_name: Optional[str] = Options.wallet_name,
3048
- wallet_path: Optional[str] = Options.wallet_path,
3049
- wallet_hotkey: Optional[str] = Options.wallet_hotkey,
3050
- network: Optional[list[str]] = Options.network,
3051
- # TODO add the following to config
3052
- processors: Optional[int] = typer.Option(
3053
- defaults.pow_register.num_processes,
3054
- "--processors",
3055
- help="Number of processors to use for proof of work (POW) registration.",
3056
- ),
3057
- update_interval: Optional[int] = typer.Option(
3058
- defaults.pow_register.update_interval,
3059
- "--update-interval",
3060
- "-u",
3061
- help="The number of nonces to process before checking for next block during registration",
3062
- ),
3063
- output_in_place: Optional[bool] = typer.Option(
3064
- defaults.pow_register.output_in_place,
3065
- help="Whether to output the registration statistics in-place.",
3066
- ),
3067
- verbose: Optional[bool] = typer.Option( # TODO verbosity handler
3068
- defaults.pow_register.verbose,
3069
- "--verbose",
3070
- "-v",
3071
- help="Whether to output the registration statistics verbosely.",
3072
- ),
3073
- use_cuda: Optional[bool] = typer.Option(
3074
- defaults.pow_register.cuda.use_cuda,
3075
- "--use-cuda/--no-use-cuda",
3076
- "--cuda/--no-cuda",
3077
- help="Set flag to use CUDA for proof of work (POW) registration.",
3078
- ),
3079
- dev_id: Optional[int] = typer.Option(
3080
- defaults.pow_register.cuda.dev_id,
3081
- "--dev-id",
3082
- "-d",
3083
- help="Set the CUDA device id(s) in the order of speed, where 0 is the fastest.",
3084
- ),
3085
- threads_per_block: Optional[int] = typer.Option(
3086
- defaults.pow_register.cuda.tpb,
3087
- "--threads-per-block",
3088
- "-tbp",
3089
- help="Set the number of threads per block for CUDA.",
3090
- ),
3091
- max_successes: Optional[int] = typer.Option(
3092
- 3,
3093
- "--max-successes",
3094
- help="Set the maximum number of times to successfully run the faucet for this command.",
3095
- ),
3096
- prompt: bool = Options.prompt,
3097
- ):
3098
- """
3099
- Obtain test TAO tokens by performing Proof of Work (PoW).
3100
-
3101
- This command is useful for users who need test tokens for operations on a local blockchain.
3102
-
3103
- [blue bold]IMPORTANT[/blue bold]: THIS COMMAND IS DISABLED ON FINNEY AND TESTNET.
3104
-
3105
- USAGE
3106
-
3107
- The command uses the proof-of-work (POW) mechanism to validate the user's effort and rewards them with test TAO tokens. It is
3108
- typically used in local blockchain environments where transactions do not use real TAO tokens.
3109
-
3110
- EXAMPLE
3111
-
3112
- [green]$[/green] btcli wallet faucet --faucet.num_processes 4 --faucet.cuda.use_cuda
3113
-
3114
- [bold]Note[/bold]: This command is meant for used in local environments where users can experiment with the blockchain without using real TAO tokens. Users must have the necessary hardware setup, especially when opting for CUDA-based GPU calculations. It is currently disabled on testnet and mainnet (finney). You can only use this command on a local blockchain.
3115
- """
3116
- # TODO should we add json_output?
3117
- wallet = self.wallet_ask(
3118
- wallet_name,
3119
- wallet_path,
3120
- wallet_hotkey,
3121
- ask_for=[WO.NAME, WO.PATH],
3122
- validate=WV.WALLET,
3123
- )
3124
- logger.debug(
3125
- "args:\n"
3126
- f"network {network}\n"
3127
- f"threads_per_block {threads_per_block}\n"
3128
- f"update_interval {update_interval}\n"
3129
- f"processors {processors}\n"
3130
- f"use_cuda {use_cuda}\n"
3131
- f"dev_id {dev_id}\n"
3132
- f"output_in_place {output_in_place}\n"
3133
- f"max_successes {max_successes}\n"
3134
- )
3135
- return self._run_command(
3136
- wallets.faucet(
3137
- wallet,
3138
- self.initialize_chain(network),
3139
- threads_per_block,
3140
- update_interval,
3141
- processors,
3142
- use_cuda,
3143
- dev_id,
3144
- output_in_place,
3145
- verbose,
3146
- max_successes,
3147
- prompt,
3148
- )
3149
- )
3150
-
3151
3040
  def wallet_regen_coldkey(
3152
3041
  self,
3153
3042
  wallet_name: Optional[str] = Options.wallet_name,
@@ -81,17 +81,6 @@ class Defaults:
81
81
  chain_endpoint = None
82
82
  _mock = False
83
83
 
84
- class pow_register:
85
- num_processes = None
86
- update_interval = 50_000
87
- output_in_place = True
88
- verbose = False
89
-
90
- class cuda:
91
- dev_id = 0
92
- use_cuda = False
93
- tpb = 256
94
-
95
84
  class wallet:
96
85
  name = "default"
97
86
  hotkey = "default"
@@ -0,0 +1,286 @@
1
+ import asyncio
2
+ import time
3
+ import typing
4
+ from typing import Optional
5
+
6
+ from async_substrate_interface import AsyncExtrinsicReceipt
7
+ from bittensor_wallet import Wallet
8
+
9
+ from bittensor_cli.src import COLOR_PALETTE
10
+ from bittensor_cli.src.bittensor.balances import Balance
11
+ from bittensor_cli.src.bittensor.utils import (
12
+ confirm_action,
13
+ console,
14
+ print_error,
15
+ print_success,
16
+ print_verbose,
17
+ unlock_key,
18
+ get_hotkey_pub_ss58,
19
+ print_extrinsic_id,
20
+ )
21
+
22
+ if typing.TYPE_CHECKING:
23
+ from bittensor_cli.src.bittensor.subtensor_interface import SubtensorInterface
24
+
25
+
26
+ async def is_hotkey_registered(
27
+ subtensor: "SubtensorInterface", netuid: int, hotkey_ss58: str
28
+ ) -> bool:
29
+ """Checks to see if the hotkey is registered on a given netuid"""
30
+ _result = await subtensor.query(
31
+ module="SubtensorModule",
32
+ storage_function="Uids",
33
+ params=[netuid, hotkey_ss58],
34
+ )
35
+ if _result is not None:
36
+ return True
37
+ else:
38
+ return False
39
+
40
+
41
+ async def burned_register_extrinsic(
42
+ subtensor: "SubtensorInterface",
43
+ wallet: Wallet,
44
+ netuid: int,
45
+ old_balance: Balance,
46
+ wait_for_inclusion: bool = True,
47
+ wait_for_finalization: bool = True,
48
+ era: Optional[int] = None,
49
+ proxy: Optional[str] = None,
50
+ limit: Optional[float] = None,
51
+ ) -> tuple[bool, str, Optional[str]]:
52
+ """Registers the wallet to chain by recycling TAO.
53
+
54
+ :param subtensor: The SubtensorInterface object to use for the call, initialized
55
+ :param wallet: Bittensor wallet object.
56
+ :param netuid: The `netuid` of the subnet to register on.
57
+ :param old_balance: The wallet balance prior to the registration burn.
58
+ :param wait_for_inclusion: If set, waits for the extrinsic to enter a block before returning `True`, or returns
59
+ `False` if the extrinsic fails to enter the block within the timeout.
60
+ :param wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`,
61
+ or returns `False` if the extrinsic fails to be finalized within the timeout.
62
+ :param era: the period (in blocks) for which the transaction should remain valid.
63
+ :param proxy: the proxy address to use for the call.
64
+
65
+ :return: (success, msg), where success is `True` if extrinsic was finalized or included in the block. If we did not
66
+ wait for finalization/inclusion, the response is `True`.
67
+ """
68
+
69
+ if not (unlock_status := unlock_key(wallet, print_out=False)).success:
70
+ return False, unlock_status.message, None
71
+
72
+ with console.status(
73
+ f":satellite: Checking Account on [bold]subnet:{netuid}[/bold]...",
74
+ spinner="aesthetic",
75
+ ) as status:
76
+ block_hash = await subtensor.substrate.get_chain_head()
77
+ my_uid = await subtensor.query(
78
+ module="SubtensorModule",
79
+ storage_function="Uids",
80
+ params=[netuid, get_hotkey_pub_ss58(wallet)],
81
+ block_hash=block_hash,
82
+ )
83
+ print_verbose("Checking if already registered", status)
84
+ neuron = await subtensor.neuron_for_uid(
85
+ uid=my_uid, netuid=netuid, block_hash=block_hash
86
+ )
87
+ if not era:
88
+ current_block, tempo, blocks_since_last_step = await asyncio.gather(
89
+ subtensor.substrate.get_block_number(block_hash=block_hash),
90
+ subtensor.get_hyperparameter(
91
+ "Tempo", netuid=netuid, block_hash=block_hash
92
+ ),
93
+ subtensor.query(
94
+ "SubtensorModule",
95
+ "BlocksSinceLastStep",
96
+ [netuid],
97
+ block_hash=block_hash,
98
+ ),
99
+ )
100
+ validity_period = tempo - blocks_since_last_step
101
+ era_ = {
102
+ "period": validity_period,
103
+ "current": current_block,
104
+ }
105
+ else:
106
+ era_ = {"period": era}
107
+
108
+ if not neuron.is_null:
109
+ print_success("[dark_sea_green3]Already Registered[/dark_sea_green3]:")
110
+ console.print(
111
+ f"uid: [{COLOR_PALETTE.G.NETUID_EXTRA}]{neuron.uid}[/{COLOR_PALETTE.G.NETUID_EXTRA}]\n"
112
+ f"netuid: [{COLOR_PALETTE.G.NETUID}]{neuron.netuid}[/{COLOR_PALETTE.G.NETUID}]\n"
113
+ f"hotkey: [{COLOR_PALETTE.G.HK}]{neuron.hotkey}[/{COLOR_PALETTE.G.HK}]\n"
114
+ f"coldkey: [{COLOR_PALETTE.G.CK}]{neuron.coldkey}[/{COLOR_PALETTE.G.CK}]"
115
+ )
116
+ return True, "Already registered", None
117
+
118
+ with console.status(
119
+ ":satellite: Recycling TAO for Registration...", spinner="aesthetic"
120
+ ):
121
+ call_data = {
122
+ "call_module": "SubtensorModule",
123
+ "call_params": {"netuid": netuid, "hotkey": get_hotkey_pub_ss58(wallet)},
124
+ "block_hash": block_hash,
125
+ }
126
+ if limit is not None:
127
+ call_data["call_params"]["limit_price"] = Balance.from_tao(limit).rao
128
+ call_data["call_function"] = "register_limit"
129
+ else:
130
+ call_data["call_function"] = "burned_register"
131
+ call = await subtensor.substrate.compose_call(
132
+ **call_data,
133
+ )
134
+ success, err_msg, ext_receipt = await subtensor.sign_and_send_extrinsic(
135
+ call,
136
+ wallet,
137
+ wait_for_inclusion,
138
+ wait_for_finalization,
139
+ era=era_,
140
+ proxy=proxy,
141
+ )
142
+
143
+ if not success:
144
+ print_error(f"Failed: {err_msg}")
145
+ await asyncio.sleep(0.5)
146
+ return False, err_msg, None
147
+ # Successful registration, final check for neuron and pubkey
148
+ else:
149
+ ext_id = await ext_receipt.get_extrinsic_identifier()
150
+ await print_extrinsic_id(ext_receipt)
151
+ with console.status(":satellite: Checking Balance...", spinner="aesthetic"):
152
+ block_hash = await subtensor.substrate.get_chain_head()
153
+ new_balance, netuids_for_hotkey, my_uid = await asyncio.gather(
154
+ subtensor.get_balance(
155
+ wallet.coldkeypub.ss58_address,
156
+ block_hash=block_hash,
157
+ ),
158
+ subtensor.get_netuids_for_hotkey(
159
+ get_hotkey_pub_ss58(wallet), block_hash=block_hash
160
+ ),
161
+ subtensor.query(
162
+ "SubtensorModule", "Uids", [netuid, get_hotkey_pub_ss58(wallet)]
163
+ ),
164
+ )
165
+
166
+ console.print(
167
+ "Balance:\n"
168
+ f" [blue]{old_balance}[/blue] :arrow_right: "
169
+ f"[{COLOR_PALETTE.S.STAKE_AMOUNT}]{new_balance}[/{COLOR_PALETTE.S.STAKE_AMOUNT}]"
170
+ )
171
+
172
+ if len(netuids_for_hotkey) > 0:
173
+ print_success(f"Registered on netuid {netuid} with UID {my_uid}")
174
+ return True, f"Registered on {netuid} with UID {my_uid}", ext_id
175
+ else:
176
+ # neuron not found, try again
177
+ print_error("Unknown error. Neuron not found.")
178
+ return False, "Unknown error. Neuron not found.", ext_id
179
+
180
+
181
+ async def swap_hotkey_extrinsic(
182
+ subtensor: "SubtensorInterface",
183
+ wallet: Wallet,
184
+ new_wallet: Wallet,
185
+ netuid: Optional[int] = None,
186
+ proxy: Optional[str] = None,
187
+ prompt: bool = False,
188
+ decline: bool = False,
189
+ quiet: bool = False,
190
+ ) -> tuple[bool, Optional[AsyncExtrinsicReceipt]]:
191
+ """
192
+ Performs an extrinsic update for swapping two hotkeys on the chain
193
+
194
+ :return: Success
195
+ """
196
+ block_hash = await subtensor.substrate.get_chain_head()
197
+ hk_ss58 = get_hotkey_pub_ss58(wallet)
198
+ new_hk_ss58 = get_hotkey_pub_ss58(new_wallet)
199
+
200
+ netuids_registered = await subtensor.get_netuids_for_hotkey(
201
+ hk_ss58, block_hash=block_hash
202
+ )
203
+ netuids_registered_new_hotkey = await subtensor.get_netuids_for_hotkey(
204
+ new_hk_ss58, block_hash=block_hash
205
+ )
206
+
207
+ if netuid is not None and netuid not in netuids_registered:
208
+ print_error(
209
+ f"Failed: Original hotkey {hk_ss58} is not registered on subnet {netuid}"
210
+ )
211
+ return False, None
212
+
213
+ elif not len(netuids_registered) > 0:
214
+ print_error(
215
+ f"Original hotkey [dark_orange]{hk_ss58}[/dark_orange] is not registered on any subnet. "
216
+ f"Please register and try again"
217
+ )
218
+ return False, None
219
+
220
+ if netuid is not None:
221
+ if netuid in netuids_registered_new_hotkey:
222
+ print_error(
223
+ f"Failed: New hotkey {new_hk_ss58} "
224
+ f"is already registered on subnet {netuid}"
225
+ )
226
+ return False, None
227
+ else:
228
+ if len(netuids_registered_new_hotkey) > 0:
229
+ print_error(
230
+ f"Failed: New hotkey {new_hk_ss58} "
231
+ f"is already registered on subnet(s) {netuids_registered_new_hotkey}"
232
+ )
233
+ return False, None
234
+
235
+ if not unlock_key(wallet).success:
236
+ return False, None
237
+
238
+ if prompt:
239
+ # Prompt user for confirmation.
240
+ if netuid is not None:
241
+ confirm_message = (
242
+ f"Do you want to swap [dark_orange]{wallet.name}[/dark_orange] hotkey \n\t"
243
+ f"[dark_orange]{hk_ss58} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
244
+ f"[dark_orange]{new_hk_ss58} ({new_wallet.hotkey_str})[/dark_orange] on subnet {netuid}\n"
245
+ "This operation will cost [bold cyan]1 TAO (recycled)[/bold cyan]"
246
+ )
247
+ else:
248
+ confirm_message = (
249
+ f"Do you want to swap [dark_orange]{wallet.name}[/dark_orange] hotkey \n\t"
250
+ f"[dark_orange]{hk_ss58} ({wallet.hotkey_str})[/dark_orange] with hotkey \n\t"
251
+ f"[dark_orange]{new_hk_ss58} ({new_wallet.hotkey_str})[/dark_orange] on all subnets\n"
252
+ "This operation will cost [bold cyan]1 TAO (recycled)[/bold cyan]"
253
+ )
254
+
255
+ if not confirm_action(confirm_message, decline=decline, quiet=quiet):
256
+ return False, None
257
+ print_verbose(
258
+ f"Swapping {wallet.name}'s hotkey ({hk_ss58} - {wallet.hotkey_str}) with "
259
+ f"{new_wallet.name}'s hotkey ({new_hk_ss58} - {new_wallet.hotkey_str})"
260
+ )
261
+ with console.status(":satellite: Swapping hotkeys...", spinner="aesthetic"):
262
+ call_params = {
263
+ "hotkey": hk_ss58,
264
+ "new_hotkey": new_hk_ss58,
265
+ "netuid": netuid,
266
+ }
267
+
268
+ call = await subtensor.substrate.compose_call(
269
+ call_module="SubtensorModule",
270
+ call_function="swap_hotkey",
271
+ call_params=call_params,
272
+ )
273
+ success, err_msg, ext_receipt = await subtensor.sign_and_send_extrinsic(
274
+ call=call, wallet=wallet, proxy=proxy
275
+ )
276
+
277
+ if success:
278
+ console.print(
279
+ f"Hotkey {hk_ss58} ({wallet.hotkey_str}) swapped for new hotkey: "
280
+ f"{new_hk_ss58} ({new_wallet.hotkey_str})"
281
+ )
282
+ return True, ext_receipt
283
+ else:
284
+ print_error(f"Failed: {err_msg}")
285
+ time.sleep(0.5)
286
+ return False, ext_receipt