1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix inpage provider behavior on unlock (#12339)

This fixes a bug where we were failing to notify the inpage provider of the user's currently selected account when the extension becomes unlocked.
This commit is contained in:
Erik Marks 2021-10-14 10:50:07 -07:00 committed by GitHub
parent 859b80955b
commit 20b921f520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -380,7 +380,7 @@ export default class MetamaskController extends EventEmitter {
this.keyringController.memStore.subscribe((state) =>
this._onKeyringControllerUpdate(state),
);
this.keyringController.on('unlock', () => this.emit('unlock'));
this.keyringController.on('unlock', () => this._onUnlock());
this.keyringController.on('lock', () => this._onLock());
this.permissionsController = new PermissionsController(
@ -2626,10 +2626,10 @@ export default class MetamaskController extends EventEmitter {
? (origin) => payload(origin)
: () => payload;
Object.values(this.connections).forEach((origin) => {
Object.values(origin).forEach((conn) => {
Object.keys(this.connections).forEach((origin) => {
Object.values(this.connections[origin]).forEach(async (conn) => {
if (conn.engine) {
conn.engine.emit('notification', getPayload(origin));
conn.engine.emit('notification', await getPayload(origin));
}
});
});
@ -2664,12 +2664,12 @@ export default class MetamaskController extends EventEmitter {
* Notifies all connections that the extension is unlocked.
*/
_onUnlock() {
this.notifyAllConnections((origin) => {
this.notifyAllConnections(async (origin) => {
return {
method: NOTIFICATION_NAMES.unlockStateChanged,
params: {
isUnlocked: true,
accounts: this.permissionsController.getAccounts(origin),
accounts: await this.permissionsController.getAccounts(origin),
},
};
});