Skip to content

Commit b32986d

Browse files
authored
fix: Ensure SRP backup reminder only displays when on HDKey account (#29857)
## **Description** Ensures that the SRP backup reminder only displays if the user is on HD keyring, so will not display if the user is on hardware wallet or imported wallet [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/29857?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. Create a new wallet and do _NOT_ backup SRP 2. Finish onboarding, see SRP reminder 3. Import a new account, do _NOT_ see SRP reminder 4. Add hardware wallet account, do _NOT_ see SRP reminder ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent bdd01f0 commit b32986d

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

ui/selectors/selectors.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -2908,16 +2908,22 @@ export function getShouldShowSeedPhraseReminder(state) {
29082908
const { tokens, seedPhraseBackedUp, dismissSeedBackUpReminder } =
29092909
state.metamask;
29102910

2911+
const currentKeyring = getCurrentKeyring(state);
2912+
const isNativeAccount =
2913+
currentKeyring?.type && currentKeyring.type === KeyringType.hdKeyTree;
2914+
29112915
// if there is no account, we don't need to show the seed phrase reminder
29122916
const accountBalance = getSelectedInternalAccount(state)
29132917
? getCurrentEthBalance(state)
29142918
: 0;
29152919

2916-
return (
2920+
const showMessage =
29172921
seedPhraseBackedUp === false &&
29182922
(parseInt(accountBalance, 16) > 0 || tokens.length > 0) &&
2919-
dismissSeedBackUpReminder === false
2920-
);
2923+
dismissSeedBackUpReminder === false &&
2924+
isNativeAccount;
2925+
2926+
return showMessage;
29212927
}
29222928

29232929
export function getUnconnectedAccounts(state, activeTab) {

ui/selectors/selectors.test.js

+40
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,46 @@ describe('Selectors', () => {
296296
});
297297
});
298298

299+
describe('#getShouldShowSeedPhraseReminder', () => {
300+
it('returns true if the account is a native account', () => {
301+
const state = {
302+
...mockState,
303+
metamask: {
304+
...mockState.metamask,
305+
seedPhraseBackedUp: false,
306+
},
307+
};
308+
expect(selectors.getShouldShowSeedPhraseReminder(state)).toBe(true);
309+
});
310+
311+
it('returns false if the account is not native', () => {
312+
const state = {
313+
...mockState,
314+
metamask: {
315+
...mockState.metamask,
316+
seedPhraseBackedUp: false,
317+
internalAccounts: {
318+
...mockState.metamask.internalAccounts,
319+
accounts: {
320+
...mockState.metamask.internalAccounts.accounts,
321+
'cf8dace4-9439-4bd4-b3a8-88c821c8fcb3': {
322+
...mockState.metamask.internalAccounts.accounts[
323+
'cf8dace4-9439-4bd4-b3a8-88c821c8fcb3'
324+
],
325+
metadata: {
326+
keyring: {
327+
type: KeyringType.imported,
328+
},
329+
},
330+
},
331+
},
332+
},
333+
},
334+
};
335+
expect(selectors.getShouldShowSeedPhraseReminder(state)).toBe(false);
336+
});
337+
});
338+
299339
describe('#getNetworkToAutomaticallySwitchTo', () => {
300340
const SELECTED_ORIGIN = 'https://portfolio.metamask.io';
301341
const SELECTED_ORIGIN_NETWORK_ID = NETWORK_TYPES.LINEA_SEPOLIA;

0 commit comments

Comments
 (0)