@@ -4875,6 +4875,7 @@ def subnets_burn_cost(
4875
4875
network : Optional [list [str ]] = Options .network ,
4876
4876
quiet : bool = Options .quiet ,
4877
4877
verbose : bool = Options .verbose ,
4878
+ json_output : bool = Options .json_output ,
4878
4879
):
4879
4880
"""
4880
4881
Shows the required amount of TAO to be recycled for creating a new subnet, i.e., cost of registering a new subnet.
@@ -4885,8 +4886,10 @@ def subnets_burn_cost(
4885
4886
4886
4887
[green]$[/green] btcli subnets burn_cost
4887
4888
"""
4888
- self .verbosity_handler (quiet , verbose )
4889
- return self ._run_command (subnets .burn_cost (self .initialize_chain (network )))
4889
+ self .verbosity_handler (quiet , verbose , json_output )
4890
+ return self ._run_command (
4891
+ subnets .burn_cost (self .initialize_chain (network ), json_output )
4892
+ )
4890
4893
4891
4894
def subnets_create (
4892
4895
self ,
@@ -4919,6 +4922,7 @@ def subnets_create(
4919
4922
additional_info : Optional [str ] = typer .Option (
4920
4923
None , "--additional-info" , help = "Additional information"
4921
4924
),
4925
+ json_output : bool = Options .json_output ,
4922
4926
prompt : bool = Options .prompt ,
4923
4927
quiet : bool = Options .quiet ,
4924
4928
verbose : bool = Options .verbose ,
@@ -4937,7 +4941,7 @@ def subnets_create(
4937
4941
2. Create with GitHub repo and contact email:
4938
4942
[green]$[/green] btcli subnets create --subnet-name MySubnet --github-repo https://github.com/myorg/mysubnet --subnet-contact [email protected]
4939
4943
"""
4940
- self .verbosity_handler (quiet , verbose )
4944
+ self .verbosity_handler (quiet , verbose , json_output )
4941
4945
wallet = self .wallet_ask (
4942
4946
wallet_name ,
4943
4947
wallet_path ,
@@ -4959,34 +4963,19 @@ def subnets_create(
4959
4963
description = description ,
4960
4964
additional = additional_info ,
4961
4965
)
4962
- success = self ._run_command (
4963
- subnets .create (wallet , self .initialize_chain (network ), identity , prompt ),
4964
- exit_early = False ,
4966
+ self ._run_command (
4967
+ subnets .create (
4968
+ wallet , self .initialize_chain (network ), identity , json_output , prompt
4969
+ )
4965
4970
)
4966
4971
4967
- if success and prompt :
4968
- set_id = Confirm .ask (
4969
- "[dark_sea_green3]Do you want to set/update your identity?" ,
4970
- default = False ,
4971
- show_default = True ,
4972
- )
4973
- if set_id :
4974
- self .wallet_set_id (
4975
- wallet_name = wallet .name ,
4976
- wallet_hotkey = wallet .hotkey ,
4977
- wallet_path = wallet .path ,
4978
- network = network ,
4979
- prompt = prompt ,
4980
- quiet = quiet ,
4981
- verbose = verbose ,
4982
- )
4983
-
4984
4972
def subnets_get_identity (
4985
4973
self ,
4986
4974
network : Optional [list [str ]] = Options .network ,
4987
4975
netuid : int = Options .netuid ,
4988
4976
quiet : bool = Options .quiet ,
4989
4977
verbose : bool = Options .verbose ,
4978
+ json_output : bool = Options .json_output ,
4990
4979
):
4991
4980
"""
4992
4981
Get the identity information for a subnet.
@@ -4995,11 +4984,10 @@ def subnets_get_identity(
4995
4984
4996
4985
[green]$[/green] btcli subnets get-identity --netuid 1
4997
4986
"""
4998
- self .verbosity_handler (quiet , verbose )
4987
+ self .verbosity_handler (quiet , verbose , json_output )
4999
4988
return self ._run_command (
5000
4989
subnets .get_identity (
5001
- self .initialize_chain (network ),
5002
- netuid ,
4990
+ self .initialize_chain (network ), netuid , json_output = json_output
5003
4991
)
5004
4992
)
5005
4993
@@ -5035,6 +5023,7 @@ def subnets_set_identity(
5035
5023
additional_info : Optional [str ] = typer .Option (
5036
5024
None , "--additional-info" , help = "Additional information"
5037
5025
),
5026
+ json_output : bool = Options .json_output ,
5038
5027
prompt : bool = Options .prompt ,
5039
5028
quiet : bool = Options .quiet ,
5040
5029
verbose : bool = Options .verbose ,
@@ -5052,7 +5041,7 @@ def subnets_set_identity(
5052
5041
2. Set subnet identity with specific values:
5053
5042
[green]$[/green] btcli subnets set-identity --netuid 1 --subnet-name MySubnet --github-repo https://github.com/myorg/mysubnet --subnet-contact [email protected]
5054
5043
"""
5055
- self .verbosity_handler (quiet , verbose )
5044
+ self .verbosity_handler (quiet , verbose , json_output )
5056
5045
wallet = self .wallet_ask (
5057
5046
wallet_name ,
5058
5047
wallet_path ,
@@ -5070,7 +5059,9 @@ def subnets_set_identity(
5070
5059
exit_early = False ,
5071
5060
)
5072
5061
if current_identity is None :
5073
- raise typer .Exit ()
5062
+ if json_output :
5063
+ json_console .print ('{"success": false}' )
5064
+ return
5074
5065
5075
5066
identity = prompt_for_subnet_identity (
5076
5067
current_identity = current_identity ,
@@ -5083,15 +5074,13 @@ def subnets_set_identity(
5083
5074
additional = additional_info ,
5084
5075
)
5085
5076
5086
- return self ._run_command (
5077
+ success = self ._run_command (
5087
5078
subnets .set_identity (
5088
- wallet ,
5089
- self .initialize_chain (network ),
5090
- netuid ,
5091
- identity ,
5092
- prompt ,
5079
+ wallet , self .initialize_chain (network ), netuid , identity , prompt
5093
5080
)
5094
5081
)
5082
+ if json_output :
5083
+ json_console .print (json .dumps ({"success" : success }))
5095
5084
5096
5085
def subnets_pow_register (
5097
5086
self ,
@@ -5196,6 +5185,7 @@ def subnets_register(
5196
5185
help = "Length (in blocks) for which the transaction should be valid. Note that it is possible that if you "
5197
5186
"use an era for this transaction that you may pay a different fee to register than the one stated." ,
5198
5187
),
5188
+ json_output : bool = Options .json_output ,
5199
5189
prompt : bool = Options .prompt ,
5200
5190
quiet : bool = Options .quiet ,
5201
5191
verbose : bool = Options .verbose ,
@@ -5211,7 +5201,7 @@ def subnets_register(
5211
5201
5212
5202
[green]$[/green] btcli subnets register --netuid 1
5213
5203
"""
5214
- self .verbosity_handler (quiet , verbose )
5204
+ self .verbosity_handler (quiet , verbose , json_output )
5215
5205
wallet = self .wallet_ask (
5216
5206
wallet_name ,
5217
5207
wallet_path ,
@@ -5225,6 +5215,7 @@ def subnets_register(
5225
5215
self .initialize_chain (network ),
5226
5216
netuid ,
5227
5217
era ,
5218
+ json_output ,
5228
5219
prompt ,
5229
5220
)
5230
5221
)
0 commit comments