@metamask/snaps-simulation 3.4.1 → 3.5.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 (52) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/helpers.cjs +28 -9
  3. package/dist/helpers.cjs.map +1 -1
  4. package/dist/helpers.d.cts +61 -0
  5. package/dist/helpers.d.cts.map +1 -1
  6. package/dist/helpers.d.mts +61 -0
  7. package/dist/helpers.d.mts.map +1 -1
  8. package/dist/helpers.mjs +29 -9
  9. package/dist/helpers.mjs.map +1 -1
  10. package/dist/middleware/mock.cjs +16 -7
  11. package/dist/middleware/mock.cjs.map +1 -1
  12. package/dist/middleware/mock.d.cts +1 -1
  13. package/dist/middleware/mock.d.cts.map +1 -1
  14. package/dist/middleware/mock.d.mts +1 -1
  15. package/dist/middleware/mock.d.mts.map +1 -1
  16. package/dist/middleware/mock.mjs +17 -8
  17. package/dist/middleware/mock.mjs.map +1 -1
  18. package/dist/request.cjs +1 -1
  19. package/dist/request.cjs.map +1 -1
  20. package/dist/request.mjs +1 -1
  21. package/dist/request.mjs.map +1 -1
  22. package/dist/simulation.cjs +3 -2
  23. package/dist/simulation.cjs.map +1 -1
  24. package/dist/simulation.d.cts +9 -2
  25. package/dist/simulation.d.cts.map +1 -1
  26. package/dist/simulation.d.mts +9 -2
  27. package/dist/simulation.d.mts.map +1 -1
  28. package/dist/simulation.mjs +3 -2
  29. package/dist/simulation.mjs.map +1 -1
  30. package/dist/store/mocks.cjs +5 -8
  31. package/dist/store/mocks.cjs.map +1 -1
  32. package/dist/store/mocks.d.cts +6 -19
  33. package/dist/store/mocks.d.cts.map +1 -1
  34. package/dist/store/mocks.d.mts +6 -19
  35. package/dist/store/mocks.d.mts.map +1 -1
  36. package/dist/store/mocks.mjs +5 -8
  37. package/dist/store/mocks.mjs.map +1 -1
  38. package/dist/store/store.cjs +1 -1
  39. package/dist/store/store.cjs.map +1 -1
  40. package/dist/store/store.d.cts.map +1 -1
  41. package/dist/store/store.d.mts.map +1 -1
  42. package/dist/store/store.mjs +1 -1
  43. package/dist/store/store.mjs.map +1 -1
  44. package/dist/structs.d.cts +3 -3
  45. package/dist/structs.d.mts +3 -3
  46. package/dist/types.cjs.map +1 -1
  47. package/dist/types.d.cts +70 -2
  48. package/dist/types.d.cts.map +1 -1
  49. package/dist/types.d.mts +70 -2
  50. package/dist/types.d.mts.map +1 -1
  51. package/dist/types.mjs.map +1 -1
  52. package/package.json +11 -11
package/dist/types.d.cts CHANGED
@@ -2,7 +2,7 @@ import type { NotificationType, EnumToUnion, TrackableError, TraceRequest } from
2
2
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
3
3
  import type { InferMatching } from "@metamask/snaps-utils";
4
4
  import type { Infer } from "@metamask/superstruct";
5
- import type { CaipChainId, Json, JsonRpcId, JsonRpcParams } from "@metamask/utils";
5
+ import type { CaipChainId, Json, JsonRpcId, JsonRpcParams, JsonRpcRequest } from "@metamask/utils";
6
6
  import type { NameLookupOptionsStruct, SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "./structs.cjs";
7
7
  export type RequestOptions = {
8
8
  /**
@@ -292,7 +292,14 @@ export type JsonRpcMockOptions = {
292
292
  * specified method is sent.
293
293
  */
294
294
  result: Json;
295
- };
295
+ } | JsonRpcMockImplementation;
296
+ /**
297
+ * A function that can be used to mock a JSON-RPC implementation.
298
+ *
299
+ * @param request - The JSON-RPC request.
300
+ * @returns A valid JSON value, optionally as a promise or undefined.
301
+ */
302
+ export type JsonRpcMockImplementation = (request: JsonRpcRequest) => Promise<Json> | Json | undefined;
296
303
  /**
297
304
  * This is the main entry point to interact with the snap. It is returned by
298
305
  * {@link installSnap}, and has methods to send requests to the snap.
@@ -449,6 +456,21 @@ export type Snap = {
449
456
  * // In the Snap
450
457
  * const response =
451
458
  * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
459
+ *
460
+ * @example
461
+ * import { installSnap } from '@metamask/snaps-jest';
462
+ *
463
+ * // In the test
464
+ * const snap = await installSnap();
465
+ * snap.mockJsonRpc((request) => {
466
+ * if (request.method === 'eth_accounts') {
467
+ * return ['0x1234'];
468
+ * }
469
+ * });
470
+ *
471
+ * // In the Snap
472
+ * const response =
473
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
452
474
  */
