Skip to content

Commit

Permalink
fix: Correct preferences controller usage for isOnPhishingList hook (
Browse files Browse the repository at this point in the history
…#28803)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

In [this
commit](cedabc6)
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.');
  }
};

```
  • Loading branch information
FrederikBolding authored Nov 29, 2024
1 parent cbb57a1 commit db4386f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit db4386f

Please sign in to comment.