@metamask/snaps-jest 8.1.3 → 8.2.0

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/{chunk-AFA4KKWW.mjs → chunk-43HRTFLS.mjs} +148 -33
  3. package/dist/chunk-43HRTFLS.mjs.map +1 -0
  4. package/dist/{chunk-2OHD2VKS.js → chunk-4MAA7WGJ.js} +8 -34
  5. package/dist/chunk-4MAA7WGJ.js.map +1 -0
  6. package/dist/{chunk-UPR3PTSA.mjs → chunk-5SGLRSWR.mjs} +8 -34
  7. package/dist/chunk-5SGLRSWR.mjs.map +1 -0
  8. package/dist/{chunk-KQBJQLZG.js → chunk-7Y27L2EV.js} +1 -1
  9. package/dist/chunk-7Y27L2EV.js.map +1 -0
  10. package/dist/{chunk-U3DVRTS2.mjs → chunk-CYPP66I7.mjs} +2 -2
  11. package/dist/{chunk-EDFQDZNY.js → chunk-DVDAOXO7.js} +3 -3
  12. package/dist/{chunk-R55KAAM4.js → chunk-GVTDUKXK.js} +148 -33
  13. package/dist/chunk-GVTDUKXK.js.map +1 -0
  14. package/dist/{chunk-3FDEYMQU.js → chunk-IVFVB4VR.js} +7 -7
  15. package/dist/chunk-IWJ4HKDR.mjs +50 -0
  16. package/dist/chunk-IWJ4HKDR.mjs.map +1 -0
  17. package/dist/{chunk-6V5GEUDO.mjs → chunk-MAT5SBM7.mjs} +1 -1
  18. package/dist/chunk-MAT5SBM7.mjs.map +1 -0
  19. package/dist/{chunk-K55LIE3W.mjs → chunk-NSMTFK33.mjs} +2 -2
  20. package/dist/{chunk-E2BYTLOT.mjs → chunk-O24GTINW.mjs} +2 -2
  21. package/dist/chunk-SW65QYFV.js +50 -0
  22. package/dist/chunk-SW65QYFV.js.map +1 -0
  23. package/dist/{chunk-JXAJWUVZ.js → chunk-WRKY2DLV.js} +3 -3
  24. package/dist/environment.js +6 -6
  25. package/dist/environment.mjs +5 -5
  26. package/dist/helpers.js +6 -6
  27. package/dist/helpers.mjs +5 -5
  28. package/dist/index.js +7 -7
  29. package/dist/index.mjs +6 -6
  30. package/dist/internals/index.js +9 -5
  31. package/dist/internals/index.mjs +10 -6
  32. package/dist/internals/request.js +5 -5
  33. package/dist/internals/request.mjs +4 -4
  34. package/dist/internals/simulation/files.js +8 -2
  35. package/dist/internals/simulation/files.mjs +7 -1
  36. package/dist/internals/simulation/index.js +8 -4
  37. package/dist/internals/simulation/index.mjs +9 -5
  38. package/dist/internals/simulation/interface.js +7 -2
  39. package/dist/internals/simulation/interface.mjs +8 -3
  40. package/dist/internals/simulation/simulation.js +3 -3
  41. package/dist/internals/simulation/simulation.mjs +2 -2
  42. package/dist/matchers.js +6 -6
  43. package/dist/matchers.mjs +5 -5
  44. package/dist/setup.js +5 -5
  45. package/dist/setup.mjs +5 -5
  46. package/dist/tsconfig.build.tsbuildinfo +1 -1
  47. package/dist/types/internals/request.d.ts +2 -1
  48. package/dist/types/internals/simulation/files.d.ts +36 -0
  49. package/dist/types/internals/simulation/interface.d.ts +39 -4
  50. package/dist/types/types.d.ts +32 -0
  51. package/package.json +8 -6
  52. package/dist/chunk-2OHD2VKS.js.map +0 -1
  53. package/dist/chunk-6V5GEUDO.mjs.map +0 -1
  54. package/dist/chunk-AFA4KKWW.mjs.map +0 -1
  55. package/dist/chunk-KQBJQLZG.js.map +0 -1
  56. package/dist/chunk-R55KAAM4.js.map +0 -1
  57. package/dist/chunk-TBDYQSRT.mjs +0 -16
  58. package/dist/chunk-TBDYQSRT.mjs.map +0 -1
  59. package/dist/chunk-TVD4SWH7.js +0 -16
  60. package/dist/chunk-TVD4SWH7.js.map +0 -1
  61. package/dist/chunk-UPR3PTSA.mjs.map +0 -1
  62. /package/dist/{chunk-U3DVRTS2.mjs.map → chunk-CYPP66I7.mjs.map} +0 -0
  63. /package/dist/{chunk-EDFQDZNY.js.map → chunk-DVDAOXO7.js.map} +0 -0
  64. /package/dist/{chunk-3FDEYMQU.js.map → chunk-IVFVB4VR.js.map} +0 -0
  65. /package/dist/{chunk-K55LIE3W.mjs.map → chunk-NSMTFK33.mjs.map} +0 -0
  66. /package/dist/{chunk-E2BYTLOT.mjs.map → chunk-O24GTINW.mjs.map} +0 -0
  67. /package/dist/{chunk-JXAJWUVZ.js.map → chunk-WRKY2DLV.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [8.2.0]
10
+ ### Added
11
+ - Add support for `Checkbox` to `snaps-jest` ([#2515](https://github.com/MetaMask/snaps/pull/2515))
12
+ - Checkboxes can be interacted with using `clickElement`.
13
+ - Add support for `FileInput` to `snaps-jest` ([#2494](https://github.com/MetaMask/snaps/pull/2494))
14
+ - Files can be uploaded to file inputs using `uploadFile`.
15
+
9
16
  ## [8.1.3]
10
17
  ### Changed
11
18
  - Bump MetaMask dependencies ([#2460](https://github.com/MetaMask/snaps/pull/2460), [#2477](https://github.com/MetaMask/snaps/pull/2477))
@@ -165,7 +172,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
165
172
  - The version of the package no longer needs to match the version of all other
166
173
  MetaMask Snaps packages.
167
174
 
168
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.1.3...HEAD
175
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.2.0...HEAD
176
+ [8.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.1.3...@metamask/snaps-jest@8.2.0
169
177
  [8.1.3]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.1.2...@metamask/snaps-jest@8.1.3
170
178
  [8.1.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.1.1...@metamask/snaps-jest@8.1.2
171
179
  [8.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-jest@8.1.0...@metamask/snaps-jest@8.1.1
@@ -1,3 +1,7 @@
1
+ import {
2
+ getFileSize,
3
+ getFileToUpload
4
+ } from "./chunk-IWJ4HKDR.mjs";
1
5
  import {
2
6
  getCurrentInterface,
3
7
  resolveInterface,
@@ -12,8 +16,9 @@ import {
12
16
  unwrapError,
13
17
  walkJsx
14
18
  } from "@metamask/snaps-utils";
15
- import { hasProperty } from "@metamask/utils";
19
+ import { assertExhaustive, hasProperty } from "@metamask/utils";
16
20
  import { call, put, select, take } from "redux-saga/effects";
21
+ var MAX_FILE_SIZE = 1e7;
17
22
  function getInterfaceResponse(runSaga, type, content, interfaceActions) {
18
23
  switch (type) {
19
24
  case DialogType.Alert:
@@ -137,36 +142,68 @@ async function clickElement(controllerMessenger, id, content, snapId, name) {
137
142
  `Could not find an element in the interface with the name "${name}".`
138
143
  );
139
144
  assert(
140
- result.element.type === "Button",
141
- `Expected an element of type "Button", but found "${result.element.type}".`
145
+ result.element.type === "Button" || result.element.type === "Checkbox",
146
+ `Expected an element of type "Button" or "Checkbox", but found "${result.element.type}".`
142
147
  );
143
148
  const { state, context } = controllerMessenger.call(
144
149
  "SnapInterfaceController:getInterface",
145
150
  snapId,
146
151
  id
147
152
  );
148
- await handleEvent(
149
- controllerMessenger,
150
- snapId,
151
- id,
152
- {
153
- type: UserInputEventType.ButtonClickEvent,
154
- name: result.element.props.name
155
- },
156
- context
157
- );
158
- if (result.form && result.element.props.type === "submit") {
159
- await handleEvent(
160
- controllerMessenger,
161
- snapId,
162
- id,
163
- {
164
- type: UserInputEventType.FormSubmitEvent,
165
- name: result.form,
166
- value: state[result.form]
167
- },
168
- context
169
- );
153
+ const { type } = result.element;
154
+ const elementName = result.element.props.name;
155
+ const formState = result.form ? state[result.form] : state;
156
+ const currentValue = formState[elementName];
157
+ switch (type) {
158
+ case "Button": {
159
+ await handleEvent(
160
+ controllerMessenger,
161
+ snapId,
162
+ id,
163
+ {
164
+ type: UserInputEventType.ButtonClickEvent,
165
+ name: elementName
166
+ },
167
+ context
168
+ );
169
+ if (result.form && result.element.props.type === "submit") {
170
+ await handleEvent(
171
+ controllerMessenger,
172
+ snapId,
173
+ id,
174
+ {
175
+ type: UserInputEventType.FormSubmitEvent,
176
+ name: result.form,
177
+ value: state[result.form]
178
+ },
179
+ context
180
+ );
181
+ }
182
+ break;
183
+ }
184
+ case "Checkbox": {
185
+ const newValue = !currentValue;
186
+ const newState = mergeValue(state, name, newValue, result.form);
187
+ controllerMessenger.call(
188
+ "SnapInterfaceController:updateInterfaceState",
189
+ id,
190
+ newState
191
+ );
192
+ await handleEvent(
193
+ controllerMessenger,
194
+ snapId,
195
+ id,
196
+ {
197
+ type: UserInputEventType.InputChangeEvent,
198
+ name: elementName,
199
+ value: newValue
200
+ },
201
+ context
202
+ );
203
+ break;
204
+ }
205
+ default:
206
+ assertExhaustive(type);
170
207
  }
171
208
  }
172
209
  function mergeValue(state, name, value, form) {
@@ -267,13 +304,61 @@ async function selectInDropdown(controllerMessenger, id, content, snapId, name,
267
304
  }
268
305
  });
269
306
  }
270
- function* getInterface(runSaga, snapId, controllerMessenger) {
271
- const { type, id, content } = yield call(
272
- getStoredInterface,
273
- controllerMessenger,
274
- snapId
307
+ function getFormattedFileSize(size) {
308
+ return `${(size / 1e6).toFixed(2)} MB`;
309
+ }
310
+ async function uploadFile(controllerMessenger, id, content, snapId, name, file, options) {
311
+ const result = getElement(content, name);
312
+ assert(
313
+ result !== void 0,
314
+ `Could not find an element in the interface with the name "${name}".`
275
315
  );
276
- const interfaceActions = {
316
+ assert(
317
+ result.element.type === "FileInput",
318
+ `Expected an element of type "FileInput", but found "${result.element.type}".`
319
+ );
320
+ const { state, context } = controllerMessenger.call(
321
+ "SnapInterfaceController:getInterface",
322
+ snapId,
323
+ id
324
+ );
325
+ const fileSize = await getFileSize(file);
326
+ if (fileSize > MAX_FILE_SIZE) {
327
+ throw new Error(
328
+ `The file size (${getFormattedFileSize(
329
+ fileSize
330
+ )}) exceeds the maximum allowed size of ${getFormattedFileSize(
331
+ MAX_FILE_SIZE
332
+ )}.`
333
+ );
334
+ }
335
+ const fileObject = await getFileToUpload(file, options);
336
+ const newState = mergeValue(state, name, fileObject, result.form);
337
+ controllerMessenger.call(
338
+ "SnapInterfaceController:updateInterfaceState",
339
+ id,
340
+ newState
341
+ );
342
+ await controllerMessenger.call("ExecutionService:handleRpcRequest", snapId, {
343
+ origin: "",
344
+ handler: HandlerType.OnUserInput,
345
+ request: {
346
+ jsonrpc: "2.0",
347
+ method: " ",
348
+ params: {
349
+ event: {
350
+ type: UserInputEventType.FileUploadEvent,
351
+ name: result.element.props.name,
352
+ file: fileObject
353
+ },
354
+ id,
355
+ context
356
+ }
357
+ }
358
+ });
359
+ }
360
+ function getInterfaceActions(snapId, controllerMessenger, { content, id }) {
361
+ return {
277
362
  clickElement: async (name) => {
278
363
  await clickElement(controllerMessenger, id, content, snapId, name);
279
364
  },
@@ -289,9 +374,37 @@ function* getInterface(runSaga, snapId, controllerMessenger) {
289
374
  name,
290
375
  value
291
376
  );
377
+ },
378
+ uploadFile: async (name, file, options) => {
379
+ await uploadFile(
380
+ controllerMessenger,
381
+ id,
382
+ content,
383
+ snapId,
384
+ name,
385
+ file,
386
+ options
387
+ );
292
388
  }
293
389
  };
294
- return getInterfaceResponse(runSaga, type, content, interfaceActions);
390
+ }
391
+ function* getInterface(runSaga, snapId, controllerMessenger) {
392
+ const storedInterface = yield call(
393
+ getStoredInterface,
394
+ controllerMessenger,
395
+ snapId
396
+ );
397
+ const interfaceActions = getInterfaceActions(
398
+ snapId,
399
+ controllerMessenger,
400
+ storedInterface
401
+ );
402
+ return getInterfaceResponse(
403
+ runSaga,
404
+ storedInterface.type,
405
+ storedInterface.content,
406
+ interfaceActions
407
+ );
295
408
  }
296
409
 
297
410
  export {
@@ -301,6 +414,8 @@ export {
301
414
  mergeValue,
302
415
  typeInField,
303
416
  selectInDropdown,
417
+ uploadFile,
418
+ getInterfaceActions,
304
419
  getInterface
305
420
  };
306
- //# sourceMappingURL=chunk-AFA4KKWW.mjs.map
421
+ //# sourceMappingURL=chunk-43HRTFLS.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/simulation/interface.ts"],"sourcesContent":["import type {\n FormState,\n InterfaceContext,\n InterfaceState,\n SnapId,\n UserInputEvent,\n File,\n} from '@metamask/snaps-sdk';\nimport { DialogType, UserInputEventType, assert } from '@metamask/snaps-sdk';\nimport type { FormElement, JSXElement } from '@metamask/snaps-sdk/jsx';\nimport {\n HandlerType,\n getJsxChildren,\n unwrapError,\n walkJsx,\n} from '@metamask/snaps-utils';\nimport { assertExhaustive, hasProperty } from '@metamask/utils';\nimport type { PayloadAction } from '@reduxjs/toolkit';\nimport { type SagaIterator } from 'redux-saga';\nimport { call, put, select, take } from 'redux-saga/effects';\n\nimport type {\n FileOptions,\n SnapInterface,\n SnapInterfaceActions,\n} from '../../types';\nimport type { RootControllerMessenger } from './controllers';\nimport { getFileSize, getFileToUpload } from './files';\nimport type { Interface, RunSagaFunction } from './store';\nimport { getCurrentInterface, resolveInterface, setInterface } from './store';\n\n/**\n * The maximum file size that can be uploaded.\n */\nconst MAX_FILE_SIZE = 10_000_000; // 10 MB\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 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: DialogType,\n content: JSXElement,\n interfaceActions: SnapInterfaceActions,\n): SnapInterface {\n switch (type) {\n case DialogType.Alert:\n return {\n ...interfaceActions,\n type,\n content,\n ok: resolveWith(runSaga, null),\n };\n\n case DialogType.Confirmation:\n return {\n ...interfaceActions,\n type,\n content,\n\n ok: resolveWith(runSaga, true),\n cancel: resolveWith(runSaga, false),\n };\n\n case DialogType.Prompt:\n return {\n ...interfaceActions,\n type,\n content,\n\n ok: resolveWithInput(runSaga),\n cancel: resolveWith(runSaga, null),\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. 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 /**\n * Resolve the current user interface with the given value.\n *\n * @yields Puts the resolve user interface action.\n */\n function* resolveWithSaga(): SagaIterator {\n yield put(resolveInterface(value));\n }\n\n return async () => {\n await runSaga(resolveWithSaga).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 /**\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 */\n function* resolveWithSaga(value: string): SagaIterator {\n yield put(resolveInterface(value));\n }\n\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 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 { element: 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 { element };\n }\n\n return undefined;\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: '',\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: string | File | boolean | 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 * 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 result.element.type === 'Input',\n `Expected an element of type \"Input\", but found \"${result.element.type}\".`,\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: '',\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 * 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: '',\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 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: '',\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 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 { 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 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 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}\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 * @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): SagaIterator<SnapInterface> {\n const storedInterface = yield call(\n getStoredInterface,\n controllerMessenger,\n snapId,\n );\n\n const interfaceActions = getInterfaceActions(\n snapId,\n controllerMessenger,\n storedInterface,\n );\n\n return getInterfaceResponse(\n runSaga,\n storedInterface.type,\n storedInterface.content,\n interfaceActions,\n );\n}\n"],"mappings":";;;;;;;;;;;AAQA,SAAS,YAAY,oBAAoB,cAAc;AAEvD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB,mBAAmB;AAG9C,SAAS,MAAM,KAAK,QAAQ,YAAY;AAexC,IAAM,gBAAgB;AAWf,SAAS,qBACd,SACA,MACA,SACA,kBACe;AACf,UAAQ,MAAM;AAAA,IACZ,KAAK,WAAW;AACd,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,IAAI,YAAY,SAAS,IAAI;AAAA,MAC/B;AAAA,IAEF,KAAK,WAAW;AACd,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QAEA,IAAI,YAAY,SAAS,IAAI;AAAA,QAC7B,QAAQ,YAAY,SAAS,KAAK;AAAA,MACpC;AAAA,IAEF,KAAK,WAAW;AACd,aAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QAEA,IAAI,iBAAiB,OAAO;AAAA,QAC5B,QAAQ,YAAY,SAAS,IAAI;AAAA,MACnC;AAAA,IAEF;AACE,YAAM,IAAI,MAAM,wCAAwC,OAAO,IAAI,CAAC,IAAI;AAAA,EAC5E;AACF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Q;AAAA,QACN,OAAO;AAAA,UACL,MAAM,mBAAmB;AAAA,UACzB,MAAM,OAAO,QAAQ,MAAM;AAAA,UAC3B,MAAM;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAaO,SAAS,oBACd,QACA,qBACA,EAAE,SAAS,GAAG,GACQ;AACtB,SAAO;AAAA,IACL,cAAc,OAAO,SAAiB;AACpC,YAAM,aAAa,qBAAqB,IAAI,SAAS,QAAQ,IAAI;AAAA,IACnE;AAAA,IAEA,aAAa,OAAO,MAAc,UAAkB;AAClD,YAAM,YAAY,qBAAqB,IAAI,SAAS,QAAQ,MAAM,KAAK;AAAA,IACzE;AAAA,IAEA,kBAAkB,OAAO,MAAc,UAAkB;AACvD,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IAEA,YAAY,OACV,MACA,MACA,YACG;AACH,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAWO,UAAU,aACf,SACA,QACA,qBAC6B;AAC7B,QAAM,kBAAkB,MAAM;AAAA,IAC5B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,QAAM,mBAAmB;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB;AAAA,EACF;AACF;","names":["content"]}
@@ -1,9 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
-
5
-
6
- var _chunkR55KAAM4js = require('./chunk-R55KAAM4.js');
4
+ var _chunkGVTDUKXKjs = require('./chunk-GVTDUKXK.js');
7
5
 
8
6
 
9
7
  var _chunkYNUVT3HCjs = require('./chunk-YNUVT3HC.js');
@@ -88,7 +86,7 @@ function handleRequest({
88
86
  });
89
87
  promise.getInterface = async () => {
90
88
  const sagaPromise = runSaga(
91
- _chunkR55KAAM4js.getInterface,
89
+ _chunkGVTDUKXKjs.getInterface,
92
90
  runSaga,
93
91
  snapId,
94
92
  controllerMessenger
@@ -134,37 +132,13 @@ async function getInterfaceApi(result, snapId, controllerMessenger) {
134
132
  snapId,
135
133
  interfaceId
136
134
  );
135
+ const actions = _chunkGVTDUKXKjs.getInterfaceActions.call(void 0, snapId, controllerMessenger, {
136
+ id: interfaceId,
137
+ content
138
+ });
137
139
  return {
138
140
  content,
139
- clickElement: async (name) => {
140
- await _chunkR55KAAM4js.clickElement.call(void 0,
141
- controllerMessenger,
142
- interfaceId,
143
- content,
144
- snapId,
145
- name
146
- );
147
- },
148
- typeInField: async (name, value) => {
149
- await _chunkR55KAAM4js.typeInField.call(void 0,
150
- controllerMessenger,
151
- interfaceId,
152
- content,
153
- snapId,
154
- name,
155
- value
156
- );
157
- },
158
- selectInDropdown: async (name, value) => {
159
- await _chunkR55KAAM4js.selectInDropdown.call(void 0,
160
- controllerMessenger,
161
- interfaceId,
162
- content,
163
- snapId,
164
- name,
165
- value
166
- );
167
- }
141
+ ...actions
168
142
  };
169
143
  };
170
144
  }
@@ -176,4 +150,4 @@ async function getInterfaceApi(result, snapId, controllerMessenger) {
176
150
 
177
151
 
178
152
  exports.handleRequest = handleRequest; exports.getInterfaceFromResult = getInterfaceFromResult; exports.getInterfaceApi = getInterfaceApi;
179
- //# sourceMappingURL=chunk-2OHD2VKS.js.map
153
+ //# sourceMappingURL=chunk-4MAA7WGJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/request.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA;AAAA,EAEE;AAAA,OAGK;AAEP,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAA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MAChB,cAAc;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,UAAQ,eAAe,YAAY;AACjC,UAAM,cAAc;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,EAAE,UAAU;AACZ,UAAM,SAAS,MAAM,QAAQ,KAAK,CAAC,SAAS,WAAW,CAAC;AAIxD,QACE,GAAG,QAAQ,kBAAkB,KAC7B,YAAY,OAAO,UAAU,OAAO,GACpC;AACA,YAAM,IAAI;AAAA,QACR,qHACG,OAAO,SAAS,MAAuB,OAC1C;AAAA,MACF;AAAA,IACF;AAEA,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUA,eAAsB,uBACpB,QACA,QACA,qBACA;AACA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,IAAI,GAAG;AACtD,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,SAAS,GAAG;AAC3D;AAAA,MACE,GAAG,OAAO,SAAS,wBAAwB;AAAA,MAC3C;AAAA,IACF;AACA,UAAM,KAAK,MAAM,oBAAoB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAWA,eAAsB,gBACpB,QACA,QACA,qBACmD;AACnD,QAAM,cAAc,MAAM;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,aAAa;AACf,WAAO,MAAM;AACX,YAAM,EAAE,QAAQ,IAAI,oBAAoB;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,YAAM,UAAU,oBAAoB,QAAQ,qBAAqB;AAAA,QAC/D,IAAI;AAAA,QACJ;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT","sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\nimport { is } from 'superstruct';\n\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from '../types';\nimport type { RunSagaFunction, Store } from './simulation';\nimport {\n clearNotifications,\n getInterface,\n getInterfaceActions,\n getNotifications,\n} from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\nimport { SnapResponseStruct } from './structs';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n if (interfaceId) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n interfaceId,\n );\n\n const actions = getInterfaceActions(snapId, controllerMessenger, {\n id: interfaceId,\n content,\n });\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"]}
@@ -1,9 +1,7 @@
1
1
  import {
2
- clickElement,
3
2
  getInterface,
4
- selectInDropdown,
5
- typeInField
6
- } from "./chunk-AFA4KKWW.mjs";
3
+ getInterfaceActions
4
+ } from "./chunk-43HRTFLS.mjs";
7
5
  import {
8
6
  SnapResponseStruct
9
7
  } from "./chunk-HOI6FPLR.mjs";
@@ -134,37 +132,13 @@ async function getInterfaceApi(result, snapId, controllerMessenger) {
134
132
  snapId,
135
133
  interfaceId
136
134
  );
135
+ const actions = getInterfaceActions(snapId, controllerMessenger, {
136
+ id: interfaceId,
137
+ content
138
+ });
137
139
  return {
138
140
  content,
139
- clickElement: async (name) => {
140
- await clickElement(
141
- controllerMessenger,
142
- interfaceId,
143
- content,
144
- snapId,
145
- name
146
- );
147
- },
148
- typeInField: async (name, value) => {
149
- await typeInField(
150
- controllerMessenger,
151
- interfaceId,
152
- content,
153
- snapId,
154
- name,
155
- value
156
- );
157
- },
158
- selectInDropdown: async (name, value) => {
159
- await selectInDropdown(
160
- controllerMessenger,
161
- interfaceId,
162
- content,
163
- snapId,
164
- name,
165
- value
166
- );
167
- }
141
+ ...actions
168
142
  };
169
143
  };
170
144
  }
@@ -176,4 +150,4 @@ export {
176
150
  getInterfaceFromResult,
177
151
  getInterfaceApi
178
152
  };
179
- //# sourceMappingURL=chunk-UPR3PTSA.mjs.map
153
+ //# sourceMappingURL=chunk-5SGLRSWR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internals/request.ts"],"sourcesContent":["import type { AbstractExecutionService } from '@metamask/snaps-controllers';\nimport {\n type ComponentOrElement,\n ComponentOrElementStruct,\n type JsonRpcError,\n type SnapId,\n} from '@metamask/snaps-sdk';\nimport type { HandlerType } from '@metamask/snaps-utils';\nimport { unwrapError } from '@metamask/snaps-utils';\nimport {\n assert,\n getSafeJson,\n hasProperty,\n isPlainObject,\n} from '@metamask/utils';\nimport { nanoid } from '@reduxjs/toolkit';\nimport { is } from 'superstruct';\n\nimport type {\n RequestOptions,\n SnapHandlerInterface,\n SnapRequest,\n} from '../types';\nimport type { RunSagaFunction, Store } from './simulation';\nimport {\n clearNotifications,\n getInterface,\n getInterfaceActions,\n getNotifications,\n} from './simulation';\nimport type { RootControllerMessenger } from './simulation/controllers';\nimport { SnapResponseStruct } from './structs';\n\nexport type HandleRequestOptions = {\n snapId: SnapId;\n store: Store;\n executionService: AbstractExecutionService<unknown>;\n handler: HandlerType;\n controllerMessenger: RootControllerMessenger;\n runSaga: RunSagaFunction;\n request: RequestOptions;\n};\n\n/**\n * Send a JSON-RPC request to the Snap, and wrap the response in a\n * {@link SnapResponse} object.\n *\n * @param options - The request options.\n * @param options.snapId - The ID of the Snap to send the request to.\n * @param options.store - The Redux store.\n * @param options.executionService - The execution service to use to send the\n * request.\n * @param options.handler - The handler to use to send the request.\n * @param options.controllerMessenger - The controller messenger used to call actions.\n * @param options.runSaga - A function to run a saga outside the usual Redux\n * flow.\n * @param options.request - The request to send.\n * @param options.request.id - The ID of the request. If not provided, a random\n * ID will be generated.\n * @param options.request.origin - The origin of the request. Defaults to\n * `https://metamask.io`.\n * @returns The response, wrapped in a {@link SnapResponse} object.\n */\nexport function handleRequest({\n snapId,\n store,\n executionService,\n handler,\n controllerMessenger,\n runSaga,\n request: { id = nanoid(), origin = 'https://metamask.io', ...options },\n}: HandleRequestOptions): SnapRequest {\n const getInterfaceError = () => {\n throw new Error(\n 'Unable to get the interface from the Snap: The request to the Snap failed.',\n );\n };\n\n const promise = executionService\n .handleRpcRequest(snapId, {\n origin,\n handler,\n request: {\n jsonrpc: '2.0',\n id: 1,\n ...options,\n },\n })\n .then(async (result) => {\n const notifications = getNotifications(store.getState());\n store.dispatch(clearNotifications());\n\n try {\n const getInterfaceFn = await getInterfaceApi(\n result,\n snapId,\n controllerMessenger,\n );\n\n return {\n id: String(id),\n response: {\n result: getSafeJson(result),\n },\n notifications,\n ...(getInterfaceFn ? { getInterface: getInterfaceFn } : {}),\n };\n } catch (error) {\n const [unwrappedError] = unwrapError(error);\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }\n })\n .catch((error) => {\n const [unwrappedError] = unwrapError(error);\n\n return {\n id: String(id),\n response: {\n error: unwrappedError.serialize(),\n },\n notifications: [],\n getInterface: getInterfaceError,\n };\n }) as unknown as SnapRequest;\n\n promise.getInterface = async () => {\n const sagaPromise = runSaga(\n getInterface,\n runSaga,\n snapId,\n controllerMessenger,\n ).toPromise();\n const result = await Promise.race([promise, sagaPromise]);\n\n // If the request promise has resolved to an error, we should throw\n // instead of waiting for an interface that likely will never be displayed\n if (\n is(result, SnapResponseStruct) &&\n hasProperty(result.response, 'error')\n ) {\n throw new Error(\n `Unable to get the interface from the Snap: The returned interface may be invalid. The error message received was: ${\n (result.response.error as JsonRpcError).message\n }`,\n );\n }\n\n return await sagaPromise;\n };\n\n return promise;\n}\n\n/**\n * Get the interface ID from the result if it's available or create a new interface if the result contains static components.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The interface ID or undefined if the result doesn't include content.\n */\nexport async function getInterfaceFromResult(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n) {\n if (isPlainObject(result) && hasProperty(result, 'id')) {\n return result.id as string;\n }\n\n if (isPlainObject(result) && hasProperty(result, 'content')) {\n assert(\n is(result.content, ComponentOrElementStruct),\n 'The Snap returned an invalid interface.',\n );\n const id = await controllerMessenger.call(\n 'SnapInterfaceController:createInterface',\n snapId,\n result.content as ComponentOrElement,\n );\n\n return id;\n }\n\n return undefined;\n}\n\n/**\n * Get the response content from the `SnapInterfaceController` and include the\n * interaction methods.\n *\n * @param result - The handler result object.\n * @param snapId - The Snap ID.\n * @param controllerMessenger - The controller messenger.\n * @returns The content components if any.\n */\nexport async function getInterfaceApi(\n result: unknown,\n snapId: SnapId,\n controllerMessenger: RootControllerMessenger,\n): Promise<(() => SnapHandlerInterface) | undefined> {\n const interfaceId = await getInterfaceFromResult(\n result,\n snapId,\n controllerMessenger,\n );\n\n if (interfaceId) {\n return () => {\n const { content } = controllerMessenger.call(\n 'SnapInterfaceController:getInterface',\n snapId,\n interfaceId,\n );\n\n const actions = getInterfaceActions(snapId, controllerMessenger, {\n id: interfaceId,\n content,\n });\n\n return {\n content,\n ...actions,\n };\n };\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;;;;;;;;AACA;AAAA,EAEE;AAAA,OAGK;AAEP,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,UAAU;AA+CZ,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS,EAAE,KAAK,OAAO,GAAG,SAAS,uBAAuB,GAAG,QAAQ;AACvE,GAAsC;AACpC,QAAM,oBAAoB,MAAM;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAAU,iBACb,iBAAiB,QAAQ;AAAA,IACxB;AAAA,IACA;A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AuB,OAC1C;AAAA,MACF;AAAA,IACF;AAEA,WAAO,MAAM;AAAA,EACf;AAEA,SAAO;AACT;AAUA,eAAsB,uBACpB,QACA,QACA,qBACA;AACA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,IAAI,GAAG;AACtD,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI,cAAc,MAAM,KAAK,YAAY,QAAQ,SAAS,GAAG;AAC3D;AAAA,MACE,GAAG,OAAO,SAAS,wBAAwB;AAAA,MAC3C;AAAA,IACF;AACA,UAAM,KAAK,MAAM,oBAAoB;AAAA,MACnC;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAWA,eAAsB,gBACpB,QACA,QACA,qBACmD;AACnD,QAAM,cAAc,MAAM;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAEA,MAAI,aAAa;AACf,WAAO,MAAM;AACX,YAAM,EAAE,QAAQ,IAAI,oBAAoB;AAAA,QACtC;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAEA,YAAM,UAAU,oBAAoB,QAAQ,qBAAqB;AAAA,QAC/D,IAAI;AAAA,QACJ;AAAA,MACF,CAAC;AAED,aAAO;AAAA,QACL;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -208,4 +208,4 @@ _globals.expect.extend({
208
208
 
209
209
 
210
210
  exports.toRespondWith = toRespondWith; exports.toRespondWithError = toRespondWithError; exports.toSendNotification = toSendNotification; exports.serialiseJsx = serialiseJsx; exports.toRender = toRender;
211
- //# sourceMappingURL=chunk-KQBJQLZG.js.map
211
+ //# sourceMappingURL=chunk-7Y27L2EV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/matchers.ts"],"names":["message"],"mappings":";;;;;;AAMA,SAAS,cAAc;AAYvB,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAE3C,SAAS,mBA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AA,EACtB;AAEA,QAAM,UAAU,OACZ,MACE,GAAG,KAAK,MAAM,YAAY,eAAe,CAAC;AAAA;AAAA;AAAA,EAC5B,eAAe,aAAa,QAAQ,CAAC,CAAC;AAAA;AAAA;AAAA,EACtC,eAAe,aAAa,OAAO,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAC7B,UAAU,KAClC,MACE,GAAG,KAAK,MAAM,YAAY,WAAW,CAAC;AAAA;AAAA;AAAA,EACxB,eAAe,aAAa,QAAQ,CAAC,CAAC;AAAA;AAAA;AAAA,EACtC,eAAe,aAAa,OAAO,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA,EAC7B,UAAU;AAEtC,SAAO,EAAE,SAAS,KAAK;AACzB;AAEF,OAAO,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC","sourcesContent":["/* eslint-disable no-invalid-this */\n\n// Note: Because this file imports from `@jest/globals`, it can only be used in\n// a Jest environment. This is why it's not exported from the index file.\n\nimport type { MatcherFunction } from '@jest/expect';\nimport { expect } from '@jest/globals';\nimport type {\n NotificationType,\n EnumToUnion,\n ComponentOrElement,\n Component,\n} from '@metamask/snaps-sdk';\nimport type {\n GenericSnapElement,\n JSXElement,\n SnapNode,\n} from '@metamask/snaps-sdk/jsx';\nimport { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx';\nimport { getJsxElementFromComponent } from '@metamask/snaps-utils';\nimport type { Json } from '@metamask/utils';\nimport { hasProperty } from '@metamask/utils';\nimport type { MatcherHintOptions } from 'jest-matcher-utils';\nimport {\n EXPECTED_COLOR,\n diff,\n matcherErrorMessage,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n} from 'jest-matcher-utils';\nimport { is } from 'superstruct';\n\nimport { InterfaceStruct, SnapResponseStruct } from './internals';\nimport type { SnapResponse } from './types';\n\n/**\n * Ensure that the actual value is a response from the `request` function.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertActualIsSnapResponse(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is SnapResponse {\n if (!is(actual, SnapResponseStruct)) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR(\n 'received',\n )} value must be a response from the \\`request\\` function`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Ensure that the actual value is a response from the `request` function, and\n * that it has a `ui` property.\n *\n * @param actual - The actual value.\n * @param matcherName - The name of the matcher.\n * @param options - The matcher options.\n */\nfunction assertHasInterface(\n actual: unknown,\n matcherName: string,\n options?: MatcherHintOptions,\n): asserts actual is { content: JSXElement } {\n if (!is(actual, InterfaceStruct) || !actual.content) {\n throw new Error(\n matcherErrorMessage(\n matcherHint(matcherName, undefined, undefined, options),\n `${RECEIVED_COLOR('received')} value must have a \\`content\\` property`,\n printWithType('Received', actual, printReceived),\n ),\n );\n }\n}\n\n/**\n * Check if a JSON-RPC response matches the expected value. This matcher is\n * intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected response.\n * @returns The status and message.\n */\nexport const toRespondWith: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWith');\n\n const { response } = actual;\n if (hasProperty(response, 'error')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected response: ${this.utils.printExpected(expected)}\\n` +\n `Received error: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.result, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWith')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass };\n};\n\nexport const toRespondWithError: MatcherFunction<[expected: Json]> = function (\n actual,\n expected,\n) {\n assertActualIsSnapResponse(actual, 'toRespondWithError');\n\n const { response } = actual;\n if (hasProperty(response, 'result')) {\n const message = () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected error: ${this.utils.printExpected(expected)}\\n` +\n `Received result: ${this.utils.printReceived(response.result)}`;\n\n return { message, pass: false };\n }\n\n const pass = this.equals(response.error, expected);\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`\n : () =>\n `${this.utils.matcherHint('.toRespondWithError')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Received: ${this.utils.printReceived(response.error)}`;\n\n return { message, pass };\n};\n\n/**\n * Check if the snap sent a notification with the expected message. This matcher\n * is intended to be used with the `expect` global.\n *\n * @param actual - The actual response.\n * @param expected - The expected notification message.\n * @param type - The expected notification type.\n * @returns The status and message.\n */\nexport const toSendNotification: MatcherFunction<\n [expected: string, type?: EnumToUnion<NotificationType> | undefined]\n> = function (actual, expected, type) {\n assertActualIsSnapResponse(actual, 'toSendNotification');\n\n const { notifications } = actual;\n const pass = notifications.some(\n (notification) =>\n this.equals(notification.message, expected) &&\n (type === undefined || notification.type === type),\n );\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`\n : () =>\n `${this.utils.matcherHint('.toSendNotification')}\\n\\n` +\n `Expected: ${this.utils.printExpected(expected)}\\n` +\n `Expected type: ${this.utils.printExpected(type)}\\n` +\n `Received: ${this.utils.printReceived(notifications)}`;\n\n return { message, pass };\n};\n\n/**\n * Serialise a JSX prop to a string.\n *\n * @param prop - The JSX prop.\n * @returns The serialised JSX prop.\n */\nfunction serialiseProp(prop: unknown): string {\n if (typeof prop === 'string') {\n return `\"${prop}\"`;\n }\n\n return `{${JSON.stringify(prop)}}`;\n}\n\n/**\n * Serialise JSX props to a string.\n *\n * @param props - The JSX props.\n * @returns The serialised JSX props.\n */\nfunction serialiseProps(props: Record<string, unknown>): string {\n return Object.entries(props)\n .filter(([key]) => key !== 'children')\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([key, value]) => ` ${key}=${serialiseProp(value)}`)\n .join('');\n}\n\n/**\n * Serialise a JSX node to a string.\n *\n * @param node - The JSX node.\n * @param indentation - The indentation level. Defaults to `0`. This should not\n * be set by the caller, as it is used for recursion.\n * @returns The serialised JSX node.\n */\nexport function serialiseJsx(node: SnapNode, indentation = 0): string {\n if (Array.isArray(node)) {\n return node.map((child) => serialiseJsx(child, indentation)).join('');\n }\n\n const indent = ' '.repeat(indentation);\n if (typeof node === 'string') {\n return `${indent}${node}\\n`;\n }\n\n if (!node) {\n return '';\n }\n\n const { type, props } = node as GenericSnapElement;\n const trailingNewline = indentation > 0 ? '\\n' : '';\n\n if (hasProperty(props, 'children')) {\n const children = serialiseJsx(props.children as SnapNode, indentation + 1);\n return `${indent}<${type}${serialiseProps(\n props,\n )}>\\n${children}${indent}</${type}>${trailingNewline}`;\n }\n\n return `${indent}<${type}${serialiseProps(props)} />${trailingNewline}`;\n}\n\nconst toRenderLegacy: MatcherFunction<[expected: Component]> = function (\n actual,\n expected,\n) {\n assertHasInterface(actual, 'toRender');\n\n const { content } = actual;\n const expectedElement = getJsxElementFromComponent(expected);\n const pass = this.equals(content, expectedElement);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(expectedElement, content) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${this.utils.printExpected(expectedElement)}\\n\\n` +\n `Received:\\n${this.utils.printReceived(content)}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n};\n\nexport const toRender: MatcherFunction<[expected: ComponentOrElement]> =\n function (actual, expected) {\n assertHasInterface(actual, 'toRender');\n\n if (!isJSXElementUnsafe(expected)) {\n return toRenderLegacy.call(this, actual, expected);\n }\n\n const { content } = actual;\n const pass = this.equals(content, expected);\n\n // This is typed as `string | null`, but in practice it's always a string.\n // The function only returns `null` if both the expected and actual values\n // are numbers, bigints, or booleans, which is never the case here.\n const difference = diff(\n serialiseJsx(expected),\n serialiseJsx(content),\n ) as string;\n\n const message = pass\n ? () =>\n `${this.utils.matcherHint('.not.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`\n : () =>\n `${this.utils.matcherHint('.toRender')}\\n\\n` +\n `Expected:\\n${EXPECTED_COLOR(serialiseJsx(expected))}\\n\\n` +\n `Received:\\n${RECEIVED_COLOR(serialiseJsx(content))}` +\n `\\n\\nDifference:\\n\\n${difference}`;\n\n return { message, pass };\n };\n\nexpect.extend({\n toRespondWith,\n toRespondWithError,\n toSendNotification,\n toRender,\n});\n"]}
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-XK5HPZZC.mjs";
4
4
  import {
5
5
  handleRequest
6
- } from "./chunk-UPR3PTSA.mjs";
6
+ } from "./chunk-5SGLRSWR.mjs";
7
7
  import {
8
8
  rootLogger
9
9
  } from "./chunk-J4ZPUCLX.mjs";
@@ -160,4 +160,4 @@ async function installSnap(snapId, options = {}) {
160
160
  export {
161
161
  installSnap
162
162
  };
163
- //# sourceMappingURL=chunk-U3DVRTS2.mjs.map
163
+ //# sourceMappingURL=chunk-CYPP66I7.mjs.map
@@ -3,7 +3,7 @@
3
3
  var _chunkXWGECIXIjs = require('./chunk-XWGECIXI.js');
4
4
 
5
5
 
6
- var _chunkTVD4SWH7js = require('./chunk-TVD4SWH7.js');
6
+ var _chunkSW65QYFVjs = require('./chunk-SW65QYFV.js');
7
7
 
8
8
 
9
9
  var _chunkVXPCUDBIjs = require('./chunk-VXPCUDBI.js');
@@ -96,7 +96,7 @@ async function handleInstallSnap(snapId, {
96
96
  function getHooks(options, snapFiles, snapId, controllerMessenger) {
97
97
  return {
98
98
  getMnemonic: async () => Promise.resolve(_keytree.mnemonicPhraseToBytes.call(void 0, options.secretRecoveryPhrase)),
99
- getSnapFile: async (path, encoding) => await _chunkTVD4SWH7js.getSnapFile.call(void 0, snapFiles.auxiliaryFiles, path, encoding),
99
+ getSnapFile: async (path, encoding) => await _chunkSW65QYFVjs.getSnapFile.call(void 0, snapFiles.auxiliaryFiles, path, encoding),
100
100
  getIsLocked: () => false,
101
101
  createInterface: async (...args) => controllerMessenger.call(
102
102
  "SnapInterfaceController:createInterface",
@@ -131,4 +131,4 @@ function registerActions(controllerMessenger) {
131
131
 
132
132
 
133
133
  exports.handleInstallSnap = handleInstallSnap; exports.getHooks = getHooks; exports.registerActions = registerActions;
134
- //# sourceMappingURL=chunk-EDFQDZNY.js.map
134
+ //# sourceMappingURL=chunk-DVDAOXO7.js.map