aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2018-06-05 04:43:26 +0800
committerDan Finlay <dan@danfinlay.com>2018-06-05 04:43:26 +0800
commit7382bd0847145b58db8414ae015c41778e5ebb75 (patch)
treeb080fc09f8223c89c87c354ee5aeb8d8a3ae7add /app/scripts/metamask-controller.js
parent797e63b37bc10b2aa3cb78e65024c4a68c099f0b (diff)
downloadtangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar.gz
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar.bz2
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar.lz
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar.xz
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.tar.zst
tangerine-wallet-browser-7382bd0847145b58db8414ae015c41778e5ebb75.zip
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.
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js18
1 files changed, 17 insertions, 1 deletions
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<object>} - 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.