diff --git a/app/scripts/lib/ppom/ppom-util.ts b/app/scripts/lib/ppom/ppom-util.ts index 193717d35ef1..73999061a910 100644 --- a/app/scripts/lib/ppom/ppom-util.ts +++ b/app/scripts/lib/ppom/ppom-util.ts @@ -53,7 +53,11 @@ export async function validateRequestWithPPOM({ const ppomResponse = isSecurityAlertsAPIEnabled() ? await validateWithAPI(ppomController, chainId, normalizedRequest) - : await validateWithController(ppomController, normalizedRequest); + : await validateWithController( + ppomController, + normalizedRequest, + chainId, + ); return { ...ppomResponse, @@ -207,9 +211,11 @@ async function findConfirmationBySecurityAlertId( async function validateWithController( ppomController: PPOMController, request: SecurityAlertsAPIRequest | JsonRpcRequest, + chainId: string, ): Promise { - const response = (await ppomController.usePPOM((ppom: PPOM) => - ppom.validateJsonRpc(request), + const response = (await ppomController.usePPOM( + (ppom: PPOM) => ppom.validateJsonRpc(request), + chainId, )) as SecurityAlertResponse; return { @@ -232,6 +238,6 @@ async function validateWithAPI( }; } catch (error: unknown) { handlePPOMError(error, `Error validating request with security alerts API`); - return await validateWithController(ppomController, request); + return await validateWithController(ppomController, request, chainId); } } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 1d5803237bb7..522a269e3ab0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -845,7 +845,10 @@ export default class MetamaskController extends EventEmitter { this.ppomController = new PPOMController({ messenger: this.controllerMessenger.getRestricted({ name: 'PPOMController', - allowedEvents: ['NetworkController:stateChange'], + allowedEvents: [ + 'NetworkController:stateChange', + 'NetworkController:networkDidChange', + ], allowedActions: ['NetworkController:getNetworkClientById'], }), storageBackend: new IndexedDBPPOMStorage('PPOMDB', 1), diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index c5f58fb84b85..8cbb2cfe5181 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -2098,23 +2098,16 @@ "crypto": true }, "packages": { + "@metamask/base-controller": true, "@metamask/eth-query>json-rpc-random-id": true, - "@metamask/ppom-validator>@metamask/base-controller": true, "@metamask/ppom-validator>@metamask/controller-utils": true, "@metamask/ppom-validator>crypto-js": true, "@metamask/ppom-validator>elliptic": true, + "@metamask/rpc-errors": true, "await-semaphore": true, "browserify>buffer": true } }, - "@metamask/ppom-validator>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/ppom-validator>@metamask/controller-utils": { "globals": { "URL": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index c5f58fb84b85..8cbb2cfe5181 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -2098,23 +2098,16 @@ "crypto": true }, "packages": { + "@metamask/base-controller": true, "@metamask/eth-query>json-rpc-random-id": true, - "@metamask/ppom-validator>@metamask/base-controller": true, "@metamask/ppom-validator>@metamask/controller-utils": true, "@metamask/ppom-validator>crypto-js": true, "@metamask/ppom-validator>elliptic": true, + "@metamask/rpc-errors": true, "await-semaphore": true, "browserify>buffer": true } }, - "@metamask/ppom-validator>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/ppom-validator>@metamask/controller-utils": { "globals": { "URL": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index c5f58fb84b85..8cbb2cfe5181 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -2098,23 +2098,16 @@ "crypto": true }, "packages": { + "@metamask/base-controller": true, "@metamask/eth-query>json-rpc-random-id": true, - "@metamask/ppom-validator>@metamask/base-controller": true, "@metamask/ppom-validator>@metamask/controller-utils": true, "@metamask/ppom-validator>crypto-js": true, "@metamask/ppom-validator>elliptic": true, + "@metamask/rpc-errors": true, "await-semaphore": true, "browserify>buffer": true } }, - "@metamask/ppom-validator>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/ppom-validator>@metamask/controller-utils": { "globals": { "URL": true, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index adcfd27bae1e..1cbf803bc079 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -2190,23 +2190,16 @@ "crypto": true }, "packages": { + "@metamask/base-controller": true, "@metamask/eth-query>json-rpc-random-id": true, - "@metamask/ppom-validator>@metamask/base-controller": true, "@metamask/ppom-validator>@metamask/controller-utils": true, "@metamask/ppom-validator>crypto-js": true, "@metamask/ppom-validator>elliptic": true, + "@metamask/rpc-errors": true, "await-semaphore": true, "browserify>buffer": true } }, - "@metamask/ppom-validator>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/ppom-validator>@metamask/controller-utils": { "globals": { "URL": true, diff --git a/package.json b/package.json index 87b25af08723..099f42199796 100644 --- a/package.json +++ b/package.json @@ -342,7 +342,7 @@ "@metamask/permission-log-controller": "^2.0.1", "@metamask/phishing-controller": "^12.0.1", "@metamask/post-message-stream": "^8.0.0", - "@metamask/ppom-validator": "patch:@metamask/ppom-validator@npm%3A0.32.0#~/.yarn/patches/@metamask-ppom-validator-npm-0.32.0-f677deea54.patch", + "@metamask/ppom-validator": "0.34.0", "@metamask/profile-sync-controller": "^0.2.1", "@metamask/providers": "^14.0.2", "@metamask/queued-request-controller": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index d96e6d441915..58f5d87c01ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4871,16 +4871,6 @@ __metadata: languageName: node linkType: hard -"@metamask/base-controller@npm:^3.0.0": - version: 3.2.3 - resolution: "@metamask/base-controller@npm:3.2.3" - dependencies: - "@metamask/utils": "npm:^8.1.0" - immer: "npm:^9.0.6" - checksum: 10/1a3005f4143f0a3e37094ce389ae9c2010194672d67c1b115a401379c1b712fb3d7ce8f1cbc8a4d21cffba61aafba6dc1aaae12172e57b9f14021a2505fadafe - languageName: node - linkType: hard - "@metamask/base-controller@npm:^5.0.1": version: 5.0.2 resolution: "@metamask/base-controller@npm:5.0.2" @@ -5996,37 +5986,21 @@ __metadata: languageName: node linkType: hard -"@metamask/ppom-validator@npm:0.32.0": - version: 0.32.0 - resolution: "@metamask/ppom-validator@npm:0.32.0" +"@metamask/ppom-validator@npm:0.34.0": + version: 0.34.0 + resolution: "@metamask/ppom-validator@npm:0.34.0" dependencies: - "@metamask/base-controller": "npm:^3.0.0" - "@metamask/controller-utils": "npm:^8.0.1" - "@metamask/network-controller": "npm:^17.0.0" - "@metamask/utils": "npm:^8.3.0" - await-semaphore: "npm:^0.1.3" - crypto-js: "npm:^4.2.0" - elliptic: "npm:^6.5.4" - eslint-plugin-n: "npm:^16.6.2" - json-rpc-random-id: "npm:^1.0.1" - checksum: 10/6b88fc9b5dc4ddcff88c15aed96994f93a95c350ae522115415d44aa38da981bdbdee56c7889cb44992a08eff4bcaf6198516961d3a69ec3d7a83c8014748496 - languageName: node - linkType: hard - -"@metamask/ppom-validator@patch:@metamask/ppom-validator@npm%3A0.32.0#~/.yarn/patches/@metamask-ppom-validator-npm-0.32.0-f677deea54.patch": - version: 0.32.0 - resolution: "@metamask/ppom-validator@patch:@metamask/ppom-validator@npm%3A0.32.0#~/.yarn/patches/@metamask-ppom-validator-npm-0.32.0-f677deea54.patch::version=0.32.0&hash=e59920" - dependencies: - "@metamask/base-controller": "npm:^3.0.0" + "@metamask/base-controller": "npm:^6.0.2" "@metamask/controller-utils": "npm:^8.0.1" - "@metamask/network-controller": "npm:^17.0.0" + "@metamask/network-controller": "npm:^20.0.0" + "@metamask/rpc-errors": "npm:^6.3.1" "@metamask/utils": "npm:^8.3.0" await-semaphore: "npm:^0.1.3" crypto-js: "npm:^4.2.0" elliptic: "npm:^6.5.4" eslint-plugin-n: "npm:^16.6.2" json-rpc-random-id: "npm:^1.0.1" - checksum: 10/87d74699a7d05bca3fb9e09a60f60738511b045aa231d82eeadf838f531b5a147bd8819caad46d24b588eed940e342c67b87e3ce7840553753ef2e281d45cc8f + checksum: 10/140b2070ddf4a9d7d13518ab1a10aa71961715434053096d0caa6f4ce104bbcaea5f5152edfa9b6c42f9bc929116afbb6a0542c1147e3101d04ef29bcf7a6c9f languageName: node linkType: hard @@ -26174,7 +26148,7 @@ __metadata: "@metamask/phishing-controller": "npm:^12.0.1" "@metamask/phishing-warning": "npm:^4.0.0" "@metamask/post-message-stream": "npm:^8.0.0" - "@metamask/ppom-validator": "patch:@metamask/ppom-validator@npm%3A0.32.0#~/.yarn/patches/@metamask-ppom-validator-npm-0.32.0-f677deea54.patch" + "@metamask/ppom-validator": "npm:0.34.0" "@metamask/profile-sync-controller": "npm:^0.2.1" "@metamask/providers": "npm:^14.0.2" "@metamask/queued-request-controller": "npm:^2.0.0"