diff --git a/src/sagas/networkSettings.js b/src/sagas/networkSettings.js index 2a49e1ba8..613581cd5 100644 --- a/src/sagas/networkSettings.js +++ b/src/sagas/networkSettings.js @@ -12,7 +12,7 @@ import { types, reloadWalletRequested, onExceptionCaptured, - networkSettingsUpdateReady + networkSettingsUpdateReady, } from '../actions'; import { NETWORK_MAINNET, @@ -23,13 +23,13 @@ import { STAGE_DEV_PRIVNET, STAGE_TESTNET, WALLET_SERVICE_REQUEST_TIMEOUT, - NETWORK_PRIVATENET + NETWORK_PRIVATENET, } from '../constants'; import { getFullnodeNetwork, getWalletServiceNetwork, } from './helpers'; -import { REGISTERED_TOKENS_KEY, STORE } from '../store'; +import { STORE } from '../store'; import { isWalletServiceEnabled } from './wallet'; import { logger } from '../logger'; @@ -299,8 +299,8 @@ export function* persistNetworkSettings(action) { return; } - // Remove registered tokens - STORE.removeItem(REGISTERED_TOKENS_KEY); + // Remove registered tokens only + yield call([wallet.storage, wallet.storage.cleanStorage], false, false, true) // Stop wallet and clean its storage without clean its access data. wallet.stop({ cleanStorage: true, cleanAddresses: true }); // This action should clean the tokens history on redux. diff --git a/src/store.js b/src/store.js index 88d6fcb93..9bf8cd037 100644 --- a/src/store.js +++ b/src/store.js @@ -143,6 +143,22 @@ class HybridStore extends MemoryStore { contracts[ncId] = ncValue; STORE.setItem(REGISTERED_NANO_CONTRACTS_KEY, contracts) } + + /** + * Clean the storage. + * @param {boolean} cleanHistory if we should clean the transaction history. + * @param {boolean} cleanAddresses if we should clean the addresses. + * @param {boolean} cleanTokens if we should clean the registered tokens. + * @async + * @returns {Promise} + */ + async cleanStorage(cleanHistory = false, cleanAddresses = false, cleanTokens = false) { + super.cleanStorage(cleanHistory, cleanAddresses, cleanTokens); + if (cleanTokens) { + // Remove from the cache + STORE.removeItem(REGISTERED_TOKENS_KEY); + } + } } /* eslint-enable class-methods-use-this */