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.
feature/default_network_editable
Erik Marks 3 years ago committed by GitHub
parent 859b80955b
commit 20b921f520
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/scripts/metamask-controller.js

@ -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),
},
};
});

Loading…
Cancel
Save