Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure SRP backup reminder only displays when on HDKey account #29857

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2837,16 +2837,21 @@ export function getShouldShowSeedPhraseReminder(state) {
const { tokens, seedPhraseBackedUp, dismissSeedBackUpReminder } =
state.metamask;

const currentKeyring = getCurrentKeyring(state);
const isNativeAccount = currentKeyring.type === KeyringType.hdKeyTree;

// if there is no account, we don't need to show the seed phrase reminder
const accountBalance = getSelectedInternalAccount(state)
? getCurrentEthBalance(state)
: 0;

return (
const showMessage =
seedPhraseBackedUp === false &&
(parseInt(accountBalance, 16) > 0 || tokens.length > 0) &&
dismissSeedBackUpReminder === false
);
dismissSeedBackUpReminder === false &&
isNativeAccount;

return showMessage;
}

export function getUnconnectedAccounts(state, activeTab) {
Expand Down
40 changes: 40 additions & 0 deletions ui/selectors/selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,46 @@ describe('Selectors', () => {
});
});

describe('#getShouldShowSeedPhraseReminder', () => {
it('returns true if the account is a native account', () => {
const state = {
...mockState,
metamask: {
...mockState.metamask,
seedPhraseBackedUp: false,
},
};
expect(selectors.getShouldShowSeedPhraseReminder(state)).toBe(true);
});

it('returns false if the account is not native', () => {
const state = {
...mockState,
metamask: {
...mockState.metamask,
seedPhraseBackedUp: false,
internalAccounts: {
...mockState.metamask.internalAccounts,
accounts: {
...mockState.metamask.internalAccounts.accounts,
'cf8dace4-9439-4bd4-b3a8-88c821c8fcb3': {
...mockState.metamask.internalAccounts.accounts[
'cf8dace4-9439-4bd4-b3a8-88c821c8fcb3'
],
metadata: {
keyring: {
type: KeyringType.imported,
},
},
},
},
},
},
};
expect(selectors.getShouldShowSeedPhraseReminder(state)).toBe(false);
});
});

describe('#getNetworkToAutomaticallySwitchTo', () => {
const SELECTED_ORIGIN = 'https://portfolio.metamask.io';
const SELECTED_ORIGIN_NETWORK_ID = NETWORK_TYPES.LINEA_SEPOLIA;
Expand Down
Loading