From 0e74cf2cba206520dbb8d7cc7b2a989566317201 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 24 Mar 2017 09:45:03 -0700 Subject: Disable accept button when gas limit is too low --- ui/app/components/pending-tx.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'ui/app/components/pending-tx.js') diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index 2f9e9885b..cfccf2a89 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -16,7 +16,7 @@ const nameForAddress = require('../../lib/contract-namer') const HexInput = require('./hex-as-decimal-input') const MIN_GAS_PRICE_BN = new BN(20000000) - +const MIN_GAS_LIMIT_BN = new BN(21000) module.exports = connect(mapStateToProps)(PendingTx) @@ -164,7 +164,7 @@ PendingTx.prototype.render = function () { h(HexInput, { name: 'Gas Limit', value: gas, - min: 21000, // The hard lower limit for gas. + min: MIN_GAS_LIMIT_BN.toString(10), // The hard lower limit for gas. suffix: 'UNITS', style: { position: 'relative', @@ -298,6 +298,7 @@ PendingTx.prototype.render = function () { }, }, 'Reset'), + // Accept Button h('input.confirm.btn-green', { type: 'submit', value: 'ACCEPT', @@ -374,10 +375,6 @@ PendingTx.prototype.componentDidUpdate = function (prevProps, previousState) { } } -PendingTx.prototype.isValid = function () { - return this.state.valid -} - PendingTx.prototype.calculateGas = function () { const state = this.state const props = this.props @@ -388,10 +385,10 @@ PendingTx.prototype.calculateGas = function () { const txParams = txMeta.txParams const gasLimit = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16) - const gasPriceHex = (state.gasPrice === undefined) ? txData.gasPrice : state.gasPrice + const gasPriceHex = state.gasPrice || txData.gasPrice const gasPrice = new BN(ethUtil.stripHexPrefix(gasPriceHex), 16) - const valid = !gasPrice.lt(MIN_GAS_PRICE_BN) + const valid = !gasPrice.lt(MIN_GAS_PRICE_BN) && !gasLimit.lt(MIN_GAS_LIMIT_BN) this.validChanged(valid) const txFee = gasLimit.mul(gasPrice) -- cgit