From 03d17c75ae47806e9afa562cf664819b83a2b926 Mon Sep 17 00:00:00 2001 From: Bruno Barbieri Date: Wed, 31 Jan 2018 04:25:32 -0500 Subject: [PATCH] wipe only transactions for current account --- app/scripts/controllers/transactions.js | 4 ++-- app/scripts/lib/tx-state-manager.js | 12 +++++++++--- app/scripts/metamask-controller.js | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 7ca04caf1..a3670155a 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -152,8 +152,8 @@ module.exports = class TransactionController extends EventEmitter { } } - wipeTransactions(){ - this.txStateManager.wipeTransactions(); + wipeTransactions (address) { + this.txStateManager.wipeTransactions(address) } // Adds a tx to the txlist diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index 6b4a196f2..13e645a28 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -221,10 +221,16 @@ module.exports = class TransactionStateManger extends EventEmitter { this._setTxStatus(txId, 'failed') } - wipeTransactions () { - this._saveTxList([]); + wipeTransactions (address) { + // network only tx + const txs = this.getTxList() + + // Filter out the ones from the current account + const otherAccountTxs = txs.filter((txMeta) => txMeta.from !== address) + + // Update state + this._saveTxList(otherAccountTxs) } - // // PRIVATE METHODS // diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 79e3de4cc..14ce9c590 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -605,10 +605,10 @@ module.exports = class MetamaskController extends EventEmitter { cb(null, this.preferencesController.getSelectedAddress()) } - - resetAccount(cb){ - this.txController.wipeTransactions(); - cb(null, this.preferencesController.getSelectedAddress()) + resetAccount (cb) { + const selectedAddress = this.preferencesController.getSelectedAddress() + this.txController.wipeTransactions(selectedAddress) + cb(null, selectedAddress) }