1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00

Emit updated tx values on accept click

This commit is contained in:
Dan Finlay 2017-02-27 18:33:33 -08:00
parent 2e80e8f722
commit 3ddfdfff98
2 changed files with 20 additions and 1 deletions

View File

@ -253,6 +253,13 @@ PTXP.componentDidUpdate = function (prevProps, prevState) {
state.gasPrice !== prevState.gasPrice)) {
log.debug(`recalculating gas since prev state change: ${JSON.stringify({ prevState, state })}`)
this.calculateGas()
// Otherwise this was a recalculation,
// so we should inform the parent:
} else {
if (this.props.onTxChange) {
this.props.onTxChange(this.gatherParams)
}
}
}

View File

@ -104,6 +104,8 @@ ConfirmTxScreen.prototype.render = function () {
accounts: props.accounts,
identities: props.identities,
insufficientBalance: this.checkBalanceAgainstTx(txData),
// State actions
onTxChange: this.updateTxCache.bind(this),
// Actions
buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress),
sendTransaction: this.sendTransaction.bind(this, txData),
@ -159,9 +161,19 @@ ConfirmTxScreen.prototype.buyEth = function (address, event) {
this.props.dispatch(actions.buyEthView(address))
}
// Allows the detail view to update the gas calculations,
// for manual gas controls.
ConfirmTxScreen.prototype.onTxChange = function (txData) {
this.setState({ txData })
}
// Must default to any local state txData,
// to allow manual override of gas calculations.
ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
event.stopPropagation()
this.props.dispatch(actions.sendTx(txData))
const state = this.state || {}
const txMeta = state.txData
this.props.dispatch(actions.sendTx(txMeta || txData))
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {