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:
parent
8661989f51
commit
34e2f6650d
@ -241,23 +241,24 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
|
|
||||||
this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
|
this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
const errorMessage = err.message.toLowerCase()
|
|
||||||
/*
|
/*
|
||||||
Dont marked as failed if the error is because
|
Dont marked as failed if the error is a "known" transaction warning
|
||||||
it's a "known" transaction
|
|
||||||
"there is already a transaction with the same sender-nonce
|
"there is already a transaction with the same sender-nonce
|
||||||
but higher/same gas price"
|
but higher/same gas price"
|
||||||
*/
|
*/
|
||||||
|
const errorMessage = err.message.toLowerCase()
|
||||||
// geth
|
const isKnownTx = (
|
||||||
if (errorMessage !== 'replacement transaction underpriced'
|
// geth
|
||||||
// geth
|
errorMessage === 'replacement transaction underpriced'
|
||||||
&& !errorMessage.startsWith('known transaction')
|
|| errorMessage.startsWith('known transaction')
|
||||||
// parity
|
// parity
|
||||||
&& errorMessage !== 'gas price too low to replace'
|
|| errorMessage === 'gas price too low to replace'
|
||||||
) {
|
)
|
||||||
this.setTxStatusFailed(txId)
|
// ignore resubmit warnings, return early
|
||||||
}
|
if (isKnownTx) return cb()
|
||||||
|
|
||||||
|
// encountered unknown error, set status to failed
|
||||||
|
this.setTxStatusFailed(txId, err.message)
|
||||||
return cb(err)
|
return cb(err)
|
||||||
}
|
}
|
||||||
this.setTxHash(txId, txHash)
|
this.setTxHash(txId, txHash)
|
||||||
|
Loading…
Reference in New Issue
Block a user