2
2
import asyncio
3
3
import curses
4
4
import importlib
5
+ import json
5
6
import os .path
6
7
import re
7
8
import ssl
@@ -3460,6 +3461,7 @@ def stake_move(
3460
3461
prompt : bool = Options .prompt ,
3461
3462
quiet : bool = Options .quiet ,
3462
3463
verbose : bool = Options .verbose ,
3464
+ json_output : bool = Options .json_output ,
3463
3465
):
3464
3466
"""
3465
3467
Move staked TAO between hotkeys while keeping the same coldkey ownership.
@@ -3481,13 +3483,14 @@ def stake_move(
3481
3483
3482
3484
[green]$[/green] btcli stake move
3483
3485
"""
3484
- self .verbosity_handler (quiet , verbose )
3486
+ self .verbosity_handler (quiet , verbose , json_output )
3485
3487
console .print (
3486
3488
"[dim]This command moves stake from one hotkey to another hotkey while keeping the same coldkey.[/dim]"
3487
3489
)
3488
3490
if not destination_hotkey :
3489
3491
dest_wallet_or_ss58 = Prompt .ask (
3490
- "Enter the [blue]destination wallet[/blue] where destination hotkey is located or [blue]ss58 address[/blue]"
3492
+ "Enter the [blue]destination wallet[/blue] where destination hotkey is located or "
3493
+ "[blue]ss58 address[/blue]"
3491
3494
)
3492
3495
if is_valid_ss58_address (dest_wallet_or_ss58 ):
3493
3496
destination_hotkey = dest_wallet_or_ss58
@@ -3574,7 +3577,7 @@ def stake_move(
3574
3577
"Enter the [blue]destination subnet[/blue] (netuid) to move stake to"
3575
3578
)
3576
3579
3577
- return self ._run_command (
3580
+ result = self ._run_command (
3578
3581
move_stake .move_stake (
3579
3582
subtensor = self .initialize_chain (network ),
3580
3583
wallet = wallet ,
@@ -3588,6 +3591,9 @@ def stake_move(
3588
3591
prompt = prompt ,
3589
3592
)
3590
3593
)
3594
+ if json_output :
3595
+ json_console .print (json .dumps ({"success" : result }))
3596
+ return result
3591
3597
3592
3598
def stake_transfer (
3593
3599
self ,
@@ -3624,6 +3630,7 @@ def stake_transfer(
3624
3630
prompt : bool = Options .prompt ,
3625
3631
quiet : bool = Options .quiet ,
3626
3632
verbose : bool = Options .verbose ,
3633
+ json_output : bool = Options .json_output ,
3627
3634
):
3628
3635
"""
3629
3636
Transfer stake between coldkeys while keeping the same hotkey ownership.
@@ -3657,10 +3664,10 @@ def stake_transfer(
3657
3664
Transfer all available stake from origin hotkey:
3658
3665
[green]$[/green] btcli stake transfer --all --origin-netuid 1 --dest-netuid 2
3659
3666
"""
3667
+ self .verbosity_handler (quiet , verbose , json_output )
3660
3668
console .print (
3661
3669
"[dim]This command transfers stake from one coldkey to another while keeping the same hotkey.[/dim]"
3662
3670
)
3663
- self .verbosity_handler (quiet , verbose )
3664
3671
3665
3672
if not dest_ss58 :
3666
3673
dest_ss58 = Prompt .ask (
@@ -3732,7 +3739,7 @@ def stake_transfer(
3732
3739
"Enter the [blue]destination subnet[/blue] (netuid)"
3733
3740
)
3734
3741
3735
- return self ._run_command (
3742
+ result = self ._run_command (
3736
3743
move_stake .transfer_stake (
3737
3744
wallet = wallet ,
3738
3745
subtensor = self .initialize_chain (network ),
@@ -3746,6 +3753,9 @@ def stake_transfer(
3746
3753
prompt = prompt ,
3747
3754
)
3748
3755
)
3756
+ if json_output :
3757
+ json_console .print (json .dumps ({"success" : result }))
3758
+ return result
3749
3759
3750
3760
def stake_swap (
3751
3761
self ,
@@ -3784,6 +3794,7 @@ def stake_swap(
3784
3794
wait_for_finalization : bool = Options .wait_for_finalization ,
3785
3795
quiet : bool = Options .quiet ,
3786
3796
verbose : bool = Options .verbose ,
3797
+ json_output : bool = Options .json_output ,
3787
3798
):
3788
3799
"""
3789
3800
Swap stake between different subnets while keeping the same coldkey-hotkey pair ownership.
@@ -3805,10 +3816,10 @@ def stake_swap(
3805
3816
Swap 100 TAO from subnet 1 to subnet 2:
3806
3817
[green]$[/green] btcli stake swap --wallet-name default --wallet-hotkey default --origin-netuid 1 --dest-netuid 2 --amount 100
3807
3818
"""
3819
+ self .verbosity_handler (quiet , verbose , json_output )
3808
3820
console .print (
3809
3821
"[dim]This command moves stake from one subnet to another subnet while keeping the same coldkey-hotkey pair.[/dim]"
3810
3822
)
3811
- self .verbosity_handler (quiet , verbose )
3812
3823
3813
3824
wallet = self .wallet_ask (
3814
3825
wallet_name ,
@@ -3833,7 +3844,7 @@ def stake_swap(
3833
3844
if not amount and not swap_all :
3834
3845
amount = FloatPrompt .ask ("Enter the [blue]amount[/blue] to swap" )
3835
3846
3836
- return self ._run_command (
3847
+ result = self ._run_command (
3837
3848
move_stake .swap_stake (
3838
3849
wallet = wallet ,
3839
3850
subtensor = self .initialize_chain (network ),
@@ -3847,6 +3858,9 @@ def stake_swap(
3847
3858
wait_for_finalization = wait_for_finalization ,
3848
3859
)
3849
3860
)
3861
+ if json_output :
3862
+ json_console .print (json .dumps ({"success" : result }))
3863
+ return result
3850
3864
3851
3865
def stake_get_children (
3852
3866
self ,
@@ -3868,6 +3882,7 @@ def stake_get_children(
3868
3882
),
3869
3883
quiet : bool = Options .quiet ,
3870
3884
verbose : bool = Options .verbose ,
3885
+ json_output : bool = Options .json_output ,
3871
3886
):
3872
3887
"""
3873
3888
Get all the child hotkeys on a specified subnet.
@@ -3879,7 +3894,7 @@ def stake_get_children(
3879
3894
[green]$[/green] btcli stake child get --netuid 1
3880
3895
[green]$[/green] btcli stake child get --all-netuids
3881
3896
"""
3882
- self .verbosity_handler (quiet , verbose )
3897
+ self .verbosity_handler (quiet , verbose , json_output )
3883
3898
wallet = self .wallet_ask (
3884
3899
wallet_name ,
3885
3900
wallet_path ,
@@ -3900,11 +3915,14 @@ def stake_get_children(
3900
3915
"Enter a netuid (leave blank for all)" , default = None , show_default = True
3901
3916
)
3902
3917
3903
- return self ._run_command (
3918
+ result = self ._run_command (
3904
3919
children_hotkeys .get_children (
3905
3920
wallet , self .initialize_chain (network ), netuid
3906
3921
)
3907
3922
)
3923
+ if json_output :
3924
+ json_console .print (json .dumps (result ))
3925
+ return result
3908
3926
3909
3927
def stake_set_children (
3910
3928
self ,
0 commit comments