From 36c0dfb1f21dc26ee4fb068f1c4a33ed13be5a6a Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 2 Aug 2023 15:16:43 +0200 Subject: [PATCH] Check for blocked snaps on extension startup (#20336) * allow `SnapController` to call `SnapsRegistry:update` * call `SnapController:updateBlockedSnaps` on extension startup * only check if at least one snap is installed --- app/scripts/background.js | 7 +++++++ app/scripts/metamask-controller.js | 1 + 2 files changed, 8 insertions(+) diff --git a/app/scripts/background.js b/app/scripts/background.js index 9dc28d238..5eac5d1d6 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -801,6 +801,13 @@ export function setupController( }); } ///: END:ONLY_INCLUDE_IN + + ///: BEGIN:ONLY_INCLUDE_IN(snaps) + // Updates the snaps registry and check for newly blocked snaps to block if the user has at least one snap installed. + if (Object.keys(controller.snapController.state.snaps).length > 0) { + controller.snapController.updateBlockedSnaps(); + } + ///: END:ONLY_INCLUDE_IN } // diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 04f2ce22e..f0e87fd6c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -986,6 +986,7 @@ export default class MetamaskController extends EventEmitter { 'ExecutionService:handleRpcRequest', 'SnapsRegistry:get', 'SnapsRegistry:getMetadata', + 'SnapsRegistry:update', ], });