From 3f232b62cd7b4fb5bbcba87ed2e33b620a1ea098 Mon Sep 17 00:00:00 2001 From: Albina Nikiforova Date: Wed, 8 Jan 2025 14:55:13 +0100 Subject: [PATCH] fix(suite): swap accounts sort --- .../__tests__/filterReceiveAccounts.test.ts | 6 +++--- .../wallet-utils/src/filterReceiveAccounts.ts | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts b/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts index 2d4ecb79c65..f06b371b254 100644 --- a/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts +++ b/suite-common/wallet-utils/src/__tests__/filterReceiveAccounts.test.ts @@ -78,9 +78,9 @@ describe('filter receive accounts', () => { it('returns all accounts when debug mode is on', () => { const filteredAccounts = [ - getWalletAccount({ symbol: 'eth', accountType: 'legacy' }), getWalletAccount({ symbol: 'eth', accountType: 'normal' }), getWalletAccount({ symbol: 'eth', accountType: 'ledger' }), + getWalletAccount({ symbol: 'eth', accountType: 'legacy' }), ]; expect(runFilterReceiveAccouns({})).toEqual(filteredAccounts); }); @@ -99,10 +99,10 @@ describe('filter receive accounts', () => { it('excludes coinjoin accounts for BTC network (also tests isAnotherNetwork and isCoinjoinAccount methods)', () => { const filteredAccounts = [ + getWalletAccount({ symbol: 'btc', accountType: 'ledger' }), getWalletAccount({ symbol: 'btc', accountType: 'taproot' }), - getWalletAccount({ symbol: 'btc', accountType: 'legacy' }), getWalletAccount({ symbol: 'btc', accountType: 'segwit' }), - getWalletAccount({ symbol: 'btc', accountType: 'ledger' }), + getWalletAccount({ symbol: 'btc', accountType: 'legacy' }), ]; expect(runFilterReceiveAccouns({ symbol: 'btc' })).toEqual(filteredAccounts); diff --git a/suite-common/wallet-utils/src/filterReceiveAccounts.ts b/suite-common/wallet-utils/src/filterReceiveAccounts.ts index 54960b50599..8ac59e60b49 100644 --- a/suite-common/wallet-utils/src/filterReceiveAccounts.ts +++ b/suite-common/wallet-utils/src/filterReceiveAccounts.ts @@ -2,6 +2,8 @@ import { AccountType, NetworkSymbol, getNetwork } from '@suite-common/wallet-con import { Account } from '@suite-common/wallet-types'; import { StaticSessionId } from '@trezor/connect'; +import { sortByCoin } from './accountUtils'; + export const isDebugOnlyAccountType = ( accountType: AccountType, symbol?: NetworkSymbol, @@ -38,14 +40,12 @@ export const filterReceiveAccounts = ({ account.accountType === 'normal' && account.index === 0; const isCoinjoinAccount = (account: Account) => account.accountType === 'coinjoin'; - return accounts.filter( - account => - isSameDevice(account) && - isSameNetwork(account) && - !isCoinjoinAccount(account) && - shouldDisplayDebugOnly(account) && - (isNotEmptyAccount(account) || - isVisibleAccount(account) || - isFirstNormalAccount(account)), - ); + const isRelevantAccount = (account: Account) => + isSameDevice(account) && + isSameNetwork(account) && + !isCoinjoinAccount(account) && + shouldDisplayDebugOnly(account) && + (isNotEmptyAccount(account) || isVisibleAccount(account) || isFirstNormalAccount(account)); + + return sortByCoin(accounts.filter(isRelevantAccount)); };