From b258cbafe7ac6abfbc630b459bc72d6866c0f513 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Wed, 11 May 2022 16:15:26 +0200 Subject: [PATCH] Remove confirmation for terminated snaps (#14566) --- app/scripts/metamask-controller.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index c1479f9b7..5e70d5787 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1226,6 +1226,26 @@ export default class MetamaskController extends EventEmitter { }); }, ); + + this.controllerMessenger.subscribe( + `${this.snapController.name}:snapTerminated`, + (snapId) => { + const approvals = Object.values( + this.approvalController.state.pendingApprovals, + ).filter( + (approval) => + approval.origin === snapId && + approval.type === MESSAGE_TYPE.SNAP_CONFIRM, + ); + for (const approval of approvals) { + this.approvalController.reject( + approval.id, + new Error('Snap was terminated.'), + ); + } + }, + ); + ///: END:ONLY_INCLUDE_IN }