1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

tx controller - clean code

This commit is contained in:
kumavis 2017-07-07 01:50:48 -07:00 committed by GitHub
parent 8661989f51
commit 34e2f6650d

View File

@ -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)