From d4cdd1a0f304141a6ce6d5c817953f06080a6299 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 3 Jun 2018 11:27:25 -0700 Subject: metamask - update preferences controller identities on keyring controller update --- app/scripts/controllers/preferences.js | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index a4ff1207e..38136e174 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -63,6 +63,13 @@ class PreferencesController { this.store.updateState({ currentLocale: key }) } + /** + * Updates identities to only include specified addresses. Removes identities + * not included in addresses array + * + * @param {arrays} addresses An array of hex addresses + * + */ setAddresses (addresses) { const oldIdentities = this.store.getState().identities const identities = addresses.reduce((ids, address, index) => { @@ -73,6 +80,24 @@ class PreferencesController { this.store.updateState({ identities }) } + /** + * Adds addresses to the identities object without removing identities + * + * @param {arrays} 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 * @@ -111,7 +136,7 @@ class PreferencesController { /** * Adds a new token to the token array, or updates the token if passed an address that already exists. * Modifies the existing tokens array from the store. All objects in the tokens array array AddedToken objects. - * @see AddedToken {@link AddedToken} + * @see AddedToken {@link AddedToken} * * @param {string} rawAddress Hex address of the token contract. May or may not be a checksum address. * @param {string} symbol The symbol of the token @@ -197,7 +222,7 @@ class PreferencesController { } /** - * Setter for the `currentAccountTab` property + * Setter for the `currentAccountTab` property * * @param {string} currentAccountTab Specifies the new tab to be marked as current * @returns {Promise} Promise resolves with undefined @@ -215,7 +240,7 @@ class PreferencesController { * The returned list will have a max length of 2. If the _url currently exists it the list, it will be moved to the * end of the list. The current list is modified and returned as a promise. * - * @param {string} _url The rpc url to add to the frequentRpcList. + * @param {string} _url The rpc url to add to the frequentRpcList. * @returns {Promise} The updated frequentRpcList. * */ -- cgit From 54a9c62fd66a367ebca8ae963c080eb8eb9db0a7 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 3 Jun 2018 11:30:11 -0700 Subject: preferences controller - jsdoc fix --- app/scripts/controllers/preferences.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 38136e174..760868ddf 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -67,7 +67,7 @@ class PreferencesController { * Updates identities to only include specified addresses. Removes identities * not included in addresses array * - * @param {arrays} addresses An array of hex addresses + * @param {string[]} addresses An array of hex addresses * */ setAddresses (addresses) { @@ -83,7 +83,7 @@ class PreferencesController { /** * Adds addresses to the identities object without removing identities * - * @param {arrays} addresses An array of hex addresses + * @param {string[]} addresses An array of hex addresses * */ addAddresses (addresses) { -- cgit From 7382bd0847145b58db8414ae015c41778e5ebb75 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 13:43:26 -0700 Subject: Add identity synchronizing code Addresses #4475, where entries in the identities object do not necessarily have corresponding accounts in the vault. On password submission, this change passes known accounts to the preferencesController (responsible for nickname management), and removes unknown entries. Includes "TODO" notes for where we could log the issue to sentry or notify the user. --- app/scripts/controllers/preferences.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 760868ddf..426ee5a02 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -98,6 +98,37 @@ class PreferencesController { this.store.updateState({ identities }) } + /* + * Synchronizes identity entries with known accounts. + * Removes any unknown identities, and returns the resulting selected address. + * + * @param {Array} addresses known to the vault. + * @returns {Promise} selectedAddress the selected address. + */ + syncAddresses (addresses) { + const identities = this.store.getState().identities + + Object.keys(identities).forEach((identity) => { + if (!addresses.includes(identity)) { + delete identities[identity] + + // TODO: Report the bug to Sentry including the now-lost identity. + // TODO: Inform the user of the lost identity. + } + }) + + this.store.updateState({ identities }) + this.addAddresses(addresses) + + let selected = this.getSelectedAddress() + if (!addresses.includes(selected)) { + selected = addresses[0] + this.setSelectedAddress(selected) + } + + return selected + } + /** * Setter for the `selectedAddress` property * -- cgit From f5d4acf53b2d518df1b2c0b9b983bbc5224fb670 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:01:05 -0700 Subject: Add minimal user notification of issue. --- app/scripts/controllers/preferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 426ee5a02..8cb846476 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -113,7 +113,7 @@ class PreferencesController { delete identities[identity] // TODO: Report the bug to Sentry including the now-lost identity. - // TODO: Inform the user of the lost identity. + alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.') } }) -- cgit From 8fcaa2cf56936388ef8dfc528ecbd2354adb201e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:05:56 -0700 Subject: Persist lost identities to storage for later analysis --- app/scripts/controllers/preferences.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 8cb846476..38e93dea8 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -28,6 +28,7 @@ class PreferencesController { featureFlags: {}, currentLocale: opts.initLangCode, identities: {}, + lostIdentities: {}, }, opts.initState) this.store = new ObservableStore(initState) } @@ -106,18 +107,19 @@ class PreferencesController { * @returns {Promise} selectedAddress the selected address. */ syncAddresses (addresses) { - const identities = this.store.getState().identities + let { identities, lostIdentities } = this.store.getState() Object.keys(identities).forEach((identity) => { if (!addresses.includes(identity)) { delete identities[identity] + lostIdentities[identity] = identities[identity] // TODO: Report the bug to Sentry including the now-lost identity. alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.') } }) - this.store.updateState({ identities }) + this.store.updateState({ identities, lostIdentities }) this.addAddresses(addresses) let selected = this.getSelectedAddress() -- cgit From fd1ce4d741cc5992cc5d3d6109dc46cddf871ec2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:21:46 -0700 Subject: Begin adding unconfigured notifier --- app/scripts/controllers/preferences.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 38e93dea8..f822f61c5 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -1,6 +1,8 @@ const ObservableStore = require('obs-store') const normalizeAddress = require('eth-sig-util').normalize const extend = require('xtend') +const BugNotifier = require('../lib/bug-notifier') +const notifier = new BugNotifier() class PreferencesController { @@ -30,6 +32,7 @@ class PreferencesController { identities: {}, lostIdentities: {}, }, opts.initState) + this.store = new ObservableStore(initState) } // PUBLIC METHODS @@ -108,17 +111,27 @@ class PreferencesController { */ syncAddresses (addresses) { let { identities, lostIdentities } = this.store.getState() - Object.keys(identities).forEach((identity) => { if (!addresses.includes(identity)) { delete identities[identity] lostIdentities[identity] = identities[identity] - - // TODO: Report the bug to Sentry including the now-lost identity. - alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.') } }) + // Identities are no longer present. + if (Object.keys(lostIdentities).length > 0) { + + // timeout to prevent blocking the thread: + setTimeout(() => { + alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.') + }, 10) + + // Notify our servers: + const uri = + notifier.notify(uri, { accounts: Object.keys(lostIdentities) }) + .catch(log.error) + } + this.store.updateState({ identities, lostIdentities }) this.addAddresses(addresses) -- cgit From f3b385cb093cbd9706643c0feae2702adfcc11da Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:22:34 -0700 Subject: Add reporting uri --- app/scripts/controllers/preferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index f822f61c5..cff70272f 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -127,7 +127,7 @@ class PreferencesController { }, 10) // Notify our servers: - const uri = + const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' notifier.notify(uri, { accounts: Object.keys(lostIdentities) }) .catch(log.error) } -- cgit From b858cc4b1bf13c7c813fe48bb0b12f9eb3cc4a0d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:24:45 -0700 Subject: Only notify first time lost ids are detected --- app/scripts/controllers/preferences.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index cff70272f..038bab37b 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -111,15 +111,17 @@ class PreferencesController { */ syncAddresses (addresses) { let { identities, lostIdentities } = this.store.getState() + + let newlyLost = {} Object.keys(identities).forEach((identity) => { if (!addresses.includes(identity)) { delete identities[identity] - lostIdentities[identity] = identities[identity] + newlyLost[identity] = identities[identity] } }) // Identities are no longer present. - if (Object.keys(lostIdentities).length > 0) { + if (Object.keys(newlyLost).length > 0) { // timeout to prevent blocking the thread: setTimeout(() => { @@ -130,6 +132,10 @@ class PreferencesController { const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' notifier.notify(uri, { accounts: Object.keys(lostIdentities) }) .catch(log.error) + + for (let key in newlyLost) { + lostIdentities[key] = newlyLost[key] + } } this.store.updateState({ identities, lostIdentities }) -- cgit From d07c664b2c31469d84dd3c84a929b8d4ba552e8c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:30:24 -0700 Subject: Fine tune error posting --- app/scripts/controllers/preferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 038bab37b..18254af4b 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -130,7 +130,7 @@ class PreferencesController { // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' - notifier.notify(uri, { accounts: Object.keys(lostIdentities) }) + notifier.notify(uri, { accounts: Object.keys(newlyLost) }) .catch(log.error) for (let key in newlyLost) { -- cgit From 3bfc40c2848d3e814fca663fa039c261097976c3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:59:46 -0700 Subject: Add version to report --- app/scripts/controllers/preferences.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 18254af4b..39ca16f28 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -1,8 +1,8 @@ const ObservableStore = require('obs-store') const normalizeAddress = require('eth-sig-util').normalize const extend = require('xtend') -const BugNotifier = require('../lib/bug-notifier') -const notifier = new BugNotifier() +const notifier = require('../lib/bug-notifier') +const { version } = require('../../manifest.json') class PreferencesController { @@ -130,7 +130,7 @@ class PreferencesController { // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' - notifier.notify(uri, { accounts: Object.keys(newlyLost) }) + notifier.notify(uri, { accounts: Object.keys(newlyLost), version }) .catch(log.error) for (let key in newlyLost) { -- cgit From 0eacee8e45a3f9c3cbedf99ac79d0c37a8a9f87f Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:03:31 -0700 Subject: Add first time info to bug report --- app/scripts/controllers/preferences.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 39ca16f28..70fbd1224 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -33,6 +33,8 @@ class PreferencesController { lostIdentities: {}, }, opts.initState) + this.getFirstTimeInfo = opts.getFirstTimeInfo || null + this.store = new ObservableStore(initState) } // PUBLIC METHODS @@ -130,7 +132,8 @@ class PreferencesController { // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' - notifier.notify(uri, { accounts: Object.keys(newlyLost), version }) + const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} + notifier.notify(uri, { accounts: Object.keys(newlyLost), version, firstTimeInfo }) .catch(log.error) for (let key in newlyLost) { -- cgit From 7b87afb4b72b36a581912365501295b685007869 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:06:21 -0700 Subject: Add bug info under metadata key --- app/scripts/controllers/preferences.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 70fbd1224..0bfb3b5a3 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -133,7 +133,13 @@ class PreferencesController { // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} - notifier.notify(uri, { accounts: Object.keys(newlyLost), version, firstTimeInfo }) + notifier.notify(uri, { + accounts: Object.keys(newlyLost), + metadata: { + version, + firstTimeInfo, + }, + }) .catch(log.error) for (let key in newlyLost) { -- cgit From 22754e3e1f496b2dde140eea56a88bc7237fda42 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:10:51 -0700 Subject: Linted --- app/scripts/controllers/preferences.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 0bfb3b5a3..b5171214f 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -2,6 +2,7 @@ const ObservableStore = require('obs-store') const normalizeAddress = require('eth-sig-util').normalize const extend = require('xtend') const notifier = require('../lib/bug-notifier') +const log = require('loglevel') const { version } = require('../../manifest.json') class PreferencesController { -- cgit From 415ab2d5349903b3cc330b1fdc19afb737eca838 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:17:03 -0700 Subject: Do not alert to user --- app/scripts/controllers/preferences.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index b5171214f..30e00f298 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -126,11 +126,6 @@ class PreferencesController { // Identities are no longer present. if (Object.keys(newlyLost).length > 0) { - // timeout to prevent blocking the thread: - setTimeout(() => { - alert('Error 4486: MetaMask has encountered a very strange error. Please open a support issue immediately at support@metamask.io.') - }, 10) - // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} -- cgit From f07ca73e07c15e338e2f2d2ab794fa1c95619056 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:18:12 -0700 Subject: Add comment --- app/scripts/controllers/preferences.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 30e00f298..b63dd5fcc 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -146,6 +146,8 @@ class PreferencesController { this.store.updateState({ identities, lostIdentities }) this.addAddresses(addresses) + // If the selected account is no longer valid, + // select an arbitrary other account: let selected = this.getSelectedAddress() if (!addresses.includes(selected)) { selected = addresses[0] -- cgit From ae156e10872faae3040540a7f440af5882a79ec2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:26:01 -0700 Subject: Mock notifier in test --- app/scripts/controllers/preferences.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index b63dd5fcc..942546528 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -35,6 +35,7 @@ class PreferencesController { }, opts.initState) this.getFirstTimeInfo = opts.getFirstTimeInfo || null + this.notifier = opts.notifier || notifier this.store = new ObservableStore(initState) } @@ -129,7 +130,7 @@ class PreferencesController { // Notify our servers: const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} - notifier.notify(uri, { + this.notifier.notify(uri, { accounts: Object.keys(newlyLost), metadata: { version, -- cgit From 41f292437dd6c7144e36efa8609a419c7dd88da7 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:34:38 -0700 Subject: Record identity before deleting it --- app/scripts/controllers/preferences.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 942546528..2fe009f9a 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -119,8 +119,8 @@ class PreferencesController { let newlyLost = {} Object.keys(identities).forEach((identity) => { if (!addresses.includes(identity)) { - delete identities[identity] newlyLost[identity] = identities[identity] + delete identities[identity] } }) -- cgit From 20bdba3d1710a070d06c2a395f92d948b9396d47 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 5 Jun 2018 11:51:27 -0700 Subject: diagnostics - rewrite bug-notifier as diagnostics-reporter --- app/scripts/controllers/preferences.js | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 2fe009f9a..a5d8cc27b 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -1,9 +1,7 @@ const ObservableStore = require('obs-store') const normalizeAddress = require('eth-sig-util').normalize const extend = require('xtend') -const notifier = require('../lib/bug-notifier') -const log = require('loglevel') -const { version } = require('../../manifest.json') + class PreferencesController { @@ -34,8 +32,7 @@ class PreferencesController { lostIdentities: {}, }, opts.initState) - this.getFirstTimeInfo = opts.getFirstTimeInfo || null - this.notifier = opts.notifier || notifier + this.diagnostics = opts.diagnostics this.store = new ObservableStore(initState) } @@ -128,17 +125,9 @@ class PreferencesController { if (Object.keys(newlyLost).length > 0) { // Notify our servers: - const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts' - const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {} - this.notifier.notify(uri, { - accounts: Object.keys(newlyLost), - metadata: { - version, - firstTimeInfo, - }, - }) - .catch(log.error) + if (this.diagnostics) this.diagnostics.reportOrphans(newlyLost) + // store lost accounts for (let key in newlyLost) { lostIdentities[key] = newlyLost[key] } -- cgit From 3cc85c219ef565267093de80e709e53d57b38d4e Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Tue, 5 Jun 2018 14:06:56 -0700 Subject: Add account type assertion to PreferencesController#setAccountLabel --- app/scripts/controllers/preferences.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index a5d8cc27b..8411e3a28 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -247,6 +247,7 @@ class PreferencesController { * @return {Promise} */ setAccountLabel (account, label) { + if (!account) throw new Error('setAccountLabel requires a valid address, got ' + String(account)) const address = normalizeAddress(account) const {identities} = this.store.getState() identities[address] = identities[address] || {} -- cgit From a8f745f9fe74751b87f500af3857b66d4c80f45e Mon Sep 17 00:00:00 2001 From: brunobar79 Date: Mon, 2 Jul 2018 18:49:33 -0400 Subject: eslint --fix . --- app/scripts/controllers/preferences.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/scripts/controllers/preferences.js') diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 8411e3a28..b314745f5 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -111,9 +111,9 @@ class PreferencesController { * @returns {Promise} selectedAddress the selected address. */ syncAddresses (addresses) { - let { identities, lostIdentities } = this.store.getState() + const { identities, lostIdentities } = this.store.getState() - let newlyLost = {} + const newlyLost = {} Object.keys(identities).forEach((identity) => { if (!addresses.includes(identity)) { newlyLost[identity] = identities[identity] @@ -128,7 +128,7 @@ class PreferencesController { if (this.diagnostics) this.diagnostics.reportOrphans(newlyLost) // store lost accounts - for (let key in newlyLost) { + for (const key in newlyLost) { lostIdentities[key] = newlyLost[key] } } -- cgit