aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-07-12 06:52:19 +0800
committerGitHub <noreply@github.com>2017-07-12 06:52:19 +0800
commit6811fb26793ca71989df2f0c0604e72cbf03ca23 (patch)
treede84f20d9ac31151c27be26af0670c09dc5ae192 /app/scripts/controllers
parentde967d2dfd2119d2468263ecb9646fd0a92df195 (diff)
parent91ef01be4c2c0a39107e1200c5f94fa5fc7defb7 (diff)
downloadtangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.gz
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.bz2
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.lz
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.xz
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.tar.zst
tangerine-wallet-browser-6811fb26793ca71989df2f0c0604e72cbf03ca23.zip
Merge branch 'master' into 3.8.5
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r--app/scripts/controllers/transactions.js36
1 files changed, 16 insertions, 20 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 41d70194e..43735a691 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -417,46 +417,42 @@ module.exports = class TransactionController extends EventEmitter {
// only try resubmitting if their are transactions to resubmit
if (!pending.length) return
const resubmit = denodeify(this._resubmitTx.bind(this))
- pending.forEach((txMeta) => resubmit(txMeta)
- .catch((reason) => {
+ pending.forEach((txMeta) => resubmit(txMeta).catch((err) => {
/*
Dont marked as failed if the error is a "known" transaction warning
"there is already a transaction with the same sender-nonce
but higher/same gas price"
*/
- const errorMessage = reason.message.toLowerCase()
+ const errorMessage = err.message.toLowerCase()
const isKnownTx = (
// geth
- errorMessage === 'replacement transaction underpriced'
- || errorMessage.startsWith('known transaction')
+ errorMessage.includes('replacement transaction underpriced')
+ || errorMessage.includes('known transaction')
// parity
- || errorMessage === 'gas price too low to replace'
+ || errorMessage.includes('gas price too low to replace')
+ || errorMessage.includes('transaction with the same hash was already imported')
+ // other
+ || errorMessage.includes('gateway timeout')
)
// ignore resubmit warnings, return early
- if (!isKnownTx) this.setTxStatusFailed(txMeta.id, reason.message)
+ if (isKnownTx) return
+ // encountered real error - transition to error state
+ this.setTxStatusFailed(txMeta.id, {
+ errCode: err.errCode || err,
+ message: err.message,
+ })
}))
}
_resubmitTx (txMeta, cb) {
const address = txMeta.txParams.from
const balance = this.ethStore.getState().accounts[address].balance
- const nonce = Number.parseInt(this.ethStore.getState().accounts[address].nonce)
- const txNonce = Number.parseInt(txMeta.txParams.nonce)
- const gtBalance = Number.parseInt(txMeta.txParams.value) > Number.parseInt(balance)
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
// if the value of the transaction is greater then the balance, fail.
- if (gtBalance) {
+ if (!this.txProviderUtils.sufficientBalance(txMeta.txParams, balance)) {
const message = 'Insufficient balance.'
- this.setTxStatusFailed(txMeta.id, message)
- cb()
- return log.error(message)
- }
-
- // if the nonce of the transaction is lower then the accounts nonce, fail.
- if (txNonce < nonce) {
- const message = 'Invalid nonce.'
- this.setTxStatusFailed(txMeta.id, message)
+ this.setTxStatusFailed(txMeta.id, { message })
cb()
return log.error(message)
}