@@ -293,8 +293,11 @@ class Options:
293
293
"--json-out" ,
294
294
help = "Outputs the result of the command as JSON." ,
295
295
)
296
- era : int = typer .Option (
297
- 3 , help = "Length (in blocks) for which the transaction should be valid."
296
+ period : int = typer .Option (
297
+ 16 ,
298
+ "--period" ,
299
+ "--era" ,
300
+ help = "Length (in blocks) for which the transaction should be valid." ,
298
301
)
299
302
300
303
@@ -436,36 +439,49 @@ def parse_mnemonic(mnemonic: str) -> str:
436
439
def get_creation_data (
437
440
mnemonic : Optional [str ],
438
441
seed : Optional [str ],
439
- json : Optional [str ],
442
+ json_path : Optional [str ],
440
443
json_password : Optional [str ],
441
444
) -> tuple [str , str , str , str ]:
442
445
"""
443
446
Determines which of the key creation elements have been supplied, if any. If None have been supplied,
444
447
prompts to user, and determines what they've supplied. Returns all elements in a tuple.
445
448
"""
446
- if not mnemonic and not seed and not json :
447
- prompt_answer = Prompt .ask (
448
- "Enter the mnemonic, or the seed hex string, or the location of the JSON file."
449
+ if not mnemonic and not seed and not json_path :
450
+ choices = {
451
+ 1 : "mnemonic" ,
452
+ 2 : "seed hex string" ,
453
+ 3 : "path to JSON File" ,
454
+ }
455
+ type_answer = IntPrompt .ask (
456
+ "Select one of the following to enter\n "
457
+ f"[{ COLORS .G .HINT } ][1][/{ COLORS .G .HINT } ] Mnemonic\n "
458
+ f"[{ COLORS .G .HINT } ][2][/{ COLORS .G .HINT } ] Seed hex string\n "
459
+ f"[{ COLORS .G .HINT } ][3][/{ COLORS .G .HINT } ] Path to JSON File\n " ,
460
+ choices = ["1" , "2" , "3" ],
461
+ show_choices = False ,
449
462
)
450
- if prompt_answer .startswith ("0x" ):
463
+ prompt_answer = Prompt .ask (f"Please enter your { choices [type_answer ]} " )
464
+ if type_answer == 1 :
465
+ mnemonic = prompt_answer
466
+ elif type_answer == 2 :
451
467
seed = prompt_answer
452
- elif len ( prompt_answer . split ( " " )) > 1 :
453
- mnemonic = parse_mnemonic ( prompt_answer )
454
- else :
455
- json = prompt_answer
468
+ if seed . startswith ( "0x" ) :
469
+ seed = seed [ 2 :]
470
+ elif type_answer == 3 :
471
+ json_path = prompt_answer
456
472
elif mnemonic :
457
473
mnemonic = parse_mnemonic (mnemonic )
458
474
459
- if json :
460
- if not os .path .exists (json ):
461
- print_error (f"The JSON file '{ json } ' does not exist." )
475
+ if json_path :
476
+ if not os .path .exists (json_path ):
477
+ print_error (f"The JSON file '{ json_path } ' does not exist." )
462
478
raise typer .Exit ()
463
479
464
- if json and not json_password :
480
+ if json_path and not json_password :
465
481
json_password = Prompt .ask (
466
482
"Enter the backup password for JSON file." , password = True
467
483
)
468
- return mnemonic , seed , json , json_password
484
+ return mnemonic , seed , json_path , json_password
469
485
470
486
471
487
def config_selector (conf : dict , title : str ):
@@ -1792,7 +1808,7 @@ def wallet_transfer(
1792
1808
transfer_all : bool = typer .Option (
1793
1809
False , "--all" , prompt = False , help = "Transfer all available balance."
1794
1810
),
1795
- era : int = Options .era ,
1811
+ period : int = Options .period ,
1796
1812
wallet_name : str = Options .wallet_name ,
1797
1813
wallet_path : str = Options .wallet_path ,
1798
1814
wallet_hotkey : str = Options .wallet_hotkey ,
@@ -1847,7 +1863,7 @@ def wallet_transfer(
1847
1863
destination = destination_ss58_address ,
1848
1864
amount = amount ,
1849
1865
transfer_all = transfer_all ,
1850
- era = era ,
1866
+ era = period ,
1851
1867
prompt = prompt ,
1852
1868
json_output = json_output ,
1853
1869
)
@@ -2090,7 +2106,7 @@ def wallet_regen_coldkey(
2090
2106
wallet_hotkey : Optional [str ] = Options .wallet_hotkey ,
2091
2107
mnemonic : Optional [str ] = Options .mnemonic ,
2092
2108
seed : Optional [str ] = Options .seed ,
2093
- json : Optional [str ] = Options .json ,
2109
+ json_path : Optional [str ] = Options .json ,
2094
2110
json_password : Optional [str ] = Options .json_password ,
2095
2111
use_password : Optional [bool ] = Options .use_password ,
2096
2112
overwrite : bool = Options .overwrite ,
@@ -2130,15 +2146,15 @@ def wallet_regen_coldkey(
2130
2146
2131
2147
wallet = Wallet (wallet_name , wallet_hotkey , wallet_path )
2132
2148
2133
- mnemonic , seed , json , json_password = get_creation_data (
2134
- mnemonic , seed , json , json_password
2149
+ mnemonic , seed , json_path , json_password = get_creation_data (
2150
+ mnemonic , seed , json_path , json_password
2135
2151
)
2136
2152
return self ._run_command (
2137
2153
wallets .regen_coldkey (
2138
2154
wallet ,
2139
2155
mnemonic ,
2140
2156
seed ,
2141
- json ,
2157
+ json_path ,
2142
2158
json_password ,
2143
2159
use_password ,
2144
2160
overwrite ,
@@ -2214,7 +2230,7 @@ def wallet_regen_hotkey(
2214
2230
wallet_hotkey : Optional [str ] = Options .wallet_hotkey ,
2215
2231
mnemonic : Optional [str ] = Options .mnemonic ,
2216
2232
seed : Optional [str ] = Options .seed ,
2217
- json : Optional [str ] = Options .json ,
2233
+ json_path : Optional [str ] = Options .json ,
2218
2234
json_password : Optional [str ] = Options .json_password ,
2219
2235
use_password : bool = typer .Option (
2220
2236
False , # Overriden to False
@@ -2250,15 +2266,15 @@ def wallet_regen_hotkey(
2250
2266
ask_for = [WO .NAME , WO .PATH , WO .HOTKEY ],
2251
2267
validate = WV .WALLET ,
2252
2268
)
2253
- mnemonic , seed , json , json_password = get_creation_data (
2254
- mnemonic , seed , json , json_password
2269
+ mnemonic , seed , json_path , json_password = get_creation_data (
2270
+ mnemonic , seed , json_path , json_password
2255
2271
)
2256
2272
return self ._run_command (
2257
2273
wallets .regen_hotkey (
2258
2274
wallet ,
2259
2275
mnemonic ,
2260
2276
seed ,
2261
- json ,
2277
+ json_path ,
2262
2278
json_password ,
2263
2279
use_password ,
2264
2280
overwrite ,
@@ -3190,7 +3206,7 @@ def stake_add(
3190
3206
rate_tolerance : Optional [float ] = Options .rate_tolerance ,
3191
3207
safe_staking : Optional [bool ] = Options .safe_staking ,
3192
3208
allow_partial_stake : Optional [bool ] = Options .allow_partial_stake ,
3193
- era : int = Options .era ,
3209
+ period : int = Options .period ,
3194
3210
prompt : bool = Options .prompt ,
3195
3211
quiet : bool = Options .quiet ,
3196
3212
verbose : bool = Options .verbose ,
@@ -3386,7 +3402,7 @@ def stake_add(
3386
3402
rate_tolerance ,
3387
3403
allow_partial_stake ,
3388
3404
json_output ,
3389
- era ,
3405
+ period ,
3390
3406
)
3391
3407
)
3392
3408
@@ -3438,7 +3454,7 @@ def stake_remove(
3438
3454
rate_tolerance : Optional [float ] = Options .rate_tolerance ,
3439
3455
safe_staking : Optional [bool ] = Options .safe_staking ,
3440
3456
allow_partial_stake : Optional [bool ] = Options .allow_partial_stake ,
3441
- era : int = Options .era ,
3457
+ period : int = Options .period ,
3442
3458
prompt : bool = Options .prompt ,
3443
3459
interactive : bool = typer .Option (
3444
3460
False ,
@@ -3631,7 +3647,7 @@ def stake_remove(
3631
3647
exclude_hotkeys = exclude_hotkeys ,
3632
3648
prompt = prompt ,
3633
3649
json_output = json_output ,
3634
- era = era ,
3650
+ era = period ,
3635
3651
)
3636
3652
)
3637
3653
elif (
@@ -3687,7 +3703,7 @@ def stake_remove(
3687
3703
rate_tolerance = rate_tolerance ,
3688
3704
allow_partial_stake = allow_partial_stake ,
3689
3705
json_output = json_output ,
3690
- era = era ,
3706
+ era = period ,
3691
3707
)
3692
3708
)
3693
3709
@@ -3715,7 +3731,7 @@ def stake_move(
3715
3731
stake_all : bool = typer .Option (
3716
3732
False , "--stake-all" , "--all" , help = "Stake all" , prompt = False
3717
3733
),
3718
- era : int = Options .era ,
3734
+ period : int = Options .period ,
3719
3735
prompt : bool = Options .prompt ,
3720
3736
quiet : bool = Options .quiet ,
3721
3737
verbose : bool = Options .verbose ,
@@ -3845,7 +3861,7 @@ def stake_move(
3845
3861
destination_hotkey = destination_hotkey ,
3846
3862
amount = amount ,
3847
3863
stake_all = stake_all ,
3848
- era = era ,
3864
+ era = period ,
3849
3865
interactive_selection = interactive_selection ,
3850
3866
prompt = prompt ,
3851
3867
)
@@ -3886,7 +3902,7 @@ def stake_transfer(
3886
3902
stake_all : bool = typer .Option (
3887
3903
False , "--stake-all" , "--all" , help = "Stake all" , prompt = False
3888
3904
),
3889
- era : int = Options .era ,
3905
+ period : int = Options .period ,
3890
3906
prompt : bool = Options .prompt ,
3891
3907
quiet : bool = Options .quiet ,
3892
3908
verbose : bool = Options .verbose ,
@@ -4008,7 +4024,7 @@ def stake_transfer(
4008
4024
dest_netuid = dest_netuid ,
4009
4025
dest_coldkey_ss58 = dest_ss58 ,
4010
4026
amount = amount ,
4011
- era = era ,
4027
+ era = period ,
4012
4028
interactive_selection = interactive_selection ,
4013
4029
stake_all = stake_all ,
4014
4030
prompt = prompt ,
@@ -4050,7 +4066,7 @@ def stake_swap(
4050
4066
"--all" ,
4051
4067
help = "Swap all available stake" ,
4052
4068
),
4053
- era : int = Options .era ,
4069
+ period : int = Options .period ,
4054
4070
prompt : bool = Options .prompt ,
4055
4071
wait_for_inclusion : bool = Options .wait_for_inclusion ,
4056
4072
wait_for_finalization : bool = Options .wait_for_finalization ,
@@ -4115,7 +4131,7 @@ def stake_swap(
4115
4131
destination_netuid = dest_netuid ,
4116
4132
amount = amount ,
4117
4133
swap_all = swap_all ,
4118
- era = era ,
4134
+ era = period ,
4119
4135
interactive_selection = interactive_selection ,
4120
4136
prompt = prompt ,
4121
4137
wait_for_inclusion = wait_for_inclusion ,
@@ -4430,6 +4446,7 @@ def sudo_set(
4430
4446
param_value : Optional [str ] = typer .Option (
4431
4447
"" , "--value" , help = "Value to set the hyperparameter to."
4432
4448
),
4449
+ prompt : bool = Options .prompt ,
4433
4450
quiet : bool = Options .quiet ,
4434
4451
verbose : bool = Options .verbose ,
4435
4452
json_output : bool = Options .json_output ,
@@ -4454,6 +4471,11 @@ def sudo_set(
4454
4471
raise typer .Exit ()
4455
4472
4456
4473
if not param_name :
4474
+ if not prompt :
4475
+ err_console .print (
4476
+ "Param name not supplied with `--no-prompt` flag. Cannot continue"
4477
+ )
4478
+ return False
4457
4479
hyperparam_list = [field .name for field in fields (SubnetHyperparameters )]
4458
4480
console .print ("Available hyperparameters:\n " )
4459
4481
for idx , param in enumerate (hyperparam_list , start = 1 ):
@@ -4467,6 +4489,11 @@ def sudo_set(
4467
4489
param_name = hyperparam_list [choice - 1 ]
4468
4490
4469
4491
if param_name in ["alpha_high" , "alpha_low" ]:
4492
+ if not prompt :
4493
+ err_console .print (
4494
+ "`alpha_high` and `alpha_low` values cannot be set with `--no-prompt`"
4495
+ )
4496
+ return False
4470
4497
param_name = "alpha_values"
4471
4498
low_val = FloatPrompt .ask (
4472
4499
"Enter the new value for [dark_orange]alpha_low[/dark_orange]"
@@ -4477,6 +4504,11 @@ def sudo_set(
4477
4504
param_value = f"{ low_val } ,{ high_val } "
4478
4505
4479
4506
if not param_value :
4507
+ if not prompt :
4508
+ err_console .print (
4509
+ "Param value not supplied with `--no-prompt` flag. Cannot continue."
4510
+ )
4511
+ return False
4480
4512
if HYPERPARAMS .get (param_name ):
4481
4513
param_value = Prompt .ask (
4482
4514
f"Enter the new value for [{ COLORS .G .SUBHEAD } ]{ param_name } [/{ COLORS .G .SUBHEAD } ] "
@@ -4495,6 +4527,7 @@ def sudo_set(
4495
4527
netuid ,
4496
4528
param_name ,
4497
4529
param_value ,
4530
+ prompt ,
4498
4531
json_output ,
4499
4532
)
4500
4533
)
@@ -5258,10 +5291,12 @@ def subnets_register(
5258
5291
wallet_hotkey : str = Options .wallet_hotkey ,
5259
5292
network : Optional [list [str ]] = Options .network ,
5260
5293
netuid : int = Options .netuid ,
5261
- era : Optional [
5294
+ period : Optional [
5262
5295
int
5263
- ] = typer .Option ( # Should not be Options.era bc this needs to be an Optional[int]
5296
+ ] = typer .Option ( # Should not be Options.period bc this needs to be an Optional[int]
5264
5297
None ,
5298
+ "--period" ,
5299
+ "--era" ,
5265
5300
help = "Length (in blocks) for which the transaction should be valid. Note that it is possible that if you "
5266
5301
"use an era for this transaction that you may pay a different fee to register than the one stated." ,
5267
5302
),
@@ -5294,7 +5329,7 @@ def subnets_register(
5294
5329
wallet ,
5295
5330
self .initialize_chain (network ),
5296
5331
netuid ,
5297
- era ,
5332
+ period ,
5298
5333
json_output ,
5299
5334
prompt ,
5300
5335
)
0 commit comments