mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Provide method for tx tracker to refer to all txs
This commit is contained in:
parent
a32d71e8ed
commit
94513cae7b
@ -62,6 +62,7 @@ module.exports = class TransactionController extends EventEmitter {
|
||||
retryTimePeriod: 86400000, // Retry 3500 blocks, or about 1 day.
|
||||
publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx),
|
||||
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
|
||||
getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
|
||||
})
|
||||
|
||||
this.txStateManager.store.subscribe(() => this.emit('update:badge'))
|
||||
|
@ -46,6 +46,12 @@ module.exports = class TransactionStateManger extends EventEmitter {
|
||||
return this.getFilteredTxList(opts)
|
||||
}
|
||||
|
||||
getConfirmedTransactions (address) {
|
||||
const opts = { status: 'confirmed' }
|
||||
if (address) opts.from = address
|
||||
return this.getFilteredTxList(opts)
|
||||
}
|
||||
|
||||
addTx (txMeta) {
|
||||
this.once(`${txMeta.id}:signed`, function (txId) {
|
||||
this.removeAllListeners(`${txMeta.id}:rejected`)
|
||||
@ -242,4 +248,4 @@ module.exports = class TransactionStateManger extends EventEmitter {
|
||||
_saveTxList (transactions) {
|
||||
this.store.updateState({ transactions })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ describe('PendingTransactionTracker', function () {
|
||||
}
|
||||
},
|
||||
getPendingTransactions: () => {return []},
|
||||
getCompletedTransactions: () => {return []},
|
||||
publishTransaction: () => {},
|
||||
})
|
||||
})
|
||||
@ -82,7 +83,7 @@ describe('PendingTransactionTracker', function () {
|
||||
nonce: '0x01',
|
||||
}, { count: 1 })[0]
|
||||
|
||||
stub = sinon.stub(pendingTxTracker, 'getPendingTransactions')
|
||||
stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
|
||||
.returns(txGen.txs)
|
||||
|
||||
// THE EXPECTATION
|
||||
@ -97,7 +98,7 @@ describe('PendingTransactionTracker', function () {
|
||||
await pendingTxTracker._checkPendingTx(pending)
|
||||
|
||||
// THE ASSERTION
|
||||
return sinon.assert.calledWith(spy, pending.id, 'tx failed should be emitted')
|
||||
assert.ok(spy.calledWith(pending.id), 'tx failed should be emitted')
|
||||
})
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user