From 16e3769b3bb2361a13a918d53622b79932e32e5d Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Mon, 28 Aug 2023 15:29:49 +0200 Subject: [PATCH] Fix: Invalid handling of optional value --- src/aleph/sdk/wallets/ledger/ethereum.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/aleph/sdk/wallets/ledger/ethereum.py b/src/aleph/sdk/wallets/ledger/ethereum.py index a8ba6899..392a68d4 100644 --- a/src/aleph/sdk/wallets/ledger/ethereum.py +++ b/src/aleph/sdk/wallets/ledger/ethereum.py @@ -38,10 +38,16 @@ def from_address( a known wallet address. """ device = device or init_dongle() - account = find_account(address=address, dongle=device, count=5) - return LedgerETHAccount( - account=account, - device=device, + account: Optional[LedgerAccount] = find_account( + address=address, dongle=device, count=5 + ) + return ( + LedgerETHAccount( + account=account, + device=device, + ) + if account + else None ) @staticmethod @@ -49,7 +55,7 @@ def from_path(path: str, device: Optional[Dongle] = None) -> LedgerETHAccount: """Initialize an aleph.im account from a LedgerHQ device from a known wallet account path.""" device = device or init_dongle() - account = get_account_by_path(path_string=path, dongle=device) + account: LedgerAccount = get_account_by_path(path_string=path, dongle=device) return LedgerETHAccount( account=account, device=device,