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

trandsactions - remove rejected transactions from history

This commit is contained in:
frankiebee 2018-06-25 15:07:54 -07:00
parent 7d3da0ae96
commit 9b92ba4c47
2 changed files with 20 additions and 0 deletions

View File

@ -288,6 +288,7 @@ class TransactionStateManager extends EventEmitter {
*/
setTxStatusRejected (txId) {
this._setTxStatus(txId, 'rejected')
this._removeTx(txId)
}
/**
@ -422,6 +423,11 @@ class TransactionStateManager extends EventEmitter {
_saveTxList (transactions) {
this.store.updateState({ transactions })
}
_removeTx (txId) {
const transactionList = this.getFullTxList()
this._saveTxList(transactionList.filter((txMeta) => txMeta.id !== txId))
}
}
module.exports = TransactionStateManager

View File

@ -288,4 +288,18 @@ describe('TransactionStateManager', function () {
})
})
describe.only('#_removeTx', function () {
it('should remove the transaction from the storage', () => {
txStateManager._saveTxList([ {id: 1} ])
txStateManager._removeTx(1)
assert(!txStateManager.getFullTxList().length, 'txList should be empty')
})
it('should only remove the transaction with ID 1 from the storage', () => {
txStateManager._saveTxList([ {id: 1}, {id: 2} ])
txStateManager._removeTx(1)
assert.equal(txStateManager.getFullTxList()[0].id, 2, 'txList should have a id of 2')
})
})
})