aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/actions.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2018-03-14 01:46:14 +0800
committerGitHub <noreply@github.com>2018-03-14 01:46:14 +0800
commit572234e383f944eb2be28c4192f209c3972747b7 (patch)
tree3d6a214b845790c96e2c98e6c140ed6724d261e4 /ui/app/actions.js
parent70f33d47472863e3fce41eff60c1fe078efef7de (diff)
parent1fa5cec2ec784ace2dd8d1afab6c0d8cc195feb5 (diff)
downloadtangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar.gz
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar.bz2
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar.lz
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar.xz
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.tar.zst
tangerine-wallet-browser-572234e383f944eb2be28c4192f209c3972747b7.zip
Merge branch 'master' into i3033-responsive-newui-onboarding
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r--ui/app/actions.js127
1 files changed, 87 insertions, 40 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index e1d000f72..092af080b 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -286,20 +286,43 @@ function goHome () {
// async actions
function tryUnlockMetamask (password) {
- return (dispatch) => {
+ return dispatch => {
dispatch(actions.showLoadingIndication())
dispatch(actions.unlockInProgress())
log.debug(`background.submitPassword`)
- background.submitPassword(password, (err) => {
- dispatch(actions.hideLoadingIndication())
- if (err) {
- dispatch(actions.unlockFailed(err.message))
- } else {
+
+ return new Promise((resolve, reject) => {
+ background.submitPassword(password, error => {
+ if (error) {
+ return reject(error)
+ }
+
+ resolve()
+ })
+ })
+ .then(() => {
dispatch(actions.unlockSucceeded())
+ return forceUpdateMetamaskState(dispatch)
+ })
+ .then(() => {
+ return new Promise((resolve, reject) => {
+ background.verifySeedPhrase(err => {
+ if (err) {
+ dispatch(actions.displayWarning(err.message))
+ }
+
+ resolve()
+ })
+ })
+ })
+ .then(() => {
dispatch(actions.transitionForward())
- forceUpdateMetamaskState(dispatch)
- }
- })
+ dispatch(actions.hideLoadingIndication())
+ })
+ .catch(err => {
+ dispatch(actions.unlockFailed(err.message))
+ dispatch(actions.hideLoadingIndication())
+ })
}
}
@@ -341,46 +364,53 @@ function createNewVaultAndRestore (password, seed) {
log.debug(`background.createNewVaultAndRestore`)
return new Promise((resolve, reject) => {
- background.createNewVaultAndRestore(password, seed, (err) => {
-
- dispatch(actions.hideLoadingIndication())
-
+ background.createNewVaultAndRestore(password, seed, err => {
if (err) {
- dispatch(actions.displayWarning(err.message))
return reject(err)
}
- dispatch(actions.showAccountsPage())
resolve()
})
})
+ .then(() => dispatch(actions.unMarkPasswordForgotten()))
+ .then(() => {
+ dispatch(actions.showAccountsPage())
+ dispatch(actions.hideLoadingIndication())
+ })
+ .catch(err => {
+ dispatch(actions.displayWarning(err.message))
+ dispatch(actions.hideLoadingIndication())
+ })
}
}
function createNewVaultAndKeychain (password) {
- return (dispatch) => {
+ return dispatch => {
dispatch(actions.showLoadingIndication())
log.debug(`background.createNewVaultAndKeychain`)
return new Promise((resolve, reject) => {
- background.createNewVaultAndKeychain(password, (err) => {
+ 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)
}
- dispatch(actions.hideLoadingIndication())
- forceUpdateMetamaskState(dispatch)
+
resolve()
})
})
})
-
+ .then(() => forceUpdateMetamaskState(dispatch))
+ .then(() => dispatch(actions.hideLoadingIndication()))
+ .catch(() => dispatch(actions.hideLoadingIndication()))
}
}
@@ -391,18 +421,27 @@ function revealSeedConfirmation () {
}
function requestRevealSeed (password) {
- return (dispatch) => {
+ return dispatch => {
dispatch(actions.showLoadingIndication())
log.debug(`background.submitPassword`)
- background.submitPassword(password, (err) => {
- if (err) {
- return dispatch(actions.displayWarning(err.message))
- }
- log.debug(`background.placeSeedWords`)
- background.placeSeedWords((err, result) => {
- if (err) return dispatch(actions.displayWarning(err.message))
- dispatch(actions.hideLoadingIndication())
- dispatch(actions.showNewVaultSeed(result))
+ 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()
+ })
})
})
}
@@ -751,7 +790,7 @@ function updateTransaction (txData) {
function updateAndApproveTx (txData) {
log.info('actions: updateAndApproveTx: ' + JSON.stringify(txData))
return (dispatch) => {
- log.debug(`actions calling background.updateAndApproveTx`)
+ log.debug(`actions calling background.updateAndApproveTx.`)
background.updateAndApproveTransaction(txData, (err) => {
dispatch(actions.hideLoadingIndication())
dispatch(actions.updateTransactionParams(txData.id, txData.txParams))
@@ -853,11 +892,14 @@ function markPasswordForgotten () {
}
function unMarkPasswordForgotten () {
- return (dispatch) => {
- return background.unMarkPasswordForgotten(() => {
- dispatch(actions.forgotPassword(false))
- forceUpdateMetamaskState(dispatch)
+ return dispatch => {
+ return new Promise(resolve => {
+ background.unMarkPasswordForgotten(() => {
+ dispatch(actions.forgotPassword(false))
+ resolve()
+ })
})
+ .then(() => forceUpdateMetamaskState(dispatch))
}
}
@@ -1712,11 +1754,16 @@ function callBackgroundThenUpdate (method, ...args) {
function forceUpdateMetamaskState (dispatch) {
log.debug(`background.getState`)
- background.getState((err, newState) => {
- if (err) {
- return dispatch(actions.displayWarning(err.message))
- }
- dispatch(actions.updateMetamaskState(newState))
+ return new Promise((resolve, reject) => {
+ background.getState((err, newState) => {
+ if (err) {
+ dispatch(actions.displayWarning(err.message))
+ return reject(err)
+ }
+
+ dispatch(actions.updateMetamaskState(newState))
+ resolve()
+ })
})
}