aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-03-01 03:37:05 +0800
committerKevin Serrano <kevgagser@gmail.com>2017-03-01 03:37:05 +0800
commit61a19a028b0cf56230fc6512b5f5651d7e1aad5b (patch)
treea3eadb000f4210f8ef8f47a5b64b37f27c170b67
parent666044d417d45ee0e5e491cac388d1f57ee83932 (diff)
parent45138af6c6b97f795bac954ffb1229a3569591bc (diff)
downloadtangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar.gz
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar.bz2
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar.lz
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar.xz
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.tar.zst
tangerine-wallet-browser-61a19a028b0cf56230fc6512b5f5651d7e1aad5b.zip
Merge branch 'i765-gaslimits' of github.com:MetaMask/metamask-plugin into i765-gaslimits
-rw-r--r--ui/app/components/pending-tx-details.js68
-rw-r--r--ui/app/conf-tx.js1
2 files changed, 39 insertions, 30 deletions
diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js
index 510ef78e6..643e69902 100644
--- a/ui/app/components/pending-tx-details.js
+++ b/ui/app/components/pending-tx-details.js
@@ -247,27 +247,55 @@ PTXP.miniAccountPanelForRecipient = function () {
}
}
-PTXP.componentDidUpdate = function (prevProps, prevState) {
+PTXP.componentDidUpdate = function (prevProps, previousState) {
const state = this.state || {}
+ const prevState = previousState || {}
+ const { gas, gasPrice } = state
+
log.debug(`pending-tx-details componentDidUpdate`)
console.log(arguments)
// Only if gas or gasPrice changed:
- if (prevState &&
- (state.gas !== prevState.gas ||
- state.gasPrice !== prevState.gasPrice)) {
+ if (!prevState ||
+ (gas !== prevState.gas ||
+ 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)
- }
+PTXP.calculateGas = function () {
+ const txMeta = this.gatherParams()
+ log.debug(`pending-tx-details calculating gas for ${JSON.stringify(txMeta)}`)
+
+ var txParams = txMeta.txParams
+ var gasMultiplier = txMeta.gasMultiplier
+ var gasCost = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
+ var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice || '0x4a817c800'), 16)
+ gasPrice = gasPrice.mul(new BN(gasMultiplier * 100), 10).div(new BN(100, 10))
+ var txFee = gasCost.mul(gasPrice)
+ var txValue = new BN(ethUtil.stripHexPrefix(txParams.value || '0x0'), 16)
+ var maxCost = txValue.add(txFee)
+
+ const txFeeHex = '0x' + txFee.toString('hex')
+ const maxCostHex = '0x' + maxCost.toString('hex')
+ const gasPriceHex = '0x' + gasPrice.toString('hex')
+
+ txMeta.txFee = txFeeHex
+ txMeta.maxCost = maxCostHex
+ txMeta.txParams.gasPrice = gasPriceHex
+
+ this.setState({
+ txFee: '0x' + txFee.toString('hex'),
+ maxCost: '0x' + maxCost.toString('hex'),
+ })
+
+ if (this.props.onTxChange) {
+ this.props.onTxChange(txMeta)
}
}
+// After a customizable state value has been updated,
PTXP.gatherParams = function () {
log.debug(`pending-tx-details#gatherParams`)
const props = this.props
@@ -284,29 +312,9 @@ PTXP.gatherParams = function () {
const resultTxMeta = extend(txData, {
txParams: resultTx,
})
- log.debug(`gathered params: ${JSON.stringify(resultTxMeta)}`)
return resultTxMeta
}
-PTXP.calculateGas = function () {
- const txMeta = this.gatherParams()
- log.debug(`pending-tx-details calculating gas for ${JSON.stringify(txMeta)}`)
-
- var txParams = txMeta.txParams
- var gasMultiplier = txMeta.gasMultiplier
- var gasCost = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
- var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice || '0x4a817c800'), 16)
- gasPrice = gasPrice.mul(new BN(gasMultiplier * 100), 10).div(new BN(100, 10))
- var txFee = gasCost.mul(gasPrice)
- var txValue = new BN(ethUtil.stripHexPrefix(txParams.value || '0x0'), 16)
- var maxCost = txValue.add(txFee)
-
- this.setState({
- txFee: '0x' + txFee.toString('hex'),
- maxCost: '0x' + maxCost.toString('hex'),
- })
-}
-
function forwardCarrat () {
return (
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index de2c73cbc..0a59eee37 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -164,6 +164,7 @@ ConfirmTxScreen.prototype.buyEth = function (address, event) {
// Allows the detail view to update the gas calculations,
// for manual gas controls.
ConfirmTxScreen.prototype.onTxChange = function (txData) {
+ log.debug(`conf-tx onTxChange triggered with ${JSON.stringify(txData)}`)
this.setState({ txData })
}