Skip to content

Commit 8920567

Browse files
author
Andres D. Molins
committed
Fix: Solve issue loading the good configuration.
1 parent b3322d4 commit 8920567

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/aleph_client/commands/account.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,14 @@ def display_active_address(
160160
typer.secho("No private key available", fg=RED)
161161
raise typer.Exit(code=1)
162162

163-
evm_address = _load_account(private_key, private_key_file, chain=Chain.ETH).get_address()
164-
sol_address = _load_account(private_key, private_key_file, chain=Chain.SOL).get_address()
163+
config_file_path = Path(settings.CONFIG_FILE)
164+
config = load_main_configuration(config_file_path)
165+
if config and config.type and config.type == AccountType.EXTERNAL:
166+
evm_address = _load_account(None, None, chain=Chain.ETH).get_address()
167+
sol_address = _load_account(None, None, chain=Chain.SOL).get_address()
168+
else:
169+
evm_address = _load_account(private_key, private_key_file, chain=Chain.ETH).get_address()
170+
sol_address = _load_account(private_key, private_key_file, chain=Chain.SOL).get_address()
165171

166172
console.print(
167173
"✉ [bold italic blue]Addresses for Active Account[/bold italic blue] ✉\n\n"
@@ -476,9 +482,6 @@ async def configure(
476482

477483
unlinked_keys, config = await list_unlinked_keys()
478484

479-
if not account_type:
480-
account_type = AccountType.INTERNAL
481-
482485
# Fixes private key file path
483486
if private_key_file:
484487
if not private_key_file.name.endswith(".key"):
@@ -492,7 +495,8 @@ async def configure(
492495
raise typer.Exit()
493496

494497
# Configures active private key file
495-
if not account_type and not private_key_file and config and hasattr(config, "path") and Path(config.path).exists():
498+
if (not account_type or account_type == AccountType.INTERNAL and
499+
not private_key_file and config and hasattr(config, "path") and Path(config.path).exists()):
496500
if not yes_no_input(
497501
f"Active private key file: [bright_cyan]{config.path}[/bright_cyan]\n[yellow]Keep current active private "
498502
"key?[/yellow]",
@@ -518,9 +522,9 @@ async def configure(
518522
else: # No change
519523
private_key_file = Path(config.path)
520524

521-
if not private_key_file:
525+
if not private_key_file and account_type == AccountType.EXTERNAL:
522526
if yes_no_input(
523-
"[bright_cyan]No private key file found.[/bright_cyan] [yellow]"
527+
"[bright_cyan]Loading External keys.[/bright_cyan] [yellow]"
524528
"Do you want to import from Ledger?[/yellow]",
525529
default="y",
526530
):
@@ -566,6 +570,9 @@ async def configure(
566570
typer.secho("No chain provided.", fg=typer.colors.RED)
567571
raise typer.Exit()
568572

573+
if not account_type:
574+
account_type = AccountType.INTERNAL.value
575+
569576
try:
570577
config = MainConfiguration(path=private_key_file, chain=chain, address=address, type=account_type)
571578
save_main_configuration(settings.CONFIG_FILE, config)

0 commit comments

Comments
 (0)