453
475
  mockJsonRpc(mock: JsonRpcMockOptions): {
454
476
  /**
@@ -456,6 +478,52 @@ export type Snap = {
456
478
  */
457
479
  unmock(): void;
458
480
  };
481
+ /**
482
+ * Mock a JSON-RPC request once. This will cause the snap to respond with the
483
+ * specified response when a request with the specified method is sent.
484
+ *
485
+ * @param mock - The mock options.
486
+ * @param mock.method - The JSON-RPC request method.
487
+ * @param mock.result - The JSON-RPC response, which will be returned when a
488
+ * request with the specified method is sent.
489
+ * @example
490
+ * import { installSnap } from '@metamask/snaps-jest';
491
+ *
492
+ * // In the test
493
+ * const snap = await installSnap();
494
+ * snap.mockJsonRpcOnce({ method: 'eth_accounts', result: ['0x1234'] });
495
+ *
496
+ * // In the Snap
497
+ * const response =
498
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
499
+ *
500
+ * const response2 =
501
+ * await ethereum.request({ method: 'eth_accounts' }); // Default behavior
502
+ *
503
+ * @example
504
+ * import { installSnap } from '@metamask/snaps-jest';
505
+ *
506
+ * // In the test
507
+ * const snap = await installSnap();
508
+ * snap.mockJsonRpcOnce((request) => {
509
+ * if (request.method === 'eth_accounts') {
510
+ * return ['0x1234'];
511
+ * }
512
+ * });
513
+ *
514
+ * // In the Snap
515
+ * const response =
516
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
517
+ *
518
+ * const response2 =
519
+ * await ethereum.request({ method: 'eth_accounts' }); // Default behavior
520
+ */
521
+ mockJsonRpcOnce(mock: JsonRpcMockOptions): {
522
+ /**
523
+ * Remove the mock.
524
+ */
525
+ unmock(): void;
526
+ };
459
527
  /**
460
528
  * Close the page running the snap. This is mainly useful for cleaning up
461
529
  * the test environment, and calling it is not strictly necessary.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,YAAY,EACb,4BAA4B;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EACV,WAAW,EACX,IAAI,EACJ,SAAS,EACT,aAAa,EACd,wBAAwB;AAEzB,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACzB,sBAAkB;AAEnB,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,EAAE,CAAC,EAAE,SAAS,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,cAAc,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAEtE;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,KAAK,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B,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;KAC5C,EAAE,CAAC;IACJ,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,IAAI,CAAA;KAAE,CAAC;IAE7C,aAAa,EAAE;QACb,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,UAAU,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG,SAAS,CAAC;KACzD,EAAE,CAAC;IAEJ,OAAO,EAAE,uBAAuB,CAAC;IAEjC,YAAY,IAAI,oBAAoB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,yBAAyB,EACzB,cAAc,CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,4BAA4B,GAC5B,yBAAyB,CAAC;AAE9B,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,OAAO,kBAAkB,EACzB,gBAAgB,CACjB,CAAC"}
package/dist/types.d.mts CHANGED
@@ -2,7 +2,7 @@ import type { NotificationType, EnumToUnion, TrackableError, TraceRequest } from
2
2
  import type { JSXElement } from "@metamask/snaps-sdk/jsx";
3
3
  import type { InferMatching } from "@metamask/snaps-utils";
4
4
  import type { Infer } from "@metamask/superstruct";
5
- import type { CaipChainId, Json, JsonRpcId, JsonRpcParams } from "@metamask/utils";
5
+ import type { CaipChainId, Json, JsonRpcId, JsonRpcParams, JsonRpcRequest } from "@metamask/utils";
6
6
  import type { NameLookupOptionsStruct, SignatureOptionsStruct, SnapOptionsStruct, SnapResponseStruct, TransactionOptionsStruct } from "./structs.mjs";
7
7
  export type RequestOptions = {
8
8
  /**
@@ -292,7 +292,14 @@ export type JsonRpcMockOptions = {
292
292
  * specified method is sent.
293
293
  */
294
294
  result: Json;
