mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #2228 from MetaMask/i2218-SelectAccountBugFix
Ensure selected account is always set if possible
This commit is contained in:
commit
d61f36808a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
|
|
||||||
|
- Fixed bug where sometimes the current account was not correctly set and exposed to web apps.
|
||||||
- Added AUD, HKD, SGD, IDR, PHP to currency conversion list
|
- Added AUD, HKD, SGD, IDR, PHP to currency conversion list
|
||||||
|
|
||||||
## 3.10.6 2017-9-27
|
## 3.10.6 2017-9-27
|
||||||
|
@ -100,6 +100,14 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
encryptor: opts.encryptor || undefined,
|
encryptor: opts.encryptor || undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// If only one account exists, make sure it is selected.
|
||||||
|
this.keyringController.store.subscribe((state) => {
|
||||||
|
const addresses = Object.keys(state.walletNicknames || {})
|
||||||
|
if (addresses.length === 1) {
|
||||||
|
const address = addresses[0]
|
||||||
|
this.preferencesController.setSelectedAddress(address)
|
||||||
|
}
|
||||||
|
})
|
||||||
this.keyringController.on('newAccount', (address) => {
|
this.keyringController.on('newAccount', (address) => {
|
||||||
this.preferencesController.setSelectedAddress(address)
|
this.preferencesController.setSelectedAddress(address)
|
||||||
this.accountTracker.addAccount(address)
|
this.accountTracker.addAccount(address)
|
||||||
@ -222,6 +230,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
|
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
|
||||||
const result = []
|
const result = []
|
||||||
const selectedAddress = this.preferencesController.getSelectedAddress()
|
const selectedAddress = this.preferencesController.getSelectedAddress()
|
||||||
|
|
||||||
// only show address if account is unlocked
|
// only show address if account is unlocked
|
||||||
if (isUnlocked && selectedAddress) {
|
if (isUnlocked && selectedAddress) {
|
||||||
result.push(selectedAddress)
|
result.push(selectedAddress)
|
||||||
|
Loading…
Reference in New Issue
Block a user