aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-07-07 16:50:48 +0800
committerGitHub <noreply@github.com>2017-07-07 16:50:48 +0800
commit34e2f6650d0db42b9f820d56a7acf9b72ca14da2 (patch)
treef98933bfc6725f46d85acf859c87af799a2d9b61 /app
parent8661989f516ae4455117e5158a97b4a6912a1980 (diff)
downloadtangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar.gz
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar.bz2
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar.lz
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar.xz
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.tar.zst
tangerine-wallet-browser-34e2f6650d0db42b9f820d56a7acf9b72ca14da2.zip
tx controller - clean code
Diffstat (limited to 'app')
-rw-r--r--app/scripts/controllers/transactions.js27
1 files changed, 14 insertions, 13 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 42baaaadc..b855f910c 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -241,23 +241,24 @@ module.exports = class TransactionController extends EventEmitter {
this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
if (err) {
- const errorMessage = err.message.toLowerCase()
/*
- Dont marked as failed if the error is because
- it's a "known" transaction
+ 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"
*/
-
- // geth
- if (errorMessage !== 'replacement transaction underpriced'
- // geth
- && !errorMessage.startsWith('known transaction')
- // parity
- && errorMessage !== 'gas price too low to replace'
- ) {
- this.setTxStatusFailed(txId)
- }
+ 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)
}
this.setTxHash(txId, txHash)