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/metamask-controller.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index a570f2567..46f4a79a8 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -139,6 +139,8 @@ module.exports = class MetamaskController extends EventEmitter { const address = addresses[0] this.preferencesController.setSelectedAddress(address) } + // ensure preferences + identities controller know about all addresses + this.preferencesController.addAddresses(addresses) this.accountTracker.syncWithAddresses(addresses) }) -- cgit From eb3241ccba8e08d694f6887cae56daabace9efe9 Mon Sep 17 00:00:00 2001 From: kumavis Date: Sun, 3 Jun 2018 12:02:35 -0700 Subject: metamask-controller - clear account labels on restore from seed phrase --- app/scripts/metamask-controller.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 46f4a79a8..96f976568 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -458,7 +458,11 @@ module.exports = class MetamaskController extends EventEmitter { async createNewVaultAndRestore (password, seed) { const release = await this.createVaultMutex.acquire() try { + // clear known identities + this.preferencesController.setAddresses([]) + // create new vault const vault = await this.keyringController.createNewVaultAndRestore(password, seed) + // set new identities const accounts = await this.keyringController.getAccounts() this.preferencesController.setAddresses(accounts) this.selectFirstIdentity() -- 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/metamask-controller.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 96f976568..85c1fe09c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -356,7 +356,7 @@ module.exports = class MetamaskController extends EventEmitter { importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this), // vault management - submitPassword: nodeify(keyringController.submitPassword, keyringController), + submitPassword: nodeify(this.submitPassword, this), // network management setProviderType: nodeify(networkController.setProviderType, networkController), @@ -474,6 +474,22 @@ module.exports = class MetamaskController extends EventEmitter { } } + /* + * Submits the user's password and attempts to unlock the vault. + * Also synchronizes the preferencesController, to ensure its schema + * is up to date with known accounts once the vault is decrypted. + * + * @param {string} password - The user's password + * @returns {Promise} - The keyringController update. + */ + async submitPassword (password) { + await this.keyringController.submitPassword(password) + const accounts = await this.keyringController.getAccounts() + + await this.preferencesController.syncAddresses(accounts) + return this.keyringController.fullUpdate() + } + /** * @type Identity * @property {string} name - The account nickname. -- 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/metamask-controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts/metamask-controller.js') diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 85c1fe09c..c753fc06f 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -85,6 +85,7 @@ module.exports = class MetamaskController extends EventEmitter { this.preferencesController = new PreferencesController({ initState: initState.PreferencesController, initLangCode: opts.initLangCode, + getFirstTimeInfo: () => initState.firstTimeInfo, }) // currency controller -- cgit