From db4386f6e25c8a96bd2510588c9ba462a51d9ca1 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 29 Nov 2024 11:31:07 +0100 Subject: [PATCH] fix: Correct preferences controller usage for `isOnPhishingList` hook (#28803) ## **Description** In [this commit](https://github.com/MetaMask/metamask-extension/commit/cedabc62e45601c77871689425320c54d717275e) the preferences controller was converted to `BaseControllerV2`, however the `isOnPhishingList` hook was not corrected to reference the state properly. The hook will currently always throw which means that link validation fails for Snaps notifications, making them unable to display. This PR corrects that mistake. Note: This is an edge-case of the Snaps API that doesn't have good E2E coverage yet. We should prioritize that. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28803?quickstart=1) ## **Manual testing steps** The following Snap should work correctly and display a notification: ``` export const onRpcRequest: OnRpcRequestHandler = async ({ origin, request, }) => { switch (request.method) { case 'hello': return snap.request({ method: 'snap_notify', params: { type: 'inApp', message: 'Hello! [metamask.io](https://metamask.io)', }, }); default: throw new Error('Method not found.'); } }; ``` --- app/scripts/metamask-controller.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 992302983baf..d60d937e1c3c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2897,8 +2897,7 @@ export default class MetamaskController extends EventEmitter { ); }, isOnPhishingList: (url) => { - const { usePhishDetect } = - this.preferencesController.store.getState(); + const { usePhishDetect } = this.preferencesController.state; if (!usePhishDetect) { return false;