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

Provide method for tx tracker to refer to all txs

This commit is contained in:
Dan Finlay 2017-10-06 12:50:33 -07:00
parent a32d71e8ed
commit 94513cae7b
3 changed files with 11 additions and 3 deletions

View File

@ -62,6 +62,7 @@ module.exports = class TransactionController extends EventEmitter {
retryTimePeriod: 86400000, // Retry 3500 blocks, or about 1 day. retryTimePeriod: 86400000, // Retry 3500 blocks, or about 1 day.
publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx), publishTransaction: (rawTx) => this.query.sendRawTransaction(rawTx),
getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager), getPendingTransactions: this.txStateManager.getPendingTransactions.bind(this.txStateManager),
getCompletedTransactions: this.txStateManager.getConfirmedTransactions.bind(this.txStateManager),
}) })
this.txStateManager.store.subscribe(() => this.emit('update:badge')) this.txStateManager.store.subscribe(() => this.emit('update:badge'))

View File

@ -46,6 +46,12 @@ module.exports = class TransactionStateManger extends EventEmitter {
return this.getFilteredTxList(opts) return this.getFilteredTxList(opts)
} }
getConfirmedTransactions (address) {
const opts = { status: 'confirmed' }
if (address) opts.from = address
return this.getFilteredTxList(opts)
}
addTx (txMeta) { addTx (txMeta) {
this.once(`${txMeta.id}:signed`, function (txId) { this.once(`${txMeta.id}:signed`, function (txId) {
this.removeAllListeners(`${txMeta.id}:rejected`) this.removeAllListeners(`${txMeta.id}:rejected`)

View File

@ -48,6 +48,7 @@ describe('PendingTransactionTracker', function () {
} }
}, },
getPendingTransactions: () => {return []}, getPendingTransactions: () => {return []},
getCompletedTransactions: () => {return []},
publishTransaction: () => {}, publishTransaction: () => {},
}) })
}) })
@ -82,7 +83,7 @@ describe('PendingTransactionTracker', function () {
nonce: '0x01', nonce: '0x01',
}, { count: 1 })[0] }, { count: 1 })[0]
stub = sinon.stub(pendingTxTracker, 'getPendingTransactions') stub = sinon.stub(pendingTxTracker, 'getCompletedTransactions')
.returns(txGen.txs) .returns(txGen.txs)
// THE EXPECTATION // THE EXPECTATION
@ -97,7 +98,7 @@ describe('PendingTransactionTracker', function () {
await pendingTxTracker._checkPendingTx(pending) await pendingTxTracker._checkPendingTx(pending)
// THE ASSERTION // 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')
}) })
}) })