|
|
@ -95,7 +95,7 @@ var actions = { |
|
|
|
setRpcTarget: setRpcTarget, |
|
|
|
setRpcTarget: setRpcTarget, |
|
|
|
setProviderType: setProviderType, |
|
|
|
setProviderType: setProviderType, |
|
|
|
// hacky - need a way to get a reference to account manager
|
|
|
|
// hacky - need a way to get a reference to account manager
|
|
|
|
_setAccountManager: _setAccountManager, |
|
|
|
_setKeyringController: _setKeyringController, |
|
|
|
// loading overlay
|
|
|
|
// loading overlay
|
|
|
|
SHOW_LOADING: 'SHOW_LOADING_INDICATION', |
|
|
|
SHOW_LOADING: 'SHOW_LOADING_INDICATION', |
|
|
|
HIDE_LOADING: 'HIDE_LOADING_INDICATION', |
|
|
|
HIDE_LOADING: 'HIDE_LOADING_INDICATION', |
|
|
@ -132,13 +132,17 @@ var actions = { |
|
|
|
RECOVERY_IN_PROGRESS: 'RECOVERY_IN_PROGRESS', |
|
|
|
RECOVERY_IN_PROGRESS: 'RECOVERY_IN_PROGRESS', |
|
|
|
BACK_TO_UNLOCK_VIEW: 'BACK_TO_UNLOCK_VIEW', |
|
|
|
BACK_TO_UNLOCK_VIEW: 'BACK_TO_UNLOCK_VIEW', |
|
|
|
backToUnlockView: backToUnlockView, |
|
|
|
backToUnlockView: backToUnlockView, |
|
|
|
|
|
|
|
// SHOWING KEYCHAIN
|
|
|
|
|
|
|
|
SHOW_NEW_KEYCHAIN: 'SHOW_NEW_KEYCHAIN', |
|
|
|
|
|
|
|
showNewKeychain: showNewKeychain, |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = actions |
|
|
|
module.exports = actions |
|
|
|
|
|
|
|
|
|
|
|
var _accountManager = null |
|
|
|
var _keyringController = null |
|
|
|
function _setAccountManager (accountManager) { |
|
|
|
function _setKeyringController (accountManager) { |
|
|
|
_accountManager = accountManager |
|
|
|
_keyringController = accountManager |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function goHome () { |
|
|
|
function goHome () { |
|
|
@ -153,7 +157,7 @@ function tryUnlockMetamask (password) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
dispatch(actions.unlockInProgress()) |
|
|
|
dispatch(actions.unlockInProgress()) |
|
|
|
_accountManager.submitPassword(password, (err, selectedAccount) => { |
|
|
|
_keyringController.submitPassword(password, (err, selectedAccount) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
dispatch(actions.unlockFailed()) |
|
|
|
dispatch(actions.unlockFailed()) |
|
|
@ -167,11 +171,11 @@ function tryUnlockMetamask (password) { |
|
|
|
function createNewVault (password, entropy) { |
|
|
|
function createNewVault (password, entropy) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(actions.createNewVaultInProgress()) |
|
|
|
dispatch(actions.createNewVaultInProgress()) |
|
|
|
_accountManager.createNewVault(password, entropy, (err, result) => { |
|
|
|
_keyringController.createNewVault(password, entropy, (err, result) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
} |
|
|
|
} |
|
|
|
dispatch(this.goHome()) |
|
|
|
dispatch(this.showAccountsPage()) |
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -185,14 +189,14 @@ function showInfoPage () { |
|
|
|
|
|
|
|
|
|
|
|
function setSelectedAddress (address) { |
|
|
|
function setSelectedAddress (address) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
_accountManager.setSelectedAddress(address) |
|
|
|
_keyringController.setSelectedAddress(address) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setCurrentFiat (fiat) { |
|
|
|
function setCurrentFiat (fiat) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
_accountManager.setCurrentFiat(fiat, (data, err) => { |
|
|
|
_keyringController.setCurrentFiat(fiat, (data, err) => { |
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
dispatch(this.hideLoadingIndication()) |
|
|
|
dispatch({ |
|
|
|
dispatch({ |
|
|
|
type: this.SET_CURRENT_FIAT, |
|
|
|
type: this.SET_CURRENT_FIAT, |
|
|
@ -210,7 +214,7 @@ function signMsg (msgData) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
|
|
|
|
|
|
|
|
_accountManager.signMessage(msgData, (err) => { |
|
|
|
_keyringController.signMessage(msgData, (err) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
|
|
|
|
|
|
|
|
if (err) return dispatch(actions.displayWarning(err.message)) |
|
|
|
if (err) return dispatch(actions.displayWarning(err.message)) |
|
|
@ -221,20 +225,22 @@ function signMsg (msgData) { |
|
|
|
|
|
|
|
|
|
|
|
function signTx (txData) { |
|
|
|
function signTx (txData) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
web3.eth.sendTransaction(txData, (err, data) => { |
|
|
|
_accountManager.setGasMultiplier(txData.gasMultiplier, (err) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (err) return dispatch(actions.displayWarning(err.message)) |
|
|
|
if (err) return dispatch(actions.displayWarning(err.message)) |
|
|
|
dispatch(actions.hideWarning()) |
|
|
|
web3.eth.sendTransaction(txData, (err, data) => { |
|
|
|
dispatch(actions.goHome()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
|
|
|
|
if (err) return dispatch(actions.displayWarning(err.message)) |
|
|
|
|
|
|
|
dispatch(actions.hideWarning()) |
|
|
|
|
|
|
|
dispatch(actions.goHome()) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
dispatch(this.showConfTxPage()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
dispatch(this.showConfTxPage()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function sendTx (txData) { |
|
|
|
function sendTx (txData) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
_accountManager.approveTransaction(txData.id, (err) => { |
|
|
|
_keyringController.approveTransaction(txData.id, (err) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
alert(err.message) |
|
|
|
alert(err.message) |
|
|
|
dispatch(actions.txError(err)) |
|
|
|
dispatch(actions.txError(err)) |
|
|
@ -260,12 +266,12 @@ function txError (err) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function cancelMsg (msgData) { |
|
|
|
function cancelMsg (msgData) { |
|
|
|
_accountManager.cancelMessage(msgData.id) |
|
|
|
_keyringController.cancelMessage(msgData.id) |
|
|
|
return actions.completedTx(msgData.id) |
|
|
|
return actions.completedTx(msgData.id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function cancelTx (txData) { |
|
|
|
function cancelTx (txData) { |
|
|
|
_accountManager.cancelTransaction(txData.id) |
|
|
|
_keyringController.cancelTransaction(txData.id) |
|
|
|
return actions.completedTx(txData.id) |
|
|
|
return actions.completedTx(txData.id) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -294,7 +300,7 @@ function showInitializeMenu () { |
|
|
|
function agreeToDisclaimer () { |
|
|
|
function agreeToDisclaimer () { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
dispatch(this.showLoadingIndication()) |
|
|
|
_accountManager.agreeToDisclaimer((err) => { |
|
|
|
_keyringController.agreeToDisclaimer((err) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
} |
|
|
|
} |
|
|
@ -326,6 +332,12 @@ function backToUnlockView () { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function showNewKeychain () { |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
type: actions.SHOW_NEW_KEYCHAIN |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// unlock screen
|
|
|
|
// unlock screen
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -358,7 +370,7 @@ function updateMetamaskState (newState) { |
|
|
|
|
|
|
|
|
|
|
|
function lockMetamask () { |
|
|
|
function lockMetamask () { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
_accountManager.setLocked((err) => { |
|
|
|
_keyringController.setLocked((err) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
@ -374,7 +386,7 @@ function lockMetamask () { |
|
|
|
function showAccountDetail (address) { |
|
|
|
function showAccountDetail (address) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
_accountManager.setSelectedAddress(address, (err, address) => { |
|
|
|
_keyringController.setSelectedAddress(address, (err, address) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
@ -445,7 +457,7 @@ function goBackToInitView () { |
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
function setRpcTarget (newRpc) { |
|
|
|
function setRpcTarget (newRpc) { |
|
|
|
_accountManager.setRpcTarget(newRpc) |
|
|
|
_keyringController.setRpcTarget(newRpc) |
|
|
|
return { |
|
|
|
return { |
|
|
|
type: actions.SET_RPC_TARGET, |
|
|
|
type: actions.SET_RPC_TARGET, |
|
|
|
value: newRpc, |
|
|
|
value: newRpc, |
|
|
@ -453,7 +465,7 @@ function setRpcTarget (newRpc) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setProviderType (type) { |
|
|
|
function setProviderType (type) { |
|
|
|
_accountManager.setProviderType(type) |
|
|
|
_keyringController.setProviderType(type) |
|
|
|
return { |
|
|
|
return { |
|
|
|
type: actions.SET_PROVIDER_TYPE, |
|
|
|
type: actions.SET_PROVIDER_TYPE, |
|
|
|
value: type, |
|
|
|
value: type, |
|
|
@ -461,7 +473,7 @@ function setProviderType (type) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function useEtherscanProvider () { |
|
|
|
function useEtherscanProvider () { |
|
|
|
_accountManager.useEtherscanProvider() |
|
|
|
_keyringController.useEtherscanProvider() |
|
|
|
return { |
|
|
|
return { |
|
|
|
type: actions.USE_ETHERSCAN_PROVIDER, |
|
|
|
type: actions.USE_ETHERSCAN_PROVIDER, |
|
|
|
} |
|
|
|
} |
|
|
@ -520,7 +532,7 @@ function exportAccount (address) { |
|
|
|
return function (dispatch) { |
|
|
|
return function (dispatch) { |
|
|
|
dispatch(self.showLoadingIndication()) |
|
|
|
dispatch(self.showLoadingIndication()) |
|
|
|
|
|
|
|
|
|
|
|
_accountManager.exportAccount(address, function (err, result) { |
|
|
|
_keyringController.exportAccount(address, function (err, result) { |
|
|
|
dispatch(self.hideLoadingIndication()) |
|
|
|
dispatch(self.hideLoadingIndication()) |
|
|
|
|
|
|
|
|
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
@ -543,7 +555,7 @@ function showPrivateKey (key) { |
|
|
|
function saveAccountLabel (account, label) { |
|
|
|
function saveAccountLabel (account, label) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
dispatch(actions.showLoadingIndication()) |
|
|
|
_accountManager.saveAccountLabel(account, label, (err) => { |
|
|
|
_keyringController.saveAccountLabel(account, label, (err) => { |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
dispatch(actions.hideLoadingIndication()) |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
|
return dispatch(actions.showWarning(err.message)) |
|
|
@ -564,7 +576,7 @@ function showSendPage () { |
|
|
|
|
|
|
|
|
|
|
|
function agreeToEthWarning () { |
|
|
|
function agreeToEthWarning () { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
_accountManager.agreeToEthWarning((err) => { |
|
|
|
_keyringController.agreeToEthWarning((err) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
return dispatch(actions.showEthWarning(err.message)) |
|
|
|
return dispatch(actions.showEthWarning(err.message)) |
|
|
|
} |
|
|
|
} |
|
|
@ -583,7 +595,7 @@ function showEthWarning () { |
|
|
|
|
|
|
|
|
|
|
|
function buyEth (address, amount) { |
|
|
|
function buyEth (address, amount) { |
|
|
|
return (dispatch) => { |
|
|
|
return (dispatch) => { |
|
|
|
_accountManager.buyEth(address, amount) |
|
|
|
_keyringController.buyEth(address, amount) |
|
|
|
dispatch({ |
|
|
|
dispatch({ |
|
|
|
type: actions.BUY_ETH, |
|
|
|
type: actions.BUY_ETH, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -661,7 +673,7 @@ function coinShiftRquest (data, marketData) { |
|
|
|
if (response.error) return dispatch(actions.showWarning(response.error)) |
|
|
|
if (response.error) return dispatch(actions.showWarning(response.error)) |
|
|
|
var message = ` |
|
|
|
var message = ` |
|
|
|
Deposit your ${response.depositType} to the address bellow:` |
|
|
|
Deposit your ${response.depositType} to the address bellow:` |
|
|
|
_accountManager.createShapeShiftTx(response.deposit, response.depositType) |
|
|
|
_keyringController.createShapeShiftTx(response.deposit, response.depositType) |
|
|
|
dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) |
|
|
|
dispatch(actions.showQrView(response.deposit, [message].concat(marketData))) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|