|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
var actions = { |
|
|
|
|
GO_HOME: 'GO_HOME', |
|
|
|
|
goHome: goHome, |
|
|
|
|
// remote state
|
|
|
|
|
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE', |
|
|
|
|
updateMetamaskState: updateMetamaskState, |
|
|
|
@ -87,24 +89,29 @@ var actions = { |
|
|
|
|
|
|
|
|
|
module.exports = actions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _accountManager = null |
|
|
|
|
function _setAccountManager(accountManager){ |
|
|
|
|
_accountManager = accountManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function goHome() { |
|
|
|
|
return { |
|
|
|
|
type: this.GO_HOME, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// async actions
|
|
|
|
|
|
|
|
|
|
function tryUnlockMetamask(password) { |
|
|
|
|
return (dispatch) => { |
|
|
|
|
dispatch(this.unlockInProgress()) |
|
|
|
|
_accountManager.submitPassword(password, (err) => { |
|
|
|
|
_accountManager.submitPassword(password, (err, selectedAccount) => { |
|
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
|
if (err) { |
|
|
|
|
dispatch(this.unlockFailed()) |
|
|
|
|
} else { |
|
|
|
|
dispatch(this.unlockMetamask()) |
|
|
|
|
dispatch(this.setSelectedAddress()) |
|
|
|
|
dispatch(this.showAccountDetail(selectedAccount)) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -123,7 +130,7 @@ function recoverFromSeed(password, seed) { |
|
|
|
|
return (dispatch) => { |
|
|
|
|
// dispatch(this.createNewVaultInProgress())
|
|
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
|
_accountManager.recoverFromSeed(password, seed, (err, result) => { |
|
|
|
|
_accountManager.recoverFromSeed(password, seed, (err, selectedAccount) => { |
|
|
|
|
if (err) { |
|
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
|
var message = err.message |
|
|
|
@ -131,10 +138,8 @@ function recoverFromSeed(password, seed) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dispatch(this.unlockMetamask()) |
|
|
|
|
dispatch(this.setSelectedAddress()) |
|
|
|
|
dispatch(this.updateMetamaskState(result)) |
|
|
|
|
dispatch(this.showAccountDetail(selectedAccount)) |
|
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
|
dispatch(this.showAccountsPage()) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -276,9 +281,13 @@ function lockMetamask() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function showAccountDetail(address) { |
|
|
|
|
return { |
|
|
|
|
return (dispatch) => { |
|
|
|
|
_accountManager.setSelectedAddress(address) |
|
|
|
|
|
|
|
|
|
dispatch({ |
|
|
|
|
type: this.SHOW_ACCOUNT_DETAIL, |
|
|
|
|
value: address, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -297,10 +306,10 @@ function clearSeedWordCache() { |
|
|
|
|
function confirmSeedWords() { |
|
|
|
|
return (dispatch) => { |
|
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
|
_accountManager.clearSeedWordCache((err) => { |
|
|
|
|
_accountManager.clearSeedWordCache((err, accounts) => { |
|
|
|
|
dispatch(this.clearSeedWordCache()) |
|
|
|
|
console.log('Seed word cache cleared.') |
|
|
|
|
dispatch(this.setSelectedAddress()) |
|
|
|
|
dispatch(this.showAccountDetail(accounts[0].address)) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|