Skip to content

Commit

Permalink
Refactor eth_getEncryptionPublicKey handling (#18319)
Browse files Browse the repository at this point in the history
* add EncryptionPublicKeyController

* update message-managers package
  • Loading branch information
bergarces authored Apr 13, 2023
1 parent 6439551 commit 6ed72d6
Show file tree
Hide file tree
Showing 10 changed files with 871 additions and 458 deletions.
20 changes: 5 additions & 15 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ export function setupController(
METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,
updateBadge,
);
controller.encryptionPublicKeyManager.on(
controller.encryptionPublicKeyController.hub.on(
METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,
updateBadge,
);
Expand Down Expand Up @@ -727,17 +727,12 @@ export function setupController(

function getUnapprovedTransactionCount() {
const { unapprovedDecryptMsgCount } = controller.decryptMessageManager;
const { unapprovedEncryptionPublicKeyMsgCount } =
controller.encryptionPublicKeyManager;
const pendingApprovalCount =
controller.approvalController.getTotalApprovalCount();
const waitingForUnlockCount =
controller.appStateController.waitingForUnlock.length;
return (
unapprovedDecryptMsgCount +
unapprovedEncryptionPublicKeyMsgCount +
pendingApprovalCount +
waitingForUnlockCount
unapprovedDecryptMsgCount + pendingApprovalCount + waitingForUnlockCount
);
}

Expand Down Expand Up @@ -767,14 +762,9 @@ export function setupController(
REJECT_NOTIFICATION_CLOSE,
),
);
controller.encryptionPublicKeyManager.messages
.filter((msg) => msg.status === 'unapproved')
.forEach((tx) =>
controller.encryptionPublicKeyManager.rejectMsg(
tx.id,
REJECT_NOTIFICATION_CLOSE,
),
);
controller.encryptionPublicKeyController.rejectUnapproved(
REJECT_NOTIFICATION_CLOSE,
);

// Finally, resolve snap dialog approvals on Flask and reject all the others managed by the ApprovalController.
Object.values(controller.approvalController.state.pendingApprovals).forEach(
Expand Down
Loading

0 comments on commit 6ed72d6

Please sign in to comment.