Fix gas calculation and nonce / forceGasMin state setting errors; retry button shows on correct tx.

feature/default_network_editable
Dan 7 years ago
parent c1ff927fa0
commit f805a2eb73
  1. 6
      ui/app/components/customize-gas-modal/index.js
  2. 52
      ui/app/components/pending-tx/confirm-send-ether.js
  3. 6
      ui/app/components/tx-list-item.js

@ -117,9 +117,9 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) {
updateSendAmount(maxAmount) updateSendAmount(maxAmount)
} }
updateGasPrice(gasPrice) updateGasPrice(ethUtil.addHexPrefix(gasPrice))
updateGasLimit(gasLimit) updateGasLimit(ethUtil.addHexPrefix(gasLimit))
updateGasTotal(gasTotal) updateGasTotal(ethUtil.addHexPrefix(gasTotal))
hideModal() hideModal()
} }

@ -8,7 +8,11 @@ const Identicon = require('../identicon')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN const BN = ethUtil.BN
const hexToBn = require('../../../../app/scripts/lib/hex-to-bn') const hexToBn = require('../../../../app/scripts/lib/hex-to-bn')
const { conversionUtil, addCurrencies } = require('../../conversion-util') const {
conversionUtil,
addCurrencies,
multiplyCurrencies
} = require('../../conversion-util')
const GasFeeDisplay = require('../send/gas-fee-display-v2') const GasFeeDisplay = require('../send/gas-fee-display-v2')
const { MIN_GAS_PRICE_HEX } = require('../send/send-constants') const { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
@ -37,7 +41,7 @@ function mapDispatchToProps (dispatch) {
return { return {
clearSend: () => dispatch(actions.clearSend()), clearSend: () => dispatch(actions.clearSend()),
editTransaction: txMeta => { editTransaction: txMeta => {
const { id, txParams, lastGasPrice } = txMeta const { id, txParams } = txMeta
const { const {
gas: gasLimit, gas: gasLimit,
gasPrice, gasPrice,
@ -45,21 +49,6 @@ function mapDispatchToProps (dispatch) {
value: amount, value: amount,
} = txParams } = txParams
let forceGasMin
let nonce
if (lastGasPrice) {
const stripped = ethUtil.stripHexPrefix(lastGasPrice)
forceGasMin = ethUtil.addHexPrefix(addCurrencies(stripped, MIN_GAS_PRICE_HEX, {
aBase: 16,
bBase: 16,
toNumericBase: 'hex',
fromDenomination: 'WEI',
toDenomination: 'GWEI',
}))
nonce = txParams.nonce
}
dispatch(actions.updateSend({ dispatch(actions.updateSend({
gasLimit, gasLimit,
gasPrice, gasPrice,
@ -68,21 +57,36 @@ function mapDispatchToProps (dispatch) {
amount, amount,
errors: { to: null, amount: null }, errors: { to: null, amount: null },
editingTransactionId: id, editingTransactionId: id,
forceGasMin,
nonce,
})) }))
dispatch(actions.showSendPage()) dispatch(actions.showSendPage())
}, },
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })), cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => { showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => {
const { id, txParams } = txMeta const { id, txParams, lastGasPrice } = txMeta
const { gas: txGasLimit, gasPrice: txGasPrice } = txParams const { gas: txGasLimit, gasPrice: txGasPrice } = txParams
let forceGasMin
let nonce
if (lastGasPrice) {
const stripped = ethUtil.stripHexPrefix(lastGasPrice)
forceGasMin = ethUtil.addHexPrefix(multiplyCurrencies(stripped, 1.1, {
multiplicandBase: 16,
multiplierBase: 10,
toNumericBase: 'hex',
fromDenomination: 'WEI',
toDenomination: 'GWEI',
}))
nonce = txParams.nonce
}
dispatch(actions.updateSend({ dispatch(actions.updateSend({
gasLimit: sendGasLimit || txGasLimit, gasLimit: sendGasLimit || txGasLimit,
gasPrice: sendGasPrice || txGasPrice, gasPrice: sendGasPrice || txGasPrice,
editingTransactionId: id, editingTransactionId: id,
gasTotal: sendGasTotal, gasTotal: sendGasTotal,
forceGasMin,
nonce,
})) }))
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' })) dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' }))
}, },
@ -493,6 +497,14 @@ ConfirmSendEther.prototype.gatherTxMeta = function () {
const state = this.state const state = this.state
const txData = clone(state.txData) || clone(props.txData) const txData = clone(state.txData) || clone(props.txData)
if (txData.lastGasPrice) {
const { gasPrice: sendGasPrice, gas: sendGasLimit } = props.send
const { gasPrice: txGasPrice, gas: txGasLimit } = txData.txParams
txData.txParams.gasPrice = sendGasPrice || txGasPrice
txData.txParams.gas = sendGasLimit || txGasLimit
}
// log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`) // log.debug(`UI has defaulted to tx meta ${JSON.stringify(txData)}`)
return txData return txData
} }

@ -185,9 +185,11 @@ TxListItem.prototype.showRetryButton = function () {
} = this.props } = this.props
const currentNonce = txParams.nonce const currentNonce = txParams.nonce
const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce) const currentNonceTxs = selectedAddressTxList.filter(tx => tx.txParams.nonce === currentNonce)
const isLastWithNonce = currentNonceTxs[currentNonceTxs.length - 1].id === transactionId const currentStatusNonceTx = currentNonceTxs.filter(tx =>
tx.status !== 'rejected' && tx.status !== 'failed')
const isLastPassingWithNonce = currentStatusNonceTx[currentStatusNonceTx.length - 1].id === transactionId
return transactionStatus === 'submitted' && isLastWithNonce && Date.now() - transactionTime > 5000 return transactionStatus === 'submitted' && isLastPassingWithNonce && Date.now() - transactionTime > 30000
} }
TxListItem.prototype.resubmit = function () { TxListItem.prototype.resubmit = function () {

Loading…
Cancel
Save