diff --git a/.changeset/eight-coins-listen.md b/.changeset/eight-coins-listen.md new file mode 100644 index 000000000000..b649879b7d60 --- /dev/null +++ b/.changeset/eight-coins-listen.md @@ -0,0 +1,7 @@ +--- +"ledger-live-desktop": patch +"live-mobile": patch +"@ledgerhq/live-common": patch +--- + +desactivate tezos unrevealed account swap diff --git a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/index.tsx b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/index.tsx index 29439da40714..458a911ba6e8 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/exchange/Swap2/Form/index.tsx @@ -37,6 +37,7 @@ import SwapFormSelectors from "./FormSelectors"; import { SwapMigrationUI } from "./Migrations/SwapMigrationUI"; import EmptyState from "./Rates/EmptyState"; import SwapWebView, { SwapWebProps, useSwapLiveAppManifestID } from "./SwapWebView"; +import { maybeTezosAccountUnrevealedAccount } from "@ledgerhq/live-common/exchange/swap/index"; const DAPP_PROVIDERS = ["paraswap", "oneinch", "moonpay"]; @@ -105,7 +106,10 @@ const SwapForm = () => { }, []); const exchangeRatesState = swapTransaction.swap?.rates; - const swapError = swapTransaction.fromAmountError || exchangeRatesState?.error; + const swapError = + swapTransaction.fromAmountError || + exchangeRatesState?.error || + maybeTezosAccountUnrevealedAccount(swapTransaction); const swapWarning = swapTransaction.fromAmountWarning; const pageState = usePageState(swapTransaction, swapError); const provider = useMemo(() => exchangeRate?.provider, [exchangeRate?.provider]); diff --git a/apps/ledger-live-desktop/static/i18n/en/app.json b/apps/ledger-live-desktop/static/i18n/en/app.json index 82aa40511781..2c94e8647585 100644 --- a/apps/ledger-live-desktop/static/i18n/en/app.json +++ b/apps/ledger-live-desktop/static/i18n/en/app.json @@ -6082,6 +6082,9 @@ "FailedToRetrieveFirmwareUpdateInfo": { "title": "OS update check failed", "description": "Something went wrong. Please try again or contact Ledger Support if in doubt." + }, + "TezosUnrevealedAccount": { + "title": "Swap unavailable: Initial send/delegate needed with Tezos account or change pair." } }, "cryptoOrg": { diff --git a/apps/ledger-live-mobile/src/locales/en/common.json b/apps/ledger-live-mobile/src/locales/en/common.json index 3ffd12d7f688..aaf636c4667d 100644 --- a/apps/ledger-live-mobile/src/locales/en/common.json +++ b/apps/ledger-live-mobile/src/locales/en/common.json @@ -916,6 +916,9 @@ "SequenceNumberError": { "title": "Sequence number error", "description": "Please close the window and try again later" + }, + "TezosUnrevealedAccount": { + "title": "Swap unavailable: Initial send/delegate needed with Tezos account or change pair." } }, "crash": { diff --git a/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx b/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx index 38d3033505ed..5c93d1f43fa4 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx @@ -40,7 +40,10 @@ import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/Ba import { SwapFormNavigatorParamList } from "~/components/RootNavigator/types/SwapFormNavigator"; import { formatCurrencyUnit } from "@ledgerhq/live-common/currencies/index"; import type { DetailsSwapParamList } from "../types"; -import { getAvailableProviders } from "@ledgerhq/live-common/exchange/swap/index"; +import { + getAvailableProviders, + maybeTezosAccountUnrevealedAccount, +} from "@ledgerhq/live-common/exchange/swap/index"; import { DEFAULT_SWAP_RATES_LLM_INTERVAL_MS } from "@ledgerhq/live-common/exchange/swap/const/timeout"; import { useSelectedSwapRate } from "./useSelectedSwapRate"; import { walletSelector } from "~/reducers/wallet"; @@ -133,7 +136,10 @@ export function SwapForm({ ); }, [exchangeRatesState.value, swapTransaction.swap.to.currency]); - const swapError = swapTransaction.fromAmountError || exchangeRatesState?.error; + const swapError = + swapTransaction.fromAmountError || + exchangeRatesState?.error || + maybeTezosAccountUnrevealedAccount(swapTransaction); const swapWarning = swapTransaction.fromAmountWarning; const pageState = usePageState(swapTransaction, swapError || swapWarning); diff --git a/libs/ledger-live-common/src/exchange/swap/index.ts b/libs/ledger-live-common/src/exchange/swap/index.ts index c4948140a511..ae5b8ca3a4ec 100644 --- a/libs/ledger-live-common/src/exchange/swap/index.ts +++ b/libs/ledger-live-common/src/exchange/swap/index.ts @@ -19,6 +19,7 @@ import getCompleteSwapHistory from "./getCompleteSwapHistory"; import initSwap from "./initSwap"; import { postSwapAccepted, postSwapCancelled } from "./postSwapState"; import getExchangeRates from "./getExchangeRates"; +import { maybeTezosAccountUnrevealedAccount } from "./maybeTezosAccountUnrevealedAccount"; export { getAvailableProviders } from "../providers"; @@ -130,6 +131,7 @@ export { getCompleteSwapHistory, postSwapAccepted, getExchangeRates, + maybeTezosAccountUnrevealedAccount, postSwapCancelled, initSwap, USStates, diff --git a/libs/ledger-live-common/src/exchange/swap/maybeTezosAccountUnrevealedAccount.ts b/libs/ledger-live-common/src/exchange/swap/maybeTezosAccountUnrevealedAccount.ts new file mode 100644 index 000000000000..a4571d28212b --- /dev/null +++ b/libs/ledger-live-common/src/exchange/swap/maybeTezosAccountUnrevealedAccount.ts @@ -0,0 +1,15 @@ +import { SwapTransactionType } from "./types"; + +export const maybeTezosAccountUnrevealedAccount = ( + swapTransaction: SwapTransactionType, +): Error | undefined => { + if ( + swapTransaction?.transaction?.family == "tezos" && + swapTransaction?.transaction?.estimatedFees && + swapTransaction?.transaction?.fees !== swapTransaction?.transaction?.estimatedFees + ) { + const tezosError = new Error("Cannot swap with an unrevealed Tezos account"); + tezosError.name = "TezosUnrevealedAccount"; + return tezosError; + } +};