Skip to content

Commit

Permalink
fix(wallet-api): request account was not showing token accounts in so…
Browse files Browse the repository at this point in the history
…me 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
  • Loading branch information
Justkant committed Sep 19, 2023
1 parent 4a57e0b commit 7cb2d03
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .changeset/neat-insects-sin.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ function SelectAccountAndCurrencyDrawer(props: SelectAccountAndCurrencyDrawerPro
[onAccountSelected, props, onClose, accounts$],
);
if (currencies.length === 1) {
return <SelectAccountDrawer currency={currencies[0]} onAccountSelected={onAccountSelected} />;
return (
<SelectAccountDrawer
currency={currencies[0]}
onAccountSelected={onAccountSelected}
accounts$={accounts$}
/>
);
}
return (
<SelectAccountAndCurrencyDrawerContainer>
Expand Down
12 changes: 7 additions & 5 deletions apps/ledger-live-mobile/src/reducers/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7cb2d03

Please sign in to comment.