Skip to content

Commit

Permalink
fix(wallet-utils): Fix getNetworkAccountFeatures fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemonexe authored and tomasklim committed Sep 26, 2024
1 parent e25f9c2 commit cdde4fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions suite-common/wallet-utils/src/__tests__/accountUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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', () => {
Expand Down
4 changes: 1 addition & 3 deletions suite-common/wallet-utils/src/accountUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1065,9 +1065,7 @@ export const getNetworkAccountFeatures = ({
}: Pick<Account, 'symbol' | 'accountType'>): NetworkFeature[] => {
const matchedNetwork = getNetwork(symbol);

return accountType === 'normal'
? matchedNetwork.features
: matchedNetwork.accountTypes[accountType]?.features ?? [];
return matchedNetwork.accountTypes[accountType]?.features ?? matchedNetwork.features;
};

export const hasNetworkFeatures = (
Expand Down

0 comments on commit cdde4fd

Please sign in to comment.