UNPKG

@metamask/snaps-simulation

Version:

A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment

1 lines 1.8 kB
{"version":3,"file":"interface.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/interface.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAC9C,mBAA4C;IAE5C,OAAO,KAAK,EACV,MAAc,EACd,OAAkB,EAClB,OAA0B,EAC1B,WAAyB,EACzB,EAAE,CACF,mBAAmB,CAAC,IAAI,CACtB,yCAAyC,EACzC,MAAM,EACN,OAAO,EACP,OAAO,EACP,WAAW,CACZ,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,mBAA4C;IAE5C,OAAO,CAAC,MAAc,EAAE,EAAU,EAAE,EAAE,CACpC,mBAAmB,CAAC,IAAI,CACtB,sCAAsC,EACtC,MAAM,EACN,EAAE,CACH,CAAC;AACN,CAAC","sourcesContent":["import type {\n Component,\n ContentType,\n InterfaceContext,\n SnapId,\n} from '@metamask/snaps-sdk';\n\nimport type { RootControllerMessenger } from '../../controllers';\n\n/**\n * Get the implementation of the `createInterface` hook.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @returns The implementation of the `createInterface` hook.\n */\nexport function getCreateInterfaceImplementation(\n controllerMessenger: RootControllerMessenger,\n) {\n return async (\n snapId: SnapId,\n content: Component,\n context?: InterfaceContext,\n contentType?: ContentType,\n ) =>\n controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n content,\n context,\n contentType,\n );\n}\n\n/**\n * Get the implementation of the `getInterface` hook.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @returns The implementation of the `getInterface` hook.\n */\nexport function getGetInterfaceImplementation(\n controllerMessenger: RootControllerMessenger,\n) {\n return (snapId: SnapId, id: string) =>\n controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n}\n"]}