From cdde4fd6824dbbd73f2aa67756ebcc274dba8975 Mon Sep 17 00:00:00 2001 From: Jiri Zbytovsky Date: Thu, 26 Sep 2024 12:53:24 +0200 Subject: [PATCH] fix(wallet-utils): Fix getNetworkAccountFeatures fallback --- .../wallet-utils/src/__tests__/accountUtils.test.ts | 6 +++--- suite-common/wallet-utils/src/accountUtils.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/suite-common/wallet-utils/src/__tests__/accountUtils.test.ts b/suite-common/wallet-utils/src/__tests__/accountUtils.test.ts index 1544256b7f6..d0cf056f266 100644 --- a/suite-common/wallet-utils/src/__tests__/accountUtils.test.ts +++ b/suite-common/wallet-utils/src/__tests__/accountUtils.test.ts @@ -217,11 +217,9 @@ describe('account utils', () => { it('getNetworkAccountFeatures', () => { const btcAcc = getWalletAccount({ symbol: 'btc' }); - const btcTaprootAcc = getWalletAccount({ symbol: 'btc', accountType: 'taproot' }); - + const btcLegacy = getWalletAccount({ symbol: 'btc', accountType: 'legacy' }); const ethAcc = getWalletAccount(); - const coinjoinAcc = getWalletAccount({ symbol: 'regtest', accountType: 'coinjoin' }); expect(getNetworkAccountFeatures(btcAcc)).toEqual(['rbf', 'sign-verify', 'amount-unit']); @@ -235,6 +233,8 @@ describe('account utils', () => { 'staking', ]); expect(getNetworkAccountFeatures(coinjoinAcc)).toEqual(['rbf', 'amount-unit']); + // when account does not have features defined, take them from root network object + expect(getNetworkAccountFeatures(btcLegacy)).toEqual(getNetworkAccountFeatures(btcAcc)); }); it('hasNetworkFeatures', () => { diff --git a/suite-common/wallet-utils/src/accountUtils.ts b/suite-common/wallet-utils/src/accountUtils.ts index d13fdac5944..530f543b452 100644 --- a/suite-common/wallet-utils/src/accountUtils.ts +++ b/suite-common/wallet-utils/src/accountUtils.ts @@ -1065,9 +1065,7 @@ export const getNetworkAccountFeatures = ({ }: Pick): NetworkFeature[] => { const matchedNetwork = getNetwork(symbol); - return accountType === 'normal' - ? matchedNetwork.features - : matchedNetwork.accountTypes[accountType]?.features ?? []; + return matchedNetwork.accountTypes[accountType]?.features ?? matchedNetwork.features; }; export const hasNetworkFeatures = (