Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,14 @@ def parse_mnemonic(mnemonic: str) -> str:
def get_creation_data(
mnemonic: Optional[str],
seed: Optional[str],
json: Optional[str],
json_path: Optional[str],
json_password: Optional[str],
) -> tuple[str, str, str, str]:
"""
Determines which of the key creation elements have been supplied, if any. If None have been supplied,
prompts to user, and determines what they've supplied. Returns all elements in a tuple.
"""
if not mnemonic and not seed and not json:
if not mnemonic and not seed and not json_path:
prompt_answer = Prompt.ask(
"Enter the mnemonic, or the seed hex string, or the location of the JSON file."
)
Expand All @@ -455,20 +455,20 @@ def get_creation_data(
elif len(prompt_answer.split(" ")) > 1:
mnemonic = parse_mnemonic(prompt_answer)
else:
json = prompt_answer
json_path = prompt_answer
elif mnemonic:
mnemonic = parse_mnemonic(mnemonic)

if json:
if not os.path.exists(json):
print_error(f"The JSON file '{json}' does not exist.")
if json_path:
if not os.path.exists(json_path):
print_error(f"The JSON file '{json_path}' does not exist.")
raise typer.Exit()

if json and not json_password:
if json_path and not json_password:
json_password = Prompt.ask(
"Enter the backup password for JSON file.", password=True
)
return mnemonic, seed, json, json_password
return mnemonic, seed, json_path, json_password


def config_selector(conf: dict, title: str):
Expand Down Expand Up @@ -2093,7 +2093,7 @@ def wallet_regen_coldkey(
wallet_hotkey: Optional[str] = Options.wallet_hotkey,
mnemonic: Optional[str] = Options.mnemonic,
seed: Optional[str] = Options.seed,
json: Optional[str] = Options.json,
json_path: Optional[str] = Options.json,
json_password: Optional[str] = Options.json_password,
use_password: Optional[bool] = Options.use_password,
overwrite: bool = Options.overwrite,
Expand Down Expand Up @@ -2133,15 +2133,15 @@ def wallet_regen_coldkey(

wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)

mnemonic, seed, json, json_password = get_creation_data(
mnemonic, seed, json, json_password
mnemonic, seed, json_path, json_password = get_creation_data(
mnemonic, seed, json_path, json_password
)
return self._run_command(
wallets.regen_coldkey(
wallet,
mnemonic,
seed,
json,
json_path,
json_password,
use_password,
overwrite,
Expand Down Expand Up @@ -2217,7 +2217,7 @@ def wallet_regen_hotkey(
wallet_hotkey: Optional[str] = Options.wallet_hotkey,
mnemonic: Optional[str] = Options.mnemonic,
seed: Optional[str] = Options.seed,
json: Optional[str] = Options.json,
json_path: Optional[str] = Options.json,
json_password: Optional[str] = Options.json_password,
use_password: bool = typer.Option(
False, # Overriden to False
Expand Down Expand Up @@ -2253,15 +2253,15 @@ def wallet_regen_hotkey(
ask_for=[WO.NAME, WO.PATH, WO.HOTKEY],
validate=WV.WALLET,
)
mnemonic, seed, json, json_password = get_creation_data(
mnemonic, seed, json, json_password
mnemonic, seed, json_path, json_password = get_creation_data(
mnemonic, seed, json_path, json_password
)
return self._run_command(
wallets.regen_hotkey(
wallet,
mnemonic,
seed,
json,
json_path,
json_password,
use_password,
overwrite,
Expand Down
Loading