@@ -109,6 +109,17 @@ class Options:
109
109
"--wallet.hotkey" ,
110
110
help = "Hotkey of the wallet" ,
111
111
)
112
+ wallet_ss58_address = typer .Option (
113
+ None ,
114
+ "--wallet-name" ,
115
+ "--name" ,
116
+ "--wallet_name" ,
117
+ "--wallet.name" ,
118
+ "--address" ,
119
+ "--ss58" ,
120
+ "--ss58-address" ,
121
+ help = "SS58 address or wallet name to check. Leave empty to be prompted." ,
122
+ )
112
123
wallet_hotkey_ss58 = typer .Option (
113
124
None ,
114
125
"--hotkey" ,
@@ -684,6 +695,12 @@ def __init__(self):
684
695
self .wallet_app .command (
685
696
"swap-hotkey" , rich_help_panel = HELP_PANELS ["WALLET" ]["SECURITY" ]
686
697
)(self .wallet_swap_hotkey )
698
+ self .wallet_app .command (
699
+ "swap-coldkey" , rich_help_panel = HELP_PANELS ["WALLET" ]["SECURITY" ]
700
+ )(self .wallet_swap_coldkey )
701
+ self .wallet_app .command (
702
+ "swap-check" , rich_help_panel = HELP_PANELS ["WALLET" ]["SECURITY" ]
703
+ )(self .wallet_check_ck_swap )
687
704
self .wallet_app .command (
688
705
"regen-coldkey" , rich_help_panel = HELP_PANELS ["WALLET" ]["SECURITY" ]
689
706
)(self .wallet_regen_coldkey )
@@ -2306,28 +2323,92 @@ def wallet_new_coldkey(
2306
2323
2307
2324
def wallet_check_ck_swap (
2308
2325
self ,
2309
- wallet_name : Optional [str ] = Options .wallet_name ,
2326
+ wallet_ss58_address : Optional [str ] = Options .wallet_ss58_address ,
2310
2327
wallet_path : Optional [str ] = Options .wallet_path ,
2311
2328
wallet_hotkey : Optional [str ] = Options .wallet_hotkey ,
2329
+ scheduled_block : Optional [int ] = typer .Option (
2330
+ None ,
2331
+ "--block" ,
2332
+ help = "Block number where the swap was scheduled" ,
2333
+ ),
2334
+ show_all : bool = typer .Option (
2335
+ False ,
2336
+ "--all" ,
2337
+ "-a" ,
2338
+ help = "Show all pending coldkey swaps" ,
2339
+ ),
2312
2340
network : Optional [list [str ]] = Options .network ,
2313
2341
quiet : bool = Options .quiet ,
2314
2342
verbose : bool = Options .verbose ,
2315
2343
):
2316
2344
"""
2317
- Check the status of your scheduled coldkey swap .
2345
+ Check the status of scheduled coldkey swaps .
2318
2346
2319
2347
USAGE
2320
2348
2321
- Users should provide the old coldkey wallet to check the swap status.
2349
+ This command can be used in three ways:
2350
+ 1. Show all pending swaps (--all)
2351
+ 2. Check status of a specific wallet's swap or SS58 address
2352
+ 3. Check detailed swap status with block number (--block)
2322
2353
2323
- EXAMPLE
2354
+ EXAMPLES
2355
+
2356
+ Show all pending swaps:
2357
+ [green]$[/green] btcli wallet swap-check --all
2324
2358
2325
- [green]$[/green] btcli wallet check_coldkey_swap
2359
+ Check specific wallet's swap:
2360
+ [green]$[/green] btcli wallet swap-check --wallet-name my_wallet
2361
+
2362
+ Check swap using SS58 address:
2363
+ [green]$[/green] btcli wallet swap-check --ss58 5DkQ4...
2364
+
2365
+ Check swap details with block number:
2366
+ [green]$[/green] btcli wallet swap-check --wallet-name my_wallet --block 12345
2326
2367
"""
2327
2368
self .verbosity_handler (quiet , verbose )
2328
- wallet = self .wallet_ask (wallet_name , wallet_path , wallet_hotkey )
2329
2369
self .initialize_chain (network )
2330
- return self ._run_command (wallets .check_coldkey_swap (wallet , self .subtensor ))
2370
+
2371
+ if show_all :
2372
+ return self ._run_command (
2373
+ wallets .check_swap_status (self .subtensor , None , None )
2374
+ )
2375
+
2376
+ if not wallet_ss58_address :
2377
+ wallet_ss58_address = Prompt .ask (
2378
+ "Enter [blue]wallet name[/blue] or [blue]SS58 address[/blue] [dim](leave blank to show all pending swaps)[/dim]"
2379
+ )
2380
+ if not wallet_ss58_address :
2381
+ return self ._run_command (
2382
+ wallets .check_swap_status (self .subtensor , None , None )
2383
+ )
2384
+
2385
+ if is_valid_ss58_address (wallet_ss58_address ):
2386
+ ss58_address = wallet_ss58_address
2387
+ else :
2388
+ wallet = self .wallet_ask (
2389
+ wallet_ss58_address ,
2390
+ wallet_path ,
2391
+ wallet_hotkey ,
2392
+ ask_for = [WO .NAME , WO .PATH ],
2393
+ validate = WV .WALLET ,
2394
+ )
2395
+ ss58_address = wallet .coldkeypub .ss58_address
2396
+
2397
+ if not scheduled_block :
2398
+ block_input = Prompt .ask (
2399
+ "[blue]Enter the block number[/blue] where the swap was scheduled [dim](optional, press enter to skip)[/dim]" ,
2400
+ default = "" ,
2401
+ )
2402
+ if block_input :
2403
+ try :
2404
+ scheduled_block = int (block_input )
2405
+ except ValueError :
2406
+ print_error ("Invalid block number" )
2407
+ raise typer .Exit ()
2408
+
2409
+ return self ._run_command (
2410
+ wallets .check_swap_status (self .subtensor , ss58_address , scheduled_block )
2411
+ )
2331
2412
2332
2413
def wallet_create_wallet (
2333
2414
self ,
@@ -2762,6 +2843,91 @@ def wallet_sign(
2762
2843
2763
2844
return self ._run_command (wallets .sign (wallet , message , use_hotkey ))
2764
2845
2846
+ def wallet_swap_coldkey (
2847
+ self ,
2848
+ wallet_name : Optional [str ] = Options .wallet_name ,
2849
+ wallet_path : Optional [str ] = Options .wallet_path ,
2850
+ wallet_hotkey : Optional [str ] = Options .wallet_hotkey ,
2851
+ new_wallet_or_ss58 : Optional [str ] = typer .Option (
2852
+ None ,
2853
+ "--new-coldkey" ,
2854
+ "--new-coldkey-ss58" ,
2855
+ "--new-wallet" ,
2856
+ "--new" ,
2857
+ help = "SS58 address of the new coldkey that will replace the current one." ,
2858
+ ),
2859
+ network : Optional [list [str ]] = Options .network ,
2860
+ quiet : bool = Options .quiet ,
2861
+ verbose : bool = Options .verbose ,
2862
+ force_swap : bool = typer .Option (
2863
+ False ,
2864
+ "--force" ,
2865
+ "-f" ,
2866
+ "--force-swap" ,
2867
+ help = "Force the swap even if the new coldkey is already scheduled for a swap." ,
2868
+ ),
2869
+ ):
2870
+ """
2871
+ Schedule a coldkey swap for a wallet.
2872
+
2873
+ This command allows you to schedule a coldkey swap for a wallet. You can either provide a new wallet name, or SS58 address.
2874
+
2875
+ EXAMPLES
2876
+
2877
+ [green]$[/green] btcli wallet schedule-coldkey-swap --new-wallet my_new_wallet
2878
+
2879
+ [green]$[/green] btcli wallet schedule-coldkey-swap --new-coldkey-ss58 5Dk...X3q
2880
+ """
2881
+ self .verbosity_handler (quiet , verbose )
2882
+
2883
+ if not wallet_name :
2884
+ wallet_name = Prompt .ask (
2885
+ "Enter the [blue]wallet name[/blue] which you want to swap the coldkey for" ,
2886
+ default = self .config .get ("wallet_name" ) or defaults .wallet .name ,
2887
+ )
2888
+ wallet = self .wallet_ask (
2889
+ wallet_name ,
2890
+ wallet_path ,
2891
+ wallet_hotkey ,
2892
+ ask_for = [WO .NAME ],
2893
+ validate = WV .WALLET ,
2894
+ )
2895
+ console .print (
2896
+ f"\n Wallet selected to swap the [blue]coldkey[/blue] from: \n "
2897
+ f"[dark_sea_green3]{ wallet } [/dark_sea_green3]\n "
2898
+ )
2899
+
2900
+ if not new_wallet_or_ss58 :
2901
+ new_wallet_or_ss58 = Prompt .ask (
2902
+ "Enter the [blue]new wallet name[/blue] or [blue]SS58 address[/blue] of the new coldkey" ,
2903
+ )
2904
+
2905
+ if is_valid_ss58_address (new_wallet_or_ss58 ):
2906
+ new_wallet_coldkey_ss58 = new_wallet_or_ss58
2907
+ else :
2908
+ new_wallet_name = new_wallet_or_ss58
2909
+ new_wallet = self .wallet_ask (
2910
+ new_wallet_name ,
2911
+ wallet_path ,
2912
+ wallet_hotkey ,
2913
+ ask_for = [WO .NAME ],
2914
+ validate = WV .WALLET ,
2915
+ )
2916
+ console .print (
2917
+ f"\n New wallet to swap the [blue]coldkey[/blue] to: \n "
2918
+ f"[dark_sea_green3]{ new_wallet } [/dark_sea_green3]\n "
2919
+ )
2920
+ new_wallet_coldkey_ss58 = new_wallet .coldkeypub .ss58_address
2921
+
2922
+ return self ._run_command (
2923
+ wallets .schedule_coldkey_swap (
2924
+ wallet = wallet ,
2925
+ subtensor = self .initialize_chain (network ),
2926
+ new_coldkey_ss58 = new_wallet_coldkey_ss58 ,
2927
+ force_swap = force_swap ,
2928
+ )
2929
+ )
2930
+
2765
2931
def stake_list (
2766
2932
self ,
2767
2933
network : Optional [list [str ]] = Options .network ,
0 commit comments