Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuri committed Jul 24, 2023
1 parent 6cd8b29 commit 725a385
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions app/scripts/lib/ppom/ppom-middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,23 @@ describe('PPOMMiddleware', () => {
);
expect(validateMock).toHaveBeenCalledTimes(1);
});

it('should not call ppom.validateJsonRpc when request is not for confirmation method', async () => {
const validateMock = jest.fn();
const ppom = {
validateJsonRpc: validateMock,
};
const controller = {
usePPOM: async (callback: any) => {
callback(ppom);
},
};
const middlewareFunction = createPPOMMiddleware(controller as any);
await middlewareFunction(
{ method: 'eth_someRequest' },
undefined,
() => undefined,
);
expect(validateMock).toHaveBeenCalledTimes(0);
});
});
4 changes: 2 additions & 2 deletions app/scripts/lib/ppom/ppom-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PPOM } from '@blockaid/ppom';

import { PPOMController } from '@metamask/ppom-validator';

const ConfirmationMethods = [
const ConfirmationMethods = Object.freeze([
'eth_sendRawTransaction',
'eth_sendTransaction',
'eth_sign',
Expand All @@ -11,7 +11,7 @@ const ConfirmationMethods = [
'eth_signTypedData_v3',
'eth_signTypedData_v4',
'personal_sign',
];
]);

/**
* Middleware function that handles JSON RPC requests.
Expand Down

0 comments on commit 725a385

Please sign in to comment.