From 1112277cd628378f8b0e659067456677ec9a45ac Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Fri, 26 Jul 2019 10:35:21 -0300 Subject: Remove `seedWords` completely from metamask state (#6920) `seedWords` used to be stored on the metamask state temporarily at certain points. This hasn't been the case since #5994, but references to this state remained. All of the logic remained for correctly updating these `seedWords`, handling them during navigation, and scrubbing them from the state. However the state was never updated in practice. The `seedWords` are still returned by `verifySeedPhrase`, and they're still stored in component state in a few places. But they aren't ever set in the Redux metadata state or the Preferences controller. All references to this state have been removed, along with any logic for interacting with this state. A few unused actions were removed as well. --- ui/app/store/actions.js | 99 +------------------------------------------------ 1 file changed, 2 insertions(+), 97 deletions(-) (limited to 'ui/app/store/actions.js') diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 942a518db..f02cdd0fa 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -67,7 +67,6 @@ var actions = { markPasswordForgotten, unMarkPasswordForgotten, SHOW_INIT_MENU: 'SHOW_INIT_MENU', - SHOW_NEW_VAULT_SEED: 'SHOW_NEW_VAULT_SEED', SHOW_INFO_PAGE: 'SHOW_INFO_PAGE', SHOW_IMPORT_PAGE: 'SHOW_IMPORT_PAGE', SHOW_NEW_ACCOUNT_PAGE: 'SHOW_NEW_ACCOUNT_PAGE', @@ -81,7 +80,6 @@ var actions = { showImportPage, showNewAccountPage, setNewAccountForm, - createNewVaultAndKeychain: createNewVaultAndKeychain, createNewVaultAndRestore: createNewVaultAndRestore, createNewVaultInProgress: createNewVaultInProgress, createNewVaultAndGetSeedPhrase, @@ -97,14 +95,12 @@ var actions = { navigateToNewAccountScreen, resetAccount, removeAccount, - showNewVaultSeed: showNewVaultSeed, showInfoPage: showInfoPage, CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN', closeWelcomeScreen, // seed recovery actions REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION', revealSeedConfirmation: revealSeedConfirmation, - requestRevealSeed: requestRevealSeed, requestRevealSeedWords, // unlock screen UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS', @@ -217,7 +213,6 @@ var actions = { gasLoadingStarted, gasLoadingFinished, // app messages - confirmSeedWords: confirmSeedWords, showAccountDetail: showAccountDetail, BACK_TO_ACCOUNT_DETAIL: 'BACK_TO_ACCOUNT_DETAIL', backToAccountDetail: backToAccountDetail, @@ -444,44 +439,18 @@ function transitionBackward () { } } -function confirmSeedWords () { - return dispatch => { - dispatch(actions.showLoadingIndication()) - log.debug(`background.clearSeedWordCache`) - return new Promise((resolve, reject) => { - background.clearSeedWordCache((err, account) => { - dispatch(actions.hideLoadingIndication()) - if (err) { - dispatch(actions.displayWarning(err.message)) - return reject(err) - } - - log.info('Seed word cache cleared. ' + account) - dispatch(actions.showAccountsPage()) - resolve(account) - }) - }) - } -} - function createNewVaultAndRestore (password, seed) { return (dispatch) => { dispatch(actions.showLoadingIndication()) log.debug(`background.createNewVaultAndRestore`) return new Promise((resolve, reject) => { - background.clearSeedWordCache((err) => { + background.createNewVaultAndRestore(password, seed, (err) => { if (err) { return reject(err) } - background.createNewVaultAndRestore(password, seed, (err) => { - if (err) { - return reject(err) - } - - resolve() - }) + resolve() }) }) .then(() => dispatch(actions.unMarkPasswordForgotten())) @@ -497,36 +466,6 @@ function createNewVaultAndRestore (password, seed) { } } -function createNewVaultAndKeychain (password) { - return dispatch => { - dispatch(actions.showLoadingIndication()) - log.debug(`background.createNewVaultAndKeychain`) - - return new Promise((resolve, reject) => { - background.createNewVaultAndKeychain(password, err => { - if (err) { - dispatch(actions.displayWarning(err.message)) - return reject(err) - } - - log.debug(`background.placeSeedWords`) - - background.placeSeedWords((err) => { - if (err) { - dispatch(actions.displayWarning(err.message)) - return reject(err) - } - - resolve() - }) - }) - }) - .then(() => forceUpdateMetamaskState(dispatch)) - .then(() => dispatch(actions.hideLoadingIndication())) - .catch(() => dispatch(actions.hideLoadingIndication())) - } -} - function createNewVaultAndGetSeedPhrase (password) { return async dispatch => { dispatch(actions.showLoadingIndication()) @@ -616,33 +555,6 @@ function verifySeedPhrase () { }) } -function requestRevealSeed (password) { - return dispatch => { - dispatch(actions.showLoadingIndication()) - log.debug(`background.submitPassword`) - return new Promise((resolve, reject) => { - background.submitPassword(password, err => { - if (err) { - dispatch(actions.displayWarning(err.message)) - return reject(err) - } - - log.debug(`background.placeSeedWords`) - background.placeSeedWords((err, result) => { - if (err) { - dispatch(actions.displayWarning(err.message)) - return reject(err) - } - - dispatch(actions.showNewVaultSeed(result)) - dispatch(actions.hideLoadingIndication()) - resolve() - }) - }) - }) - } -} - function requestRevealSeedWords (password) { return async dispatch => { dispatch(actions.showLoadingIndication()) @@ -1531,13 +1443,6 @@ function createNewVaultInProgress () { } } -function showNewVaultSeed (seed) { - return { - type: actions.SHOW_NEW_VAULT_SEED, - value: seed, - } -} - function closeWelcomeScreen () { return { type: actions.CLOSE_WELCOME_SCREEN, -- cgit