mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-12 20:57:12 +01:00
925a19fa4a
This reverts commitf09ab88891
, reversing changes made toeffc761e0e
. This is being temporarily reverted to make it easier to release an urgent fix for v10.15.1.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { endowmentPermissionBuilders } from '@metamask/controllers';
|
|
import {
|
|
restrictedMethodPermissionBuilders,
|
|
selectHooks,
|
|
} from '@metamask/rpc-methods';
|
|
import { ExcludedSnapPermissions } from '../../../../../shared/constants/permissions';
|
|
|
|
/**
|
|
* @returns {Record<string, Record<string, unknown>>} All endowment permission
|
|
* specifications.
|
|
*/
|
|
export const buildSnapEndowmentSpecifications = () =>
|
|
Object.values(endowmentPermissionBuilders).reduce(
|
|
(allSpecifications, { targetKey, specificationBuilder }) => {
|
|
allSpecifications[targetKey] = specificationBuilder();
|
|
return allSpecifications;
|
|
},
|
|
{},
|
|
);
|
|
|
|
/**
|
|
* @param {Record<string, Function>} hooks - The hooks for the Snap
|
|
* restricted method implementations.
|
|
*/
|
|
export function buildSnapRestrictedMethodSpecifications(hooks) {
|
|
return Object.values(restrictedMethodPermissionBuilders).reduce(
|
|
(specifications, { targetKey, specificationBuilder, methodHooks }) => {
|
|
if (!ExcludedSnapPermissions.has(targetKey)) {
|
|
specifications[targetKey] = specificationBuilder({
|
|
methodHooks: selectHooks(hooks, methodHooks),
|
|
});
|
|
}
|
|
return specifications;
|
|
},
|
|
{},
|
|
);
|
|
}
|