From 7cb2d033a6b358e3508c098565393ebc64b25166 Mon Sep 17 00:00:00 2001 From: Kant Date: Tue, 19 Sep 2023 17:05:05 +0200 Subject: [PATCH] fix(wallet-api): request account was not showing token accounts in some cases The issue was only visible on mobile but is also prevented on desktop now The issue was only reproducible when omitting the parent account currency from the currencyIds of the request account query --- .changeset/neat-insects-sin.md | 9 +++++++++ .../components/PerCurrencySelectAccount/state.ts | 12 +++++++----- .../DataSelector/SelectAccountAndCurrencyDrawer.tsx | 8 +++++++- apps/ledger-live-mobile/src/reducers/accounts.ts | 12 +++++++----- 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 .changeset/neat-insects-sin.md diff --git a/.changeset/neat-insects-sin.md b/.changeset/neat-insects-sin.md new file mode 100644 index 000000000000..1c66e6789d75 --- /dev/null +++ b/.changeset/neat-insects-sin.md @@ -0,0 +1,9 @@ +--- +"ledger-live-desktop": patch +"live-mobile": patch +--- + +fix(wallet-api): request account was not showing token accounts in some cases + +The issue was only visible on mobile but is also prevented on desktop now +The issue was only reproducible when omitting the parent account currency from the currencyIds of the request account query diff --git a/apps/ledger-live-desktop/src/renderer/components/PerCurrencySelectAccount/state.ts b/apps/ledger-live-desktop/src/renderer/components/PerCurrencySelectAccount/state.ts index 423f17c58bed..fde74bab81d2 100644 --- a/apps/ledger-live-desktop/src/renderer/components/PerCurrencySelectAccount/state.ts +++ b/apps/ledger-live-desktop/src/renderer/components/PerCurrencySelectAccount/state.ts @@ -14,11 +14,13 @@ export function getAccountTuplesForCurrency( ): AccountTuple[] { if (currency.type === "TokenCurrency") { return allAccounts - .filter( - account => - account.currency.id === currency.parentCurrency.id && - (accountIds ? accountIds.has(account.id) : true), - ) + .filter(account => { + // not checking subAccounts against accountIds for TokenCurrency + // because the wallet-api is not able to setup empty accounts + // for all parentAccounts and currencies we support + // and we would lose the empty token accounts in the drawer + return account.currency.id === currency.parentCurrency.id; + }) .map(account => ({ account, subAccount: diff --git a/apps/ledger-live-desktop/src/renderer/drawers/DataSelector/SelectAccountAndCurrencyDrawer.tsx b/apps/ledger-live-desktop/src/renderer/drawers/DataSelector/SelectAccountAndCurrencyDrawer.tsx index a10ad8a540e4..620f71c60f40 100644 --- a/apps/ledger-live-desktop/src/renderer/drawers/DataSelector/SelectAccountAndCurrencyDrawer.tsx +++ b/apps/ledger-live-desktop/src/renderer/drawers/DataSelector/SelectAccountAndCurrencyDrawer.tsx @@ -95,7 +95,13 @@ function SelectAccountAndCurrencyDrawer(props: SelectAccountAndCurrencyDrawerPro [onAccountSelected, props, onClose, accounts$], ); if (currencies.length === 1) { - return ; + return ( + + ); } return ( diff --git a/apps/ledger-live-mobile/src/reducers/accounts.ts b/apps/ledger-live-mobile/src/reducers/accounts.ts index f92b87ebbdff..fadae0a3373f 100644 --- a/apps/ledger-live-mobile/src/reducers/accounts.ts +++ b/apps/ledger-live-mobile/src/reducers/accounts.ts @@ -184,11 +184,13 @@ export const accountsTuplesByCurrencySelector = createSelector( (accounts, currency, accountIds): { account: AccountLike; subAccount: SubAccount | null }[] => { if (currency.type === "TokenCurrency") { return accounts - .filter( - account => - account.currency.id === currency.parentCurrency.id && - (accountIds ? accountIds.has(account.id) : true), - ) + .filter(account => { + // not checking subAccounts against accountIds for TokenCurrency + // because the wallet-api is not able to setup empty accounts + // for all parentAccounts and currencies we support + // and we would lose the empty token accounts in the select account + return account.currency.id === currency.parentCurrency.id; + }) .map(account => ({ account, subAccount: