From 28e6323ea9cb78ddab87a943602585c7a2bfca12 Mon Sep 17 00:00:00 2001 From: Mikhail Date: Tue, 16 Jan 2024 10:09:55 +0300 Subject: [PATCH] fix: show solana frozen account error for wallet ata --- apps/ledger-live-desktop/static/i18n/en/app.json | 2 +- apps/ledger-live-mobile/src/locales/en/common.json | 3 +++ .../src/families/solana/js-prepareTransaction.ts | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/ledger-live-desktop/static/i18n/en/app.json b/apps/ledger-live-desktop/static/i18n/en/app.json index 9f97a61c795f..9395910775b9 100644 --- a/apps/ledger-live-desktop/static/i18n/en/app.json +++ b/apps/ledger-live-desktop/static/i18n/en/app.json @@ -5762,7 +5762,7 @@ "title": "Account will be funded" }, "SolanaTokenAccountFrozen": { - "title": "Account assets are frozen" + "title": "Token account assets are frozen" }, "SolanaTokenAccounNotInitialized": { "title": "Account not initialized" diff --git a/apps/ledger-live-mobile/src/locales/en/common.json b/apps/ledger-live-mobile/src/locales/en/common.json index 96f82d2e0bd8..38769749f6d9 100644 --- a/apps/ledger-live-mobile/src/locales/en/common.json +++ b/apps/ledger-live-mobile/src/locales/en/common.json @@ -756,6 +756,9 @@ "SolanaAssociatedTokenAccountWillBeFunded": { "title": "Account will be funded" }, + "SolanaTokenAccountFrozen": { + "title": "Token account assets are frozen" + }, "SolanaAddressOfEd25519": { "title": "Address off ed25519 curve" }, diff --git a/libs/ledger-live-common/src/families/solana/js-prepareTransaction.ts b/libs/ledger-live-common/src/families/solana/js-prepareTransaction.ts index 548e868cd57a..6dabc87c4a93 100644 --- a/libs/ledger-live-common/src/families/solana/js-prepareTransaction.ts +++ b/libs/ledger-live-common/src/families/solana/js-prepareTransaction.ts @@ -238,6 +238,17 @@ async function getTokenRecipient( api, )); + if (!shouldCreateAsAssociatedTokenAccount) { + const associatedTokenAccount = await getMaybeTokenAccount( + recipientAssociatedTokenAccountAddress, + api, + ); + if (associatedTokenAccount instanceof Error) throw recipientTokenAccount; + if (associatedTokenAccount?.state === "frozen") { + return new SolanaTokenAccountFrozen(); + } + } + return { walletAddress: recipientAddress, shouldCreateAsAssociatedTokenAccount,