diff options
author | brunobar79 <brunobar79@gmail.com> | 2018-07-11 12:20:40 +0800 |
---|---|---|
committer | brunobar79 <brunobar79@gmail.com> | 2018-07-11 12:20:40 +0800 |
commit | 523cf9ad33d88719520ae5e7293329d133b64d4d (patch) | |
tree | d547846aa4938afbd90d242548f89f11200fe1b6 /app/scripts/controllers | |
parent | b9c2994d24e688305d63aaefd7fac88d88773ad9 (diff) | |
download | tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar.gz tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar.bz2 tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar.lz tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar.xz tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.tar.zst tangerine-wallet-browser-523cf9ad33d88719520ae5e7293329d133b64d4d.zip |
account removal is working
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/preferences.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index b314745f5..f6250dc16 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -86,6 +86,30 @@ class PreferencesController { } /** + * Removes an address from state + * + * @param {string} address A hex address + * @returns {string} the address that was removed + */ + removeAddress (address) { + const identities = this.store.getState().identities + if (!identities[address]) { + throw new Error(`${address} can't be deleted cause it was not found`) + } + delete identities[address] + this.store.updateState({ identities }) + + // If the selected account is no longer valid, + // select an arbitrary other account: + if (address === this.getSelectedAddress()) { + const selected = Object.keys(identities)[0] + this.setSelectedAddress(selected) + } + return address + } + + + /** * Adds addresses to the identities object without removing identities * * @param {string[]} addresses An array of hex addresses |