diff options
Diffstat (limited to 'ui/app/actions.js')
-rw-r--r-- | ui/app/actions.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 0a2b4a636..a43809fc0 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -129,6 +129,17 @@ var actions = { cancelAllTx: cancelAllTx, viewPendingTx: viewPendingTx, VIEW_PENDING_TX: 'VIEW_PENDING_TX', + // send screen + estimateGas, + updateGasEstimate, + UPDATE_GAS_ESTIMATE: 'UPDATE_GAS_ESTIMATE', + updateGasPrice, + UPDATE_GAS_PRICE: 'UPDATE_GAS_PRICE', + getGasPrice, + CLEAR_GAS_ESTIMATE: 'CLEAR_GAS_ESTIMATE', + CLEAR_GAS_PRICE: 'CLEAR_GAS_PRICE', + clearGasEstimate, + clearGasPrice, // app messages confirmSeedWords: confirmSeedWords, showAccountDetail: showAccountDetail, @@ -449,6 +460,26 @@ function signTx (txData) { } } +function estimateGas ({ to, amount }) { + return (dispatch) => { + global.ethQuery.estimateGas({ to, amount }, (err, data) => { + if (err) return dispatch(actions.displayWarning(err.message)) + dispatch(actions.hideWarning()) + dispatch(actions.updateGasEstimate(data)) + }) + } +} + +function getGasPrice () { + return (dispatch) => { + global.ethQuery.gasPrice((err, data) => { + if (err) return dispatch(actions.displayWarning(err.message)) + dispatch(actions.hideWarning()) + dispatch(actions.updateGasPrice(data)) + }) + } +} + function sendTx (txData) { log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`) return (dispatch) => { @@ -506,6 +537,32 @@ function txError (err) { } } +function updateGasEstimate (gas) { + return { + type: actions.UPDATE_GAS_ESTIMATE, + value: gas, + } +} + +function clearGasEstimate () { + return { + type: actions.CLEAR_GAS_ESTIMATE, + } +} + +function updateGasPrice (gasPrice) { + return { + type: actions.UPDATE_GAS_PRICE, + value: gasPrice, + } +} + +function clearGasPrice () { + return { + type: actions.CLEAR_GAS_PRICE, + } +} + function cancelMsg (msgData) { log.debug(`background.cancelMessage`) background.cancelMessage(msgData.id) |