diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index ce9df0e5c..0661b338c 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -556,6 +556,12 @@ "dismiss": { "message": "Dismiss" }, + "dismissReminderDescriptionField": { + "message": "Turn this on to dismiss the recovery phrase backup reminder message. We highly recommend that you back up your seed phrase to avoid loss of funds" + }, + "dismissReminderField": { + "message": "Dismiss recovery phrase backup reminder" + }, "done": { "message": "Done" }, diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index e7b532ba8..19aef453e 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -43,6 +43,7 @@ export default class PreferencesController { useBlockie: false, useNonceField: false, usePhishDetect: true, + dismissSeedBackUpReminder: false, // WARNING: Do not use feature flags for security-sensitive things. // Feature flag toggling is available in the global namespace @@ -669,7 +670,7 @@ export default class PreferencesController { /** * A setter for the `useLedgerLive` property - * @param {bool} domain - Value for ledger live support + * @param {bool} useLedgerLive - Value for ledger live support * @returns {Promise} A promise of the update to useLedgerLive */ async setLedgerLivePreference(useLedgerLive) { @@ -685,6 +686,17 @@ export default class PreferencesController { return this.store.getState().useLedgerLive; } + /** + * A setter for the user preference to dismiss the seed phrase backup reminder + * @param {bool} dismissBackupReminder- User preference for dismissing the back up reminder + * @returns {void} + */ + async setDismissSeedBackUpReminder(dismissSeedBackUpReminder) { + await this.store.updateState({ + dismissSeedBackUpReminder, + }); + } + // // PRIVATE METHODS // diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 7f928d8cc..2dc90970c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -735,6 +735,10 @@ export default class MetamaskController extends EventEmitter { preferencesController.addKnownMethodData, preferencesController, ), + setDismissSeedBackUpReminder: nodeify( + this.preferencesController.setDismissSeedBackUpReminder, + this.preferencesController, + ), // AddressController setAddressBook: nodeify( diff --git a/ui/pages/home/home.container.js b/ui/pages/home/home.container.js index c9e0e68a6..f5ff5a966 100644 --- a/ui/pages/home/home.container.js +++ b/ui/pages/home/home.container.js @@ -52,6 +52,7 @@ const mapStateToProps = (state) => { connectedStatusPopoverHasBeenShown, defaultHomeActiveTabName, swapsState, + dismissSeedBackUpReminder, } = metamask; const accountBalance = getCurrentEthBalance(state); const { forgottenPassword, threeBoxLastUpdated } = appState; @@ -84,7 +85,8 @@ const mapStateToProps = (state) => { unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state), shouldShowSeedPhraseReminder: seedPhraseBackedUp === false && - (parseInt(accountBalance, 16) > 0 || tokens.length > 0), + (parseInt(accountBalance, 16) > 0 || tokens.length > 0) && + dismissSeedBackUpReminder === false, isPopup, isNotification, threeBoxSynced, diff --git a/ui/pages/settings/advanced-tab/advanced-tab.component.js b/ui/pages/settings/advanced-tab/advanced-tab.component.js index cfda8a786..09e70a303 100644 --- a/ui/pages/settings/advanced-tab/advanced-tab.component.js +++ b/ui/pages/settings/advanced-tab/advanced-tab.component.js @@ -38,6 +38,8 @@ export default class AdvancedTab extends PureComponent { ipfsGateway: PropTypes.string.isRequired, useLedgerLive: PropTypes.bool.isRequired, setLedgerLivePreference: PropTypes.func.isRequired, + setDismissSeedBackUpReminder: PropTypes.func.isRequired, + dismissSeedBackUpReminder: PropTypes.bool.isRequired, }; state = { @@ -258,7 +260,7 @@ export default class AdvancedTab extends PureComponent { data-testid="advanced-setting-custom-nonce" >
- {this.context.t('nonceField')} + {t('nonceField')}
{t('nonceFieldDescription')}
@@ -494,6 +496,38 @@ export default class AdvancedTab extends PureComponent { ); } + renderDismissSeedBackupReminderControl() { + const { t } = this.context; + const { + dismissSeedBackUpReminder, + setDismissSeedBackUpReminder, + } = this.props; + + return ( +
+
+ {t('dismissReminderField')} +
+ {t('dismissReminderDescriptionField')} +
+
+
+
+ setDismissSeedBackUpReminder(!value)} + offLabel={t('off')} + onLabel={t('on')} + /> +
+
+
+ ); + } + render() { const { warning } = this.props; @@ -511,6 +545,7 @@ export default class AdvancedTab extends PureComponent { {this.renderThreeBoxControl()} {this.renderIpfsGatewayControl()} {this.renderLedgerLiveControl()} + {this.renderDismissSeedBackupReminderControl()}
); } diff --git a/ui/pages/settings/advanced-tab/advanced-tab.component.test.js b/ui/pages/settings/advanced-tab/advanced-tab.component.test.js index b73b90212..2cf193f52 100644 --- a/ui/pages/settings/advanced-tab/advanced-tab.component.test.js +++ b/ui/pages/settings/advanced-tab/advanced-tab.component.test.js @@ -23,7 +23,7 @@ describe('AdvancedTab Component', () => { }, ); - expect(root.find('.settings-page__content-row')).toHaveLength(11); + expect(root.find('.settings-page__content-row')).toHaveLength(12); }); it('should update autoLockTimeLimit', () => { diff --git a/ui/pages/settings/advanced-tab/advanced-tab.container.js b/ui/pages/settings/advanced-tab/advanced-tab.container.js index 2fe9eaf39..3ea88dc8d 100644 --- a/ui/pages/settings/advanced-tab/advanced-tab.container.js +++ b/ui/pages/settings/advanced-tab/advanced-tab.container.js @@ -12,6 +12,7 @@ import { setUseNonceField, setIpfsGateway, setLedgerLivePreference, + setDismissSeedBackUpReminder, } from '../../../store/actions'; import { getPreferences } from '../../../selectors'; import AdvancedTab from './advanced-tab.component'; @@ -28,6 +29,7 @@ export const mapStateToProps = (state) => { useNonceField, ipfsGateway, useLedgerLive, + dismissSeedBackUpReminder, } = metamask; const { showFiatInTestnets, autoLockTimeLimit } = getPreferences(state); @@ -42,6 +44,7 @@ export const mapStateToProps = (state) => { useNonceField, ipfsGateway, useLedgerLive, + dismissSeedBackUpReminder, }; }; @@ -71,8 +74,12 @@ export const mapDispatchToProps = (dispatch) => { setIpfsGateway: (value) => { return dispatch(setIpfsGateway(value)); }, - setLedgerLivePreference: (value) => - dispatch(setLedgerLivePreference(value)), + setLedgerLivePreference: (value) => { + return dispatch(setLedgerLivePreference(value)); + }, + setDismissSeedBackUpReminder: (value) => { + return dispatch(setDismissSeedBackUpReminder(value)); + }, }; }; diff --git a/ui/store/actionConstants.js b/ui/store/actionConstants.js index 8613318c8..362ce905f 100644 --- a/ui/store/actionConstants.js +++ b/ui/store/actionConstants.js @@ -72,6 +72,7 @@ export const BUY_ETH = 'BUY_ETH'; export const TOGGLE_ACCOUNT_MENU = 'TOGGLE_ACCOUNT_MENU'; +// preferences export const SET_USE_BLOCKIE = 'SET_USE_BLOCKIE'; export const SET_USE_NONCEFIELD = 'SET_USE_NONCEFIELD'; export const UPDATE_CUSTOM_NONCE = 'UPDATE_CUSTOM_NONCE'; diff --git a/ui/store/actions.js b/ui/store/actions.js index 141c14537..1c23e2ac0 100644 --- a/ui/store/actions.js +++ b/ui/store/actions.js @@ -2561,6 +2561,14 @@ export function setLastActiveTime() { }; } +export function setDismissSeedBackUpReminder(value) { + return async (dispatch) => { + dispatch(showLoadingIndication()); + await promisifiedBackground.setDismissSeedBackUpReminder(value); + dispatch(hideLoadingIndication()); + }; +} + export function setConnectedStatusPopoverHasBeenShown() { return () => { background.setConnectedStatusPopoverHasBeenShown((err) => {