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. --- app/scripts/background.js | 1 - app/scripts/controllers/preferences.js | 9 - app/scripts/metamask-controller.js | 34 --- test/unit/actions/tx_test.js | 1 - .../app/controllers/metamask-controller-test.js | 32 --- .../app/controllers/preferences-controller-test.js | 15 -- test/unit/ui/app/actions.spec.js | 243 +-------------------- test/unit/ui/app/reducers/app.spec.js | 13 -- test/unit/ui/app/reducers/metamask.spec.js | 36 --- ui/app/ducks/app/app.js | 22 +- ui/app/ducks/index.js | 9 +- ui/app/ducks/metamask/metamask.js | 17 -- ui/app/pages/home/home.component.js | 8 - ui/app/pages/home/home.container.js | 2 - ui/app/pages/routes/index.js | 6 +- ui/app/store/actions.js | 99 +-------- 16 files changed, 8 insertions(+), 539 deletions(-) diff --git a/app/scripts/background.js b/app/scripts/background.js index 7bedfcc19..8e65bd5a4 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -116,7 +116,6 @@ setupMetamaskMeshMetrics() * @property {boolean} useBlockie - Indicates preferred user identicon format. True for blockie, false for Jazzicon. * @property {Object} featureFlags - An object for optional feature flags. * @property {string} networkEndpointType - TODO: Document - * @property {boolean} isRevealingSeedWords - True if seed words are currently being recovered, and should be shown to user. * @property {boolean} welcomeScreen - True if welcome screen should be shown. * @property {string} currentLocale - A locale string matching the user's preferred display language. * @property {Object} provider - The current selected network provider. diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 86c9517f5..4197781d2 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -49,7 +49,6 @@ class PreferencesController { currentLocale: opts.initLangCode, identities: {}, lostIdentities: {}, - seedWords: null, forgottenPassword: false, preferences: { useNativeCurrencyAsPrimaryCurrency: true, @@ -79,14 +78,6 @@ class PreferencesController { this.store.updateState({ forgottenPassword }) } - /** - * Sets the {@code seedWords} seed words - * @param {string|null} seedWords the seed words - */ - setSeedWords (seedWords) { - this.store.updateState({ seedWords }) - } - /** * Setter for the `useBlockie` property * diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 17d38d43c..84a25b008 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -420,9 +420,7 @@ module.exports = class MetamaskController extends EventEmitter { // primary HD keyring management addNewAccount: nodeify(this.addNewAccount, this), - placeSeedWords: this.placeSeedWords.bind(this), verifySeedPhrase: nodeify(this.verifySeedPhrase, this), - clearSeedWordCache: this.clearSeedWordCache.bind(this), resetAccount: nodeify(this.resetAccount, this), removeAccount: nodeify(this.removeAccount, this), importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this), @@ -844,26 +842,6 @@ module.exports = class MetamaskController extends EventEmitter { return {...keyState, identities} } - /** - * Adds the current vault's seed words to the UI's state tree. - * - * Used when creating a first vault, to allow confirmation. - * Also used when revealing the seed words in the confirmation view. - * - * @param {Function} cb - A callback called on completion. - */ - placeSeedWords (cb) { - - this.verifySeedPhrase() - .then((seedWords) => { - this.preferencesController.setSeedWords(seedWords) - return cb(null, seedWords) - }) - .catch((err) => { - return cb(err) - }) - } - /** * Verifies the validity of the current vault's seed phrase. * @@ -897,18 +875,6 @@ module.exports = class MetamaskController extends EventEmitter { } } - /** - * Remove the primary account seed phrase from the UI's state tree. - * - * The seed phrase remains available in the background process. - * - * @param {function} cb Callback function called with the current address. - */ - clearSeedWordCache (cb) { - this.preferencesController.setSeedWords(null) - cb(null, this.preferencesController.getSelectedAddress()) - } - /** * Clears the transaction history, to allow users to force-reset their nonces. * Mostly used in development environments, when networks are restarted with diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js index f2f8f1d1c..66378b594 100644 --- a/test/unit/actions/tx_test.js +++ b/test/unit/actions/tx_test.js @@ -35,7 +35,6 @@ describe('tx confirmation screen', function () { actions._setBackgroundConnection({ approveTransaction (_, cb) { cb('An error!') }, cancelTransaction (_, cb) { cb() }, - clearSeedWordCache (cb) { cb() }, getState (cb) { cb() }, }) done() diff --git a/test/unit/app/controllers/metamask-controller-test.js b/test/unit/app/controllers/metamask-controller-test.js index e8e407a7f..effd7c0ce 100644 --- a/test/unit/app/controllers/metamask-controller-test.js +++ b/test/unit/app/controllers/metamask-controller-test.js @@ -497,8 +497,6 @@ describe('MetaMaskController', function () { }) describe('#verifyseedPhrase', function () { - let seedPhrase, getConfigSeed - it('errors when no keying is provided', async function () { try { await metamaskController.verifySeedPhrase() @@ -509,21 +507,6 @@ describe('MetaMaskController', function () { beforeEach(async function () { await metamaskController.createNewVaultAndKeychain('password') - seedPhrase = await metamaskController.verifySeedPhrase() - }) - - it('#placeSeedWords should match the initially created vault seed', function () { - - metamaskController.placeSeedWords((err, result) => { - if (err) { - console.log(err) - } else { - getConfigSeed = metamaskController.configManager.getSeedWords() - assert.equal(result, seedPhrase) - assert.equal(result, getConfigSeed) - } - }) - assert.equal(getConfigSeed, undefined) }) it('#addNewAccount', async function () { @@ -589,21 +572,6 @@ describe('MetaMaskController', function () { }) }) - describe('#clearSeedWordCache', function () { - it('should set seed words to null', function (done) { - sandbox.stub(metamaskController.preferencesController, 'setSeedWords') - metamaskController.clearSeedWordCache((err) => { - if (err) { - done(err) - } - - assert.ok(metamaskController.preferencesController.setSeedWords.calledOnce) - assert.deepEqual(metamaskController.preferencesController.setSeedWords.args, [[null]]) - done() - }) - }) - }) - describe('#setCurrentLocale', function () { it('checks the default currentLocale', function () { diff --git a/test/unit/app/controllers/preferences-controller-test.js b/test/unit/app/controllers/preferences-controller-test.js index 81b152f3d..7e047a2a8 100644 --- a/test/unit/app/controllers/preferences-controller-test.js +++ b/test/unit/app/controllers/preferences-controller-test.js @@ -496,21 +496,6 @@ describe('preferences controller', function () { }) }) - describe('setSeedWords', function () { - it('should default to null', function () { - const state = preferencesController.store.getState() - assert.equal(state.seedWords, null) - }) - - it('should set the seedWords property in state', function () { - assert.equal(preferencesController.store.getState().seedWords, null) - - preferencesController.setSeedWords('foo bar baz') - - assert.equal(preferencesController.store.getState().seedWords, 'foo bar baz') - }) - }) - describe('#updateRpc', function () { it('should update the rpcDetails properly', () => { preferencesController.store.updateState({frequentRpcListDetail: [{}, { rpcUrl: 'test' }, {}]}) diff --git a/test/unit/ui/app/actions.spec.js b/test/unit/ui/app/actions.spec.js index 34dd6a39b..392321481 100644 --- a/test/unit/ui/app/actions.spec.js +++ b/test/unit/ui/app/actions.spec.js @@ -134,95 +134,25 @@ describe('Actions', () => { }) }) - describe('#confirmSeedWords', () => { - - let clearSeedWordCacheSpy - - afterEach(() => { - clearSeedWordCacheSpy.restore() - }) - - it('shows account page after clearing seed word cache', () => { - - const store = mockStore({}) - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'HIDE_LOADING_INDICATION' }, - { type: 'SHOW_ACCOUNTS_PAGE' }, - ] - - clearSeedWordCacheSpy = sinon.spy(background, 'clearSeedWordCache') - - return store.dispatch(actions.confirmSeedWords()) - .then(() => { - assert.equal(clearSeedWordCacheSpy.callCount, 1) - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - - it('errors in callback will display warning', () => { - const store = mockStore({}) - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'HIDE_LOADING_INDICATION' }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - clearSeedWordCacheSpy = sinon.stub(background, 'clearSeedWordCache') - - clearSeedWordCacheSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.confirmSeedWords()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#createNewVaultAndRestore', () => { - let createNewVaultAndRestoreSpy, clearSeedWordCacheSpy + let createNewVaultAndRestoreSpy afterEach(() => { createNewVaultAndRestoreSpy.restore() }) - it('clears seed words and restores new vault', () => { + it('restores new vault', () => { const store = mockStore({}) createNewVaultAndRestoreSpy = sinon.spy(background, 'createNewVaultAndRestore') - clearSeedWordCacheSpy = sinon.spy(background, 'clearSeedWordCache') return store.dispatch(actions.createNewVaultAndRestore()) .catch(() => { - assert(clearSeedWordCacheSpy.calledOnce) assert(createNewVaultAndRestoreSpy.calledOnce) }) }) - it('errors when callback in clearSeedWordCache throws', () => { - const store = mockStore() - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - clearSeedWordCacheSpy = sinon.stub(background, 'clearSeedWordCache') - clearSeedWordCacheSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndRestore()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - it('errors when callback in createNewVaultAndRestore throws', () => { const store = mockStore({}) @@ -246,113 +176,6 @@ describe('Actions', () => { }) }) - describe('#createNewVaultAndKeychain', () => { - - let createNewVaultAndKeychainSpy, placeSeedWordsSpy - - afterEach(() => { - createNewVaultAndKeychainSpy.restore() - placeSeedWordsSpy.restore() - }) - - it('calls createNewVaultAndKeychain and placeSeedWords in background', () => { - - const store = mockStore() - - createNewVaultAndKeychainSpy = sinon.spy(background, 'createNewVaultAndKeychain') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert(createNewVaultAndKeychainSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays error and value when callback errors', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - createNewVaultAndKeychainSpy = sinon.stub(background, 'createNewVaultAndKeychain') - createNewVaultAndKeychainSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - - }) - - it('errors when placeSeedWords throws', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - { type: 'HIDE_LOADING_INDICATION' }, - ] - - placeSeedWordsSpy = sinon.stub(background, 'placeSeedWords') - placeSeedWordsSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.createNewVaultAndKeychain()) - .then(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - - describe('#requestRevealSeed', () => { - - let submitPasswordSpy, placeSeedWordsSpy - - afterEach(() => { - submitPasswordSpy.restore() - }) - - it('calls submitPassword and placeSeedWords from background', () => { - - const store = mockStore() - - submitPasswordSpy = sinon.spy(background, 'submitPassword') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.requestRevealSeed()) - .then(() => { - assert(submitPasswordSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays warning error with value when callback errors', () => { - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#requestRevealSeedWords', () => { let submitPasswordSpy @@ -389,68 +212,6 @@ describe('Actions', () => { }) }) - describe('#requestRevealSeed', () => { - - let submitPasswordSpy, placeSeedWordsSpy - - afterEach(() => { - submitPasswordSpy.restore() - placeSeedWordsSpy.restore() - }) - - it('calls submitPassword and placeSeedWords in background', () => { - - const store = mockStore() - - submitPasswordSpy = sinon.spy(background, 'submitPassword') - placeSeedWordsSpy = sinon.spy(background, 'placeSeedWords') - - return store.dispatch(actions.requestRevealSeed()) - .then(() => { - assert(submitPasswordSpy.calledOnce) - assert(placeSeedWordsSpy.calledOnce) - }) - }) - - it('displays warning error message when submitPassword in background errors', () => { - submitPasswordSpy = sinon.stub(background, 'submitPassword') - submitPasswordSpy.callsFake((_, callback) => { - callback(new Error('error')) - }) - - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - - it('errors when placeSeedWords throw', () => { - placeSeedWordsSpy = sinon.stub(background, 'placeSeedWords') - placeSeedWordsSpy.callsFake((callback) => { - callback(new Error('error')) - }) - - const store = mockStore() - - const expectedActions = [ - { type: 'SHOW_LOADING_INDICATION', value: undefined }, - { type: 'DISPLAY_WARNING', value: 'error' }, - ] - - return store.dispatch(actions.requestRevealSeed()) - .catch(() => { - assert.deepEqual(store.getActions(), expectedActions) - }) - }) - }) - describe('#removeAccount', () => { let removeAccountSpy diff --git a/test/unit/ui/app/reducers/app.spec.js b/test/unit/ui/app/reducers/app.spec.js index 28f5ebb33..6f8dd920c 100644 --- a/test/unit/ui/app/reducers/app.spec.js +++ b/test/unit/ui/app/reducers/app.spec.js @@ -270,18 +270,6 @@ describe('App State', () => { assert.equal(state.isLoading, true) }) - it('shows new vault seed', () => { - const state = reduceApp(metamaskState, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(state.currentView.name, 'createVaultComplete') - assert.equal(state.currentView.seedWords, 'test seed words') - assert.equal(state.transForward, true) - assert.equal(state.isLoading, false) - }) - it('shows new account screen', () => { const state = reduceApp(metamaskState, { type: actions.NEW_ACCOUNT_SCREEN, @@ -437,7 +425,6 @@ describe('App State', () => { }) assert.equal(state.currentView.name, 'accounts') - assert.equal(state.currentView.seedWords, undefined) assert.equal(state.transForward, true) assert.equal(state.isLoading, false) assert.equal(state.warning, null) diff --git a/test/unit/ui/app/reducers/metamask.spec.js b/test/unit/ui/app/reducers/metamask.spec.js index d7876bf39..39caf3e6a 100644 --- a/test/unit/ui/app/reducers/metamask.spec.js +++ b/test/unit/ui/app/reducers/metamask.spec.js @@ -9,32 +9,6 @@ describe('MetaMask Reducers', () => { assert(initState) }) - it('sets revealing seed to true and adds seed words to new state', () => { - const seedWordsState = reduceMetamask({}, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(seedWordsState.seedWords, 'test seed words') - assert.equal(seedWordsState.isRevealingSeedWords, true) - }) - - it('shows account page', () => { - const seedWordsState = { - metamask: { - seedwords: 'test seed words', - isRevealing: true, - }, - } - - const state = reduceMetamask(seedWordsState, { - type: actions.SHOW_ACCOUNTS_PAGE, - }) - - assert.equal(state.seedWords, undefined) - assert.equal(state.isRevealingSeedWords, false) - }) - it('unlocks MetaMask', () => { const state = reduceMetamask({}, { type: actions.UNLOCK_METAMASK, @@ -152,16 +126,6 @@ describe('MetaMask Reducers', () => { }) }) - it('shows new vault seed words and sets isRevealingSeedWords to true', () => { - const showNewVaultSeedState = reduceMetamask({}, { - type: actions.SHOW_NEW_VAULT_SEED, - value: 'test seed words', - }) - - assert.equal(showNewVaultSeedState.isRevealingSeedWords, true) - assert.equal(showNewVaultSeedState.seedWords, 'test seed words') - }) - it('shows account detail', () => { const state = reduceMetamask({}, { diff --git a/ui/app/ducks/app/app.js b/ui/app/ducks/app/app.js index 04c8c7422..77d9116e5 100644 --- a/ui/app/ducks/app/app.js +++ b/ui/app/ducks/app/app.js @@ -27,13 +27,6 @@ function reduceApp (state, action) { context: selectedAddress, } - // confirm seed words - var seedWords = state.metamask.seedWords - var seedConfView = { - name: 'createVaultComplete', - seedWords, - } - // default state var appState = extend({ shouldClose: false, @@ -58,7 +51,7 @@ function reduceApp (state, action) { alertMessage: null, qrCodeData: null, networkDropdownOpen: false, - currentView: seedWords ? seedConfView : defaultView, + currentView: defaultView, accountDetail: { subview: 'transactions', }, @@ -279,16 +272,6 @@ function reduceApp (state, action) { isLoading: true, }) - case actions.SHOW_NEW_VAULT_SEED: - return extend(appState, { - currentView: { - name: 'createVaultComplete', - seedWords: action.value, - }, - transForward: true, - isLoading: false, - }) - case actions.NEW_ACCOUNT_SCREEN: return extend(appState, { currentView: { @@ -428,8 +411,7 @@ function reduceApp (state, action) { case actions.SHOW_ACCOUNTS_PAGE: return extend(appState, { currentView: { - name: seedWords ? 'createVaultComplete' : 'accounts', - seedWords, + name: 'accounts', }, transForward: true, isLoading: false, diff --git a/ui/app/ducks/index.js b/ui/app/ducks/index.js index 2d33edcfa..18470c441 100644 --- a/ui/app/ducks/index.js +++ b/ui/app/ducks/index.js @@ -61,9 +61,6 @@ window.getCleanAppState = function () { // append additional information state.version = global.platform.getVersion() state.browser = window.navigator.userAgent - // ensure seedWords are not included - if (state.metamask) delete state.metamask.seedWords - if (state.appState.currentView) delete state.appState.currentView.seedWords return state } @@ -72,7 +69,7 @@ window.logStateString = function (cb) { global.platform.getPlatformInfo((err, platform) => { if (err) return cb(err) state.platform = platform - const stateString = JSON.stringify(state, removeSeedWords, 2) + const stateString = JSON.stringify(state, null, 2) cb(null, stateString) }) } @@ -89,7 +86,3 @@ window.logState = function (toClipboard) { } }) } - -function removeSeedWords (key, value) { - return key === 'seedWords' ? undefined : value -} diff --git a/ui/app/ducks/metamask/metamask.js b/ui/app/ducks/metamask/metamask.js index 64ce064b9..92f190cf1 100644 --- a/ui/app/ducks/metamask/metamask.js +++ b/ui/app/ducks/metamask/metamask.js @@ -44,7 +44,6 @@ function reduceMetamask (state, action) { useBlockie: false, featureFlags: {}, networkEndpointType: OLD_UI_NETWORK_TYPE, - isRevealingSeedWords: false, welcomeScreenSeen: false, currentLocale: '', preferences: { @@ -60,13 +59,6 @@ function reduceMetamask (state, action) { switch (action.type) { - case actions.SHOW_ACCOUNTS_PAGE: - newState = extend(metamaskState, { - isRevealingSeedWords: false, - }) - delete newState.seedWords - return newState - case actions.UPDATE_METAMASK_STATE: return extend(metamaskState, action.value) @@ -128,20 +120,12 @@ function reduceMetamask (state, action) { }, }) - - case actions.SHOW_NEW_VAULT_SEED: - return extend(metamaskState, { - isRevealingSeedWords: true, - seedWords: action.value, - }) - case actions.CLEAR_SEED_WORD_CACHE: newState = extend(metamaskState, { isUnlocked: true, isInitialized: true, selectedAddress: action.value, }) - delete newState.seedWords return newState case actions.SHOW_ACCOUNT_DETAIL: @@ -150,7 +134,6 @@ function reduceMetamask (state, action) { isInitialized: true, selectedAddress: action.value, }) - delete newState.seedWords return newState case actions.SET_SELECTED_TOKEN: diff --git a/ui/app/pages/home/home.component.js b/ui/app/pages/home/home.component.js index 4d96c3131..01bec7db6 100644 --- a/ui/app/pages/home/home.component.js +++ b/ui/app/pages/home/home.component.js @@ -7,7 +7,6 @@ import TransactionView from '../../components/app/transaction-view' import ProviderApproval from '../provider-approval' import { - INITIALIZE_SEED_PHRASE_ROUTE, RESTORE_VAULT_ROUTE, CONFIRM_TRANSACTION_ROUTE, CONFIRM_ADD_SUGGESTED_TOKEN_ROUTE, @@ -17,7 +16,6 @@ export default class Home extends PureComponent { static propTypes = { history: PropTypes.object, forgottenPassword: PropTypes.bool, - seedWords: PropTypes.string, suggestedTokens: PropTypes.object, unconfirmedTransactionsCount: PropTypes.number, providerRequests: PropTypes.array, @@ -49,16 +47,10 @@ export default class Home extends PureComponent { render () { const { forgottenPassword, - seedWords, providerRequests, history, } = this.props - // seed words - if (seedWords) { - return - } - if (forgottenPassword) { return } diff --git a/ui/app/pages/home/home.container.js b/ui/app/pages/home/home.container.js index 7508654dc..a4690a17a 100644 --- a/ui/app/pages/home/home.container.js +++ b/ui/app/pages/home/home.container.js @@ -8,7 +8,6 @@ const mapStateToProps = state => { const { metamask, appState } = state const { lostAccounts, - seedWords, suggestedTokens, providerRequests, } = metamask @@ -17,7 +16,6 @@ const mapStateToProps = state => { return { lostAccounts, forgottenPassword, - seedWords, suggestedTokens, unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state), providerRequests, diff --git a/ui/app/pages/routes/index.js b/ui/app/pages/routes/index.js index 751e3e3ae..f89ab31e0 100644 --- a/ui/app/pages/routes/index.js +++ b/ui/app/pages/routes/index.js @@ -346,7 +346,6 @@ Routes.propTypes = { forgottenPassword: PropTypes.bool, activeAddress: PropTypes.string, unapprovedTxs: PropTypes.object, - seedWords: PropTypes.string, submittedPendingTransactions: PropTypes.array, unapprovedMsgCount: PropTypes.number, unapprovedPersonalMsgCount: PropTypes.number, @@ -380,7 +379,6 @@ function mapStateToProps (state) { address, keyrings, isInitialized, - seedWords, unapprovedTxs, lostAccounts, unapprovedMsgCount, @@ -404,9 +402,8 @@ function mapStateToProps (state) { currentView: state.appState.currentView, activeAddress: state.appState.activeAddress, transForward: state.appState.transForward, - isOnboarding: Boolean(seedWords || !isInitialized), + isOnboarding: Boolean(!isInitialized), isPopup: state.metamask.isPopup, - seedWords: state.metamask.seedWords, submittedPendingTransactions: submittedPendingTransactionsSelector(state), unapprovedTxs, unapprovedMsgs: state.metamask.unapprovedMsgs, @@ -421,7 +418,6 @@ function mapStateToProps (state) { frequentRpcListDetail: state.metamask.frequentRpcListDetail || [], currentCurrency: state.metamask.currentCurrency, isMouseUser: state.appState.isMouseUser, - isRevealingSeedWords: state.metamask.isRevealingSeedWords, Qr: state.appState.Qr, welcomeScreenSeen: state.metamask.welcomeScreenSeen, providerId: getNetworkIdentifier(state), 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