From 970fbd797a96a4e86175181ad30d0b7216d9d2c9 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 14 Oct 2017 12:05:00 +0000 Subject: [PATCH 01/18] fix(package): update react-simple-file-input to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b7b2056a..fb1621e29 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "react-markdown": "^2.3.0", "react-redux": "^5.0.5", "react-select": "^1.0.0-rc.2", - "react-simple-file-input": "^1.0.0", + "react-simple-file-input": "^2.0.0", "react-tooltip-component": "^0.3.0", "readable-stream": "^2.3.3", "redux": "^3.0.5", From ab31eb6a17f5ab230fe47df66344cbce59223306 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Oct 2017 13:09:41 -0700 Subject: [PATCH 02/18] Select first account on new vault creation --- app/scripts/metamask-controller.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index a742f3cba..2a45e413b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -336,7 +336,7 @@ module.exports = class MetamaskController extends EventEmitter { // KeyringController setLocked: nodeify(keyringController.setLocked, keyringController), - createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain, keyringController), + createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore, keyringController), addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController), @@ -458,6 +458,17 @@ module.exports = class MetamaskController extends EventEmitter { // Vault Management // + createNewVaultAndKeychain (password, cb) { + this.keyringController.createNewVaultAndKeychain(password) + .then((vault) => { + const { identities } = vault + const address = Object.keys(identities)[0] + this.preferencesController.setSelectedAddress(address) + cb(null, vault) + }) + .catch(reason => cb(reason)) + } + submitPassword (password, cb) { return this.keyringController.submitPassword(password) .then((newState) => { cb(null, newState) }) From d7f384485d2af15ec694208b9ef068c18c7dc91d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Oct 2017 13:19:57 -0700 Subject: [PATCH 03/18] Select first account when restoring seed Fixes #2348 --- app/scripts/metamask-controller.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2a45e413b..8a51fdd8d 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -337,7 +337,7 @@ module.exports = class MetamaskController extends EventEmitter { // KeyringController setLocked: nodeify(keyringController.setLocked, keyringController), createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), - createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore, keyringController), + createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this), addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController), exportAccount: nodeify(keyringController.exportAccount, keyringController), @@ -461,14 +461,28 @@ module.exports = class MetamaskController extends EventEmitter { createNewVaultAndKeychain (password, cb) { this.keyringController.createNewVaultAndKeychain(password) .then((vault) => { - const { identities } = vault - const address = Object.keys(identities)[0] + this.selectFirstIdentity(vault) this.preferencesController.setSelectedAddress(address) cb(null, vault) }) .catch(reason => cb(reason)) } + createNewVaultAndRestore (password, seed, cb) { + this.keyringController.createNewVaultAndRestore(password, seed) + .then((vault) => { + this.selectFirstIdentity(vault) + cb(null, vault) + }) + .catch(reason => cb(reason)) + } + + selectFirstIdentity (vault) { + const { identities } = vault + const address = Object.keys(identities)[0] + this.preferencesController.setSelectedAddress(address) + } + submitPassword (password, cb) { return this.keyringController.submitPassword(password) .then((newState) => { cb(null, newState) }) From 50e8599988c54bbf9ee0e9f324f79f5835fa6727 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Oct 2017 13:25:27 -0700 Subject: [PATCH 04/18] Promisify metamask-controller vault creating methods --- app/scripts/metamask-controller.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8a51fdd8d..4b11f6024 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -336,8 +336,8 @@ module.exports = class MetamaskController extends EventEmitter { // KeyringController setLocked: nodeify(keyringController.setLocked, keyringController), - createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), - createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this), + createNewVaultAndKeychain: nodeify(this.createNewVaultAndKeychain, this), + createNewVaultAndRestore: nodeify(this.createNewVaultAndRestore, this), addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController), exportAccount: nodeify(keyringController.exportAccount, keyringController), @@ -458,23 +458,16 @@ module.exports = class MetamaskController extends EventEmitter { // Vault Management // - createNewVaultAndKeychain (password, cb) { - this.keyringController.createNewVaultAndKeychain(password) - .then((vault) => { - this.selectFirstIdentity(vault) - this.preferencesController.setSelectedAddress(address) - cb(null, vault) - }) - .catch(reason => cb(reason)) + async createNewVaultAndKeychain (password, cb) { + const vault = await this.keyringController.createNewVaultAndKeychain(password) + this.selectFirstIdentity(vault) + return vault } - createNewVaultAndRestore (password, seed, cb) { - this.keyringController.createNewVaultAndRestore(password, seed) - .then((vault) => { - this.selectFirstIdentity(vault) - cb(null, vault) - }) - .catch(reason => cb(reason)) + async createNewVaultAndRestore (password, seed, cb) { + const vault = await this.keyringController.createNewVaultAndRestore(password, seed) + this.selectFirstIdentity(vault) + return vault } selectFirstIdentity (vault) { From 9c45af3e2567e2afab9162f27fd4919cfa0957c5 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Oct 2017 13:26:16 -0700 Subject: [PATCH 05/18] Bump changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65f75ee18..1c82c59be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Current Master - Fix bug where web3 API was sometimes injected after the page loaded. +- Fix bug where first account was sometimes not selected correctly after creating or restoring a vault. ## 3.11.0 2017-10-11 From 7032edf32b43e94a7f58c7bcb068da63fa6bda1b Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 11:13:14 -0700 Subject: [PATCH 06/18] Stop tracking old account balances after restore vault Per @kgserrano note --- app/scripts/metamask-controller.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 4b11f6024..b6a3749e4 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -459,17 +459,30 @@ module.exports = class MetamaskController extends EventEmitter { // async createNewVaultAndKeychain (password, cb) { + this.forgetOldAccounts() const vault = await this.keyringController.createNewVaultAndKeychain(password) this.selectFirstIdentity(vault) return vault } async createNewVaultAndRestore (password, seed, cb) { + this.forgetOldAccounts() const vault = await this.keyringController.createNewVaultAndRestore(password, seed) this.selectFirstIdentity(vault) return vault } + forgetOldAccounts () { + const { accountTracker } = this + let oldAccounts = [] + try { + oldAccounts = Object.keys(accountTracker.store.getState().accounts) + } catch (e) { + log.warn('Could not load old accounts to forget', e) + } + oldAccounts.forEach(addr => accountTracker.removeAccount(addr)) + } + selectFirstIdentity (vault) { const { identities } = vault const address = Object.keys(identities)[0] From ea79eca8eb19cf7ce375e03ad8cbde010299936c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 12:21:22 -0700 Subject: [PATCH 07/18] Add validation to balance constructor --- app/scripts/controllers/balance.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/scripts/controllers/balance.js b/app/scripts/controllers/balance.js index 4fa4c78fe..f83f294cc 100644 --- a/app/scripts/controllers/balance.js +++ b/app/scripts/controllers/balance.js @@ -5,7 +5,9 @@ const BN = require('ethereumjs-util').BN class BalanceController { constructor (opts = {}) { + this._validateParams(opts) const { address, accountTracker, txController, blockTracker } = opts + this.address = address this.accountTracker = accountTracker this.txController = txController @@ -65,6 +67,14 @@ class BalanceController { return pending } + _validateParams (opts) { + const { address, accountTracker, txController, blockTracker } = opts + if (!address || !accountTracker || !txController || !blockTracker) { + const error = 'Cannot construct a balance checker without address, accountTracker, txController, and blockTracker.' + throw new Error(error) + } + } + } module.exports = BalanceController From 9cc1e8a6d867b7f0663c55b017b471132f6a719e Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 14:22:04 -0700 Subject: [PATCH 08/18] Refresh computed balances controller when restoring vault --- app/scripts/controllers/computed-balances.js | 4 ++++ app/scripts/metamask-controller.js | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/controllers/computed-balances.js b/app/scripts/controllers/computed-balances.js index 2479e1b3a..3479eae2b 100644 --- a/app/scripts/controllers/computed-balances.js +++ b/app/scripts/controllers/computed-balances.js @@ -25,6 +25,10 @@ class ComputedbalancesController { } } + forgetAllBalances () { + this.balances = {} + } + _initBalanceUpdating () { const store = this.accountTracker.store.getState() this.addAnyAccountsFromStore(store) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b6a3749e4..b312106dd 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -473,7 +473,7 @@ module.exports = class MetamaskController extends EventEmitter { } forgetOldAccounts () { - const { accountTracker } = this + const { accountTracker, balancesController } = this let oldAccounts = [] try { oldAccounts = Object.keys(accountTracker.store.getState().accounts) @@ -481,6 +481,7 @@ module.exports = class MetamaskController extends EventEmitter { log.warn('Could not load old accounts to forget', e) } oldAccounts.forEach(addr => accountTracker.removeAccount(addr)) + balancesController.forgetAllBalances() } selectFirstIdentity (vault) { From 75177ce34cac589be26fb8089aac04feccdbae81 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 15:08:34 -0700 Subject: [PATCH 09/18] Make account tracking more reactive We were doing a lot of conditional observation & updating. Pulled out a bunch of that for generic observer/syncers. --- app/scripts/controllers/computed-balances.js | 22 +++++++++++++------- app/scripts/lib/account-tracker.js | 18 ++++++++++++++++ app/scripts/metamask-controller.js | 22 +------------------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/scripts/controllers/computed-balances.js b/app/scripts/controllers/computed-balances.js index 3479eae2b..009405d29 100644 --- a/app/scripts/controllers/computed-balances.js +++ b/app/scripts/controllers/computed-balances.js @@ -25,22 +25,28 @@ class ComputedbalancesController { } } - forgetAllBalances () { - this.balances = {} - } - _initBalanceUpdating () { const store = this.accountTracker.store.getState() - this.addAnyAccountsFromStore(store) - this.accountTracker.store.subscribe(this.addAnyAccountsFromStore.bind(this)) + this.syncAllAccountsFromStore(store) + this.accountTracker.store.subscribe(this.syncAllAccountsFromStore.bind(this)) } - addAnyAccountsFromStore(store) { - const balances = store.accounts + syncAllAccountsFromStore(store) { + const upstream = Object.keys(store.accounts) + const balances = Object.keys(this.balances) + .map(address => this.balances[address]) + // Follow new addresses for (let address in balances) { this.trackAddressIfNotAlready(address) } + + // Unfollow old ones + balances.forEach(({ address }) => { + if (!upstream.includes(address)) { + delete this.balances[address] + } + }) } trackAddressIfNotAlready (address) { diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index cdc21282d..13dea918f 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -38,6 +38,24 @@ class AccountTracker extends EventEmitter { // public // + syncWithAddresses (addresses) { + const accounts = this.store.getState().accounts + const locals = Object.keys(accounts) + .map(account => accounts[account.address]) + + addresses.forEach((upstream) => { + if (!locals.includes(upstream)) { + this.addAccount(upstream) + } + }) + + locals.forEach((local) => { + if (!addresses.includes(local)) { + this.removeAccount(local) + } + }) + } + addAccount (address) { const accounts = this.store.getState().accounts accounts[address] = {} diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index b312106dd..eae4478b5 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -123,13 +123,7 @@ module.exports = class MetamaskController extends EventEmitter { const address = addresses[0] this.preferencesController.setSelectedAddress(address) } - }) - this.keyringController.on('newAccount', (address) => { - this.preferencesController.setSelectedAddress(address) - this.accountTracker.addAccount(address) - }) - this.keyringController.on('removedAccount', (address) => { - this.accountTracker.removeAccount(address) + this.accountTracker.syncWithAddresses(addresses) }) // address book controller @@ -459,31 +453,17 @@ module.exports = class MetamaskController extends EventEmitter { // async createNewVaultAndKeychain (password, cb) { - this.forgetOldAccounts() const vault = await this.keyringController.createNewVaultAndKeychain(password) this.selectFirstIdentity(vault) return vault } async createNewVaultAndRestore (password, seed, cb) { - this.forgetOldAccounts() const vault = await this.keyringController.createNewVaultAndRestore(password, seed) this.selectFirstIdentity(vault) return vault } - forgetOldAccounts () { - const { accountTracker, balancesController } = this - let oldAccounts = [] - try { - oldAccounts = Object.keys(accountTracker.store.getState().accounts) - } catch (e) { - log.warn('Could not load old accounts to forget', e) - } - oldAccounts.forEach(addr => accountTracker.removeAccount(addr)) - balancesController.forgetAllBalances() - } - selectFirstIdentity (vault) { const { identities } = vault const address = Object.keys(identities)[0] From d89394a7c9a5139ed5708ce7022fbbe2809e612a Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 17:07:22 -0700 Subject: [PATCH 10/18] Make account tracking much more reactive --- app/scripts/lib/account-tracker.js | 11 ++++++++--- app/scripts/metamask-controller.js | 14 +++++--------- 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 // From 21bde66e16c3a41a1cb8fca5e9e9e3e97875d23b Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 17:14:26 -0700 Subject: [PATCH 11/18] Remove account-tracker from keyringController --- app/scripts/metamask-controller.js | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index dd34cec97..366bb6d98 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -96,7 +96,6 @@ module.exports = class MetamaskController extends EventEmitter { // key mgmt this.keyringController = new KeyringController({ initState: initState.KeyringController, - accountTracker: this.accountTracker, getNetwork: this.networkController.getNetworkState.bind(this.networkController), encryptor: opts.encryptor || undefined, }) diff --git a/package.json b/package.json index 3843a8a41..2e8faadee 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "eth-contract-metadata": "^1.1.4", "eth-hd-keyring": "^1.2.1", "eth-json-rpc-filters": "^1.2.2", - "eth-keyring-controller": "^2.1.0", + "eth-keyring-controller": "^2.1.1", "eth-phishing-detect": "^1.1.4", "eth-query": "^2.1.2", "eth-sig-util": "^1.4.0", From 4dc494fdd10603d023962fe3a3ff844c77c46d4c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 17:14:42 -0700 Subject: [PATCH 12/18] Fix bug that breaks ui dev mode --- ui/app/reducers.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/app/reducers.js b/ui/app/reducers.js index 6a2f44534..1cded7ca7 100644 --- a/ui/app/reducers.js +++ b/ui/app/reducers.js @@ -43,7 +43,12 @@ function rootReducer (state, action) { window.logState = function () { let state = window.METAMASK_CACHED_LOG_STATE - const version = global.platform.getVersion() + let version + try { + version = global.platform.getVersion() + } catch (e) { + version = 'unable to load version.' + } state.version = version let stateString = JSON.stringify(state, removeSeedWords, 2) return stateString From 942de9ba0269a7a7d35bdfcb154a087e86b12b2b Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 19 Oct 2017 09:47:48 -0700 Subject: [PATCH 13/18] Patch sandwich-expando for security update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2e8faadee..81515741e 100644 --- a/package.json +++ b/package.json @@ -134,7 +134,7 @@ "redux-logger": "^3.0.6", "redux-thunk": "^2.2.0", "request-promise": "^4.2.1", - "sandwich-expando": "^1.0.5", + "sandwich-expando": "^1.1.3", "semaphore": "^1.0.5", "sw-stream": "^2.0.0", "textarea-caret": "^3.0.1", From 0ae406e489a635ea094913ee5c20d1e8f2165db5 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 19 Oct 2017 09:59:57 -0700 Subject: [PATCH 14/18] Allow computed balances to enumerate its own view --- app/scripts/controllers/computed-balances.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/computed-balances.js b/app/scripts/controllers/computed-balances.js index 009405d29..9855f715e 100644 --- a/app/scripts/controllers/computed-balances.js +++ b/app/scripts/controllers/computed-balances.js @@ -20,9 +20,10 @@ class ComputedbalancesController { } updateAllBalances () { - for (let address in this.accountTracker.store.getState().accounts) { + Object.keys(this.balances).forEach((balance) => { + const address = balance.address this.balances[address].updateBalance() - } + }) } _initBalanceUpdating () { From 3b4c679ffcd76279221bb7cb6b83c53f0468ee65 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 19 Oct 2017 12:15:26 -0700 Subject: [PATCH 15/18] Fix bug where new account was not immediately selected --- app/scripts/metamask-controller.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 366bb6d98..457d38e26 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -324,7 +324,7 @@ module.exports = class MetamaskController extends EventEmitter { createShapeShiftTx: this.createShapeShiftTx.bind(this), // primary HD keyring management - addNewAccount: this.addNewAccount.bind(this), + addNewAccount: nodeify(this.addNewAccount, this), placeSeedWords: this.placeSeedWords.bind(this), clearSeedWordCache: this.clearSeedWordCache.bind(this), importAccountWithStrategy: this.importAccountWithStrategy.bind(this), @@ -490,10 +490,21 @@ module.exports = class MetamaskController extends EventEmitter { // Opinionated Keyring Management // - addNewAccount (cb) { + async addNewAccount (cb) { const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0] if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found')) - promiseToCallback(this.keyringController.addNewAccount(primaryKeyring))(cb) + const keyringController = this.keyringController + const oldAccounts = await keyringController.getAccounts() + const keyState = await keyringController.addNewAccount(primaryKeyring) + const newAccounts = await keyringController.getAccounts() + + newAccounts.forEach((address) => { + if (!oldAccounts.includes(address)) { + this.preferencesController.setSelectedAddress(address) + } + }) + + return keyState } // Adds the current vault's seed words to the UI's state tree. From a10a600cced6273047f224c5e19d186de091efe0 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 19 Oct 2017 12:33:43 -0700 Subject: [PATCH 16/18] Linted --- app/scripts/lib/account-tracker.js | 2 +- app/scripts/metamask-controller.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/scripts/lib/account-tracker.js b/app/scripts/lib/account-tracker.js index b9959dc25..ce6642150 100644 --- a/app/scripts/lib/account-tracker.js +++ b/app/scripts/lib/account-tracker.js @@ -57,7 +57,7 @@ class AccountTracker extends EventEmitter { }) toAdd.forEach(upstream => this.addAccount(upstream)) - toRemove.forEach(local=> this.removeAccount(local)) + toRemove.forEach(local => this.removeAccount(local)) this._updateAccounts() } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 457d38e26..ad42a39fb 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1,6 +1,5 @@ const EventEmitter = require('events') const extend = require('xtend') -const promiseToCallback = require('promise-to-callback') const pump = require('pump') const Dnode = require('dnode') const ObservableStore = require('obs-store') From 69d8359639063fec86e115bbd1bfff277b0d749b Mon Sep 17 00:00:00 2001 From: Chi Kei Chan Date: Thu, 19 Oct 2017 17:48:45 -0700 Subject: [PATCH 17/18] Update eth-keyring-controller dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b1578f7b..167ca00ce 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "eth-contract-metadata": "^1.1.4", "eth-hd-keyring": "^1.2.1", "eth-json-rpc-filters": "^1.2.2", - "eth-keyring-controller": "^2.1.0", + "eth-keyring-controller": "^2.1.2", "eth-phishing-detect": "^1.1.4", "eth-query": "^2.1.2", "eth-sig-util": "^1.4.0", From 5c902423d9f20699c636d8291b6a5f5071aeae85 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Fri, 20 Oct 2017 02:30:46 -0700 Subject: [PATCH 18/18] mascara - set x-frame-options header to DENY --- mascara/server/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mascara/server/index.js b/mascara/server/index.js index 12b527e5d..24739b43f 100644 --- a/mascara/server/index.js +++ b/mascara/server/index.js @@ -17,7 +17,7 @@ function createMetamascaraServer () { const server = express() // ui window serveBundle(server, '/ui.js', uiBundle) - server.use(express.static(__dirname + '/../ui/')) + server.use(express.static(__dirname + '/../ui/', { setHeaders: (res) => res.set('X-Frame-Options', 'DENY') })) server.use(express.static(__dirname + '/../../dist/chrome')) // metamascara serveBundle(server, '/metamascara.js', metamascaraBundle)