From daf4fe439c054ea897a5ebc10eaccf107305dda7 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 1 Oct 2019 10:33:13 -0230 Subject: [PATCH] Ensure 3box validation uses the correct address (#7235) --- app/scripts/controllers/threebox.js | 15 ++++++++------- app/scripts/metamask-controller.js | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/scripts/controllers/threebox.js b/app/scripts/controllers/threebox.js index e6ae41f9c..5bcab29ed 100644 --- a/app/scripts/controllers/threebox.js +++ b/app/scripts/controllers/threebox.js @@ -20,7 +20,6 @@ class ThreeBoxController { addressBookController, version, getKeyringControllerState, - getSelectedAddress, } = opts this.preferencesController = preferencesController @@ -32,18 +31,20 @@ class ThreeBoxController { if (origin !== '3Box') { return [] } const isUnlocked = getKeyringControllerState().isUnlocked - const selectedAddress = getSelectedAddress() + const accounts = await this.keyringController.getAccounts() - if (isUnlocked && selectedAddress) { - return [selectedAddress] + if (isUnlocked && accounts[0]) { + const appKeyAddress = await this.keyringController.getAppKeyAddress(accounts[0], 'wallet://3box.metamask.io') + return [appKeyAddress] } else { return [] } }, - processPersonalMessage: (msgParams) => { - return Promise.resolve(keyringController.signPersonalMessage(msgParams, { + processPersonalMessage: async (msgParams) => { + const accounts = await this.keyringController.getAccounts() + return keyringController.signPersonalMessage({ ...msgParams, from: accounts[0] }, { withAppKeyOrigin: 'wallet://3box.metamask.io', - })) + }) }, }) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 9e339d596..cbf12fb29 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -206,7 +206,6 @@ module.exports = class MetamaskController extends EventEmitter { keyringController: this.keyringController, initState: initState.ThreeBoxController, getKeyringControllerState: this.keyringController.memStore.getState.bind(this.keyringController.memStore), - getSelectedAddress: this.preferencesController.getSelectedAddress.bind(this.preferencesController), version, })