Skip to content

Commit

Permalink
Ensures that transactions cannot be confirmed if gas limit is below 2…
Browse files Browse the repository at this point in the history
…1000.
  • Loading branch information
danjm committed May 17, 2019
1 parent b27a4d2 commit 3a0b768
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class AdvancedTabContent extends Component {
super(props)

this.debouncedGasLimitReset = debounce((dVal) => {
console.log('------------123123123123123123----------------')
if (dVal < 21000) {
props.updateCustomGasLimit(21000)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const mapDispatchToProps = dispatch => {
}

const mergeProps = (stateProps, dispatchProps, ownProps) => {
const { gasPriceButtonGroupProps, isConfirm, txId, isSpeedUp, insufficientBalance, customGasPrice } = stateProps
const { gasPriceButtonGroupProps, isConfirm, txId, isSpeedUp, insufficientBalance, customGasPrice, customGasLimit } = stateProps
const {
updateCustomGasPrice: dispatchUpdateCustomGasPrice,
hideGasButtonGroup: dispatchHideGasButtonGroup,
Expand Down Expand Up @@ -219,7 +219,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
dispatchHideSidebar()
}
},
disableSave: insufficientBalance || (isSpeedUp && customGasPrice === 0),
disableSave: insufficientBalance || (isSpeedUp && customGasPrice === 0) || customGasLimit < 21000,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { DEFAULT_ROUTE, CONFIRM_TRANSACTION_ROUTE } from '../../helpers/constant
import {
INSUFFICIENT_FUNDS_ERROR_KEY,
TRANSACTION_ERROR_KEY,
GAS_LIMIT_TOO_LOW_ERROR_KEY,
} from '../../helpers/constants/error-keys'
import { CONFIRMED_STATUS, DROPPED_STATUS } from '../../helpers/constants/transactions'
import UserPreferencedCurrencyDisplay from '../../components/app/user-preferenced-currency-display'
Expand Down Expand Up @@ -134,6 +135,7 @@ export default class ConfirmTransactionBase extends Component {
value: amount,
} = {},
} = {},
customGas,
} = this.props

const insufficientBalance = balance && !isBalanceSufficient({
Expand All @@ -150,6 +152,13 @@ export default class ConfirmTransactionBase extends Component {
}
}

if (customGas.gasLimit < 21000) {
return {
valid: false,
errorKey: GAS_LIMIT_TOO_LOW_ERROR_KEY,
}
}

if (simulationFails) {
return {
valid: true,
Expand Down

0 comments on commit 3a0b768

Please sign in to comment.