Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: LIVE-12665 desactivate tezos unrevealed account swap #6915

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/eight-coins-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"ledger-live-desktop": patch
"live-mobile": patch
"@ledgerhq/live-common": patch
---

desactivate tezos unrevealed account swap
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 3 additions & 0 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 8 additions & 2 deletions apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions libs/ledger-live-common/src/exchange/swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -130,6 +131,7 @@ export {
getCompleteSwapHistory,
postSwapAccepted,
getExchangeRates,
maybeTezosAccountUnrevealedAccount,
postSwapCancelled,
initSwap,
USStates,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
};
Loading