Skip to content

Commit 1e6fa00

Browse files
authored
Merge pull request opentensor#701 from opentensor/update/btcli-stake-claim-args
Update/btcli stake claim args
2 parents 1b83836 + c0e0306 commit 1e6fa00

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

bittensor_cli/cli.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7085,6 +7085,10 @@ def view_dashboard(
70857085

70867086
def stake_set_claim_type(
70877087
self,
7088+
claim_type: Optional[str] = typer.Argument(
7089+
None,
7090+
help="Claim type: 'keep' or 'swap'. If not provided, you'll be prompted to choose.",
7091+
),
70887092
wallet_name: Optional[str] = Options.wallet_name,
70897093
wallet_path: Optional[str] = Options.wallet_path,
70907094
wallet_hotkey: Optional[str] = Options.wallet_hotkey,
@@ -7105,13 +7109,26 @@ def stake_set_claim_type(
71057109
71067110
USAGE:
71077111
7108-
[green]$[/green] btcli root set-claim-type
7112+
[green]$[/green] btcli stake claim
7113+
[green]$[/green] btcli stake claim keep
7114+
[green]$[/green] btcli stake claim swap
71097115
71107116
With specific wallet:
71117117
7112-
[green]$[/green] btcli root set-claim-type --wallet-name my_wallet
7118+
[green]$[/green] btcli stake claim swap --wallet-name my_wallet
71137119
"""
71147120
self.verbosity_handler(quiet, verbose, json_output)
7121+
7122+
if claim_type is not None:
7123+
claim_type_normalized = claim_type.capitalize()
7124+
if claim_type_normalized not in ["Keep", "Swap"]:
7125+
err_console.print(
7126+
f":cross_mark: [red]Invalid claim type '{claim_type}'. Must be 'keep' or 'swap'.[/red]"
7127+
)
7128+
raise typer.Exit()
7129+
else:
7130+
claim_type_normalized = None
7131+
71157132
wallet = self.wallet_ask(
71167133
wallet_name,
71177134
wallet_path,
@@ -7122,6 +7139,7 @@ def stake_set_claim_type(
71227139
claim_stake.set_claim_type(
71237140
wallet=wallet,
71247141
subtensor=self.initialize_chain(network),
7142+
claim_type=claim_type_normalized,
71257143
prompt=prompt,
71267144
json_output=json_output,
71277145
)

bittensor_cli/src/commands/stake/claim.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
async def set_claim_type(
2626
wallet: Wallet,
2727
subtensor: "SubtensorInterface",
28+
claim_type: Optional[str] = None,
2829
prompt: bool = True,
2930
json_output: bool = False,
3031
) -> tuple[bool, str, Optional[str]]:
@@ -38,6 +39,7 @@ async def set_claim_type(
3839
Args:
3940
wallet: Bittensor wallet object
4041
subtensor: SubtensorInterface object
42+
claim_type: Optional claim type ("Keep" or "Swap"). If None, user will be prompted.
4143
prompt: Whether to prompt for user confirmation
4244
json_output: Whether to output JSON
4345
@@ -76,8 +78,13 @@ async def set_claim_type(
7678
wallet.coldkeypub.ss58_address, f"[yellow]{current_type}[/yellow]"
7779
)
7880
console.print(claim_table)
79-
new_type = Prompt.ask(
80-
"Select new root claim type", choices=["Swap", "Keep"], default=current_type
81+
82+
new_type = (
83+
claim_type
84+
if claim_type
85+
else Prompt.ask(
86+
"Select new root claim type", choices=["Swap", "Keep"], default=current_type
87+
)
8188
)
8289
if new_type == current_type:
8390
msg = f"Root claim type is already set to '{current_type}'. No change needed."

0 commit comments

Comments
 (0)