mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Disable accept button when gas limit is too low
This commit is contained in:
parent
6a46e9ce06
commit
0e74cf2cba
@ -16,7 +16,7 @@ const nameForAddress = require('../../lib/contract-namer')
|
|||||||
const HexInput = require('./hex-as-decimal-input')
|
const HexInput = require('./hex-as-decimal-input')
|
||||||
|
|
||||||
const MIN_GAS_PRICE_BN = new BN(20000000)
|
const MIN_GAS_PRICE_BN = new BN(20000000)
|
||||||
|
const MIN_GAS_LIMIT_BN = new BN(21000)
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(PendingTx)
|
module.exports = connect(mapStateToProps)(PendingTx)
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ PendingTx.prototype.render = function () {
|
|||||||
h(HexInput, {
|
h(HexInput, {
|
||||||
name: 'Gas Limit',
|
name: 'Gas Limit',
|
||||||
value: gas,
|
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',
|
suffix: 'UNITS',
|
||||||
style: {
|
style: {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
@ -298,6 +298,7 @@ PendingTx.prototype.render = function () {
|
|||||||
},
|
},
|
||||||
}, 'Reset'),
|
}, 'Reset'),
|
||||||
|
|
||||||
|
// Accept Button
|
||||||
h('input.confirm.btn-green', {
|
h('input.confirm.btn-green', {
|
||||||
type: 'submit',
|
type: 'submit',
|
||||||
value: 'ACCEPT',
|
value: 'ACCEPT',
|
||||||
@ -374,10 +375,6 @@ PendingTx.prototype.componentDidUpdate = function (prevProps, previousState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTx.prototype.isValid = function () {
|
|
||||||
return this.state.valid
|
|
||||||
}
|
|
||||||
|
|
||||||
PendingTx.prototype.calculateGas = function () {
|
PendingTx.prototype.calculateGas = function () {
|
||||||
const state = this.state
|
const state = this.state
|
||||||
const props = this.props
|
const props = this.props
|
||||||
@ -388,10 +385,10 @@ PendingTx.prototype.calculateGas = function () {
|
|||||||
|
|
||||||
const txParams = txMeta.txParams
|
const txParams = txMeta.txParams
|
||||||
const gasLimit = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
|
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 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)
|
this.validChanged(valid)
|
||||||
|
|
||||||
const txFee = gasLimit.mul(gasPrice)
|
const txFee = gasLimit.mul(gasPrice)
|
||||||
|
Loading…
Reference in New Issue
Block a user