From a88a087b60d432b389b645b586e643845430b113 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Fri, 22 Jan 2021 10:27:07 -0800 Subject: [PATCH] Fix site metadata JSON-RPC handler (#10243) * Fix getting the site metadata from the request origin params. Regressed from inpage-provider ts migration the request. The property domainMetadata is now set as a params key for the request. https://github.com/MetaMask/inpage-provider/blob/v7.0.0/src/siteMetadata.js#L19-L25 vs https://github.com/MetaMask/inpage-provider/blob/main/src/siteMetadata.ts#L19-L27 * Change hardcoded mocked response of the request to the prod response. --- .../controllers/permissions/permissionsMethodMiddleware.js | 4 ++-- test/unit/app/controllers/permissions/mocks.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js index de9009f13..2a2485e33 100644 --- a/app/scripts/controllers/permissions/permissionsMethodMiddleware.js +++ b/app/scripts/controllers/permissions/permissionsMethodMiddleware.js @@ -74,8 +74,8 @@ export default function createPermissionsMethodMiddleware({ // custom method for getting metadata from the requesting domain, // sent automatically by the inpage provider when it's initialized case 'metamask_sendDomainMetadata': { - if (typeof req.domainMetadata?.name === 'string') { - addDomainMetadata(req.origin, req.domainMetadata) + if (typeof req.params?.name === 'string') { + addDomainMetadata(req.origin, req.params) } res.result = true return diff --git a/test/unit/app/controllers/permissions/mocks.js b/test/unit/app/controllers/permissions/mocks.js index 48937faf2..6c977f272 100644 --- a/test/unit/app/controllers/permissions/mocks.js +++ b/test/unit/app/controllers/permissions/mocks.js @@ -600,7 +600,7 @@ export const getters = deepFreeze({ return { origin, method: 'metamask_sendDomainMetadata', - domainMetadata: { + params: { ...args, name, },