|
72 | 72 | prompt_position_id, |
73 | 73 | ) |
74 | 74 | from bittensor_cli.src.commands.stake import ( |
| 75 | + auto_staking as auto_stake, |
75 | 76 | children_hotkeys, |
76 | 77 | list as list_stake, |
77 | 78 | move as move_stake, |
@@ -617,6 +618,7 @@ def commands_callback(value: bool): |
617 | 618 | if value: |
618 | 619 | cli = CLIManager() |
619 | 620 | console.print(cli.generate_command_tree()) |
| 621 | + raise typer.Exit() |
620 | 622 |
|
621 | 623 |
|
622 | 624 | def debug_callback(value: bool): |
@@ -935,6 +937,12 @@ def __init__(self): |
935 | 937 | self.stake_app.command( |
936 | 938 | "add", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"] |
937 | 939 | )(self.stake_add) |
| 940 | + self.stake_app.command( |
| 941 | + "auto", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"] |
| 942 | + )(self.get_auto_stake) |
| 943 | + self.stake_app.command( |
| 944 | + "set-auto", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"] |
| 945 | + )(self.set_auto_stake) |
938 | 946 | self.stake_app.command( |
939 | 947 | "remove", rich_help_panel=HELP_PANELS["STAKE"]["STAKE_MGMT"] |
940 | 948 | )(self.stake_remove) |
@@ -979,7 +987,7 @@ def __init__(self): |
979 | 987 | "emissions", rich_help_panel=HELP_PANELS["MECHANISMS"]["EMISSION"] |
980 | 988 | )(self.mechanism_emission_get) |
981 | 989 | self.subnet_mechanisms_app.command( |
982 | | - "emissions-split", rich_help_panel=HELP_PANELS["MECHANISMS"]["EMISSION"] |
| 990 | + "split-emissions", rich_help_panel=HELP_PANELS["MECHANISMS"]["EMISSION"] |
983 | 991 | )(self.mechanism_emission_set) |
984 | 992 |
|
985 | 993 | # sudo commands |
@@ -1105,14 +1113,19 @@ def __init__(self): |
1105 | 1113 | "get_identity", |
1106 | 1114 | hidden=True, |
1107 | 1115 | )(self.wallet_get_id) |
1108 | | - self.wallet_app.command("associate_hotkey")(self.wallet_associate_hotkey) |
| 1116 | + self.wallet_app.command("associate_hotkey", hidden=True)( |
| 1117 | + self.wallet_associate_hotkey |
| 1118 | + ) |
1109 | 1119 |
|
1110 | 1120 | # Subnets |
1111 | 1121 | self.subnets_app.command("burn_cost", hidden=True)(self.subnets_burn_cost) |
1112 | 1122 | self.subnets_app.command("pow_register", hidden=True)(self.subnets_pow_register) |
1113 | 1123 | self.subnets_app.command("set_identity", hidden=True)(self.subnets_set_identity) |
1114 | 1124 | self.subnets_app.command("get_identity", hidden=True)(self.subnets_get_identity) |
1115 | 1125 | self.subnets_app.command("check_start", hidden=True)(self.subnets_check_start) |
| 1126 | + self.subnet_mechanisms_app.command("emissions-split", hidden=True)( |
| 1127 | + self.mechanism_emission_set |
| 1128 | + ) |
1116 | 1129 |
|
1117 | 1130 | # Sudo |
1118 | 1131 | self.sudo_app.command("senate_vote", hidden=True)(self.sudo_senate_vote) |
@@ -3593,6 +3606,137 @@ def wallet_swap_coldkey( |
3593 | 3606 | ) |
3594 | 3607 | ) |
3595 | 3608 |
|
| 3609 | + def get_auto_stake( |
| 3610 | + self, |
| 3611 | + network: Optional[list[str]] = Options.network, |
| 3612 | + wallet_name: Optional[str] = Options.wallet_name, |
| 3613 | + wallet_path: Optional[str] = Options.wallet_path, |
| 3614 | + coldkey_ss58=typer.Option( |
| 3615 | + None, |
| 3616 | + "--ss58", |
| 3617 | + "--coldkey_ss58", |
| 3618 | + "--coldkey.ss58_address", |
| 3619 | + "--coldkey.ss58", |
| 3620 | + help="Coldkey address of the wallet", |
| 3621 | + ), |
| 3622 | + quiet: bool = Options.quiet, |
| 3623 | + verbose: bool = Options.verbose, |
| 3624 | + json_output: bool = Options.json_output, |
| 3625 | + ): |
| 3626 | + """Display auto-stake destinations for a wallet across all subnets.""" |
| 3627 | + |
| 3628 | + self.verbosity_handler(quiet, verbose, json_output) |
| 3629 | + |
| 3630 | + wallet = None |
| 3631 | + if coldkey_ss58: |
| 3632 | + if not is_valid_ss58_address(coldkey_ss58): |
| 3633 | + print_error("You entered an invalid ss58 address") |
| 3634 | + raise typer.Exit() |
| 3635 | + else: |
| 3636 | + if wallet_name: |
| 3637 | + coldkey_or_ss58 = wallet_name |
| 3638 | + else: |
| 3639 | + coldkey_or_ss58 = Prompt.ask( |
| 3640 | + "Enter the [blue]wallet name[/blue] or [blue]coldkey ss58 address[/blue]", |
| 3641 | + default=self.config.get("wallet_name") or defaults.wallet.name, |
| 3642 | + ) |
| 3643 | + if is_valid_ss58_address(coldkey_or_ss58): |
| 3644 | + coldkey_ss58 = coldkey_or_ss58 |
| 3645 | + else: |
| 3646 | + wallet_name = coldkey_or_ss58 if coldkey_or_ss58 else wallet_name |
| 3647 | + wallet = self.wallet_ask( |
| 3648 | + wallet_name, |
| 3649 | + wallet_path, |
| 3650 | + None, |
| 3651 | + ask_for=[WO.NAME, WO.PATH], |
| 3652 | + validate=WV.WALLET, |
| 3653 | + ) |
| 3654 | + |
| 3655 | + return self._run_command( |
| 3656 | + auto_stake.show_auto_stake_destinations( |
| 3657 | + wallet, |
| 3658 | + self.initialize_chain(network), |
| 3659 | + coldkey_ss58=coldkey_ss58, |
| 3660 | + json_output=json_output, |
| 3661 | + verbose=verbose, |
| 3662 | + ) |
| 3663 | + ) |
| 3664 | + |
| 3665 | + def set_auto_stake( |
| 3666 | + self, |
| 3667 | + network: Optional[list[str]] = Options.network, |
| 3668 | + wallet_name: Optional[str] = Options.wallet_name, |
| 3669 | + wallet_path: Optional[str] = Options.wallet_path, |
| 3670 | + netuid: Optional[int] = Options.netuid_not_req, |
| 3671 | + quiet: bool = Options.quiet, |
| 3672 | + verbose: bool = Options.verbose, |
| 3673 | + prompt: bool = Options.prompt, |
| 3674 | + wait_for_inclusion: bool = Options.wait_for_inclusion, |
| 3675 | + wait_for_finalization: bool = Options.wait_for_finalization, |
| 3676 | + json_output: bool = Options.json_output, |
| 3677 | + ): |
| 3678 | + """Set the auto-stake destination hotkey for a coldkey.""" |
| 3679 | + |
| 3680 | + self.verbosity_handler(quiet, verbose, json_output) |
| 3681 | + |
| 3682 | + wallet = self.wallet_ask( |
| 3683 | + wallet_name, |
| 3684 | + wallet_path, |
| 3685 | + None, |
| 3686 | + ask_for=[WO.NAME, WO.PATH], |
| 3687 | + validate=WV.WALLET, |
| 3688 | + ) |
| 3689 | + |
| 3690 | + if netuid is None: |
| 3691 | + netuid = IntPrompt.ask( |
| 3692 | + "Enter the [blue]netuid[/blue] to configure", |
| 3693 | + default=defaults.netuid, |
| 3694 | + ) |
| 3695 | + validate_netuid(netuid) |
| 3696 | + |
| 3697 | + hotkey_prompt = Prompt.ask( |
| 3698 | + "Enter the [blue]hotkey ss58 address[/blue] to auto-stake to " |
| 3699 | + "[dim](Press Enter to view delegates)[/dim]", |
| 3700 | + default="", |
| 3701 | + show_default=False, |
| 3702 | + ).strip() |
| 3703 | + |
| 3704 | + if not hotkey_prompt: |
| 3705 | + selected_hotkey = self._run_command( |
| 3706 | + subnets.show( |
| 3707 | + subtensor=self.initialize_chain(network), |
| 3708 | + netuid=netuid, |
| 3709 | + sort=False, |
| 3710 | + max_rows=20, |
| 3711 | + prompt=False, |
| 3712 | + delegate_selection=True, |
| 3713 | + ), |
| 3714 | + exit_early=False, |
| 3715 | + ) |
| 3716 | + if not selected_hotkey: |
| 3717 | + print_error("No delegate selected. Exiting.") |
| 3718 | + return |
| 3719 | + hotkey_ss58 = selected_hotkey |
| 3720 | + else: |
| 3721 | + hotkey_ss58 = hotkey_prompt |
| 3722 | + |
| 3723 | + if not is_valid_ss58_address(hotkey_ss58): |
| 3724 | + print_error("You entered an invalid hotkey ss58 address") |
| 3725 | + return |
| 3726 | + |
| 3727 | + return self._run_command( |
| 3728 | + auto_stake.set_auto_stake_destination( |
| 3729 | + wallet, |
| 3730 | + self.initialize_chain(network), |
| 3731 | + netuid, |
| 3732 | + hotkey_ss58, |
| 3733 | + wait_for_inclusion=wait_for_inclusion, |
| 3734 | + wait_for_finalization=wait_for_finalization, |
| 3735 | + prompt_user=prompt, |
| 3736 | + json_output=json_output, |
| 3737 | + ) |
| 3738 | + ) |
| 3739 | + |
3596 | 3740 | def stake_list( |
3597 | 3741 | self, |
3598 | 3742 | network: Optional[list[str]] = Options.network, |
@@ -4318,15 +4462,32 @@ def stake_move( |
4318 | 4462 | network: Optional[list[str]] = Options.network, |
4319 | 4463 | wallet_name: Optional[str] = Options.wallet_name, |
4320 | 4464 | wallet_path: Optional[str] = Options.wallet_path, |
4321 | | - wallet_hotkey: Optional[str] = Options.wallet_hotkey_ss58, |
| 4465 | + wallet_hotkey: Optional[str] = typer.Option( |
| 4466 | + None, |
| 4467 | + "--from", |
| 4468 | + "--hotkey", |
| 4469 | + "--hotkey-ss58", |
| 4470 | + "-H", |
| 4471 | + "--wallet_hotkey", |
| 4472 | + "--wallet_hotkey_ss58", |
| 4473 | + "--wallet-hotkey", |
| 4474 | + "--wallet-hotkey-ss58", |
| 4475 | + "--wallet.hotkey", |
| 4476 | + help="Validator hotkey or SS58 where the stake is currently located.", |
| 4477 | + ), |
4322 | 4478 | origin_netuid: Optional[int] = typer.Option( |
4323 | 4479 | None, "--origin-netuid", help="Origin netuid" |
4324 | 4480 | ), |
4325 | 4481 | destination_netuid: Optional[int] = typer.Option( |
4326 | 4482 | None, "--dest-netuid", help="Destination netuid" |
4327 | 4483 | ), |
4328 | 4484 | destination_hotkey: Optional[str] = typer.Option( |
4329 | | - None, "--dest-ss58", "--dest", help="Destination hotkey", prompt=False |
| 4485 | + None, |
| 4486 | + "--to", |
| 4487 | + "--dest-ss58", |
| 4488 | + "--dest", |
| 4489 | + help="Destination validator hotkey SS58", |
| 4490 | + prompt=False, |
4330 | 4491 | ), |
4331 | 4492 | amount: float = typer.Option( |
4332 | 4493 | None, |
|
0 commit comments