mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 20:57:12 +01:00
f946c030b5
* added wrapper around account list to prevent storybook from collapsing the list * updated translation files * added snap-connect page * refactored account list out of the choose account component * fixed width * removed unnecessary scss from choose-account component, fixed props in choose account story * removed snaps-connect page, added comments to ChooseAccount * updated choose account subtitle text, updated styling for title & subtitle, removed redundant account list story * updated component name, updated paths * fixed linter errors * added comments * removed unused message * removed selectAccounts key from all locales * updated class name for account list header, updated allAreSelected function to use length checks * Revert "removed unused message" This reverts commit 32771bc83c08f120825ef75f0741f3034e7dbecb. * Revert "removed selectAccounts key from all locales" This reverts commit ccfa4a860f9a75693d893d7c404384e719de297e. * updated locale messages to use selectAccounts key * removed stray import * updated scss * updated translation key * removed chooseAccounts key from en locale * removed optional chaining * changes * updated subjectMetadata * updated subject types * update useOriginMetadata function to include unknown subject type * updated permission connect header props, removed host and added subjectType to targetSubjectMetadata * added subjectType to targetSubjectMetadata * removed console.log * changed prop name to iconUrl
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
import { ethErrors } from 'eth-rpc-errors';
|
|
import { MESSAGE_TYPE } from '../../../../../shared/constants/app';
|
|
|
|
/**
|
|
* This internal method is used by our external provider to send metadata about
|
|
* permission subjects so that we can e.g. display a proper name and icon in
|
|
* our UI.
|
|
*/
|
|
|
|
const sendMetadata = {
|
|
methodNames: [MESSAGE_TYPE.SEND_METADATA],
|
|
implementation: sendMetadataHandler,
|
|
hookNames: {
|
|
addSubjectMetadata: true,
|
|
subjectType: true,
|
|
},
|
|
};
|
|
export default sendMetadata;
|
|
|
|
/**
|
|
* @typedef {Record<string, Function>} SendMetadataOptions
|
|
* @property {Function} addSubjectMetadata - A function that records subject
|
|
* metadata, bound to the requesting origin.
|
|
* @property {string} subjectType - The type of the requesting origin / subject.
|
|
*/
|
|
|
|
/**
|
|
* @param {import('json-rpc-engine').JsonRpcRequest<unknown>} req - The JSON-RPC request object.
|
|
* @param {import('json-rpc-engine').JsonRpcResponse<true>} res - The JSON-RPC response object.
|
|
* @param {Function} _next - The json-rpc-engine 'next' callback.
|
|
* @param {Function} end - The json-rpc-engine 'end' callback.
|
|
* @param {SendMetadataOptions} options
|
|
*/
|
|
function sendMetadataHandler(
|
|
req,
|
|
res,
|
|
_next,
|
|
end,
|
|
{ addSubjectMetadata, subjectType },
|
|
) {
|
|
const { origin, params } = req;
|
|
if (params && typeof params === 'object' && !Array.isArray(params)) {
|
|
const { icon = null, name = null, ...remainingParams } = params;
|
|
|
|
addSubjectMetadata({
|
|
...remainingParams,
|
|
iconUrl: icon,
|
|
name,
|
|
subjectType,
|
|
origin,
|
|
});
|
|
} else {
|
|
return end(ethErrors.rpc.invalidParams({ data: params }));
|
|
}
|
|
|
|
res.result = true;
|
|
return end();
|
|
}
|