diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-01 02:04:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-01 02:04:53 +0800 |
commit | 5f3f8c85fcc5bd378ef1a886434a3e98546fee7f (patch) | |
tree | f4665fdeae73f010a676da4ec3df563e31ff01bd /ui/app/actions.js | |
parent | 9b1c07c75045f4a7124e4f0fcd416535f88182ae (diff) | |
parent | 61b8c3efff3b12e117c80db80c237dcfce0c0f49 (diff) | |
download | tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar.gz tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar.bz2 tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar.lz tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar.xz tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.tar.zst tangerine-wallet-browser-5f3f8c85fcc5bd378ef1a886434a3e98546fee7f.zip |
Merge pull request #4059 from MetaMask/i-4033-seed-words
Use new design for Reveal Seed screen. Persist seed words only in the first time flow.
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 81d9c333b..62875c629 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -83,7 +83,7 @@ var actions = { REVEAL_SEED_CONFIRMATION: 'REVEAL_SEED_CONFIRMATION', revealSeedConfirmation: revealSeedConfirmation, requestRevealSeed: requestRevealSeed, - + requestRevealSeedWords, // unlock screen UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS', UNLOCK_FAILED: 'UNLOCK_FAILED', @@ -345,11 +345,13 @@ function transitionBackward () { } } -function clearSeedWordCache () { - log.debug(`background.clearSeedWordCache`) +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) @@ -363,22 +365,6 @@ function clearSeedWordCache () { } } -function confirmSeedWords () { - return async dispatch => { - dispatch(actions.showLoadingIndication()) - const account = await dispatch(clearSeedWordCache()) - return dispatch(setIsRevealingSeedWords(false)) - .then(() => { - dispatch(actions.hideLoadingIndication()) - return account - }) - .catch(() => { - dispatch(actions.hideLoadingIndication()) - return account - }) - } -} - function createNewVaultAndRestore (password, seed) { return (dispatch) => { dispatch(actions.showLoadingIndication()) @@ -441,6 +427,30 @@ function revealSeedConfirmation () { } } +function verifyPassword (password) { + return new Promise((resolve, reject) => { + background.submitPassword(password, error => { + if (error) { + return reject(error) + } + + resolve(true) + }) + }) +} + +function verifySeedPhrase () { + return new Promise((resolve, reject) => { + background.verifySeedPhrase((error, seedWords) => { + if (error) { + return reject(error) + } + + resolve(seedWords) + }) + }) +} + function requestRevealSeed (password) { return dispatch => { dispatch(actions.showLoadingIndication()) @@ -460,13 +470,29 @@ function requestRevealSeed (password) { } dispatch(actions.showNewVaultSeed(result)) + dispatch(actions.hideLoadingIndication()) resolve() }) }) }) - .then(() => dispatch(setIsRevealingSeedWords(true))) - .then(() => dispatch(actions.hideLoadingIndication())) - .catch(() => dispatch(actions.hideLoadingIndication())) + } +} + +function requestRevealSeedWords (password) { + return async dispatch => { + dispatch(actions.showLoadingIndication()) + log.debug(`background.submitPassword`) + + try { + await verifyPassword(password) + const seedWords = await verifySeedPhrase() + dispatch(actions.hideLoadingIndication()) + return seedWords + } catch (error) { + dispatch(actions.hideLoadingIndication()) + dispatch(actions.displayWarning(error.message)) + throw new Error(error.message) + } } } @@ -1923,11 +1949,3 @@ function updateNetworkEndpointType (networkEndpointType) { value: networkEndpointType, } } - -function setIsRevealingSeedWords (reveal) { - return dispatch => { - log.debug(`background.setIsRevealingSeedWords`) - background.setIsRevealingSeedWords(reveal) - return forceUpdateMetamaskState(dispatch) - } -} |