diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-10-07 03:50:33 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-10-07 03:50:33 +0800 |
commit | 94513cae7bf3c8310ae6a248e12a9b7dd73e306f (patch) | |
tree | daf460fe9b459b83de38bb8cf5c84e1f89e4b239 | |
parent | a32d71e8ed4c91c8ad73f4a7afc52e506ccf5247 (diff) | |
download | tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar.gz tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar.bz2 tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar.lz tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar.xz tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.tar.zst tangerine-wallet-browser-94513cae7bf3c8310ae6a248e12a9b7dd73e306f.zip |
Provide method for tx tracker to refer to all txs
-rw-r--r-- | app/scripts/controllers/transactions.js | 1 | ||||
-rw-r--r-- | app/scripts/lib/tx-state-manager.js | 8 | ||||
-rw-r--r-- | test/unit/pending-tx-test.js | 5 |
3 files changed, 11 insertions, 3 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index a0f983deb..ef659a300 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -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')) diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index cf8117864..2250403f6 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -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 }) } -}
\ No newline at end of file +} diff --git a/test/unit/pending-tx-test.js b/test/unit/pending-tx-test.js index 554bd5591..32421a44f 100644 --- a/test/unit/pending-tx-test.js +++ b/test/unit/pending-tx-test.js @@ -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') }) }) |