diff options
author | Frankie <frankie.diamond@gmail.com> | 2018-02-01 03:57:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-01 03:57:38 +0800 |
commit | 201e0579a57d4638c8c61e99c63b7c26821a0f2a (patch) | |
tree | 275bc04ea86f48b2c5f9109c69c7b21b93c744bf /app/scripts | |
parent | 7e144680134e1bf87727f5dd048e846996e8367a (diff) | |
parent | f16535619692dd7f1c24bcc07875d60804d50ee2 (diff) | |
download | tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.gz tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.bz2 tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.lz tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.xz tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.tar.zst tangerine-wallet-browser-201e0579a57d4638c8c61e99c63b7c26821a0f2a.zip |
Merge branch 'master' into localStorage-clean-up
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/controllers/transactions.js | 4 | ||||
-rw-r--r-- | app/scripts/lib/tx-state-manager.js | 11 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 8 |
3 files changed, 23 insertions, 0 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index 9c3618e60..a3670155a 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -152,6 +152,10 @@ module.exports = class TransactionController extends EventEmitter { } } + wipeTransactions (address) { + this.txStateManager.wipeTransactions(address) + } + // Adds a tx to the txlist addTx (txMeta) { this.txStateManager.addTx(txMeta) diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index a8ef39891..051efd247 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -221,6 +221,17 @@ module.exports = class TransactionStateManger extends EventEmitter { this._setTxStatus(txId, 'failed') } + wipeTransactions (address) { + // network only tx + const txs = this.getFullTxList() + const network = this.getNetwork() + + // Filter out the ones from the current account and network + const otherAccountTxs = txs.filter((txMeta) => !(txMeta.txParams.from === address && txMeta.metamaskNetworkId === network)) + + // Update state + this._saveTxList(otherAccountTxs) + } // // PRIVATE METHODS // diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 15058188d..63815ab65 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -341,6 +341,7 @@ module.exports = class MetamaskController extends EventEmitter { addNewAccount: nodeify(this.addNewAccount, this), placeSeedWords: this.placeSeedWords.bind(this), clearSeedWordCache: this.clearSeedWordCache.bind(this), + resetAccount: this.resetAccount.bind(this), importAccountWithStrategy: this.importAccountWithStrategy.bind(this), // vault management @@ -597,6 +598,13 @@ module.exports = class MetamaskController extends EventEmitter { cb(null, this.preferencesController.getSelectedAddress()) } + resetAccount (cb) { + const selectedAddress = this.preferencesController.getSelectedAddress() + this.txController.wipeTransactions(selectedAddress) + cb(null, selectedAddress) + } + + importAccountWithStrategy (strategy, args, cb) { accountImporter.importAccount(strategy, args) .then((privateKey) => { |