@metamask/snaps-simulation 4.3.0 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/dist/controllers.cjs +3 -4
- package/dist/controllers.cjs.map +1 -1
- package/dist/controllers.mjs +1 -1
- package/dist/controllers.mjs.map +1 -1
- package/dist/files.cjs +4 -5
- package/dist/files.cjs.map +1 -1
- package/dist/helpers.cjs +1 -2
- package/dist/helpers.cjs.map +1 -1
- package/dist/interface.cjs +18 -19
- package/dist/interface.cjs.map +1 -1
- package/dist/interface.d.cts +2 -2
- package/dist/interface.d.cts.map +1 -1
- package/dist/interface.d.mts +2 -2
- package/dist/interface.d.mts.map +1 -1
- package/dist/interface.mjs +2 -2
- package/dist/interface.mjs.map +1 -1
- package/dist/logger.d.cts +0 -1
- package/dist/logger.d.cts.map +1 -1
- package/dist/logger.d.mts +0 -1
- package/dist/logger.d.mts.map +1 -1
- package/dist/methods/hooks/chain.cjs +1 -2
- package/dist/methods/hooks/chain.cjs.map +1 -1
- package/dist/methods/hooks/chain.d.cts +12 -1
- package/dist/methods/hooks/chain.d.cts.map +1 -1
- package/dist/methods/hooks/chain.d.mts +12 -1
- package/dist/methods/hooks/chain.d.mts.map +1 -1
- package/dist/methods/hooks/end-trace.cjs +1 -2
- package/dist/methods/hooks/end-trace.cjs.map +1 -1
- package/dist/methods/hooks/end-trace.d.cts +12 -1
- package/dist/methods/hooks/end-trace.d.cts.map +1 -1
- package/dist/methods/hooks/end-trace.d.mts +12 -1
- package/dist/methods/hooks/end-trace.d.mts.map +1 -1
- package/dist/methods/hooks/get-mnemonic.cjs +1 -2
- package/dist/methods/hooks/get-mnemonic.cjs.map +1 -1
- package/dist/methods/hooks/get-mnemonic.d.cts.map +1 -1
- package/dist/methods/hooks/get-mnemonic.d.mts.map +1 -1
- package/dist/methods/hooks/get-preferences.cjs +1 -2
- package/dist/methods/hooks/get-preferences.cjs.map +1 -1
- package/dist/methods/hooks/get-snap.cjs +1 -2
- package/dist/methods/hooks/get-snap.cjs.map +1 -1
- package/dist/methods/hooks/get-snap.d.cts.map +1 -1
- package/dist/methods/hooks/get-snap.d.mts.map +1 -1
- package/dist/methods/hooks/notifications.cjs +2 -3
- package/dist/methods/hooks/notifications.cjs.map +1 -1
- package/dist/methods/hooks/notifications.d.cts +26 -2
- package/dist/methods/hooks/notifications.d.cts.map +1 -1
- package/dist/methods/hooks/notifications.d.mts +26 -2
- package/dist/methods/hooks/notifications.d.mts.map +1 -1
- package/dist/methods/hooks/permitted/state.cjs +3 -4
- package/dist/methods/hooks/permitted/state.cjs.map +1 -1
- package/dist/methods/hooks/permitted/state.d.cts +31 -3
- package/dist/methods/hooks/permitted/state.d.cts.map +1 -1
- package/dist/methods/hooks/permitted/state.d.mts +31 -3
- package/dist/methods/hooks/permitted/state.d.mts.map +1 -1
- package/dist/methods/hooks/request-user-approval.cjs +1 -2
- package/dist/methods/hooks/request-user-approval.cjs.map +1 -1
- package/dist/methods/hooks/request-user-approval.d.cts +15 -1
- package/dist/methods/hooks/request-user-approval.d.cts.map +1 -1
- package/dist/methods/hooks/request-user-approval.d.mts +15 -1
- package/dist/methods/hooks/request-user-approval.d.mts.map +1 -1
- package/dist/methods/hooks/start-trace.cjs +1 -2
- package/dist/methods/hooks/start-trace.cjs.map +1 -1
- package/dist/methods/hooks/start-trace.d.cts +12 -1
- package/dist/methods/hooks/start-trace.d.cts.map +1 -1
- package/dist/methods/hooks/start-trace.d.mts +12 -1
- package/dist/methods/hooks/start-trace.d.mts.map +1 -1
- package/dist/methods/hooks/state.cjs +3 -4
- package/dist/methods/hooks/state.cjs.map +1 -1
- package/dist/methods/hooks/state.d.cts +37 -3
- package/dist/methods/hooks/state.d.cts.map +1 -1
- package/dist/methods/hooks/state.d.mts +37 -3
- package/dist/methods/hooks/state.d.mts.map +1 -1
- package/dist/methods/hooks/track-error.cjs +1 -2
- package/dist/methods/hooks/track-error.cjs.map +1 -1
- package/dist/methods/hooks/track-error.d.cts +11 -1
- package/dist/methods/hooks/track-error.d.cts.map +1 -1
- package/dist/methods/hooks/track-error.d.mts +11 -1
- package/dist/methods/hooks/track-error.d.mts.map +1 -1
- package/dist/methods/hooks/track-event.cjs +1 -2
- package/dist/methods/hooks/track-event.cjs.map +1 -1
- package/dist/methods/hooks/track-event.d.cts +12 -5
- package/dist/methods/hooks/track-event.d.cts.map +1 -1
- package/dist/methods/hooks/track-event.d.mts +12 -5
- package/dist/methods/hooks/track-event.d.mts.map +1 -1
- package/dist/methods/specifications.cjs +4 -5
- package/dist/methods/specifications.cjs.map +1 -1
- package/dist/middleware/engine.cjs +1 -2
- package/dist/middleware/engine.cjs.map +1 -1
- package/dist/middleware/internal-methods/accounts.cjs +1 -2
- package/dist/middleware/internal-methods/accounts.cjs.map +1 -1
- package/dist/middleware/internal-methods/chain-id.cjs +1 -2
- package/dist/middleware/internal-methods/chain-id.cjs.map +1 -1
- package/dist/middleware/internal-methods/middleware.cjs +1 -2
- package/dist/middleware/internal-methods/middleware.cjs.map +1 -1
- package/dist/middleware/internal-methods/net-version.cjs +1 -2
- package/dist/middleware/internal-methods/net-version.cjs.map +1 -1
- package/dist/middleware/internal-methods/switch-ethereum-chain.cjs +1 -2
- package/dist/middleware/internal-methods/switch-ethereum-chain.cjs.map +1 -1
- package/dist/middleware/mock.cjs +1 -2
- package/dist/middleware/mock.cjs.map +1 -1
- package/dist/middleware/multichain/create-session.cjs +1 -2
- package/dist/middleware/multichain/create-session.cjs.map +1 -1
- package/dist/middleware/multichain/create-session.d.cts +1 -1
- package/dist/middleware/multichain/create-session.d.mts +1 -1
- package/dist/middleware/multichain/get-session.cjs +1 -2
- package/dist/middleware/multichain/get-session.cjs.map +1 -1
- package/dist/middleware/multichain/invoke-method.cjs +1 -2
- package/dist/middleware/multichain/invoke-method.cjs.map +1 -1
- package/dist/middleware/multichain/middleware.cjs +1 -2
- package/dist/middleware/multichain/middleware.cjs.map +1 -1
- package/dist/middleware/multichain/revoke-session.cjs +1 -2
- package/dist/middleware/multichain/revoke-session.cjs.map +1 -1
- package/dist/middleware/multichain/utils.cjs +1 -2
- package/dist/middleware/multichain/utils.cjs.map +1 -1
- package/dist/middleware/provider.cjs +1 -2
- package/dist/middleware/provider.cjs.map +1 -1
- package/dist/options.cjs +1 -2
- package/dist/options.cjs.map +1 -1
- package/dist/options.d.cts +4 -4
- package/dist/options.d.mts +4 -4
- package/dist/request.cjs +3 -4
- package/dist/request.cjs.map +1 -1
- package/dist/simulation.cjs +9 -10
- package/dist/simulation.cjs.map +1 -1
- package/dist/simulation.d.cts.map +1 -1
- package/dist/simulation.d.mts.map +1 -1
- package/dist/simulation.mjs +4 -4
- package/dist/simulation.mjs.map +1 -1
- package/dist/store/chain.d.cts.map +1 -1
- package/dist/store/chain.d.mts.map +1 -1
- package/dist/store/mocks.d.cts.map +1 -1
- package/dist/store/mocks.d.mts.map +1 -1
- package/dist/store/notifications.d.cts.map +1 -1
- package/dist/store/notifications.d.mts.map +1 -1
- package/dist/store/state.cjs +2 -2
- package/dist/store/state.cjs.map +1 -1
- package/dist/store/state.d.cts +4 -7
- package/dist/store/state.d.cts.map +1 -1
- package/dist/store/state.d.mts +4 -7
- package/dist/store/state.d.mts.map +1 -1
- package/dist/store/store.cjs +1 -2
- package/dist/store/store.cjs.map +1 -1
- package/dist/store/store.d.cts +1 -1
- package/dist/store/store.d.mts +1 -1
- package/dist/store/trackables.d.cts +6 -6
- package/dist/store/trackables.d.cts.map +1 -1
- package/dist/store/trackables.d.mts +6 -6
- package/dist/store/trackables.d.mts.map +1 -1
- package/dist/store/ui.d.cts.map +1 -1
- package/dist/store/ui.d.mts.map +1 -1
- package/dist/structs.cjs +3 -3
- package/dist/structs.cjs.map +1 -1
- package/dist/structs.mjs +1 -1
- package/dist/structs.mjs.map +1 -1
- package/dist/utils/account.d.cts.map +1 -1
- package/dist/utils/account.d.mts.map +1 -1
- package/dist/utils/errors.cjs +1 -2
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/validation.cjs +7 -8
- package/dist/validation.cjs.map +1 -1
- package/package.json +11 -11
package/dist/interface.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interface.mjs","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAYpE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,EAAE,4BAA4B;AAM7E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,OAAO,EACR,8BAA8B;AAC/B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,wBAAwB;AAEzB,OAAO,UAAS,wBAAwB;;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B;AAE7D,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAE9C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAgB;AAGvD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,0BAAgB;AAO9E,OAAO,EAAE,sBAAsB,EAAE,2BAAuB;AAExD;;GAEG;AACH,MAAM,aAAa,GAAG,QAAU,CAAC,CAAC,QAAQ;AAE1C;;GAEG;AACH,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAE3E;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAwB,EACxB,IAAkE,EAClE,EAAU,EACV,OAAmB,EACnB,gBAAsC;IAEtC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,qBAAqB,CAAC,UAAU,CAAC,KAAK,CAAC;YAC1C,OAAO;gBACL,GAAG,gBAAgB;gBACnB,IAAI,EAAE,UAAU,CAAC,KAAK;gBACtB,OAAO;gBACP,EAAE;gBAEF,EAAE,EAAE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ent":["import type { SnapInterfaceControllerState } from '@metamask/snaps-controllers';\nimport type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport type {\n FormState,\n InterfaceContext,\n InterfaceState,\n SnapId,\n UserInputEvent,\n File,\n AccountSelectorState,\n AssetSelectorState,\n CaipAssetType,\n} from '@metamask/snaps-sdk';\nimport { DialogType, UserInputEventType, assert } from '@metamask/snaps-sdk';\nimport type {\n FooterElement,\n FormElement,\n JSXElement,\n} from '@metamask/snaps-sdk/jsx';\nimport {\n HandlerType,\n createAccountList,\n createChainIdList,\n getJsxChildren,\n unwrapError,\n walkJsx,\n} from '@metamask/snaps-utils';\nimport {\n assertExhaustive,\n hasProperty,\n parseCaipAccountId,\n} from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport deepEqual from 'fast-deep-equal';\nimport { type SagaIterator } from 'redux-saga';\nimport { call, put, select, take } from 'redux-saga/effects';\n\nimport { TYPEABLE_INPUTS } from './constants';\nimport type { RootControllerMessenger } from './controllers';\nimport { getFileSize, getFileToUpload } from './files';\nimport type { SimulationOptions } from './options';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\nimport type {\n FileOptions,\n SnapHandlerInterface,\n SnapInterface,\n SnapInterfaceActions,\n} from './types';\nimport { formatTypeErrorMessage } from './utils/errors';\n\n/**\n * The maximum file size that can be uploaded.\n */\nconst MAX_FILE_SIZE = 10_000_000; // 10 MB\n\n/**\n * The elements based on the Selector component.\n */\nconst SELECTOR_ELEMENTS = ['Selector', 'AccountSelector', 'AssetSelector'];\n\n/**\n * Get a user interface object from a type and content object.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param type - The type of the interface.\n * @param id - The interface ID.\n * @param content - The content to show in the interface.\n * @param interfaceActions - The actions to interact with the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogApprovalTypes[DialogType | 'default'] | 'Notification',\n id: string,\n content: JSXElement,\n interfaceActions: SnapInterfaceActions,\n): SnapInterface {\n switch (type) {\n case DIALOG_APPROVAL_TYPES[DialogType.Alert]:\n return {\n ...interfaceActions,\n type: DialogType.Alert,\n content,\n id,\n\n ok: resolveWith(runSaga, null),\n };\n\n case DIALOG_APPROVAL_TYPES[DialogType.Confirmation]:\n return {\n ...interfaceActions,\n type: DialogType.Confirmation,\n content,\n id,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DIALOG_APPROVAL_TYPES[DialogType.Prompt]:\n return {\n ...interfaceActions,\n type: DialogType.Prompt,\n content,\n id,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\n };\n\n case DIALOG_APPROVAL_TYPES.default: {\n const footer = getElementByType<FooterElement>(content, 'Footer');\n\n // No Footer defined so we apply a default footer.\n if (!footer) {\n return {\n ...interfaceActions,\n content,\n id,\n\n ok: resolveWith(runSaga, null),\n cancel: resolveWith(runSaga, null),\n };\n }\n\n // Only one button in footer so we apply a default cancel button.\n if (getJsxChildren(footer).length === 1) {\n return {\n ...interfaceActions,\n content,\n id,\n\n cancel: resolveWith(runSaga, null),\n };\n }\n\n // We have two buttons in the footer so we assume the snap handles the approval of the interface.\n return {\n ...interfaceActions,\n content,\n id,\n };\n }\n\n case 'Notification': {\n return {\n ...interfaceActions,\n content,\n id,\n };\n }\n\n default:\n throw new Error(`Unknown or unsupported dialog type: \"${String(type)}\".`);\n }\n}\n\n/**\n * Resolve the current user interface with the given value.\n *\n * @param value - The value to resolve the user interface with.\n * @yields Puts the resolve user interface action.\n */\nexport function* resolveWithSaga(value: unknown): SagaIterator {\n yield put(resolveInterface(value));\n}\n\n/**\n * Resolve the current user interface with the given value. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param value - The value to resolve the user interface with.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWith(runSaga: RunSagaFunction, value: unknown) {\n return async () => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Resolve the current user interface with the provided input. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWithInput(runSaga: RunSagaFunction) {\n return async (value = '') => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Get the stored user interface from the store.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nfunction* getStoredInterface(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n): SagaIterator<Interface & { content: JSXElement }> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n\n return { ...currentInterface, content };\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n payload.id,\n );\n\n return { ...payload, content };\n}\n\n/**\n * A JSX element with a name.\n */\nexport type NamedJSXElement = JSXElement & { props: { name: string } };\n\n/**\n * Check if a JSX element is a JSX element with a given name.\n *\n * @param element - The JSX element.\n * @param name - The element name.\n * @returns True if the element is a JSX element with the given name, otherwise\n * false.\n */\nfunction isJSXElementWithName<Element extends JSXElement, Name extends string>(\n element: Element,\n name: Name,\n): element is Element & { props: { name: Name } } {\n return hasProperty(element.props, 'name') && element.props.name === name;\n}\n\n/**\n * Find an element inside a form element in a JSX tree.\n *\n * @param form - The form element.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nfunction getFormElement(form: FormElement, name: string) {\n const element = walkJsx<NamedJSXElement>(form, (childElement) => {\n if (isJSXElementWithName(childElement, name)) {\n return childElement;\n }\n\n return undefined;\n });\n\n if (element === undefined) {\n return undefined;\n }\n\n return { element, form: form.props.name };\n}\n\n/**\n * Get an object containing the element, and optional form that's associated\n * with the element if any.\n *\n * @param element - The JSX element.\n * @returns An object containing the element and optional form.\n */\nfunction getElementWithOptionalForm(element: NamedJSXElement): {\n element: NamedJSXElement;\n form?: string;\n} {\n if (element.type !== 'Button' || !element.props.form) {\n return { element };\n }\n\n return { element, form: element.props.form };\n}\n\n/**\n * Get an element from a JSX tree with the given name.\n *\n * @param content - The interface content.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nexport function getElement(\n content: JSXElement,\n name: string,\n):\n | {\n element: NamedJSXElement;\n form?: string;\n }\n | undefined {\n if (isJSXElementWithName(content, name)) {\n return getElementWithOptionalForm(content);\n }\n\n return walkJsx(content, (element) => {\n if (element.type === 'Form') {\n return getFormElement(element, name);\n }\n\n if (isJSXElementWithName(element, name)) {\n return getElementWithOptionalForm(element);\n }\n\n return undefined;\n });\n}\n\n/**\n * Get an element from a JSX tree with the given type.\n *\n * @param content - The interface content.\n * @param type - The element type.\n * @returns The element with the given type.\n */\nexport function getElementByType<Element extends JSXElement>(\n content: JSXElement,\n type: string,\n) {\n return walkJsx(content, (element) => {\n if (element.type === type) {\n return element as Element;\n }\n\n return undefined;\n });\n}\n\n/**\n * Handle submitting event requests to OnUserInput including unwrapping potential errors.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @param id - The interface ID.\n * @param event - The event to submit.\n * @param context - The interface context.\n */\nasync function handleEvent(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n id: string,\n event: UserInputEvent,\n context: InterfaceContext | null,\n) {\n try {\n await controllerMessenger.call(\n 'ExecutionService:handleRpcRequest',\n snapId,\n {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event,\n id,\n context,\n },\n },\n },\n );\n } catch (error) {\n const [unwrapped] = unwrapError(error);\n throw unwrapped;\n }\n}\n\n/**\n * Click on an element of the Snap interface.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface content.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n */\nexport async function clickElement(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n): Promise<void> {\n const result = getElement(content, name);\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Button' || result.element.type === 'Checkbox',\n `Expected an element of type \"Button\" or \"Checkbox\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const { type } = result.element;\n const elementName = result.element.props.name;\n\n const formState = (result.form ? state[result.form] : state) as FormState;\n const currentValue = formState[elementName];\n\n switch (type) {\n case 'Button': {\n // Button click events are always triggered.\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.ButtonClickEvent,\n name: elementName,\n },\n context,\n );\n\n if (result.form && result.element.props.type === 'submit') {\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.FormSubmitEvent,\n name: result.form,\n value: state[result.form] as FormState,\n },\n context,\n );\n }\n break;\n }\n\n case 'Checkbox': {\n const newValue = !currentValue;\n const newState = mergeValue(state, name, newValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.InputChangeEvent,\n name: elementName,\n value: newValue,\n },\n context,\n );\n break;\n }\n\n /* istanbul ignore next */\n default:\n assertExhaustive(type);\n }\n}\n\n/**\n * Merge a value in the interface state.\n *\n * @param state - The actual interface state.\n * @param name - The component name that changed value.\n * @param value - The new value.\n * @param form - The form name if the element is in one.\n * @returns The state with the merged value.\n */\nexport function mergeValue(\n state: InterfaceState,\n name: string,\n value:\n | string\n | File\n | boolean\n | AccountSelectorState\n | AssetSelectorState\n | null,\n form?: string,\n): InterfaceState {\n if (form) {\n return {\n ...state,\n [form]: {\n ...(state[form] as FormState),\n [name]: value,\n },\n };\n }\n\n return { ...state, [name]: value };\n}\n\n/**\n * Process the input value for an input element based on the element type.\n *\n * @param value - The original input value.\n * @param element - The interface element.\n * @returns The processed value.\n */\nfunction processInputValue(value: string, element: NamedJSXElement): string {\n if (element.type === 'AddressInput') {\n const { chainId } = element.props;\n return `${chainId}:${value}`;\n }\n\n return value;\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function typeInField(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n TYPEABLE_INPUTS.includes(result.element.type),\n `Expected an element of type ${formatTypeErrorMessage(TYPEABLE_INPUTS)}, but found \"${result.element.type}\".`,\n );\n\n const newValue = processInputValue(value, result.element);\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, newValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: newValue,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectInDropdown(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Dropdown',\n `Expected an element of type \"Dropdown\", but found \"${result.element.type}\".`,\n );\n\n const options = getJsxChildren(result.element) as JSXElement[];\n const selectedOption = options.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The dropdown with the name \"${name}\" does not contain \"${value}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Choose an option with value from radio group interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectFromRadioGroup(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'RadioGroup',\n `Expected an element of type \"RadioGroup\", but found \"${result.element.type}\".`,\n );\n\n const options = getJsxChildren(result.element) as JSXElement[];\n const selectedOption = options.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The RadioGroup with the name \"${name}\" does not contain \"${value}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get the value from a Selector interface element.\n *\n * @param element - The Selector element to get the value from.\n * @param options - The simulation options.\n * @param value - The value to get from the Selector.\n *\n * @returns The value from the Selector element.\n */\nexport function getValueFromSelector(\n element: NamedJSXElement,\n options: SimulationOptions,\n value: string,\n) {\n switch (element.type) {\n case 'Selector': {\n const selectorOptions = getJsxChildren(element) as JSXElement[];\n const selectedOption = selectorOptions.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The Selector with the name \"${element.props.name}\" does not contain \"${value}\".`,\n );\n\n return value;\n }\n\n case 'AccountSelector': {\n const { accounts } = options;\n\n const selectedAccount = accounts.find((account) => account.id === value);\n\n assert(\n selectedAccount !== undefined,\n `The AccountSelector with the name \"${element.props.name}\" does not contain an account with ID \"${value}\".`,\n );\n\n return {\n accountId: selectedAccount.id,\n addresses: createAccountList(\n selectedAccount.address,\n createChainIdList(selectedAccount.scopes, element.props.chainIds),\n ),\n };\n }\n\n case 'AssetSelector': {\n const { assets, accounts } = options;\n\n const selectedAsset = assets[value as CaipAssetType];\n\n const { address } = parseCaipAccountId(element.props.addresses[0]);\n\n const account = accounts.find(\n (simulationAccount) => simulationAccount.address === address,\n );\n\n const accountHasAsset = account?.assets?.some((asset) => asset === value);\n\n assert(\n selectedAsset !== undefined && accountHasAsset,\n `The AssetSelector with the name \"${element.props.name}\" does not contain an asset with ID \"${value}\".`,\n );\n\n return {\n asset: value as CaipAssetType,\n name: selectedAsset.name,\n symbol: selectedAsset.symbol,\n };\n }\n\n default:\n throw new Error(\n `Expected an element of type ${formatTypeErrorMessage(SELECTOR_ELEMENTS)}, but found \"${element.type}\".`,\n );\n }\n}\n\n/**\n * Choose an option with value from a Selector interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectFromSelector(\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n const selectedValue = getValueFromSelector(result.element, options, value);\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, selectedValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: selectedValue,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Pick a date or time in a DateTimePicker interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to pick in the element.\n */\nexport async function pickDateTime(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: Date,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'DateTimePicker',\n `Expected an element of type \"DateTimePicker\", but found \"${result.element.type}\".`,\n );\n\n assert(\n !isNaN(value.getTime()),\n `Expected \"value\" to be a valid Date object.`,\n );\n\n const parsedDate = value.toISOString();\n\n const now = new Date();\n\n if (result.element.props.disableFuture) {\n assert(\n value <= now,\n `The selected date \"${parsedDate}\" is in the future, but the DateTimePicker with the name \"${name}\" has future dates disabled.`,\n );\n }\n\n if (result.element.props.disablePast) {\n assert(\n value >= now,\n `The selected date \"${parsedDate}\" is in the past, but the DateTimePicker with the name \"${name}\" has past dates disabled.`,\n );\n }\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, parsedDate, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: parsedDate,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Wait for an interface to be updated.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @param snapId - The Snap ID.\n * @param id - The interface ID.\n * @param originalContent - The original interface content.\n * @returns A promise that resolves to the updated interface.\n */\nexport async function waitForUpdate(\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n snapId: SnapId,\n id: string,\n originalContent: JSXElement,\n) {\n return new Promise<SnapHandlerInterface>((resolve) => {\n const listener = (state: SnapInterfaceControllerState) => {\n const currentInterface = state.interfaces[id];\n const newContent = currentInterface?.content;\n\n if (!deepEqual(originalContent, newContent)) {\n controllerMessenger.unsubscribe(\n 'SnapInterfaceController:stateChange',\n listener,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n content: newContent,\n id,\n },\n );\n\n resolve({ ...actions, content: newContent });\n }\n };\n\n controllerMessenger.subscribe(\n 'SnapInterfaceController:stateChange',\n listener,\n );\n });\n}\n\n/**\n * Get a formatted file size.\n *\n * @param size - The file size in bytes.\n * @returns The formatted file size in MB, with two decimal places.\n * @example\n * getFormattedFileSize(1_000_000); // '1.00 MB'\n */\nfunction getFormattedFileSize(size: number) {\n return `${(size / 1_000_000).toFixed(2)} MB`;\n}\n\n/**\n * Upload a file to an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function uploadFile(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'FileInput',\n `Expected an element of type \"FileInput\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const fileSize = await getFileSize(file);\n if (fileSize > MAX_FILE_SIZE) {\n throw new Error(\n `The file size (${getFormattedFileSize(\n fileSize,\n )}) exceeds the maximum allowed size of ${getFormattedFileSize(\n MAX_FILE_SIZE,\n )}.`,\n );\n }\n\n const fileObject = await getFileToUpload(file, options);\n const newState = mergeValue(state, name, fileObject, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.FileUploadEvent,\n name: result.element.props.name,\n file: fileObject,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get the user interface actions for a Snap interface. These actions can be\n * used to interact with the interface.\n *\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param simulationOptions - The simulation options.\n * @param interface - The interface object.\n * @param interface.content - The interface content.\n * @param interface.id - The interface ID.\n * @returns The user interface actions.\n */\nexport function getInterfaceActions(\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n simulationOptions: SimulationOptions,\n { content, id }: Omit<Interface, 'type'> & { content: JSXElement },\n): SnapInterfaceActions {\n return {\n clickElement: async (name: string) => {\n await clickElement(controllerMessenger, id, content, snapId, name);\n },\n\n pickDateTime: async (name: string, value: Date) => {\n await pickDateTime(controllerMessenger, id, content, snapId, name, value);\n },\n\n typeInField: async (name: string, value: string) => {\n await typeInField(controllerMessenger, id, content, snapId, name, value);\n },\n\n selectInDropdown: async (name: string, value: string) => {\n await selectInDropdown(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n selectFromRadioGroup: async (name: string, value: string) => {\n await selectFromRadioGroup(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n selectFromSelector: async (name: string, value: string) => {\n await selectFromSelector(\n controllerMessenger,\n simulationOptions,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n uploadFile: async (\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ) => {\n await uploadFile(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n file,\n options,\n );\n },\n\n waitForUpdate: async () =>\n waitForUpdate(\n controllerMessenger,\n simulationOptions,\n snapId,\n id,\n content,\n ),\n };\n}\n\n/**\n * Get a user interface object from a Snap.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nexport function* getInterface(\n runSaga: RunSagaFunction,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n): SagaIterator {\n const storedInterface = yield call(\n getStoredInterface,\n controllerMessenger,\n snapId,\n );\n\n const interfaceActions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n storedInterface,\n );\n\n return getInterfaceResponse(\n runSaga,\n storedInterface.type,\n storedInterface.id,\n storedInterface.content,\n interfaceActions,\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interface.mjs","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;;;;AAEA,OAAO,EAAE,qBAAqB,EAAE,oCAAoC;AAYpE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,EAAE,4BAA4B;AAM7E,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,OAAO,EACR,8BAA8B;AAC/B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EACnB,wBAAwB;AAEzB,OAAO,UAAS,wBAAwB;;AAExC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,2BAA2B;AAE7D,OAAO,EAAE,eAAe,EAAE,wBAAoB;AAE9C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAgB;AAGvD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAE,0BAAgB;AAO9E,OAAO,EAAE,sBAAsB,EAAE,2BA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ACJ,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,SAAS,CAAC,CAAC,YAAY,CAC3B,OAAwB,EACxB,MAAc,EACd,mBAA4C,EAC5C,OAA0B;IAE1B,MAAM,eAAe,GAAG,MAAM,IAAI,CAChC,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,CACP,CAAC;IAEF,MAAM,gBAAgB,GAAG,mBAAmB,CAC1C,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP,eAAe,CAChB,CAAC;IAEF,OAAO,oBAAoB,CACzB,OAAO,EACP,eAAe,CAAC,IAAI,EACpB,eAAe,CAAC,EAAE,EAClB,eAAe,CAAC,OAAO,EACvB,gBAAgB,CACjB,CAAC;AACJ,CAAC","sourcesContent":["import type { SnapInterfaceControllerState } from '@metamask/snaps-controllers';\nimport type { DialogApprovalTypes } from '@metamask/snaps-rpc-methods';\nimport { DIALOG_APPROVAL_TYPES } from '@metamask/snaps-rpc-methods';\nimport type {\n FormState,\n InterfaceContext,\n InterfaceState,\n SnapId,\n UserInputEvent,\n File,\n AccountSelectorState,\n AssetSelectorState,\n CaipAssetType,\n} from '@metamask/snaps-sdk';\nimport { DialogType, UserInputEventType, assert } from '@metamask/snaps-sdk';\nimport type {\n FooterElement,\n FormElement,\n JSXElement,\n} from '@metamask/snaps-sdk/jsx';\nimport {\n HandlerType,\n createAccountList,\n createChainIdList,\n getJsxChildren,\n unwrapError,\n walkJsx,\n} from '@metamask/snaps-utils';\nimport {\n assertExhaustive,\n hasProperty,\n parseCaipAccountId,\n} from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport deepEqual from 'fast-deep-equal';\nimport { type SagaIterator } from 'redux-saga';\nimport { call, put, select, take } from 'redux-saga/effects';\n\nimport { TYPEABLE_INPUTS } from './constants';\nimport type { RootControllerMessenger } from './controllers';\nimport { getFileSize, getFileToUpload } from './files';\nimport type { SimulationOptions } from './options';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\nimport type {\n FileOptions,\n SnapHandlerInterface,\n SnapInterface,\n SnapInterfaceActions,\n} from './types';\nimport { formatTypeErrorMessage } from './utils/errors';\n\n/**\n * The maximum file size that can be uploaded.\n */\nconst MAX_FILE_SIZE = 10_000_000; // 10 MB\n\n/**\n * The elements based on the Selector component.\n */\nconst SELECTOR_ELEMENTS = ['Selector', 'AccountSelector', 'AssetSelector'];\n\n/**\n * Get a user interface object from a type and content object.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param type - The type of the interface.\n * @param id - The interface ID.\n * @param content - The content to show in the interface.\n * @param interfaceActions - The actions to interact with the interface.\n * @returns The user interface object.\n */\nexport function getInterfaceResponse(\n runSaga: RunSagaFunction,\n type: DialogApprovalTypes[DialogType | 'default'] | 'Notification',\n id: string,\n content: JSXElement,\n interfaceActions: SnapInterfaceActions,\n): SnapInterface {\n switch (type) {\n case DIALOG_APPROVAL_TYPES[DialogType.Alert]:\n return {\n ...interfaceActions,\n type: DialogType.Alert,\n content,\n id,\n\n ok: resolveWith(runSaga, null),\n };\n\n case DIALOG_APPROVAL_TYPES[DialogType.Confirmation]:\n return {\n ...interfaceActions,\n type: DialogType.Confirmation,\n content,\n id,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DIALOG_APPROVAL_TYPES[DialogType.Prompt]:\n return {\n ...interfaceActions,\n type: DialogType.Prompt,\n content,\n id,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\n };\n\n case DIALOG_APPROVAL_TYPES.default: {\n const footer = getElementByType<FooterElement>(content, 'Footer');\n\n // No Footer defined so we apply a default footer.\n if (!footer) {\n return {\n ...interfaceActions,\n content,\n id,\n\n ok: resolveWith(runSaga, null),\n cancel: resolveWith(runSaga, null),\n };\n }\n\n // Only one button in footer so we apply a default cancel button.\n if (getJsxChildren(footer).length === 1) {\n return {\n ...interfaceActions,\n content,\n id,\n\n cancel: resolveWith(runSaga, null),\n };\n }\n\n // We have two buttons in the footer so we assume the snap handles the approval of the interface.\n return {\n ...interfaceActions,\n content,\n id,\n };\n }\n\n case 'Notification': {\n return {\n ...interfaceActions,\n content,\n id,\n };\n }\n\n default:\n throw new Error(`Unknown or unsupported dialog type: \"${String(type)}\".`);\n }\n}\n\n/**\n * Resolve the current user interface with the given value.\n *\n * @param value - The value to resolve the user interface with.\n * @yields Puts the resolve user interface action.\n */\nexport function* resolveWithSaga(value: unknown): SagaIterator {\n yield put(resolveInterface(value));\n}\n\n/**\n * Resolve the current user interface with the given value. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param value - The value to resolve the user interface with.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWith(runSaga: RunSagaFunction, value: unknown) {\n return async () => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Resolve the current user interface with the provided input. This returns a\n * function that can be used to resolve the user interface.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A function that can be used to resolve the user interface.\n */\nfunction resolveWithInput(runSaga: RunSagaFunction) {\n return async (value = '') => {\n await runSaga(resolveWithSaga, value).toPromise();\n };\n}\n\n/**\n * Get the stored user interface from the store.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nfunction* getStoredInterface(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n): SagaIterator<Interface & { content: JSXElement }> {\n const currentInterface: Interface | null = yield select(getCurrentInterface);\n\n if (currentInterface) {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n currentInterface.id,\n );\n\n return { ...currentInterface, content };\n }\n\n const { payload }: PayloadAction<Interface> = yield take(setInterface.type);\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n payload.id,\n );\n\n return { ...payload, content };\n}\n\n/**\n * A JSX element with a name.\n */\nexport type NamedJSXElement = JSXElement & { props: { name: string } };\n\n/**\n * Check if a JSX element is a JSX element with a given name.\n *\n * @param element - The JSX element.\n * @param name - The element name.\n * @returns True if the element is a JSX element with the given name, otherwise\n * false.\n */\nfunction isJSXElementWithName<Element extends JSXElement, Name extends string>(\n element: Element,\n name: Name,\n): element is Element & { props: { name: Name } } {\n return hasProperty(element.props, 'name') && element.props.name === name;\n}\n\n/**\n * Find an element inside a form element in a JSX tree.\n *\n * @param form - The form element.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nfunction getFormElement(form: FormElement, name: string) {\n const element = walkJsx<NamedJSXElement>(form, (childElement) => {\n if (isJSXElementWithName(childElement, name)) {\n return childElement;\n }\n\n return undefined;\n });\n\n if (element === undefined) {\n return undefined;\n }\n\n return { element, form: form.props.name };\n}\n\n/**\n * Get an object containing the element, and optional form that's associated\n * with the element if any.\n *\n * @param element - The JSX element.\n * @returns An object containing the element and optional form.\n */\nfunction getElementWithOptionalForm(element: NamedJSXElement): {\n element: NamedJSXElement;\n form?: string;\n} {\n if (element.type !== 'Button' || !element.props.form) {\n return { element };\n }\n\n return { element, form: element.props.form };\n}\n\n/**\n * Get an element from a JSX tree with the given name.\n *\n * @param content - The interface content.\n * @param name - The element name.\n * @returns An object containing the element and the form name if it's contained\n * in a form, otherwise undefined.\n */\nexport function getElement(\n content: JSXElement,\n name: string,\n):\n | {\n element: NamedJSXElement;\n form?: string;\n }\n | undefined {\n if (isJSXElementWithName(content, name)) {\n return getElementWithOptionalForm(content);\n }\n\n return walkJsx(content, (element) => {\n if (element.type === 'Form') {\n return getFormElement(element, name);\n }\n\n if (isJSXElementWithName(element, name)) {\n return getElementWithOptionalForm(element);\n }\n\n return undefined;\n });\n}\n\n/**\n * Get an element from a JSX tree with the given type.\n *\n * @param content - The interface content.\n * @param type - The element type.\n * @returns The element with the given type.\n */\nexport function getElementByType<Element extends JSXElement>(\n content: JSXElement,\n type: string,\n) {\n return walkJsx(content, (element) => {\n if (element.type === type) {\n return element as Element;\n }\n\n return undefined;\n });\n}\n\n/**\n * Handle submitting event requests to OnUserInput including unwrapping potential errors.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param snapId - The Snap ID.\n * @param id - The interface ID.\n * @param event - The event to submit.\n * @param context - The interface context.\n */\nasync function handleEvent(\n controllerMessenger: RootControllerMessenger,\n snapId: SnapId,\n id: string,\n event: UserInputEvent,\n context: InterfaceContext | null,\n) {\n try {\n await controllerMessenger.call(\n 'ExecutionService:handleRpcRequest',\n snapId,\n {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event,\n id,\n context,\n },\n },\n },\n );\n } catch (error) {\n const [unwrapped] = unwrapError(error);\n throw unwrapped;\n }\n}\n\n/**\n * Click on an element of the Snap interface.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface content.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n */\nexport async function clickElement(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n): Promise<void> {\n const result = getElement(content, name);\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Button' || result.element.type === 'Checkbox',\n `Expected an element of type \"Button\" or \"Checkbox\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const { type } = result.element;\n const elementName = result.element.props.name;\n\n const formState = (result.form ? state[result.form] : state) as FormState;\n const currentValue = formState[elementName];\n\n switch (type) {\n case 'Button': {\n // Button click events are always triggered.\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.ButtonClickEvent,\n name: elementName,\n },\n context,\n );\n\n if (result.form && result.element.props.type === 'submit') {\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.FormSubmitEvent,\n name: result.form,\n value: state[result.form] as FormState,\n },\n context,\n );\n }\n break;\n }\n\n case 'Checkbox': {\n const newValue = !currentValue;\n const newState = mergeValue(state, name, newValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await handleEvent(\n controllerMessenger,\n snapId,\n id,\n {\n type: UserInputEventType.InputChangeEvent,\n name: elementName,\n value: newValue,\n },\n context,\n );\n break;\n }\n\n /* istanbul ignore next */\n default:\n assertExhaustive(type);\n }\n}\n\n/**\n * Merge a value in the interface state.\n *\n * @param state - The actual interface state.\n * @param name - The component name that changed value.\n * @param value - The new value.\n * @param form - The form name if the element is in one.\n * @returns The state with the merged value.\n */\nexport function mergeValue(\n state: InterfaceState,\n name: string,\n value:\n | string\n | File\n | boolean\n | AccountSelectorState\n | AssetSelectorState\n | null,\n form?: string,\n): InterfaceState {\n if (form) {\n return {\n ...state,\n [form]: {\n ...(state[form] as FormState),\n [name]: value,\n },\n };\n }\n\n return { ...state, [name]: value };\n}\n\n/**\n * Process the input value for an input element based on the element type.\n *\n * @param value - The original input value.\n * @param element - The interface element.\n * @returns The processed value.\n */\nfunction processInputValue(value: string, element: NamedJSXElement): string {\n if (element.type === 'AddressInput') {\n const { chainId } = element.props;\n return `${chainId}:${value}`;\n }\n\n return value;\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function typeInField(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n TYPEABLE_INPUTS.includes(result.element.type),\n `Expected an element of type ${formatTypeErrorMessage(TYPEABLE_INPUTS)}, but found \"${result.element.type}\".`,\n );\n\n const newValue = processInputValue(value, result.element);\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, newValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: newValue,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Type a value in an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectInDropdown(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'Dropdown',\n `Expected an element of type \"Dropdown\", but found \"${result.element.type}\".`,\n );\n\n const options = getJsxChildren(result.element) as JSXElement[];\n const selectedOption = options.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The dropdown with the name \"${name}\" does not contain \"${value}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Choose an option with value from radio group interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectFromRadioGroup(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'RadioGroup',\n `Expected an element of type \"RadioGroup\", but found \"${result.element.type}\".`,\n );\n\n const options = getJsxChildren(result.element) as JSXElement[];\n const selectedOption = options.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The RadioGroup with the name \"${name}\" does not contain \"${value}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, value, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get the value from a Selector interface element.\n *\n * @param element - The Selector element to get the value from.\n * @param options - The simulation options.\n * @param value - The value to get from the Selector.\n *\n * @returns The value from the Selector element.\n */\nexport function getValueFromSelector(\n element: NamedJSXElement,\n options: SimulationOptions,\n value: string,\n) {\n switch (element.type) {\n case 'Selector': {\n const selectorOptions = getJsxChildren(element) as JSXElement[];\n const selectedOption = selectorOptions.find(\n (option) =>\n hasProperty(option.props, 'value') && option.props.value === value,\n );\n\n assert(\n selectedOption !== undefined,\n `The Selector with the name \"${element.props.name}\" does not contain \"${value}\".`,\n );\n\n return value;\n }\n\n case 'AccountSelector': {\n const { accounts } = options;\n\n const selectedAccount = accounts.find((account) => account.id === value);\n\n assert(\n selectedAccount !== undefined,\n `The AccountSelector with the name \"${element.props.name}\" does not contain an account with ID \"${value}\".`,\n );\n\n return {\n accountId: selectedAccount.id,\n addresses: createAccountList(\n selectedAccount.address,\n createChainIdList(selectedAccount.scopes, element.props.chainIds),\n ),\n };\n }\n\n case 'AssetSelector': {\n const { assets, accounts } = options;\n\n const selectedAsset = assets[value as CaipAssetType];\n\n const { address } = parseCaipAccountId(element.props.addresses[0]);\n\n const account = accounts.find(\n (simulationAccount) => simulationAccount.address === address,\n );\n\n const accountHasAsset = account?.assets?.some((asset) => asset === value);\n\n assert(\n selectedAsset !== undefined && accountHasAsset,\n `The AssetSelector with the name \"${element.props.name}\" does not contain an asset with ID \"${value}\".`,\n );\n\n return {\n asset: value as CaipAssetType,\n name: selectedAsset.name,\n symbol: selectedAsset.symbol,\n };\n }\n\n default:\n throw new Error(\n `Expected an element of type ${formatTypeErrorMessage(SELECTOR_ELEMENTS)}, but found \"${element.type}\".`,\n );\n }\n}\n\n/**\n * Choose an option with value from a Selector interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to type in the element.\n */\nexport async function selectFromSelector(\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: string,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n const selectedValue = getValueFromSelector(result.element, options, value);\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, selectedValue, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: selectedValue,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Pick a date or time in a DateTimePicker interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param value - The value to pick in the element.\n */\nexport async function pickDateTime(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n value: Date,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'DateTimePicker',\n `Expected an element of type \"DateTimePicker\", but found \"${result.element.type}\".`,\n );\n\n assert(\n !isNaN(value.getTime()),\n `Expected \"value\" to be a valid Date object.`,\n );\n\n const parsedDate = value.toISOString();\n\n const now = new Date();\n\n if (result.element.props.disableFuture) {\n assert(\n value <= now,\n `The selected date \"${parsedDate}\" is in the future, but the DateTimePicker with the name \"${name}\" has future dates disabled.`,\n );\n }\n\n if (result.element.props.disablePast) {\n assert(\n value >= now,\n `The selected date \"${parsedDate}\" is in the past, but the DateTimePicker with the name \"${name}\" has past dates disabled.`,\n );\n }\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const newState = mergeValue(state, name, parsedDate, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.InputChangeEvent,\n name: result.element.props.name,\n value: parsedDate,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Wait for an interface to be updated.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @param snapId - The Snap ID.\n * @param id - The interface ID.\n * @param originalContent - The original interface content.\n * @returns A promise that resolves to the updated interface.\n */\nexport async function waitForUpdate(\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n snapId: SnapId,\n id: string,\n originalContent: JSXElement,\n) {\n return new Promise<SnapHandlerInterface>((resolve) => {\n const listener = (state: SnapInterfaceControllerState) => {\n const currentInterface = state.interfaces[id];\n const newContent = currentInterface?.content;\n\n if (!deepEqual(originalContent, newContent)) {\n controllerMessenger.unsubscribe(\n 'SnapInterfaceController:stateChange',\n listener,\n );\n\n const actions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n {\n content: newContent,\n id,\n },\n );\n\n resolve({ ...actions, content: newContent });\n }\n };\n\n controllerMessenger.subscribe(\n 'SnapInterfaceController:stateChange',\n listener,\n );\n });\n}\n\n/**\n * Get a formatted file size.\n *\n * @param size - The file size in bytes.\n * @returns The formatted file size in MB, with two decimal places.\n * @example\n * getFormattedFileSize(1_000_000); // '1.00 MB'\n */\nfunction getFormattedFileSize(size: number) {\n return `${(size / 1_000_000).toFixed(2)} MB`;\n}\n\n/**\n * Upload a file to an interface element.\n *\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param id - The interface ID.\n * @param content - The interface Components.\n * @param snapId - The Snap ID.\n * @param name - The element name.\n * @param file - The file to upload. This can be a path to a file or a\n * `Uint8Array` containing the file contents. If this is a path, the file is\n * resolved relative to the current working directory.\n * @param options - The file options.\n * @param options.fileName - The name of the file. By default, this is\n * inferred from the file path if it's a path, and defaults to an empty string\n * if it's a `Uint8Array`.\n * @param options.contentType - The content type of the file. By default, this\n * is inferred from the file name if it's a path, and defaults to\n * `application/octet-stream` if it's a `Uint8Array` or the content type\n * cannot be inferred from the file name.\n */\nexport async function uploadFile(\n controllerMessenger: RootControllerMessenger,\n id: string,\n content: JSXElement,\n snapId: SnapId,\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n) {\n const result = getElement(content, name);\n\n assert(\n result !== undefined,\n `Could not find an element in the interface with the name \"${name}\".`,\n );\n\n assert(\n result.element.type === 'FileInput',\n `Expected an element of type \"FileInput\", but found \"${result.element.type}\".`,\n );\n\n const { state, context } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n id,\n );\n\n const fileSize = await getFileSize(file);\n if (fileSize > MAX_FILE_SIZE) {\n throw new Error(\n `The file size (${getFormattedFileSize(\n fileSize,\n )}) exceeds the maximum allowed size of ${getFormattedFileSize(\n MAX_FILE_SIZE,\n )}.`,\n );\n }\n\n const fileObject = await getFileToUpload(file, options);\n const newState = mergeValue(state, name, fileObject, result.form);\n\n controllerMessenger.call(\n 'SnapInterfaceController:updateInterfaceState',\n id,\n newState,\n );\n\n await controllerMessenger.call('ExecutionService:handleRpcRequest', snapId, {\n origin: 'metamask',\n handler: HandlerType.OnUserInput,\n request: {\n jsonrpc: '2.0',\n method: ' ',\n params: {\n event: {\n type: UserInputEventType.FileUploadEvent,\n name: result.element.props.name,\n file: fileObject,\n },\n id,\n context,\n },\n },\n });\n}\n\n/**\n * Get the user interface actions for a Snap interface. These actions can be\n * used to interact with the interface.\n *\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param simulationOptions - The simulation options.\n * @param interface - The interface object.\n * @param interface.content - The interface content.\n * @param interface.id - The interface ID.\n * @returns The user interface actions.\n */\nexport function getInterfaceActions(\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n simulationOptions: SimulationOptions,\n { content, id }: Omit<Interface, 'type'> & { content: JSXElement },\n): SnapInterfaceActions {\n return {\n clickElement: async (name: string) => {\n await clickElement(controllerMessenger, id, content, snapId, name);\n },\n\n pickDateTime: async (name: string, value: Date) => {\n await pickDateTime(controllerMessenger, id, content, snapId, name, value);\n },\n\n typeInField: async (name: string, value: string) => {\n await typeInField(controllerMessenger, id, content, snapId, name, value);\n },\n\n selectInDropdown: async (name: string, value: string) => {\n await selectInDropdown(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n selectFromRadioGroup: async (name: string, value: string) => {\n await selectFromRadioGroup(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n selectFromSelector: async (name: string, value: string) => {\n await selectFromSelector(\n controllerMessenger,\n simulationOptions,\n id,\n content,\n snapId,\n name,\n value,\n );\n },\n\n uploadFile: async (\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ) => {\n await uploadFile(\n controllerMessenger,\n id,\n content,\n snapId,\n name,\n file,\n options,\n );\n },\n\n waitForUpdate: async () =>\n waitForUpdate(\n controllerMessenger,\n simulationOptions,\n snapId,\n id,\n content,\n ),\n };\n}\n\n/**\n * Get a user interface object from a Snap.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger used to call actions.\n * @param options - The simulation options.\n * @yields Takes the set interface action.\n * @returns The user interface object.\n */\nexport function* getInterface(\n runSaga: RunSagaFunction,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n options: SimulationOptions,\n): SagaIterator {\n const storedInterface = yield call(\n getStoredInterface,\n controllerMessenger,\n snapId,\n );\n\n const interfaceActions = getInterfaceActions(\n snapId,\n controllerMessenger,\n options,\n storedInterface,\n );\n\n return getInterfaceResponse(\n runSaga,\n storedInterface.type,\n storedInterface.id,\n storedInterface.content,\n interfaceActions,\n );\n}\n"]}
|
package/dist/logger.d.cts
CHANGED
package/dist/logger.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.cts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,0BAA0C,CAAC"}
|
package/dist/logger.d.mts
CHANGED
package/dist/logger.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,0BAA0C,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSetCurrentChainImplementation =
|
|
3
|
+
exports.getSetCurrentChainImplementation = getSetCurrentChainImplementation;
|
|
4
4
|
const effects_1 = require("redux-saga/effects");
|
|
5
5
|
const store_1 = require("../../store/index.cjs");
|
|
6
6
|
/**
|
|
@@ -25,5 +25,4 @@ function getSetCurrentChainImplementation(runSaga) {
|
|
|
25
25
|
return runSaga(setCurrentChainImplementation, ...args).result();
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
exports.getSetCurrentChainImplementation = getSetCurrentChainImplementation;
|
|
29
28
|
//# sourceMappingURL=chain.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":";;AAyBA,4EAIC;AA3BD,gDAAyC;AAEzC,iDAAuC;AAGvC;;;;;;GAMG;AACH,QAAQ,CAAC,CAAC,6BAA6B,CAAC,OAAY;IAClD,MAAM,IAAA,aAAG,EAAC,IAAA,gBAAQ,EAAC,OAAO,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gCAAgC,CAAC,OAAwB;IACvE,OAAO,CAAC,GAAG,IAAsD,EAAE,EAAE;QACnE,OAAO,OAAO,CAAC,6BAA6B,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Hex } from '@metamask/utils';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport { setChain } from '../../store';\nimport type { RunSagaFunction } from '../../store';\n\n/**\n * Set the current chain ID in state.\n *\n * @param chainId - The chain ID.\n * @yields Puts the chain ID in the store.\n * @returns `null`.\n */\nfunction* setCurrentChainImplementation(chainId: Hex): SagaIterator {\n yield put(setChain(chainId));\n return null;\n}\n\n/**\n * Get a method that can be used to set the current chain.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to set the current chain.\n */\nexport function getSetCurrentChainImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof setCurrentChainImplementation>) => {\n return runSaga(setCurrentChainImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { SagaIterator } from "redux-saga";
|
|
1
3
|
import type { RunSagaFunction } from "../../store/index.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* Set the current chain ID in state.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain ID.
|
|
8
|
+
* @yields Puts the chain ID in the store.
|
|
9
|
+
* @returns `null`.
|
|
10
|
+
*/
|
|
11
|
+
declare function setCurrentChainImplementation(chainId: Hex): SagaIterator;
|
|
2
12
|
/**
|
|
3
13
|
* Get a method that can be used to set the current chain.
|
|
4
14
|
*
|
|
5
15
|
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
16
|
* @returns A method that can be used to set the current chain.
|
|
7
17
|
*/
|
|
8
|
-
export declare function getSetCurrentChainImplementation(runSaga: RunSagaFunction): (
|
|
18
|
+
export declare function getSetCurrentChainImplementation(runSaga: RunSagaFunction): (...args: Parameters<typeof setCurrentChainImplementation>) => any;
|
|
19
|
+
export {};
|
|
9
20
|
//# sourceMappingURL=chain.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB;AAI/C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAEnD;;;;;;GAMG;AACH,iBAAU,6BAA6B,CAAC,OAAO,EAAE,GAAG,GAAG,YAAY,CAGlE;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,eAAe,IAC/D,GAAG,MAAM,UAAU,CAAC,OAAO,6BAA6B,CAAC,SAGlE"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { Hex } from "@metamask/utils";
|
|
2
|
+
import type { SagaIterator } from "redux-saga";
|
|
1
3
|
import type { RunSagaFunction } from "../../store/index.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Set the current chain ID in state.
|
|
6
|
+
*
|
|
7
|
+
* @param chainId - The chain ID.
|
|
8
|
+
* @yields Puts the chain ID in the store.
|
|
9
|
+
* @returns `null`.
|
|
10
|
+
*/
|
|
11
|
+
declare function setCurrentChainImplementation(chainId: Hex): SagaIterator;
|
|
2
12
|
/**
|
|
3
13
|
* Get a method that can be used to set the current chain.
|
|
4
14
|
*
|
|
5
15
|
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
16
|
* @returns A method that can be used to set the current chain.
|
|
7
17
|
*/
|
|
8
|
-
export declare function getSetCurrentChainImplementation(runSaga: RunSagaFunction): (
|
|
18
|
+
export declare function getSetCurrentChainImplementation(runSaga: RunSagaFunction): (...args: Parameters<typeof setCurrentChainImplementation>) => any;
|
|
19
|
+
export {};
|
|
9
20
|
//# sourceMappingURL=chain.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chain.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB;AAI/C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAEnD;;;;;;GAMG;AACH,iBAAU,6BAA6B,CAAC,OAAO,EAAE,GAAG,GAAG,YAAY,CAGlE;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,eAAe,IAC/D,GAAG,MAAM,UAAU,CAAC,OAAO,6BAA6B,CAAC,SAGlE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEndTraceImplementation =
|
|
3
|
+
exports.getEndTraceImplementation = getEndTraceImplementation;
|
|
4
4
|
const effects_1 = require("redux-saga/effects");
|
|
5
5
|
const store_1 = require("../../store/index.cjs");
|
|
6
6
|
/**
|
|
@@ -25,5 +25,4 @@ function getEndTraceImplementation(runSaga) {
|
|
|
25
25
|
return runSaga(endTraceImplementation, ...args).result();
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
exports.getEndTraceImplementation = getEndTraceImplementation;
|
|
29
28
|
//# sourceMappingURL=end-trace.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-trace.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"end-trace.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":";;AAyBA,8DAIC;AA3BD,gDAAyC;AAGzC,iDAAuC;AAEvC;;;;;;GAMG;AACH,QAAQ,CAAC,CAAC,sBAAsB,CAAC,KAAqB;IACpD,MAAM,IAAA,aAAG,EAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,OAAwB;IAChE,OAAO,CAAC,GAAG,IAA+C,EAAE,EAAE;QAC5D,OAAO,OAAO,CAAC,sBAAsB,EAAE,GAAG,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { EndTraceParams } from '@metamask/snaps-sdk';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { endTrace } from '../../store';\n\n/**\n * End a performance trace.\n *\n * @param event - The performance trace to end.\n * @returns `null`.\n * @yields Adds the completed trace to the store.\n */\nfunction* endTraceImplementation(event: EndTraceParams): SagaIterator {\n yield put(endTrace(event));\n return null;\n}\n\n/**\n * Get a method that can be used to end a performance trace.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to end a performance trace.\n */\nexport function getEndTraceImplementation(runSaga: RunSagaFunction) {\n return (...args: Parameters<typeof endTraceImplementation>) => {\n return runSaga(endTraceImplementation, ...args).result();\n };\n}\n"]}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { EndTraceParams } from "@metamask/snaps-sdk";
|
|
2
|
+
import type { SagaIterator } from "redux-saga";
|
|
1
3
|
import type { RunSagaFunction } from "../../store/index.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* End a performance trace.
|
|
6
|
+
*
|
|
7
|
+
* @param event - The performance trace to end.
|
|
8
|
+
* @returns `null`.
|
|
9
|
+
* @yields Adds the completed trace to the store.
|
|
10
|
+
*/
|
|
11
|
+
declare function endTraceImplementation(event: EndTraceParams): SagaIterator;
|
|
2
12
|
/**
|
|
3
13
|
* Get a method that can be used to end a performance trace.
|
|
4
14
|
*
|
|
5
15
|
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
16
|
* @returns A method that can be used to end a performance trace.
|
|
7
17
|
*/
|
|
8
|
-
export declare function getEndTraceImplementation(runSaga: RunSagaFunction): (
|
|
18
|
+
export declare function getEndTraceImplementation(runSaga: RunSagaFunction): (...args: Parameters<typeof endTraceImplementation>) => any;
|
|
19
|
+
export {};
|
|
9
20
|
//# sourceMappingURL=end-trace.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-trace.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"end-trace.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAGnD;;;;;;GAMG;AACH,iBAAU,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,CAGpE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,IACxD,GAAG,MAAM,UAAU,CAAC,OAAO,sBAAsB,CAAC,SAG3D"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import type { EndTraceParams } from "@metamask/snaps-sdk";
|
|
2
|
+
import type { SagaIterator } from "redux-saga";
|
|
1
3
|
import type { RunSagaFunction } from "../../store/index.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* End a performance trace.
|
|
6
|
+
*
|
|
7
|
+
* @param event - The performance trace to end.
|
|
8
|
+
* @returns `null`.
|
|
9
|
+
* @yields Adds the completed trace to the store.
|
|
10
|
+
*/
|
|
11
|
+
declare function endTraceImplementation(event: EndTraceParams): SagaIterator;
|
|
2
12
|
/**
|
|
3
13
|
* Get a method that can be used to end a performance trace.
|
|
4
14
|
*
|
|
5
15
|
* @param runSaga - A function to run a saga outside the usual Redux flow.
|
|
6
16
|
* @returns A method that can be used to end a performance trace.
|
|
7
17
|
*/
|
|
8
|
-
export declare function getEndTraceImplementation(runSaga: RunSagaFunction): (
|
|
18
|
+
export declare function getEndTraceImplementation(runSaga: RunSagaFunction): (...args: Parameters<typeof endTraceImplementation>) => any;
|
|
19
|
+
export {};
|
|
9
20
|
//# sourceMappingURL=end-trace.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"end-trace.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"end-trace.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/end-trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAA4B;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB;AAG/C,OAAO,KAAK,EAAE,eAAe,EAAE,8BAAoB;AAGnD;;;;;;GAMG;AACH,iBAAU,sBAAsB,CAAC,KAAK,EAAE,cAAc,GAAG,YAAY,CAGpE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,IACxD,GAAG,MAAM,UAAU,CAAC,OAAO,sBAAsB,CAAC,SAG3D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGetMnemonicImplementation =
|
|
3
|
+
exports.getGetMnemonicImplementation = getGetMnemonicImplementation;
|
|
4
4
|
const key_tree_1 = require("@metamask/key-tree");
|
|
5
5
|
const constants_1 = require("../../constants.cjs");
|
|
6
6
|
/**
|
|
@@ -25,5 +25,4 @@ function getGetMnemonicImplementation(defaultSecretRecoveryPhrase = constants_1.
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
exports.getGetMnemonicImplementation = getGetMnemonicImplementation;
|
|
29
28
|
//# sourceMappingURL=get-mnemonic.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mnemonic.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-mnemonic.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":";;AAWA,oEAiBC;AA5BD,iDAA2D;AAE3D,mDAAuE;AAEvE;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAC1C,8BAAsC,uBAAW;IAEjD,OAAO,KAAK,EAAE,MAA2B,EAAuB,EAAE;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAA,gCAAqB,EAAC,2BAA2B,CAAC,CAAC;QAC5D,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,IAAA,gCAAqB,EAAC,2BAA2B,CAAC,CAAC;YAC5D,KAAK,aAAa;gBAChB,OAAO,IAAA,gCAAqB,EAAC,mCAAuB,CAAC,CAAC;YACxD;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { mnemonicPhraseToBytes } from '@metamask/key-tree';\n\nimport { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from '../../constants';\n\n/**\n * Get the implementation of the `getMnemonic` method.\n *\n * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to\n * use.\n * @returns The implementation of the `getMnemonic` method.\n */\nexport function getGetMnemonicImplementation(\n defaultSecretRecoveryPhrase: string = DEFAULT_SRP,\n) {\n return async (source?: string | undefined): Promise<Uint8Array> => {\n if (!source) {\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n }\n\n switch (source) {\n case 'default':\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n case 'alternative':\n return mnemonicPhraseToBytes(DEFAULT_ALTERNATIVE_SRP);\n default:\n throw new Error(`Entropy source with ID \"${source}\" not found.`);\n }\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mnemonic.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,
|
|
1
|
+
{"version":3,"file":"get-mnemonic.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,IAEnC,SAAS,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,UAAU,CAAC,CAchE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mnemonic.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,
|
|
1
|
+
{"version":3,"file":"get-mnemonic.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,IAEnC,SAAS,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,UAAU,CAAC,CAchE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGetPreferencesMethodImplementation =
|
|
3
|
+
exports.getGetPreferencesMethodImplementation = getGetPreferencesMethodImplementation;
|
|
4
4
|
/**
|
|
5
5
|
* Get the implementation of the `getPreferences` hook.
|
|
6
6
|
*
|
|
@@ -35,5 +35,4 @@ function getGetPreferencesMethodImplementation({ currency, locale, hideBalances,
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
exports.getGetPreferencesMethodImplementation = getGetPreferencesMethodImplementation;
|
|
39
38
|
//# sourceMappingURL=get-preferences.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-preferences.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-preferences.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-preferences.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-preferences.ts"],"names":[],"mappings":";;AAmBA,sFA4BC;AA7CD;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,qCAAqC,CAAC,EACpD,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,YAAY,GACM;IAClB,OAAO,GAAG,EAAE;QACV,OAAO;YACL,QAAQ;YACR,MAAM;YACN,YAAY;YACZ,iBAAiB;YACjB,sBAAsB;YACtB,iBAAiB;YACjB,kBAAkB;YAClB,eAAe;YACf,eAAe;YACf,sBAAsB;YACtB,YAAY;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { SimulationOptions } from '../../options';\n\n/**\n * Get the implementation of the `getPreferences` hook.\n *\n * @param options - The simulation options.\n * @param options.currency - The currency to use.\n * @param options.locale - The locale to use.\n * @param options.hideBalances - Whether to hide balances.\n * @param options.useSecurityAlerts - Whether to run transactions and signatures through security providers.\n * @param options.simulateOnChainActions - Whether to simulate transactions and signatures.\n * @param options.useTokenDetection - Whether to auto-detect tokens.\n * @param options.batchCheckBalances - Whether to fetch balances in an aggregated manner.\n * @param options.displayNftMedia - Whether to display NFT media.\n * @param options.useNftDetection - Whether to auto-detect NFTs.\n * @param options.useExternalPricingData - Whether to get token price data from an external source.\n * @param options.showTestnets - Whether to show testnets.\n * @returns The implementation of the `getPreferences` hook.\n */\nexport function getGetPreferencesMethodImplementation({\n currency,\n locale,\n hideBalances,\n useSecurityAlerts,\n simulateOnChainActions,\n useTokenDetection,\n batchCheckBalances,\n displayNftMedia,\n useNftDetection,\n useExternalPricingData,\n showTestnets,\n}: SimulationOptions) {\n return () => {\n return {\n currency,\n locale,\n hideBalances,\n useSecurityAlerts,\n simulateOnChainActions,\n useTokenDetection,\n batchCheckBalances,\n displayNftMedia,\n useNftDetection,\n useExternalPricingData,\n showTestnets,\n };\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGetSnapImplementation =
|
|
3
|
+
exports.getGetSnapImplementation = getGetSnapImplementation;
|
|
4
4
|
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
5
5
|
/**
|
|
6
6
|
* Get a method that gets a Snap by its ID.
|
|
@@ -47,5 +47,4 @@ function getGetSnapImplementation(preinstalled = true) {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
exports.getGetSnapImplementation = getGetSnapImplementation;
|
|
51
50
|
//# sourceMappingURL=get-snap.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-snap.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-snap.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":";;AAaA,4DAoCC;AA/CD,uDAAmD;AAGnD;;;;;;;GAOG;AACH,SAAgB,wBAAwB,CAAC,eAAwB,IAAI;IACnE,OAAO,CAAC,OAAe,EAAQ,EAAE;QAC/B,0EAA0E;QAC1E,oDAAoD;QACpD,OAAO;YACL,EAAE,EAAE,gCAA0C;YAC9C,OAAO,EAAE,OAAwB;YACjC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,wBAAU,CAAC,OAAO;YAC1B,cAAc,EAAE,EAAE;YAClB,kBAAkB,EAAE,EAAE;YACtB,QAAQ,EAAE;gBACR,OAAO,EAAE,OAAwB;gBACjC,YAAY,EAAE,WAAW;gBACzB,WAAW,EAAE,sCAAsC;gBACnD,UAAU,EAAE;oBACV,IAAI,EAAE,KAAK;oBACX,GAAG,EAAE,uCAAuC;iBAC7C;gBACD,MAAM,EAAE;oBACN,MAAM,EAAE,QAAQ;oBAChB,QAAQ,EAAE;wBACR,GAAG,EAAE;4BACH,QAAQ,EAAE,eAAe;4BACzB,WAAW,EAAE,4BAA4B;4BACzC,QAAQ,EAAE,4BAA4B;yBACvC;qBACF;iBACF;gBACD,kBAAkB,EAAE,EAAE;gBACtB,eAAe,EAAE,KAAK;aACvB;YACD,YAAY;SACb,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { SnapId } from '@metamask/snaps-sdk';\nimport type { Snap } from '@metamask/snaps-utils';\nimport { SnapStatus } from '@metamask/snaps-utils';\nimport type { SemVerVersion } from '@metamask/utils';\n\n/**\n * Get a method that gets a Snap by its ID.\n *\n * @param preinstalled - Whether the Snap is preinstalled. If `true`, the Snap\n * will be returned as a preinstalled Snap.\n * @returns A method that gets a Snap by its ID. It will always return a mock\n * Snap for simulation purposes.\n */\nexport function getGetSnapImplementation(preinstalled: boolean = true) {\n return (_snapId: string): Snap => {\n // This is a mock Snap for simulation purposes. Most of the fields are not\n // actually used, but returned for type-safety sake.\n return {\n id: 'npm:@metamask/snaps-simulation' as SnapId,\n version: '0.1.0' as SemVerVersion,\n enabled: true,\n blocked: false,\n status: SnapStatus.Running,\n versionHistory: [],\n initialPermissions: {},\n manifest: {\n version: '0.1.0' as SemVerVersion,\n proposedName: 'Test Snap',\n description: 'A test Snap for simulation purposes.',\n repository: {\n type: 'git',\n url: 'https://github.com/MetaMask/snaps.git',\n },\n source: {\n shasum: 'unused',\n location: {\n npm: {\n filePath: 'dist/index.js',\n packageName: '@metamask/snaps-simulation',\n registry: 'https://registry.npmjs.org',\n },\n },\n },\n initialPermissions: {},\n manifestVersion: '0.1',\n },\n preinstalled,\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-snap.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,8BAA8B;AAIlD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,GAAE,OAAc,
|
|
1
|
+
{"version":3,"file":"get-snap.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,8BAA8B;AAIlD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,GAAE,OAAc,IAC3D,SAAS,MAAM,KAAG,IAAI,CAmC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-snap.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,8BAA8B;AAIlD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,GAAE,OAAc,
|
|
1
|
+
{"version":3,"file":"get-snap.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-snap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,8BAA8B;AAIlD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,GAAE,OAAc,IAC3D,SAAS,MAAM,KAAG,IAAI,CAmC/B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getShowNativeNotificationImplementation = getShowNativeNotificationImplementation;
|
|
4
|
+
exports.getShowInAppNotificationImplementation = getShowInAppNotificationImplementation;
|
|
4
5
|
const snaps_sdk_1 = require("@metamask/snaps-sdk");
|
|
5
6
|
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
7
|
const effects_1 = require("redux-saga/effects");
|
|
@@ -29,7 +30,6 @@ function getShowNativeNotificationImplementation(runSaga) {
|
|
|
29
30
|
return await runSaga(showNativeNotificationImplementation, ...args).toPromise();
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
exports.getShowNativeNotificationImplementation = getShowNativeNotificationImplementation;
|
|
33
33
|
/**
|
|
34
34
|
* Show an in-app notification to the user.
|
|
35
35
|
*
|
|
@@ -67,5 +67,4 @@ function getShowInAppNotificationImplementation(runSaga) {
|
|
|
67
67
|
return await runSaga(showInAppNotificationImplementation, ...args).toPromise();
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
exports.getShowInAppNotificationImplementation = getShowInAppNotificationImplementation;
|
|
71
70
|
//# sourceMappingURL=notifications.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/notifications.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/notifications.ts"],"names":[],"mappings":";;AAmCA,0FAWC;AAkDD,wFAWC;AA1GD,mDAAuD;AACvD,8CAA0C;AAE1C,gDAAyC;AAGzC,iDAA4D;AAE5D;;;;;;;;GAQG;AACH,QAAQ,CAAC,CAAC,oCAAoC,CAC5C,OAAe,EACf,EAAE,OAAO,EAAgB;IAEzB,MAAM,IAAA,aAAG,EACP,IAAA,uBAAe,EAAC,EAAE,EAAE,EAAE,IAAA,gBAAM,GAAE,EAAE,IAAI,EAAE,4BAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAC1E,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uCAAuC,CACrD,OAAwB;IAExB,OAAO,KAAK,EACV,GAAG,IAA6D,EAChE,EAAE;QACF,OAAO,MAAM,OAAO,CAClB,oCAAoC,EACpC,GAAG,IAAI,CACR,CAAC,SAAS,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAUD;;;;;;;;;;;GAWG;AACH,QAAQ,CAAC,CAAC,mCAAmC,CAC3C,OAAe,EACf,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAA2B;IAEhE,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAA,aAAG,EAAC,IAAA,oBAAY,EAAC,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAA,aAAG,EACP,IAAA,uBAAe,EAAC;QACd,EAAE,EAAE,IAAA,gBAAM,GAAE;QACZ,IAAI,EAAE,4BAAgB,CAAC,KAAK;QAC5B,OAAO;QACP,KAAK;QACL,OAAO;QACP,UAAU;KACX,CAAC,CACH,CAAC;IAEF,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sCAAsC,CACpD,OAAwB;IAExB,OAAO,KAAK,EACV,GAAG,IAA4D,EAC/D,EAAE;QACF,OAAO,MAAM,OAAO,CAClB,mCAAmC,EACnC,GAAG,IAAI,CACR,CAAC,SAAS,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { NotifyParams } from '@metamask/snaps-sdk';\nimport { NotificationType } from '@metamask/snaps-sdk';\nimport { nanoid } from '@reduxjs/toolkit';\nimport type { SagaIterator } from 'redux-saga';\nimport { put } from 'redux-saga/effects';\n\nimport type { RunSagaFunction } from '../../store';\nimport { addNotification, setInterface } from '../../store';\n\n/**\n * Show a native notification to the user.\n *\n * @param _snapId - The ID of the Snap that created the notification.\n * @param options - The notification options.\n * @param options.message - The message to show in the notification.\n * @yields Adds the notification to the store.\n * @returns `null`.\n */\nfunction* showNativeNotificationImplementation(\n _snapId: string,\n { message }: NotifyParams,\n): SagaIterator {\n yield put(\n addNotification({ id: nanoid(), type: NotificationType.Native, message }),\n );\n\n return null;\n}\n\n/**\n * Get a method that can be used to show a native notification.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to show a native notification.\n */\nexport function getShowNativeNotificationImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (\n ...args: Parameters<typeof showNativeNotificationImplementation>\n ) => {\n return await runSaga(\n showNativeNotificationImplementation,\n ...args,\n ).toPromise();\n };\n}\n\ntype InAppNotificationParams = {\n type: NotificationType;\n message: string;\n title?: string | undefined;\n content?: string | undefined;\n footerLink?: { text: string; href: string } | undefined;\n};\n\n/**\n * Show an in-app notification to the user.\n *\n * @param _snapId - The ID of the Snap that created the notification.\n * @param options - The notification options.\n * @param options.message - The message to show in the notification.\n * @param options.title - The title to show in the notification.\n * @param options.content - The JSX content to show in the notification.\n * @param options.footerLink - The footer to show in the notification.\n * @yields Adds the notification to the store.\n * @returns `null`.\n */\nfunction* showInAppNotificationImplementation(\n _snapId: string,\n { message, title, content, footerLink }: InAppNotificationParams,\n): SagaIterator<null> {\n if (content) {\n yield put(setInterface({ type: 'Notification', id: content }));\n }\n\n yield put(\n addNotification({\n id: nanoid(),\n type: NotificationType.InApp,\n message,\n title,\n content,\n footerLink,\n }),\n );\n\n return null;\n}\n\n/**\n * Get a method that can be used to show an in-app notification.\n *\n * @param runSaga - A function to run a saga outside the usual Redux flow.\n * @returns A method that can be used to show an in-app notification.\n */\nexport function getShowInAppNotificationImplementation(\n runSaga: RunSagaFunction,\n) {\n return async (\n ...args: Parameters<typeof showInAppNotificationImplementation>\n ) => {\n return await runSaga(\n showInAppNotificationImplementation,\n ...args,\n ).toPromise();\n };\n}\n"]}
|