mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix background console errors on pending transaction (#8351)
* fix background console error on pending transaction
This commit is contained in:
parent
15616a33ca
commit
5263395add
@ -164,8 +164,8 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
// check the network if the nonce is ahead the tx
|
// check the network if the nonce is ahead the tx
|
||||||
// and the tx has not been mined into a block
|
// and the tx has not been mined into a block
|
||||||
|
|
||||||
dropped = await this._checkIftxWasDropped(txMeta, transactionReceipt)
|
dropped = await this._checkIftxWasDropped(txMeta, transactionReceipt)
|
||||||
|
|
||||||
// the dropped buffer is in case we ask a node for the tx
|
// the dropped buffer is in case we ask a node for the tx
|
||||||
// that is behind the node we asked for tx count
|
// that is behind the node we asked for tx count
|
||||||
// IS A SECURITY FOR HITTING NODES IN INFURA THAT COULD GO OUT
|
// IS A SECURITY FOR HITTING NODES IN INFURA THAT COULD GO OUT
|
||||||
@ -185,21 +185,19 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
// clean up
|
// clean up
|
||||||
delete this.droppedBuffer[txHash]
|
delete this.droppedBuffer[txHash]
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(e)
|
log.error(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taken || dropped) {
|
if (taken || dropped) {
|
||||||
return this.emit('tx:dropped', txId)
|
return this.emit('tx:dropped', txId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get latest transaction status
|
// get latest transaction status
|
||||||
try {
|
if (transactionReceipt?.blockNumber) {
|
||||||
const { blockNumber } = transactionReceipt
|
|
||||||
if (blockNumber) {
|
|
||||||
this.emit('tx:confirmed', txId, transactionReceipt)
|
this.emit('tx:confirmed', txId, transactionReceipt)
|
||||||
}
|
} else {
|
||||||
} catch (err) {
|
const err = new Error('Missing transaction receipt or block number.')
|
||||||
txMeta.warning = {
|
txMeta.warning = {
|
||||||
error: err.message,
|
error: err.message,
|
||||||
message: 'There was a problem loading this transaction.',
|
message: 'There was a problem loading this transaction.',
|
||||||
@ -215,10 +213,13 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
@returns {boolean}
|
@returns {boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
async _checkIftxWasDropped (txMeta, { blockNumber }) {
|
async _checkIftxWasDropped (txMeta, transactionReceipt) {
|
||||||
const { txParams: { nonce, from } } = txMeta
|
const { txParams: { nonce, from } } = txMeta
|
||||||
const nextNonce = await this.query.getTransactionCount(from)
|
const nextNonce = await this.query.getTransactionCount(from)
|
||||||
if (!blockNumber && parseInt(nextNonce) > parseInt(nonce)) {
|
if (
|
||||||
|
!transactionReceipt?.blockNumber &&
|
||||||
|
parseInt(nextNonce) > parseInt(nonce)
|
||||||
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user