diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-06-13 01:30:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-13 01:30:25 +0800 |
commit | 2e6e6e41250011b451412608e455fe6402634729 (patch) | |
tree | 7e84df2522037578f6761854f8316d0484d4b8a0 /ui | |
parent | cd3362f941b8eae12adbb6ffe9d60d4a6195755f (diff) | |
parent | 3e1d648ec012af9a8fe6fc3b329338f7f7fc80e2 (diff) | |
download | tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar.gz tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar.bz2 tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar.lz tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar.xz tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.tar.zst tangerine-wallet-browser-2e6e6e41250011b451412608e455fe6402634729.zip |
Merge pull request #1535 from MetaMask/gasupdater
Update GasBlockLimits on every new block
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/pending-tx.js | 11 | ||||
-rw-r--r-- | ui/app/conf-tx.js | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index e3b307b0b..4b1a00eca 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -32,7 +32,7 @@ function PendingTx () { PendingTx.prototype.render = function () { const props = this.props - const { currentCurrency } = props + const { currentCurrency, blockGasLimit } = props const conversionRate = props.conversionRate const txMeta = this.gatherTxMeta() @@ -50,7 +50,8 @@ PendingTx.prototype.render = function () { // Gas const gas = txParams.gas const gasBn = hexToBn(gas) - const safeGasLimit = parseInt(txMeta.blockGasLimit) + const gasLimit = new BN(parseInt(blockGasLimit)) + const safeGasLimit = this.bnMultiplyByFraction(gasLimit, 19, 20).toString(10) // Gas Price const gasPrice = txParams.gasPrice || MIN_GAS_PRICE_BN.toString(16) @@ -458,6 +459,12 @@ PendingTx.prototype._notZeroOrEmptyString = function (obj) { return obj !== '' && obj !== '0x0' } +PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) { + const numBN = new BN(numerator) + const denomBN = new BN(denominator) + return targetBN.mul(numBN).div(denomBN) +} + function forwardCarrat () { return ( h('img', { diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js index 4ae81f35f..747d3ce2b 100644 --- a/ui/app/conf-tx.js +++ b/ui/app/conf-tx.js @@ -29,6 +29,7 @@ function mapStateToProps (state) { provider: state.metamask.provider, conversionRate: state.metamask.conversionRate, currentCurrency: state.metamask.currentCurrency, + blockGasLimit: state.metamask.currentBlockGasLimit, } } @@ -40,7 +41,7 @@ function ConfirmTxScreen () { ConfirmTxScreen.prototype.render = function () { const props = this.props const { network, provider, unapprovedTxs, currentCurrency, - unapprovedMsgs, unapprovedPersonalMsgs, conversionRate } = props + unapprovedMsgs, unapprovedPersonalMsgs, conversionRate, blockGasLimit } = props var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network) @@ -107,6 +108,7 @@ ConfirmTxScreen.prototype.render = function () { identities: props.identities, conversionRate, currentCurrency, + blockGasLimit, // Actions buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress), sendTransaction: this.sendTransaction.bind(this), |