diff --git a/packages/desktop/components/popup/profileAuthPopups/ConnectLedgerPopup.svelte b/packages/desktop/components/popup/profileAuthPopups/ConnectLedgerPopup.svelte index 45f3b99fe9..0228fc7b9b 100644 --- a/packages/desktop/components/popup/profileAuthPopups/ConnectLedgerPopup.svelte +++ b/packages/desktop/components/popup/profileAuthPopups/ConnectLedgerPopup.svelte @@ -7,7 +7,7 @@ import PopupTemplate from '../PopupTemplate.svelte' export let ledgerAppName: LedgerAppName - export let onContinue: () => void + export let onSuccess: () => void $: isDisconnected = $ledgerConnectionState === LedgerConnectionState.Disconnected $: isLocked = $ledgerConnectionState === LedgerConnectionState.Locked @@ -53,7 +53,7 @@ function continueFlow(): void { closeProfileAuthPopup() - onContinue?.() + onSuccess?.() } function onCancelClick(): void { diff --git a/packages/desktop/views/onboarding/views/complete-onboarding/views/FinishOnboardingView.svelte b/packages/desktop/views/onboarding/views/complete-onboarding/views/FinishOnboardingView.svelte index cfa09bc8b9..c4de029c07 100644 --- a/packages/desktop/views/onboarding/views/complete-onboarding/views/FinishOnboardingView.svelte +++ b/packages/desktop/views/onboarding/views/complete-onboarding/views/FinishOnboardingView.svelte @@ -3,7 +3,7 @@ import { Animation, Illustration } from '@ui' import { completeOnboardingProcess, isOnboardingLedgerProfile, onboardingProfile } from '@contexts/onboarding' import { localize } from '@core/i18n' - import { LedgerAppName, checkOrConnectLedger } from '@core/ledger' + import { LedgerAppName, checkOrConnectLedgerAsync } from '@core/ledger' import { profiles } from '@core/profile/stores' import { OnboardingLayout } from '@views/components' import SuccessSvg from '@views/onboarding/components/SuccessSvg.svelte' @@ -22,16 +22,11 @@ $: appName = $onboardingProfile?.network?.id === SupportedNetworkId.Iota ? LedgerAppName.Iota : LedgerAppName.Shimmer - function onContinueClick(): void { - if ($isOnboardingLedgerProfile) { - checkOrConnectLedger(_continue, false, appName) - } else { - void _continue() - } - } - - async function _continue(): Promise { + async function onContinueClick(): Promise { try { + if ($isOnboardingLedgerProfile) { + await checkOrConnectLedgerAsync(appName) + } await completeOnboardingProcess() void login({ isFromOnboardingFlow: true }) $onboardingRouter.next() diff --git a/packages/desktop/views/onboarding/views/restore-profile/views/BalanceFinderView.svelte b/packages/desktop/views/onboarding/views/restore-profile/views/BalanceFinderView.svelte index 148e58ced6..b1120829d8 100644 --- a/packages/desktop/views/onboarding/views/restore-profile/views/BalanceFinderView.svelte +++ b/packages/desktop/views/onboarding/views/restore-profile/views/BalanceFinderView.svelte @@ -4,12 +4,11 @@ import { IAccount } from '@core/account' import { DEFAULT_SYNC_OPTIONS } from '@core/account/constants' import { localize } from '@core/i18n' - import { LedgerAppName, checkOrConnectLedger, ledgerRaceConditionProtectionWrapper } from '@core/ledger' + import { LedgerAppName, checkOrConnectLedgerAsync, ledgerRaceConditionProtectionWrapper } from '@core/ledger' import { StardustNetworkId, SupportedNetworkId } from '@core/network' import { ProfileType } from '@core/profile' import { RecoverAccountsPayload, createAccount, recoverAccounts } from '@core/profile-manager' import { DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION } from '@core/profile/constants' - import { checkOrUnlockStronghold } from '@core/stronghold/actions' import { formatTokenAmountBestMatch } from '@core/token' import { OnboardingLayout } from '@views/components' import { onDestroy, onMount } from 'svelte' @@ -20,9 +19,9 @@ total: string } - const { network, type } = $onboardingProfile + const { network, type } = $onboardingProfile ?? {} - const DEFAULT_CONFIG = DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION[type] + const DEFAULT_CONFIG = DEFAULT_ACCOUNT_RECOVERY_CONFIGURATION[type as ProfileType] let accountStartIndex = 0 let accountGapLimit = DEFAULT_CONFIG.initialAccountRange @@ -101,7 +100,7 @@ try { error = '' isBusy = true - const _function = networkSearchMethod[network.id] ?? singleAddressSearch + const _function = networkSearchMethod[network?.id] ?? singleAddressSearch await ledgerRaceConditionProtectionWrapper(_function) } catch (err) { error = localize(err.error) @@ -120,31 +119,24 @@ const alias = account.getMetadata()?.alias const balance = await account.getBalance() - const baseToken = network.baseToken + const baseToken = network?.baseToken const baseCoinBalance = balance?.baseCoin?.total ?? BigInt(0) const total = formatTokenAmountBestMatch(baseCoinBalance, baseToken) return { alias, total } } - function checkOnboardingProfileAuth(callback: () => Promise): Promise { - if (type === ProfileType.Software) { - return checkOrUnlockStronghold(callback) - } else { - return checkOrConnectLedger( - callback, - false, - network.id === SupportedNetworkId.Iota ? LedgerAppName.Iota : LedgerAppName.Shimmer - ) - } - } - function onContinueClick(): void { $restoreProfileRouter.next() } async function onFindBalancesClick(): Promise { - await checkOnboardingProfileAuth(async () => await findBalances()) + if (type === ProfileType.Ledger) { + await checkOrConnectLedgerAsync( + network?.id === SupportedNetworkId.Iota ? LedgerAppName.Iota : LedgerAppName.Shimmer + ) + } + await findBalances() } onMount(async () => {