diff options
rename selectedAccount to selectedAddress
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/keyring-controller.js | 4 | ||||
-rw-r--r-- | app/scripts/lib/controllers/preferences.js | 7 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 10 | ||||
-rw-r--r-- | app/scripts/migrations/006.js | 2 |
4 files changed, 13 insertions, 10 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 3e329cb3f..f7a4e4010 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -150,7 +150,7 @@ class KeyringController extends EventEmitter { const firstAccount = accounts[0] if (!firstAccount) throw new Error('KeyringController - First Account not found.') const hexAccount = normalizeAddress(firstAccount) - this.setSelectedAccount(hexAccount) + this.emit('newAccount', hexAccount) return this.setupAccounts(accounts) }) .then(this.persistAllKeyrings.bind(this, password)) @@ -391,7 +391,6 @@ class KeyringController extends EventEmitter { const firstAccount = accounts[0] if (!firstAccount) throw new Error('KeyringController - No account found on keychain.') const hexAccount = normalizeAddress(firstAccount) - this.setSelectedAccount(hexAccount) this.emit('newAccount', hexAccount) return this.setupAccounts(accounts) }) @@ -638,7 +637,6 @@ class KeyringController extends EventEmitter { this.keyrings = [] this.identities = {} - this.setSelectedAccount() } } diff --git a/app/scripts/lib/controllers/preferences.js b/app/scripts/lib/controllers/preferences.js index e338f5b5e..dc9464c4e 100644 --- a/app/scripts/lib/controllers/preferences.js +++ b/app/scripts/lib/controllers/preferences.js @@ -13,8 +13,11 @@ class PreferencesController { // setSelectedAddress(_address) { - const address = normalizeAddress(_address) - this.store.updateState({ selectedAddress: address }) + return new Promise((resolve, reject) => { + const address = normalizeAddress(_address) + this.store.updateState({ selectedAddress: address }) + resolve() + }) } getSelectedAddress(_address) { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 64deae426..e081188ce 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -62,8 +62,9 @@ module.exports = class MetamaskController extends EventEmitter { configManager: this.configManager, getNetwork: this.getStateNetwork.bind(this), }) - this.keyringController.on('newAccount', (account) => { - autoFaucet(account) + this.keyringController.on('newAccount', (address) => { + this.preferencesController.setSelectedAddress(address) + autoFaucet(address) }) // tx mgmt @@ -176,6 +177,7 @@ module.exports = class MetamaskController extends EventEmitter { this.configManager.getConfig(), this.txManager.getState(), keyringControllerState, + this.preferencesController.store.getState(), this.noticeController.getState(), { shapeShiftTxList: this.configManager.getShapeShiftTxList(), @@ -223,7 +225,7 @@ module.exports = class MetamaskController extends EventEmitter { submitPassword: this.submitPassword.bind(this), // PreferencesController - setSelectedAccount: nodeify(preferencesController.setSelectedAccount).bind(preferencesController), + setSelectedAddress: nodeify(preferencesController.setSelectedAddress).bind(preferencesController), // KeyringController setLocked: nodeify(keyringController.setLocked).bind(keyringController), @@ -351,7 +353,7 @@ module.exports = class MetamaskController extends EventEmitter { return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) }) .then(keyring => keyring.getAccounts()) - .then((accounts) => this.preferencesController.setSelectedAccount(accounts[0])) + .then((accounts) => this.preferencesController.setSelectedAddress(accounts[0])) .then(() => { cb(null, this.keyringController.fullUpdate()) }) .catch((reason) => { cb(reason) }) } diff --git a/app/scripts/migrations/006.js b/app/scripts/migrations/006.js index b2fcbae15..677e89bf7 100644 --- a/app/scripts/migrations/006.js +++ b/app/scripts/migrations/006.js @@ -30,7 +30,7 @@ function migrateState (state) { // add new state const newState = extend(state, { PreferencesController: { - selectedAccount: config.selectedAccount, + selectedAddress: config.selectedAccount, }, }) |