aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-10-19 08:07:22 +0800
committerDan Finlay <dan@danfinlay.com>2017-10-19 08:07:22 +0800
commitd89394a7c9a5139ed5708ce7022fbbe2809e612a (patch)
tree577e6de357972e7f4b0316aa0bc2a06b25305aa3 /app
parent75177ce34cac589be26fb8089aac04feccdbae81 (diff)
downloadtangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar.gz
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar.bz2
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar.lz
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar.xz
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.tar.zst
tangerine-wallet-browser-d89394a7c9a5139ed5708ce7022fbbe2809e612a.zip
Make account tracking much more reactive
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/account-tracker.js11
-rw-r--r--app/scripts/metamask-controller.js14
2 files changed, 13 insertions, 12 deletions
diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js
index 13dea918f..b9959dc25 100644
--- a/app/scripts/lib/account-tracker.js
+++ b/app/scripts/lib/account-tracker.js
@@ -41,19 +41,24 @@ class AccountTracker extends EventEmitter {
syncWithAddresses (addresses) {
const accounts = this.store.getState().accounts
const locals = Object.keys(accounts)
- .map(account => accounts[account.address])
+ const toAdd = []
addresses.forEach((upstream) => {
if (!locals.includes(upstream)) {
- this.addAccount(upstream)
+ toAdd.push(upstream)
}
})
+ const toRemove = []
locals.forEach((local) => {
if (!addresses.includes(local)) {
- this.removeAccount(local)
+ toRemove.push(local)
}
})
+
+ toAdd.forEach(upstream => this.addAccount(upstream))
+ toRemove.forEach(local=> this.removeAccount(local))
+ this._updateAccounts()
}
addAccount (address) {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index eae4478b5..11a26df64 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -117,8 +117,10 @@ module.exports = class MetamaskController extends EventEmitter {
})
// If only one account exists, make sure it is selected.
- this.keyringController.store.subscribe((state) => {
- const addresses = Object.keys(state.walletNicknames || {})
+ this.keyringController.memStore.subscribe((state) => {
+ const addresses = state.keyrings.reduce((res, keyring) => {
+ return res.concat(keyring.accounts)
+ }, [])
if (addresses.length === 1) {
const address = addresses[0]
this.preferencesController.setSelectedAddress(address)
@@ -314,7 +316,7 @@ module.exports = class MetamaskController extends EventEmitter {
importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
// vault management
- submitPassword: this.submitPassword.bind(this),
+ submitPassword: nodeify(keyringController.submitPassword, keyringController),
// network management
setProviderType: nodeify(networkController.setProviderType, networkController),
@@ -470,12 +472,6 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController.setSelectedAddress(address)
}
- submitPassword (password, cb) {
- return this.keyringController.submitPassword(password)
- .then((newState) => { cb(null, newState) })
- .catch((reason) => { cb(reason) })
- }
-
//
// Opinionated Keyring Management
//