295
- };
295
+ } | JsonRpcMockImplementation;
296
+ /**
297
+ * A function that can be used to mock a JSON-RPC implementation.
298
+ *
299
+ * @param request - The JSON-RPC request.
300
+ * @returns A valid JSON value, optionally as a promise or undefined.
301
+ */
302
+ export type JsonRpcMockImplementation = (request: JsonRpcRequest) => Promise<Json> | Json | undefined;
296
303
  /**
297
304
  * This is the main entry point to interact with the snap. It is returned by
298
305
  * {@link installSnap}, and has methods to send requests to the snap.
@@ -449,6 +456,21 @@ export type Snap = {
449
456
  * // In the Snap
450
457
  * const response =
451
458
  * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
459
+ *
460
+ * @example
461
+ * import { installSnap } from '@metamask/snaps-jest';
462
+ *
463
+ * // In the test
464
+ * const snap = await installSnap();
465
+ * snap.mockJsonRpc((request) => {
466
+ * if (request.method === 'eth_accounts') {
467
+ * return ['0x1234'];
468
+ * }
469
+ * });
470
+ *
471
+ * // In the Snap
472
+ * const response =
473
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
452
474
  */
453
475
  mockJsonRpc(mock: JsonRpcMockOptions): {
454
476
  /**
@@ -456,6 +478,52 @@ export type Snap = {
456
478
  */
457
479
  unmock(): void;
458
480
  };
