aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-03-13 13:01:35 +0800
committerDan <danjm.com@gmail.com>2018-03-13 13:39:38 +0800
commitf805a2eb735ea2ae93e91df0d35c6856987fa734 (patch)
treed65280662186a2e73bbe5473b24de75107c4de53
parentc1ff927fa0e129a828d3345b21723300d5e73ef1 (diff)
downloadtangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar.gz
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar.bz2
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar.lz
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar.xz
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.tar.zst
tangerine-wallet-browser-f805a2eb735ea2ae93e91df0d35c6856987fa734.zip
Fix gas calculation and nonce / forceGasMin state setting errors; retry button shows on correct tx.
-rw-r--r--ui/app/components/customize-gas-modal/index.js6
-rw-r--r--ui/app/components/pending-tx/confirm-send-ether.js52
-rw-r--r--ui/app/components/tx-list-item.js6
3 files changed, 39 insertions, 25 deletions
diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js
index 34a93d6c6..2bac57253 100644
--- a/ui/app/components/customize-gas-modal/index.js
+++ b/ui/app/components/customize-gas-modal/index.js
@@ -117,9 +117,9 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit, gasTotal) {
updateSendAmount(maxAmount)
}
- updateGasPrice(gasPrice)
- updateGasLimit(gasLimit)
- updateGasTotal(gasTotal)
+ updateGasPrice(ethUtil.addHexPrefix(gasPrice))
+ updateGasLimit(ethUtil.addHexPrefix(gasLimit))
+ updateGasTotal(ethUtil.addHexPrefix(gasTotal))
hideModal()
}
diff --git a/ui/app/components/pending-tx/confirm-send-ether.js b/ui/app/components/pending-tx/confirm-send-ether.js
index ec61d66b4..b1e3a0374 100644
--- a/ui/app/components/pending-tx/confirm-send-ether.js
+++ b/ui/app/components/pending-tx/confirm-send-ether.js
@@ -8,7 +8,11 @@ const Identicon = require('../identicon')
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.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 { MIN_GAS_PRICE_HEX } = require('../send/send-constants')
@@ -37,7 +41,7 @@ function mapDispatchToProps (dispatch) {
return {
clearSend: () => dispatch(actions.clearSend()),
editTransaction: txMeta => {
- const { id, txParams, lastGasPrice } = txMeta
+ const { id, txParams } = txMeta
const {
gas: gasLimit,
gasPrice,
@@ -45,21 +49,6 @@ function mapDispatchToProps (dispatch) {
value: amount,
} = 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({
gasLimit,
gasPrice,
@@ -68,21 +57,36 @@ function mapDispatchToProps (dispatch) {
amount,
errors: { to: null, amount: null },
editingTransactionId: id,
- forceGasMin,
- nonce,
}))
dispatch(actions.showSendPage())
},
cancelTransaction: ({ id }) => dispatch(actions.cancelTx({ id })),
showCustomizeGasModal: (txMeta, sendGasLimit, sendGasPrice, sendGasTotal) => {
- const { id, txParams } = txMeta
+ const { id, txParams, lastGasPrice } = txMeta
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({
gasLimit: sendGasLimit || txGasLimit,
gasPrice: sendGasPrice || txGasPrice,
editingTransactionId: id,
gasTotal: sendGasTotal,
+ forceGasMin,
+ nonce,
}))
dispatch(actions.showModal({ name: 'CUSTOMIZE_GAS' }))
},
@@ -493,6 +497,14 @@ ConfirmSendEther.prototype.gatherTxMeta = function () {
const state = this.state
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)}`)
return txData
}
diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js
index 123f723be..f7d53709f 100644
--- a/ui/app/components/tx-list-item.js
+++ b/ui/app/components/tx-list-item.js
@@ -185,9 +185,11 @@ TxListItem.prototype.showRetryButton = function () {
} = this.props
const currentNonce = txParams.nonce
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 () {