{error}
> ) } diff --git a/apps/extension/src/ui/domains/Account/LedgerSubstrateGenericAccountPicker.tsx b/apps/extension/src/ui/domains/Account/LedgerSubstrateGenericAccountPicker.tsx index efe2f5d077..2c8109f87b 100644 --- a/apps/extension/src/ui/domains/Account/LedgerSubstrateGenericAccountPicker.tsx +++ b/apps/extension/src/ui/domains/Account/LedgerSubstrateGenericAccountPicker.tsx @@ -1,6 +1,6 @@ import { InfoIcon } from "@talismn/icons" -import { classNames } from "@talismn/util" -import { SubstrateAppParams } from "@zondax/ledger-substrate/dist/common" +import { classNames, encodeAnyAddress } from "@talismn/util" +import { GenericeResponseAddress, SubstrateAppParams } from "@zondax/ledger-substrate/dist/common" import { AccountJsonAny, ChainId, SubstrateLedgerAppType } from "extension-core" import { log } from "extension-shared" import { @@ -19,6 +19,7 @@ import { FormFieldContainer, FormFieldInputText, Tooltip, TooltipTrigger } from import { convertAddress } from "@talisman/util/convertAddress" import { LedgerAccountDefSubstrateGeneric } from "@ui/domains/Account/AccountAdd/AccountAddLedger/context" import { getPolkadotLedgerDerivationPath } from "@ui/hooks/ledger/common" +import { getCustomTalismanLedgerError, TalismanLedgerError } from "@ui/hooks/ledger/errors" import { useLedgerSubstrateGeneric } from "@ui/hooks/ledger/useLedgerSubstrateGeneric" import { AccountImportDef, useAccountImportBalances } from "@ui/hooks/useAccountImportBalances" import { useAccounts, useChain, useChains } from "@ui/state" @@ -28,13 +29,13 @@ import { AccountIcon } from "./AccountIcon" import { Address } from "./Address" import { BalancesSummaryTooltipContent } from "./BalancesSummaryTooltipContent" import { DerivedAccountBase, DerivedAccountPickerBase } from "./DerivedAccountPickerBase" -import { LedgerConnectionStatus } from "./LedgerConnectionStatus" +import { LedgerConnectionStatus, LedgerConnectionStatusProps } from "./LedgerConnectionStatus" const useLedgerSubstrateGenericAccounts = ( selectedAccounts: LedgerAccountDefSubstrateGeneric[], pageIndex: number, itemsPerPage: number, - app?: SubstrateAppParams | null, + legacyApp?: SubstrateAppParams | null, ) => { const walletAccounts = useAccounts() const { t } = useTranslation() @@ -42,53 +43,98 @@ const useLedgerSubstrateGenericAccounts = ( const [ledgerAccounts, setLedgerAccounts] = useState< (LedgerSubstrateGenericAccount | undefined)[] >([...Array(itemsPerPage)]) - const [isBusy, setIsBusy] = useState(false) - const [error, setError] = useState- {error ? t("An error occured, Ledger might be locked.") : null} -
> ) } @@ -258,51 +290,68 @@ const getNextAccountDetails = ( const useLedgerAccountAddress = ( account: CustomAccountDetails | undefined, - app: SubstrateAppParams | null | undefined, + legacyApp: SubstrateAppParams | null | undefined, ) => { - const { isReady, ledger, ...connectionStatus } = useLedgerSubstrateGeneric({ app }) + const { t } = useTranslation() + const { getAddress } = useLedgerSubstrateGeneric({ legacyApp }) - // if ledger was busy when changing tabs, connection needs to be refreshed once on mount - const refInitialized = useRef(false) - useEffect(() => { - if (!refInitialized.current && connectionStatus.status === "error") { - refInitialized.current = true - connectionStatus.refresh() - return - } - }, [connectionStatus]) + const refIsBusy = useRef(false) + + const [connectionStatus, setConnectionStatus] = useState- {error ? t("An error occured, Ledger might be locked.") : null} -
> ) } diff --git a/apps/extension/src/ui/domains/Sign/ErrorMessageDrawer.tsx b/apps/extension/src/ui/domains/Sign/ErrorMessageDrawer.tsx index cf0fd078b0..79558a697f 100644 --- a/apps/extension/src/ui/domains/Sign/ErrorMessageDrawer.tsx +++ b/apps/extension/src/ui/domains/Sign/ErrorMessageDrawer.tsx @@ -1,20 +1,22 @@ -import { AlertCircleIcon } from "@talismn/icons" +import { XCircleIcon } from "@talismn/icons" +import { CONNECT_LEDGER_DOCS_URL } from "extension-shared" import { FC, useEffect, useState } from "react" -import { useTranslation } from "react-i18next" +import { Trans, useTranslation } from "react-i18next" import { Button, Drawer } from "talisman-ui" export const ErrorMessageDrawer: FC<{ message: string | undefined + name?: string // identifies specific errors, some require specific UI containerId: string | undefined onDismiss: () => void -}> = ({ message, containerId, onDismiss }) => { +}> = ({ message, name, containerId, onDismiss }) => { const { t } = useTranslation() // keep message in memory to prevent flickering on slide out const [content, setContent] = useState{content}
+
+ {name === "GenericAppRequired" ?
- {message === "GENERIC_APP_REQUIRED" ? (
-