481
+ /**
482
+ * Mock a JSON-RPC request once. This will cause the snap to respond with the
483
+ * specified response when a request with the specified method is sent.
484
+ *
485
+ * @param mock - The mock options.
486
+ * @param mock.method - The JSON-RPC request method.
487
+ * @param mock.result - The JSON-RPC response, which will be returned when a
488
+ * request with the specified method is sent.
489
+ * @example
490
+ * import { installSnap } from '@metamask/snaps-jest';
491
+ *
492
+ * // In the test
493
+ * const snap = await installSnap();
494
+ * snap.mockJsonRpcOnce({ method: 'eth_accounts', result: ['0x1234'] });
495
+ *
496
+ * // In the Snap
497
+ * const response =
498
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
499
+ *
500
+ * const response2 =
501
+ * await ethereum.request({ method: 'eth_accounts' }); // Default behavior
502
+ *
503
+ * @example
504
+ * import { installSnap } from '@metamask/snaps-jest';
505
+ *
506
+ * // In the test
507
+ * const snap = await installSnap();
508
+ * snap.mockJsonRpcOnce((request) => {
509
+ * if (request.method === 'eth_accounts') {
510
+ * return ['0x1234'];
511
+ * }
512
+ * });
513
+ *
514
+ * // In the Snap
515
+ * const response =
516
+ * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']
517
+ *
518
+ * const response2 =
519
+ * await ethereum.request({ method: 'eth_accounts' }); // Default behavior
520
+ */
521
+ mockJsonRpcOnce(mock: JsonRpcMockOptions): {
522
+ /**
523
+ * Remove the mock.
524
+ */
525
+ unmock(): void;
526
+ };
459
527
  /**
460
528
  * Close the page running the snap. This is mainly useful for cleaning up
461
529
  * the test environment, and calling it is not strictly necessary.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,YAAY,EACb,4BAA4B;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,gCAAgC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,8BAA8B;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AACnD,OAAO,KAAK,EACV,WAAW,EACX,IAAI,EACJ,SAAS,EACT,aAAa,EACd,wBAAwB;AAEzB,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EAC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,CAAC;QAChB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACpC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,UAAU,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,GAAG,SAAS,CAAC;KACzD,EAAE,CAAC;IAEJ,OAAO,EAAE,uBAAuB,CAAC;IAEjC,YAAY,IAAI,oBAAoB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,yBAAyB,EACzB,cAAc,CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,4BAA4B,GAC5B,yBAAyB,CAAC;AAE9B,MAAM,MAAM,YAAY,GAAG,aAAa,CACtC,OAAO,kBAAkB,EACzB,gBAAgB,CACjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n NotificationType,\n EnumToUnion,\n TrackableError,\n TraceRequest,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n CaipChainId,\n Json,\n JsonRpcId,\n JsonRpcParams,\n} from '@metamask/utils';\n\nimport type {\n NameLookupOptionsStruct,\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from './structs';\n\nexport type RequestOptions = {\n /**\n * The JSON-RPC request ID.\n */\n id?: JsonRpcId;\n\n /**\n * The JSON-RPC method.\n */\n method: string;\n\n /**\n * The JSON-RPC params.\n */\n params?: JsonRpcParams;\n\n /**\n * The origin to send the request from.\n */\n origin?: string;\n};\n\n/**\n * The `runCronjob` options. This is the same as {@link RequestOptions}, except\n * that it does not have an `origin` property.\n */\nexport type CronjobOptions = Omit<RequestOptions, 'origin'>;\n\n/**\n * The options to use for transaction requests.\n *\n * @property chainId - The CAIP-2 chain ID to send the transaction on. Defaults\n * to `eip155:1`.\n * @property origin - The origin to send the transaction from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the transaction from. Defaults to a\n * randomly generated address.\n * @property to - The address to send the transaction to. Defaults to a randomly\n * generated address.\n * @property value - The value to send with the transaction. Defaults to `0`.\n * @property data - The data to send with the transaction. Defaults to `0x`.\n * @property gasLimit - The gas limit to use for the transaction. Defaults to\n * `21_000`.\n * @property maxFeePerGas - The maximum fee per gas to use for the transaction.\n * Defaults to `1`.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas to use for\n * the transaction. Defaults to `1`.\n * @property nonce - The nonce to use for the transaction. Defaults to `0`.\n */\nexport type TransactionOptions = Infer<typeof TransactionOptionsStruct>;\n\n/**\n * The options to use for keyring requests.\n */\nexport type KeyringOptions = RequestOptions;\n\n/**\n * The options to use for name lookup requests.\n *\n * @property chainId - Chain ID.\n * @property domain - Domain name to lookup and resolve.\n * @property address - Address to lookup and resolve.\n */\nexport type NameLookupOptions = Infer<typeof NameLookupOptionsStruct>;\n\n/**\n * The options to use for signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\n\n/**\n * The options to use for requests to the snap.\n *\n * @property timeout - The timeout in milliseconds to use. Defaults to `1000`.\n */\nexport type SnapOptions = Infer<typeof SnapOptionsStruct>;\n\n/**\n * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * 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 cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from a Selector, AccountSelector or AssetSelector component.\n *\n * @param name - The element name to type in.\n * @param value - The value to select.\n */\n selectFromSelector(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\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 */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n\n /**\n * Wait for the interface to be updated.\n */\n waitForUpdate: () => Promise<SnapHandlerInterface>;\n};\n\n/**\n * A `snap_dialog` alert interface.\n */\nexport type SnapAlertInterface = {\n /**\n * The type of the interface. This is always `alert`.\n */\n type: 'alert';\n\n /**\n * The content to show in the alert.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the alert.\n */\n ok(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` confirmation interface.\n */\nexport type SnapConfirmationInterface = {\n /**\n * The type of the interface. This is always `confirmation`.\n */\n type: 'confirmation';\n\n /**\n * The content to show in the confirmation.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the confirmation.\n */\n ok(): Promise<void>;\n\n /**\n * Cancel the confirmation.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` prompt interface.\n */\nexport type SnapPromptInterface = {\n /**\n * The type of the interface. This is always `prompt`.\n */\n type: 'prompt';\n\n /**\n * The content to show in the prompt.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the prompt.\n *\n * @param value - The value to close the prompt with.\n */\n ok(value?: string): Promise<void>;\n\n /**\n * Cancel the prompt.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface = (\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter\n) & {\n type?: never;\n};\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\n\nexport type SnapRequestObject = {\n /**\n * Get a user interface object from a snap. This will throw an error if the\n * snap does not show a user interface within the timeout.\n *\n * @param options - The options to use.\n * @param options.timeout - The timeout in milliseconds to use. Defaults to\n * `1000`.\n * @returns The user interface object.\n */\n getInterface(options?: SnapOptions): Promise<SnapInterface>;\n};\n\n/**\n * A pending request object. This is a promise with extra\n * {@link SnapRequestObject} fields.\n */\nexport type SnapRequest = Promise<SnapResponse> & SnapRequestObject;\n\n/**\n * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions = {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n};\n\n/**\n * This is the main entry point to interact with the snap. It is returned by\n * {@link installSnap}, and has methods to send requests to the snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * const snap = await installSnap();\n * const response = await snap.request({ method: 'hello' });\n *\n * expect(response).toRespondWith('Hello, world!');\n */\nexport type Snap = {\n /**\n * Send a JSON-RPC request to the snap.\n *\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n request(request: RequestOptions): SnapRequest;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n */\n onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Run a background event in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param backgroundEvent - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified as the `request` param in the `snap_scheduleBackgroundEvent` method.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onBackgroundEvent(backgroundEvent: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Get the response from the snap's `onSettingsPage` method.\n *\n * @returns The response.\n */\n onSettingsPage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a keyring to the Snap.\n *\n * @param keyringRequest - Keyring request options.\n * @returns The response.\n */\n onKeyringRequest(keyringRequest: KeyringOptions): SnapRequest;\n\n /**\n * Get the response from the Snap's `onInstall` handler.\n *\n * @returns The response.\n */\n onInstall(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onUpdate` handler.\n *\n * @returns The response.\n */\n onUpdate(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onStart` handler.\n *\n * @returns The response.\n */\n onStart(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onNameLookup` handler.\n *\n * @returns The response.\n */\n onNameLookup(\n nameLookupRequest: NameLookupOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Send a JSON-RPC protocol request to the Snap.\n *\n * @param scope - A CAIP-2 scope.\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onProtocolRequest(\n scope: CaipChainId,\n request: RequestOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Send a JSON-RPC client request to the Snap.\n *\n * @param request - The JSON-RPC request.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onClientRequest(request: Omit<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\n\n /**\n * Close the page running the snap. This is mainly useful for cleaning up\n * the test environment, and calling it is not strictly necessary.\n *\n * @returns A promise that resolves when the page is closed.\n * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type TrackedSnapResponseData = {\n errors: TrackableError[];\n events: {\n event: string;\n properties?: Record<string, Json>;\n sensitiveProperties?: Record<string, Json>;\n }[];\n traces: TraceRequest[];\n};\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n title?: string | undefined;\n content?: string | undefined;\n footerLink?: { text: string; href: string } | undefined;\n }[];\n\n tracked: TrackedSnapResponseData;\n\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n NotificationType,\n EnumToUnion,\n TrackableError,\n TraceRequest,\n} from '@metamask/snaps-sdk';\nimport type { JSXElement } from '@metamask/snaps-sdk/jsx';\nimport type { InferMatching } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport type {\n CaipChainId,\n Json,\n JsonRpcId,\n JsonRpcParams,\n JsonRpcRequest,\n} from '@metamask/utils';\n\nimport type {\n NameLookupOptionsStruct,\n SignatureOptionsStruct,\n SnapOptionsStruct,\n SnapResponseStruct,\n TransactionOptionsStruct,\n} from './structs';\n\nexport type RequestOptions = {\n /**\n * The JSON-RPC request ID.\n */\n id?: JsonRpcId;\n\n /**\n * The JSON-RPC method.\n */\n method: string;\n\n /**\n * The JSON-RPC params.\n */\n params?: JsonRpcParams;\n\n /**\n * The origin to send the request from.\n */\n origin?: string;\n};\n\n/**\n * The `runCronjob` options. This is the same as {@link RequestOptions}, except\n * that it does not have an `origin` property.\n */\nexport type CronjobOptions = Omit<RequestOptions, 'origin'>;\n\n/**\n * The options to use for transaction requests.\n *\n * @property chainId - The CAIP-2 chain ID to send the transaction on. Defaults\n * to `eip155:1`.\n * @property origin - The origin to send the transaction from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the transaction from. Defaults to a\n * randomly generated address.\n * @property to - The address to send the transaction to. Defaults to a randomly\n * generated address.\n * @property value - The value to send with the transaction. Defaults to `0`.\n * @property data - The data to send with the transaction. Defaults to `0x`.\n * @property gasLimit - The gas limit to use for the transaction. Defaults to\n * `21_000`.\n * @property maxFeePerGas - The maximum fee per gas to use for the transaction.\n * Defaults to `1`.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas to use for\n * the transaction. Defaults to `1`.\n * @property nonce - The nonce to use for the transaction. Defaults to `0`.\n */\nexport type TransactionOptions = Infer<typeof TransactionOptionsStruct>;\n\n/**\n * The options to use for keyring requests.\n */\nexport type KeyringOptions = RequestOptions;\n\n/**\n * The options to use for name lookup requests.\n *\n * @property chainId - Chain ID.\n * @property domain - Domain name to lookup and resolve.\n * @property address - Address to lookup and resolve.\n */\nexport type NameLookupOptions = Infer<typeof NameLookupOptionsStruct>;\n\n/**\n * The options to use for signature requests.\n *\n * @property origin - The origin to send the signature request from. Defaults to\n * `metamask.io`.\n * @property from - The address to send the signature from. Defaults to a\n * randomly generated address.\n * @property data - The data to sign. Defaults to `0x`.\n * @property signatureMethod - The signature method.\n */\nexport type SignatureOptions = Infer<typeof SignatureOptionsStruct>;\n\n/**\n * The options to use for requests to the snap.\n *\n * @property timeout - The timeout in milliseconds to use. Defaults to `1000`.\n */\nexport type SnapOptions = Infer<typeof SnapOptionsStruct>;\n\n/**\n * Options for uploading a file.\n *\n * @property fileName - The name of the file. By default, this is inferred from\n * the file path if it's a path, and defaults to an empty string if it's a\n * `Uint8Array`.\n * @property contentType - The content type of the file. By default, this is\n * 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 cannot\n * be inferred from the file name.\n */\nexport type FileOptions = {\n fileName?: string;\n contentType?: string;\n};\n\nexport type SnapInterfaceActions = {\n /**\n * Click on an interface element.\n *\n * @param name - The element name to click.\n */\n clickElement(name: string): Promise<void>;\n\n /**\n * Type a value in a interface field.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n typeInField(name: string, value: string): Promise<void>;\n\n /**\n * Select an option with a value in a dropdown.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectInDropdown(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from radio group.\n *\n * @param name - The element name to type in.\n * @param value - The value to type.\n */\n selectFromRadioGroup(name: string, value: string): Promise<void>;\n\n /**\n * Choose an option with a value from a Selector, AccountSelector or AssetSelector component.\n *\n * @param name - The element name to type in.\n * @param value - The value to select.\n */\n selectFromSelector(name: string, value: string): Promise<void>;\n\n /**\n * Upload a file.\n *\n * @param name - The element name to upload the file to.\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 */\n uploadFile(\n name: string,\n file: string | Uint8Array,\n options?: FileOptions,\n ): Promise<void>;\n\n /**\n * Wait for the interface to be updated.\n */\n waitForUpdate: () => Promise<SnapHandlerInterface>;\n};\n\n/**\n * A `snap_dialog` alert interface.\n */\nexport type SnapAlertInterface = {\n /**\n * The type of the interface. This is always `alert`.\n */\n type: 'alert';\n\n /**\n * The content to show in the alert.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the alert.\n */\n ok(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` confirmation interface.\n */\nexport type SnapConfirmationInterface = {\n /**\n * The type of the interface. This is always `confirmation`.\n */\n type: 'confirmation';\n\n /**\n * The content to show in the confirmation.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the confirmation.\n */\n ok(): Promise<void>;\n\n /**\n * Cancel the confirmation.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` prompt interface.\n */\nexport type SnapPromptInterface = {\n /**\n * The type of the interface. This is always `prompt`.\n */\n type: 'prompt';\n\n /**\n * The content to show in the prompt.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n\n /**\n * Close the prompt.\n *\n * @param value - The value to close the prompt with.\n */\n ok(value?: string): Promise<void>;\n\n /**\n * Cancel the prompt.\n */\n cancel(): Promise<void>;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with two buttons defined.\n * The approval of this confirmation is handled by the snap.\n */\nexport type DefaultSnapInterfaceWithFooter = {\n /**\n * The content to show in the interface.\n */\n content: JSXElement;\n\n /**\n * The ID of the interface.\n */\n id: string;\n};\n\n/**\n * A `snap_dialog` default interface that has a Footer with one button defined.\n * A cancel button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithPartialFooter =\n DefaultSnapInterfaceWithFooter & {\n /**\n * Cancel the dialog.\n */\n cancel(): Promise<void>;\n };\n\n/**\n * A `snap_dialog` default interface that has no Footer defined.\n * A cancel and ok button is automatically applied to the interface in this case.\n */\nexport type DefaultSnapInterfaceWithoutFooter =\n DefaultSnapInterfaceWithPartialFooter & {\n /**\n * Close the dialog.\n *\n */\n ok(): Promise<void>;\n };\n\nexport type DefaultSnapInterface = (\n | DefaultSnapInterfaceWithFooter\n | DefaultSnapInterfaceWithPartialFooter\n | DefaultSnapInterfaceWithoutFooter\n) & {\n type?: never;\n};\n\nexport type SnapInterface = (\n | SnapAlertInterface\n | SnapConfirmationInterface\n | SnapPromptInterface\n | DefaultSnapInterface\n) &\n SnapInterfaceActions;\n\nexport type SnapRequestObject = {\n /**\n * Get a user interface object from a snap. This will throw an error if the\n * snap does not show a user interface within the timeout.\n *\n * @param options - The options to use.\n * @param options.timeout - The timeout in milliseconds to use. Defaults to\n * `1000`.\n * @returns The user interface object.\n */\n getInterface(options?: SnapOptions): Promise<SnapInterface>;\n};\n\n/**\n * A pending request object. This is a promise with extra\n * {@link SnapRequestObject} fields.\n */\nexport type SnapRequest = Promise<SnapResponse> & SnapRequestObject;\n\n/**\n * The options to use for mocking a JSON-RPC request.\n */\nexport type JsonRpcMockOptions =\n | {\n /**\n * The JSON-RPC request method.\n */\n method: string;\n\n /**\n * The JSON-RPC response, which will be returned when a request with the\n * specified method is sent.\n */\n result: Json;\n }\n | JsonRpcMockImplementation;\n\n/**\n * A function that can be used to mock a JSON-RPC implementation.\n *\n * @param request - The JSON-RPC request.\n * @returns A valid JSON value, optionally as a promise or undefined.\n */\nexport type JsonRpcMockImplementation = (\n request: JsonRpcRequest,\n) => Promise<Json> | Json | undefined;\n\n/**\n * This is the main entry point to interact with the snap. It is returned by\n * {@link installSnap}, and has methods to send requests to the snap.\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * const snap = await installSnap();\n * const response = await snap.request({ method: 'hello' });\n *\n * expect(response).toRespondWith('Hello, world!');\n */\nexport type Snap = {\n /**\n * Send a JSON-RPC request to the snap.\n *\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n request(request: RequestOptions): SnapRequest;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n */\n onTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a transaction to the snap.\n *\n * @param transaction - The transaction. This is similar to an Ethereum\n * transaction object, but has an extra `origin` field. Any missing fields\n * will be filled in with default values.\n * @returns The response.\n * @deprecated Use {@link onTransaction} instead.\n */\n sendTransaction(\n transaction?: Partial<TransactionOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a signature request to the snap.\n *\n * @param signature - The signature request object. Contains the params from\n * the various signature methods, but has an extra `origin` and `signatureMethod` field.\n * Any missing fields will be filled in with default values.\n * @returns The response.\n */\n onSignature(\n signature?: Partial<SignatureOptions>,\n ): Promise<SnapResponseWithInterface>;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onCronjob(cronjob?: Partial<CronjobOptions>): SnapRequest;\n\n /**\n * Run a cronjob in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param cronjob - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified in the snap manifest, under the\n * `endowment:cronjob` permission.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n * @deprecated Use {@link onCronjob} instead.\n */\n runCronjob(cronjob: CronjobOptions): SnapRequest;\n\n /**\n * Run a background event in the snap. This is similar to {@link request}, but the\n * request will be sent to the `onCronjob` method of the snap.\n *\n * @param backgroundEvent - The cronjob request. This is similar to a JSON-RPC\n * request, and is normally specified as the `request` param in the `snap_scheduleBackgroundEvent` method.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onBackgroundEvent(backgroundEvent: CronjobOptions): SnapRequest;\n\n /**\n * Get the response from the snap's `onHomePage` method.\n *\n * @returns The response.\n */\n onHomePage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Get the response from the snap's `onSettingsPage` method.\n *\n * @returns The response.\n */\n onSettingsPage(): Promise<SnapResponseWithInterface>;\n\n /**\n * Send a keyring to the Snap.\n *\n * @param keyringRequest - Keyring request options.\n * @returns The response.\n */\n onKeyringRequest(keyringRequest: KeyringOptions): SnapRequest;\n\n /**\n * Get the response from the Snap's `onInstall` handler.\n *\n * @returns The response.\n */\n onInstall(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onUpdate` handler.\n *\n * @returns The response.\n */\n onUpdate(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onStart` handler.\n *\n * @returns The response.\n */\n onStart(request?: Pick<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Get the response from the Snap's `onNameLookup` handler.\n *\n * @returns The response.\n */\n onNameLookup(\n nameLookupRequest: NameLookupOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Send a JSON-RPC protocol request to the Snap.\n *\n * @param scope - A CAIP-2 scope.\n * @param request - The request. This is similar to a JSON-RPC request, but\n * has an extra `origin` field.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onProtocolRequest(\n scope: CaipChainId,\n request: RequestOptions,\n ): Promise<SnapResponseWithoutInterface>;\n\n /**\n * Send a JSON-RPC client request to the Snap.\n *\n * @param request - The JSON-RPC request.\n * @returns The response promise, with extra {@link SnapRequestObject} fields.\n */\n onClientRequest(request: Omit<RequestOptions, 'origin'>): SnapRequest;\n\n /**\n * Mock a JSON-RPC request. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpc((request) => {\n * if (request.method === 'eth_accounts') {\n * return ['0x1234'];\n * }\n * });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n */\n mockJsonRpc(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\n\n /**\n * Mock a JSON-RPC request once. This will cause the snap to respond with the\n * specified response when a request with the specified method is sent.\n *\n * @param mock - The mock options.\n * @param mock.method - The JSON-RPC request method.\n * @param mock.result - The JSON-RPC response, which will be returned when a\n * request with the specified method is sent.\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpcOnce({ method: 'eth_accounts', result: ['0x1234'] });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n *\n * const response2 =\n * await ethereum.request({ method: 'eth_accounts' }); // Default behavior\n *\n * @example\n * import { installSnap } from '@metamask/snaps-jest';\n *\n * // In the test\n * const snap = await installSnap();\n * snap.mockJsonRpcOnce((request) => {\n * if (request.method === 'eth_accounts') {\n * return ['0x1234'];\n * }\n * });\n *\n * // In the Snap\n * const response =\n * await ethereum.request({ method: 'eth_accounts' }); // ['0x1234']\n *\n * const response2 =\n * await ethereum.request({ method: 'eth_accounts' }); // Default behavior\n */\n mockJsonRpcOnce(mock: JsonRpcMockOptions): {\n /**\n * Remove the mock.\n */\n unmock(): void;\n };\n\n /**\n * Close the page running the snap. This is mainly useful for cleaning up\n * the test environment, and calling it is not strictly necessary.\n *\n * @returns A promise that resolves when the page is closed.\n * @deprecated Snaps are now automatically closed when the test ends. This\n * method will be removed in a future release.\n */\n close(): Promise<void>;\n};\n\nexport type SnapHandlerInterface = {\n content: JSXElement;\n} & SnapInterfaceActions;\n\nexport type TrackedSnapResponseData = {\n errors: TrackableError[];\n events: {\n event: string;\n properties?: Record<string, Json>;\n sensitiveProperties?: Record<string, Json>;\n }[];\n traces: TraceRequest[];\n};\n\nexport type SnapResponseWithInterface = {\n id: string;\n response: { result: Json } | { error: Json };\n\n notifications: {\n id: string;\n message: string;\n type: EnumToUnion<NotificationType>;\n title?: string | undefined;\n content?: string | undefined;\n footerLink?: { text: string; href: string } | undefined;\n }[];\n\n tracked: TrackedSnapResponseData;\n\n getInterface(): SnapHandlerInterface;\n};\n\nexport type SnapResponseWithoutInterface = Omit<\n SnapResponseWithInterface,\n 'getInterface'\n>;\n\nexport type SnapResponseType =\n | SnapResponseWithoutInterface\n | SnapResponseWithInterface;\n\nexport type SnapResponse = InferMatching<\n typeof SnapResponseStruct,\n SnapResponseType\n>;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-simulation",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "A simulation framework for MetaMask Snaps, enabling headless testing of Snaps in a controlled environment",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -55,20 +55,20 @@
55
55
  "test:watch": "jest --watch"
56
56
  },
57
57
  "dependencies": {
58
- "@metamask/base-controller": "^8.0.1",
58
+ "@metamask/base-controller": "^8.4.1",
59
59
  "@metamask/eth-json-rpc-middleware": "^17.0.1",
60
- "@metamask/json-rpc-engine": "^10.0.2",
61
- "@metamask/json-rpc-middleware-stream": "^8.0.7",
60
+ "@metamask/json-rpc-engine": "^10.1.0",
61
+ "@metamask/json-rpc-middleware-stream": "^8.0.8",
62
62
  "@metamask/key-tree": "^10.1.1",
63
63
  "@metamask/permission-controller": "^11.0.6",
64
64
  "@metamask/phishing-controller": "^13.1.0",
65
- "@metamask/snaps-controllers": "^14.2.1",
66
- "@metamask/snaps-execution-environments": "^10.2.1",
67
- "@metamask/snaps-rpc-methods": "^13.5.0",
68
- "@metamask/snaps-sdk": "^9.3.0",
69
- "@metamask/snaps-utils": "^11.4.0",
65
+ "@metamask/snaps-controllers": "^15.0.2",
66
+ "@metamask/snaps-execution-environments": "^10.2.2",
67
+ "@metamask/snaps-rpc-methods": "^13.5.3",
68
+ "@metamask/snaps-sdk": "^10.0.0",
69
+ "@metamask/snaps-utils": "^11.6.0",
70
70
  "@metamask/superstruct": "^3.2.1",
71
- "@metamask/utils": "^11.4.2",
71
+ "@metamask/utils": "^11.8.1",
72
72
  "@reduxjs/toolkit": "^1.9.5",
73
73
  "fast-deep-equal": "^3.1.3",
74
74
  "immer": "^9.0.21",
@@ -77,7 +77,7 @@
77
77
  "redux-saga": "^1.2.3"
78
78
  },
79
79
  "devDependencies": {
80
- "@lavamoat/allow-scripts": "^3.3.4",
80
+ "@lavamoat/allow-scripts": "^3.4.0",
81
81
  "@metamask/auto-changelog": "^5.0.2",
82
82
  "@ts-bridge/cli": "^0.6.1",
83
83
  "@types/express": "^5.0.1",