diff --git a/app/scripts/lib/ppom/ppom-middleware.test.ts b/app/scripts/lib/ppom/ppom-middleware.test.ts index 222222aa31f8..be7b5558d1ca 100644 --- a/app/scripts/lib/ppom/ppom-middleware.test.ts +++ b/app/scripts/lib/ppom/ppom-middleware.test.ts @@ -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); + }); }); diff --git a/app/scripts/lib/ppom/ppom-middleware.ts b/app/scripts/lib/ppom/ppom-middleware.ts index 1e69f6c4c3be..c58f74d60c4e 100644 --- a/app/scripts/lib/ppom/ppom-middleware.ts +++ b/app/scripts/lib/ppom/ppom-middleware.ts @@ -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', @@ -11,7 +11,7 @@ const ConfirmationMethods = [ 'eth_signTypedData_v3', 'eth_signTypedData_v4', 'personal_sign', -]; +]); /** * Middleware function that handles JSON RPC requests.