mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Prevent submission of invalid gas parameters.
This commit is contained in:
parent
0ac1f749fd
commit
72932bdcba
@ -306,7 +306,6 @@ PTXP.gatherParams = function () {
|
|||||||
const state = this.state || {}
|
const state = this.state || {}
|
||||||
const txData = state.txData || props.txData
|
const txData = state.txData || props.txData
|
||||||
const txParams = txData.txParams
|
const txParams = txData.txParams
|
||||||
|
|
||||||
const gas = state.gas || txParams.gas
|
const gas = state.gas || txParams.gas
|
||||||
const gasPrice = state.gasPrice || txParams.gasPrice
|
const gasPrice = state.gasPrice || txParams.gasPrice
|
||||||
const resultTx = extend(txParams, {
|
const resultTx = extend(txParams, {
|
||||||
@ -320,6 +319,16 @@ PTXP.gatherParams = function () {
|
|||||||
return resultTxMeta
|
return resultTxMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PTXP.verifyGasParams = function () {
|
||||||
|
// We call this in case the gas has not been modified at all
|
||||||
|
if (!this.state) { return true }
|
||||||
|
return this._notZeroOrEmptyString(this.state.gas) && this._notZeroOrEmptyString(this.state.gasPrice)
|
||||||
|
}
|
||||||
|
|
||||||
|
PTXP._notZeroOrEmptyString = function (obj) {
|
||||||
|
return obj !== '' && obj !== '0x0'
|
||||||
|
}
|
||||||
|
|
||||||
function forwardCarrat () {
|
function forwardCarrat () {
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
|
const connect = require('react-redux').connect
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const inherits = require('util').inherits
|
const inherits = require('util').inherits
|
||||||
const PendingTxDetails = require('./pending-tx-details')
|
const PendingTxDetails = require('./pending-tx-details')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
|
const actions = require('../actions')
|
||||||
|
|
||||||
module.exports = PendingTx
|
module.exports = connect(mapStateToProps)(PendingTx)
|
||||||
|
|
||||||
|
function mapStateToProps (state) {
|
||||||
|
return {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inherits(PendingTx, Component)
|
inherits(PendingTx, Component)
|
||||||
function PendingTx () {
|
function PendingTx () {
|
||||||
@ -73,7 +81,13 @@ PendingTx.prototype.render = function () {
|
|||||||
|
|
||||||
h('button.confirm.btn-green', {
|
h('button.confirm.btn-green', {
|
||||||
disabled: props.insufficientBalance,
|
disabled: props.insufficientBalance,
|
||||||
onClick: props.sendTransaction,
|
onClick: (txData, event) => {
|
||||||
|
if (this.refs.details.verifyGasParams()) {
|
||||||
|
props.sendTransaction(txData, event)
|
||||||
|
} else {
|
||||||
|
this.props.dispatch(actions.displayWarning('Invalid Gas Parameters'))
|
||||||
|
}
|
||||||
|
},
|
||||||
}, 'Accept'),
|
}, 'Accept'),
|
||||||
|
|
||||||
h('button.cancel.btn-red', {
|
h('button.cancel.btn-red', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user