|
|
@ -63,6 +63,13 @@ class PreferencesController { |
|
|
|
this.store.updateState({ currentLocale: key }) |
|
|
|
this.store.updateState({ currentLocale: key }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Updates identities to only include specified addresses. Removes identities |
|
|
|
|
|
|
|
* not included in addresses array |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {string[]} addresses An array of hex addresses |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
setAddresses (addresses) { |
|
|
|
setAddresses (addresses) { |
|
|
|
const oldIdentities = this.store.getState().identities |
|
|
|
const oldIdentities = this.store.getState().identities |
|
|
|
const identities = addresses.reduce((ids, address, index) => { |
|
|
|
const identities = addresses.reduce((ids, address, index) => { |
|
|
@ -73,6 +80,24 @@ class PreferencesController { |
|
|
|
this.store.updateState({ identities }) |
|
|
|
this.store.updateState({ identities }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Adds addresses to the identities object without removing identities |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param {string[]} addresses An array of hex addresses |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
addAddresses (addresses) { |
|
|
|
|
|
|
|
const identities = this.store.getState().identities |
|
|
|
|
|
|
|
addresses.forEach((address) => { |
|
|
|
|
|
|
|
// skip if already exists
|
|
|
|
|
|
|
|
if (identities[address]) return |
|
|
|
|
|
|
|
// add missing identity
|
|
|
|
|
|
|
|
const identityCount = Object.keys(identities).length |
|
|
|
|
|
|
|
identities[address] = { name: `Account ${identityCount + 1}`, address } |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
this.store.updateState({ identities }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Setter for the `selectedAddress` property |
|
|
|
* Setter for the `selectedAddress` property |
|
|
|
* |
|
|
|
* |
|
|
|