Skip to content

Commit 2438701

Browse files
committed
Respect config sets
1 parent 42331cb commit 2438701

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

bittensor_cli/cli.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,14 +2233,15 @@ def wallet_regen_coldkey(
22332233

22342234
if not wallet_path:
22352235
wallet_path = Prompt.ask(
2236-
"Enter the path for the wallets directory", default=defaults.wallet.path
2236+
"Enter the path for the wallets directory",
2237+
default=self.config.get("wallet_path") or defaults.wallet.path,
22372238
)
22382239
wallet_path = os.path.expanduser(wallet_path)
22392240

22402241
if not wallet_name:
22412242
wallet_name = Prompt.ask(
22422243
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2243-
default=defaults.wallet.name,
2244+
default=self.config.get("wallet_name") or defaults.wallet.name,
22442245
)
22452246

22462247
wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)
@@ -2292,14 +2293,15 @@ def wallet_regen_coldkey_pub(
22922293

22932294
if not wallet_path:
22942295
wallet_path = Prompt.ask(
2295-
"Enter the path to the wallets directory", default=defaults.wallet.path
2296+
"Enter the path to the wallets directory",
2297+
default=self.config.get("wallet_path") or defaults.wallet.path,
22962298
)
22972299
wallet_path = os.path.expanduser(wallet_path)
22982300

22992301
if not wallet_name:
23002302
wallet_name = Prompt.ask(
23012303
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2302-
default=defaults.wallet.name,
2304+
default=self.config.get("wallet_name") or defaults.wallet.name,
23032305
)
23042306
wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)
23052307

@@ -2418,18 +2420,6 @@ def wallet_new_hotkey(
24182420
"""
24192421
self.verbosity_handler(quiet, verbose, json_output)
24202422

2421-
if not wallet_name:
2422-
wallet_name = Prompt.ask(
2423-
f"Enter the [{COLORS.G.CK}]wallet name",
2424-
default=defaults.wallet.name,
2425-
)
2426-
2427-
if not wallet_hotkey:
2428-
wallet_hotkey = Prompt.ask(
2429-
f"Enter the name of the [{COLORS.G.HK}]new hotkey",
2430-
default=defaults.wallet.hotkey,
2431-
)
2432-
24332423
wallet = self.wallet_ask(
24342424
wallet_name,
24352425
wallet_path,
@@ -2479,8 +2469,7 @@ def wallet_associate_hotkey(
24792469
"[blue]hotkey ss58 address[/blue] [dim](to associate with your coldkey)[/dim]"
24802470
)
24812471

2482-
hotkey_display = None
2483-
if is_valid_ss58_address(wallet_hotkey):
2472+
if wallet_hotkey and is_valid_ss58_address(wallet_hotkey):
24842473
hotkey_ss58 = wallet_hotkey
24852474
wallet = self.wallet_ask(
24862475
wallet_name,
@@ -2501,7 +2490,10 @@ def wallet_associate_hotkey(
25012490
validate=WV.WALLET_AND_HOTKEY,
25022491
)
25032492
hotkey_ss58 = wallet.hotkey.ss58_address
2504-
hotkey_display = f"hotkey [blue]{wallet_hotkey}[/blue] [{COLORS.GENERAL.HK}]({hotkey_ss58})[/{COLORS.GENERAL.HK}]"
2493+
hotkey_display = (
2494+
f"hotkey [blue]{wallet_hotkey}[/blue] "
2495+
f"[{COLORS.GENERAL.HK}]({hotkey_ss58})[/{COLORS.GENERAL.HK}]"
2496+
)
25052497

25062498
return self._run_command(
25072499
wallets.associate_hotkey(
@@ -2627,7 +2619,8 @@ def wallet_check_ck_swap(
26272619

26282620
if not wallet_ss58_address:
26292621
wallet_ss58_address = Prompt.ask(
2630-
"Enter [blue]wallet name[/blue] or [blue]SS58 address[/blue] [dim](leave blank to show all pending swaps)[/dim]"
2622+
"Enter [blue]wallet name[/blue] or [blue]SS58 address[/blue] [dim]"
2623+
"(leave blank to show all pending swaps)[/dim]"
26312624
)
26322625
if not wallet_ss58_address:
26332626
return self._run_command(
@@ -2691,18 +2684,19 @@ def wallet_create_wallet(
26912684
self.verbosity_handler(quiet, verbose, json_output)
26922685
if not wallet_path:
26932686
wallet_path = Prompt.ask(
2694-
"Enter the path of wallets directory", default=defaults.wallet.path
2687+
"Enter the path of wallets directory",
2688+
default=self.config.get("wallet_path") or defaults.wallet.path,
26952689
)
26962690

26972691
if not wallet_name:
26982692
wallet_name = Prompt.ask(
26992693
f"Enter the name of the [{COLORS.G.CK}]new wallet (coldkey)",
2700-
default=defaults.wallet.name,
2694+
default=self.config.get("wallet_name") or defaults.wallet.name,
27012695
)
27022696
if not wallet_hotkey:
27032697
wallet_hotkey = Prompt.ask(
27042698
f"Enter the the name of the [{COLORS.G.HK}]new hotkey",
2705-
default=defaults.wallet.hotkey,
2699+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
27062700
)
27072701

27082702
wallet = self.wallet_ask(
@@ -3999,7 +3993,8 @@ def stake_move(
39993993
origin_hotkey = Prompt.ask(
40003994
"Enter the [blue]origin hotkey[/blue] name or "
40013995
"[blue]ss58 address[/blue] where the stake will be moved from "
4002-
"[dim](or Press Enter to view existing stakes)[/dim]"
3996+
"[dim](or Press Enter to view existing stakes)[/dim]",
3997+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
40033998
)
40043999
if origin_hotkey == "":
40054000
interactive_selection = True
@@ -4162,8 +4157,10 @@ def stake_transfer(
41624157
interactive_selection = False
41634158
if not wallet_hotkey:
41644159
origin_hotkey = Prompt.ask(
4165-
"Enter the [blue]origin hotkey[/blue] name or ss58 address [bold](stake will be transferred FROM here)[/bold] "
4166-
"[dim](or press Enter to select from existing stakes)[/dim]"
4160+
"Enter the [blue]origin hotkey[/blue] name or ss58 address [bold]"
4161+
"(stake will be transferred FROM here)[/bold] "
4162+
"[dim](or press Enter to select from existing stakes)[/dim]",
4163+
default=self.config.get("wallet_hotkey") or defaults.wallet.hotkey,
41674164
)
41684165
if origin_hotkey == "":
41694166
interactive_selection = True

0 commit comments

Comments
 (0)