mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4131 from MetaMask/emitter-cleanup
transactions - run event emitters outside context of _setTxStatus
This commit is contained in:
commit
099fc0917d
@ -2,6 +2,7 @@ const extend = require('xtend')
|
|||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const ObservableStore = require('obs-store')
|
const ObservableStore = require('obs-store')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
const log = require('loglevel')
|
||||||
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
|
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
|
||||||
const createId = require('../../lib/random-id')
|
const createId = require('../../lib/random-id')
|
||||||
const { getFinalStates } = require('./lib/util')
|
const { getFinalStates } = require('./lib/util')
|
||||||
@ -398,13 +399,19 @@ class TransactionStateManager extends EventEmitter {
|
|||||||
_setTxStatus (txId, status) {
|
_setTxStatus (txId, status) {
|
||||||
const txMeta = this.getTx(txId)
|
const txMeta = this.getTx(txId)
|
||||||
txMeta.status = status
|
txMeta.status = status
|
||||||
this.emit(`${txMeta.id}:${status}`, txId)
|
setTimeout(() => {
|
||||||
this.emit(`tx:status-update`, txId, status)
|
try {
|
||||||
if (['submitted', 'rejected', 'failed'].includes(status)) {
|
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
|
||||||
this.emit(`${txMeta.id}:finished`, txMeta)
|
this.emit(`${txMeta.id}:${status}`, txId)
|
||||||
}
|
this.emit(`tx:status-update`, txId, status)
|
||||||
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
|
if (['submitted', 'rejected', 'failed'].includes(status)) {
|
||||||
this.emit('update:badge')
|
this.emit(`${txMeta.id}:finished`, txMeta)
|
||||||
|
}
|
||||||
|
this.emit('update:badge')
|
||||||
|
} catch (error) {
|
||||||
|
log.error(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user