aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/transactions.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-07-07 18:05:39 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-07-07 18:05:39 +0800
commit092a9c9defd4d9bd2db7f969a8076c8b624d30bb (patch)
tree21b3fe9bb287c9c0ddaa0d4ecba602922acc0bab /app/scripts/controllers/transactions.js
parent34e2f6650d0db42b9f820d56a7acf9b72ca14da2 (diff)
downloadtangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar.gz
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar.bz2
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar.lz
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar.xz
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.tar.zst
tangerine-wallet-browser-092a9c9defd4d9bd2db7f969a8076c8b624d30bb.zip
fail transactions that fail in resubmit
Diffstat (limited to 'app/scripts/controllers/transactions.js')
-rw-r--r--app/scripts/controllers/transactions.js47
1 files changed, 22 insertions, 25 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index b855f910c..41d70194e 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -23,7 +23,10 @@ module.exports = class TransactionController extends EventEmitter {
this.query = opts.ethQuery
this.txProviderUtils = new TxProviderUtil(this.query)
this.blockTracker.on('rawBlock', this.checkForTxInBlock.bind(this))
- this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this))
+ // this is a little messy but until ethstore has been either
+ // removed or redone this is to guard against the race condition
+ // where ethStore hasent been populated by the results yet
+ this.blockTracker.once('latest', () => this.blockTracker.on('latest', this.resubmitPendingTxs.bind(this)))
this.blockTracker.on('sync', this.queryPendingTxs.bind(this))
this.signEthTx = opts.signTransaction
this.nonceLock = Semaphore(1)
@@ -240,27 +243,7 @@ module.exports = class TransactionController extends EventEmitter {
this.updateTx(txMeta)
this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
- if (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 = err.message.toLowerCase()
- const isKnownTx = (
- // geth
- errorMessage === 'replacement transaction underpriced'
- || errorMessage.startsWith('known transaction')
- // parity
- || errorMessage === 'gas price too low to replace'
- )
- // ignore resubmit warnings, return early
- if (isKnownTx) return cb()
-
- // encountered unknown error, set status to failed
- this.setTxStatusFailed(txId, err.message)
- return cb(err)
- }
+ if (err) return cb(err)
this.setTxHash(txId, txHash)
this.setTxStatusSubmitted(txId)
cb()
@@ -434,10 +417,24 @@ 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))
- Promise.all(pending.map(txMeta => resubmit(txMeta)))
+ pending.forEach((txMeta) => resubmit(txMeta)
.catch((reason) => {
- log.info('Problem resubmitting tx', reason)
- })
+ /*
+ 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 isKnownTx = (
+ // geth
+ errorMessage === 'replacement transaction underpriced'
+ || errorMessage.startsWith('known transaction')
+ // parity
+ || errorMessage === 'gas price too low to replace'
+ )
+ // ignore resubmit warnings, return early
+ if (!isKnownTx) this.setTxStatusFailed(txMeta.id, reason.message)
+ }))
}
_resubmitTx (txMeta, cb) {