@metamask/snaps-simulation 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/controllers.cjs +3 -4
  3. package/dist/controllers.cjs.map +1 -1
  4. package/dist/controllers.mjs +1 -1
  5. package/dist/controllers.mjs.map +1 -1
  6. package/dist/files.cjs +4 -5
  7. package/dist/files.cjs.map +1 -1
  8. package/dist/helpers.cjs +1 -2
  9. package/dist/helpers.cjs.map +1 -1
  10. package/dist/interface.cjs +18 -19
  11. package/dist/interface.cjs.map +1 -1
  12. package/dist/interface.d.cts +2 -2
  13. package/dist/interface.d.cts.map +1 -1
  14. package/dist/interface.d.mts +2 -2
  15. package/dist/interface.d.mts.map +1 -1
  16. package/dist/interface.mjs +2 -2
  17. package/dist/interface.mjs.map +1 -1
  18. package/dist/logger.d.cts +0 -1
  19. package/dist/logger.d.cts.map +1 -1
  20. package/dist/logger.d.mts +0 -1
  21. package/dist/logger.d.mts.map +1 -1
  22. package/dist/methods/hooks/chain.cjs +1 -2
  23. package/dist/methods/hooks/chain.cjs.map +1 -1
  24. package/dist/methods/hooks/chain.d.cts +12 -1
  25. package/dist/methods/hooks/chain.d.cts.map +1 -1
  26. package/dist/methods/hooks/chain.d.mts +12 -1
  27. package/dist/methods/hooks/chain.d.mts.map +1 -1
  28. package/dist/methods/hooks/end-trace.cjs +1 -2
  29. package/dist/methods/hooks/end-trace.cjs.map +1 -1
  30. package/dist/methods/hooks/end-trace.d.cts +12 -1
  31. package/dist/methods/hooks/end-trace.d.cts.map +1 -1
  32. package/dist/methods/hooks/end-trace.d.mts +12 -1
  33. package/dist/methods/hooks/end-trace.d.mts.map +1 -1
  34. package/dist/methods/hooks/get-mnemonic.cjs +1 -2
  35. package/dist/methods/hooks/get-mnemonic.cjs.map +1 -1
  36. package/dist/methods/hooks/get-mnemonic.d.cts.map +1 -1
  37. package/dist/methods/hooks/get-mnemonic.d.mts.map +1 -1
  38. package/dist/methods/hooks/get-preferences.cjs +1 -2
  39. package/dist/methods/hooks/get-preferences.cjs.map +1 -1
  40. package/dist/methods/hooks/get-snap.cjs +1 -2
  41. package/dist/methods/hooks/get-snap.cjs.map +1 -1
  42. package/dist/methods/hooks/get-snap.d.cts.map +1 -1
  43. package/dist/methods/hooks/get-snap.d.mts.map +1 -1
  44. package/dist/methods/hooks/notifications.cjs +2 -3
  45. package/dist/methods/hooks/notifications.cjs.map +1 -1
  46. package/dist/methods/hooks/notifications.d.cts +26 -2
  47. package/dist/methods/hooks/notifications.d.cts.map +1 -1
  48. package/dist/methods/hooks/notifications.d.mts +26 -2
  49. package/dist/methods/hooks/notifications.d.mts.map +1 -1
  50. package/dist/methods/hooks/permitted/state.cjs +3 -4
  51. package/dist/methods/hooks/permitted/state.cjs.map +1 -1
  52. package/dist/methods/hooks/permitted/state.d.cts +31 -3
  53. package/dist/methods/hooks/permitted/state.d.cts.map +1 -1
  54. package/dist/methods/hooks/permitted/state.d.mts +31 -3
  55. package/dist/methods/hooks/permitted/state.d.mts.map +1 -1
  56. package/dist/methods/hooks/request-user-approval.cjs +1 -2
  57. package/dist/methods/hooks/request-user-approval.cjs.map +1 -1
  58. package/dist/methods/hooks/request-user-approval.d.cts +15 -1
  59. package/dist/methods/hooks/request-user-approval.d.cts.map +1 -1
  60. package/dist/methods/hooks/request-user-approval.d.mts +15 -1
  61. package/dist/methods/hooks/request-user-approval.d.mts.map +1 -1
  62. package/dist/methods/hooks/start-trace.cjs +1 -2
  63. package/dist/methods/hooks/start-trace.cjs.map +1 -1
  64. package/dist/methods/hooks/start-trace.d.cts +12 -1
  65. package/dist/methods/hooks/start-trace.d.cts.map +1 -1
  66. package/dist/methods/hooks/start-trace.d.mts +12 -1
  67. package/dist/methods/hooks/start-trace.d.mts.map +1 -1
  68. package/dist/methods/hooks/state.cjs +3 -4
  69. package/dist/methods/hooks/state.cjs.map +1 -1
  70. package/dist/methods/hooks/state.d.cts +37 -3
  71. package/dist/methods/hooks/state.d.cts.map +1 -1
  72. package/dist/methods/hooks/state.d.mts +37 -3
  73. package/dist/methods/hooks/state.d.mts.map +1 -1
  74. package/dist/methods/hooks/track-error.cjs +1 -2
  75. package/dist/methods/hooks/track-error.cjs.map +1 -1
  76. package/dist/methods/hooks/track-error.d.cts +11 -1
  77. package/dist/methods/hooks/track-error.d.cts.map +1 -1
  78. package/dist/methods/hooks/track-error.d.mts +11 -1
  79. package/dist/methods/hooks/track-error.d.mts.map +1 -1
  80. package/dist/methods/hooks/track-event.cjs +1 -2
  81. package/dist/methods/hooks/track-event.cjs.map +1 -1
  82. package/dist/methods/hooks/track-event.d.cts +12 -5
  83. package/dist/methods/hooks/track-event.d.cts.map +1 -1
  84. package/dist/methods/hooks/track-event.d.mts +12 -5
  85. package/dist/methods/hooks/track-event.d.mts.map +1 -1
  86. package/dist/methods/specifications.cjs +4 -5
  87. package/dist/methods/specifications.cjs.map +1 -1
  88. package/dist/middleware/engine.cjs +1 -2
  89. package/dist/middleware/engine.cjs.map +1 -1
  90. package/dist/middleware/internal-methods/accounts.cjs +1 -2
  91. package/dist/middleware/internal-methods/accounts.cjs.map +1 -1
  92. package/dist/middleware/internal-methods/chain-id.cjs +1 -2
  93. package/dist/middleware/internal-methods/chain-id.cjs.map +1 -1
  94. package/dist/middleware/internal-methods/middleware.cjs +1 -2
  95. package/dist/middleware/internal-methods/middleware.cjs.map +1 -1
  96. package/dist/middleware/internal-methods/net-version.cjs +1 -2
  97. package/dist/middleware/internal-methods/net-version.cjs.map +1 -1
  98. package/dist/middleware/internal-methods/switch-ethereum-chain.cjs +1 -2
  99. package/dist/middleware/internal-methods/switch-ethereum-chain.cjs.map +1 -1
  100. package/dist/middleware/mock.cjs +1 -2
  101. package/dist/middleware/mock.cjs.map +1 -1
  102. package/dist/middleware/multichain/create-session.cjs +1 -2
  103. package/dist/middleware/multichain/create-session.cjs.map +1 -1
  104. package/dist/middleware/multichain/create-session.d.cts +1 -1
  105. package/dist/middleware/multichain/create-session.d.mts +1 -1
  106. package/dist/middleware/multichain/get-session.cjs +1 -2
  107. package/dist/middleware/multichain/get-session.cjs.map +1 -1
  108. package/dist/middleware/multichain/invoke-method.cjs +1 -2
  109. package/dist/middleware/multichain/invoke-method.cjs.map +1 -1
  110. package/dist/middleware/multichain/middleware.cjs +1 -2
  111. package/dist/middleware/multichain/middleware.cjs.map +1 -1
  112. package/dist/middleware/multichain/revoke-session.cjs +1 -2
  113. package/dist/middleware/multichain/revoke-session.cjs.map +1 -1
  114. package/dist/middleware/multichain/utils.cjs +1 -2
  115. package/dist/middleware/multichain/utils.cjs.map +1 -1
  116. package/dist/middleware/provider.cjs +1 -2
  117. package/dist/middleware/provider.cjs.map +1 -1
  118. package/dist/options.cjs +1 -2
  119. package/dist/options.cjs.map +1 -1
  120. package/dist/options.d.cts +4 -4
  121. package/dist/options.d.mts +4 -4
  122. package/dist/request.cjs +3 -4
  123. package/dist/request.cjs.map +1 -1
  124. package/dist/simulation.cjs +9 -10
  125. package/dist/simulation.cjs.map +1 -1
  126. package/dist/simulation.d.cts.map +1 -1
  127. package/dist/simulation.d.mts.map +1 -1
  128. package/dist/simulation.mjs +4 -4
  129. package/dist/simulation.mjs.map +1 -1
  130. package/dist/store/chain.d.cts.map +1 -1
  131. package/dist/store/chain.d.mts.map +1 -1
  132. package/dist/store/mocks.d.cts.map +1 -1
  133. package/dist/store/mocks.d.mts.map +1 -1
  134. package/dist/store/notifications.d.cts.map +1 -1
  135. package/dist/store/notifications.d.mts.map +1 -1
  136. package/dist/store/state.cjs +2 -2
  137. package/dist/store/state.cjs.map +1 -1
  138. package/dist/store/state.d.cts +4 -7
  139. package/dist/store/state.d.cts.map +1 -1
  140. package/dist/store/state.d.mts +4 -7
  141. package/dist/store/state.d.mts.map +1 -1
  142. package/dist/store/store.cjs +1 -2
  143. package/dist/store/store.cjs.map +1 -1
  144. package/dist/store/store.d.cts +1 -1
  145. package/dist/store/store.d.mts +1 -1
  146. package/dist/store/trackables.d.cts +6 -6
  147. package/dist/store/trackables.d.cts.map +1 -1
  148. package/dist/store/trackables.d.mts +6 -6
  149. package/dist/store/trackables.d.mts.map +1 -1
  150. package/dist/store/ui.d.cts.map +1 -1
  151. package/dist/store/ui.d.mts.map +1 -1
  152. package/dist/structs.cjs +3 -3
  153. package/dist/structs.cjs.map +1 -1
  154. package/dist/structs.mjs +1 -1
  155. package/dist/structs.mjs.map +1 -1
  156. package/dist/utils/account.d.cts.map +1 -1
  157. package/dist/utils/account.d.mts.map +1 -1
  158. package/dist/utils/errors.cjs +1 -2
  159. package/dist/utils/errors.cjs.map +1 -1
  160. package/dist/validation.cjs +7 -8
  161. package/dist/validation.cjs.map +1 -1
  162. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"structs.mjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,4BAA4B;AAClE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,8BAA8B;AAC7D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,OAAO,EACR,8BAA8B;AAC/B,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,YAAY,EACb,wBAAwB;AACzB,OAAO,EAAE,WAAW,EAAE,eAAe;AAIrC,oDAAoD;AACpD,MAAM,eAAe,GAAG,KAAK,CAAC;IAC5B,MAAM,EAAE;IACR,MAAM,EAAE;IACR,MAAM,EAAE;IACR,QAAQ,CAAC,UAAU,CAAC;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;IAC7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,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CACzD;YACD,IAAI,EAAE,QAAQ,CACZ,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CACzD;SACF,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CACnD,kCAAkC,EAClC,MAAM,CAAC;IACL,YAAY,EAAE,IAAI,EAAE;CACrB,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;IACtC,kCAAkC;IAClC,+BAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAsB;IAEtB,YAAY,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport { TrackableErrorStruct } from '@metamask/snaps-utils';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n boolean,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n title: optional(string()),\n content: optional(string()),\n footerLink: optional(\n object({\n href: string(),\n text: string(),\n }),\n ),\n }),\n ),\n\n tracked: object({\n errors: array(TrackableErrorStruct),\n\n events: array(\n object({\n event: string(),\n properties: optional(record(string(), JsonStruct)),\n sensitiveProperties: optional(record(string(), JsonStruct)),\n }),\n ),\n\n traces: array(\n object({\n id: optional(string()),\n name: string(),\n parentContext: optional(JsonStruct),\n startTime: optional(number()),\n data: optional(\n record(string(), union([string(), number(), boolean()])),\n ),\n tags: optional(\n record(string(), union([string(), number(), boolean()])),\n ),\n }),\n ),\n }),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
1
+ {"version":3,"file":"structs.mjs","sourceRoot":"","sources":["../src/structs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,4BAA4B;AAClE,OAAO,EAAE,gBAAgB,EAAE,gCAAgC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,8BAA8B;AAC7D,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN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X,MAAM,CAAC;YACL,KAAK,EAAE,MAAM,EAAE;YACf,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;YAClD,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;SAC5D,CAAC,CACH;QAED,MAAM,EAAE,KAAK,CACX,MAAM,CAAC;YACL,EAAE,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtB,IAAI,EAAE,MAAM,EAAE;YACd,aAAa,EAAE,QAAQ,CAAC,UAAU,CAAC;YACnC,SAAS,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;YAC7B,IAAI,EAAE,QAAQ,CACZ,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CACzD;YACD,IAAI,EAAE,QAAQ,CACZ,MAAM,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CACzD;SACF,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CACnD,kCAAkC,EAClC,MAAM,CAAC;IACL,YAAY,EAAE,IAAI,EAAE;CACrB,CAAC,CACH,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;IACtC,kCAAkC;IAClC,+BAA+B;CAChC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAsB;IAEtB,YAAY,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import { NotificationType, enumValue } from '@metamask/snaps-sdk';\nimport { JSXElementStruct } from '@metamask/snaps-sdk/jsx';\nimport { TrackableErrorStruct } from '@metamask/snaps-utils';\nimport {\n array,\n assign,\n bigint,\n coerce,\n defaulted,\n instance,\n literal,\n number,\n object,\n optional,\n string,\n union,\n record,\n any,\n func,\n type,\n boolean,\n} from '@metamask/superstruct';\nimport {\n assertStruct,\n bytesToHex,\n JsonStruct,\n StrictHexStruct,\n valueToBytes,\n} from '@metamask/utils';\nimport { randomBytes } from 'crypto';\n\nimport type { SnapResponse, SnapResponseWithInterface } from './types';\n\n// TODO: Export this from `@metamask/utils` instead.\nconst BytesLikeStruct = union([\n bigint(),\n number(),\n string(),\n instance(Uint8Array),\n]);\n\nexport const TransactionOptionsStruct = object({\n /**\n * The CAIP-2 chain ID to send the transaction on. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n\n /**\n * The origin to send the transaction from. Defaults to `metamask.io`.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address to send the transaction from. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The address to send the transaction to. Defaults to a randomly generated\n * address.\n */\n // TODO: Move this coercer to `@metamask/utils`.\n to: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The value to send with the transaction. The value may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n value: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x0',\n ),\n\n /**\n * The gas limit to use for the transaction. The gas limit may be specified\n * as a `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `21_000`.\n */\n gasLimit: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(21_000),\n ),\n\n /**\n * The max fee per gas (in Wei) to use for the transaction. The max fee per\n * gas may be specified as a `number`, `bigint`, `string`, or `Uint8Array`.\n * Defaults to `1`.\n */\n maxFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The max priority fee per gas (in Wei) to use for the transaction. The max\n * priority fee per gas may be specified as a `number`, `bigint`, `string`,\n * or `Uint8Array`. Defaults to `1`.\n */\n maxPriorityFeePerGas: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(1),\n ),\n\n /**\n * The nonce to use for the transaction. The nonce may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0`.\n */\n nonce: defaulted(\n coerce(StrictHexStruct, BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n valueToBytes(0),\n ),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `number`, `bigint`, `string`, or `Uint8Array`. Defaults to `0x`.\n */\n data: defaulted(\n coerce(union([StrictHexStruct, literal('0x')]), BytesLikeStruct, (value) =>\n bytesToHex(valueToBytes(value)),\n ),\n '0x',\n ),\n});\n\nexport const SignatureOptionsStruct = object({\n /**\n * The origin making the signature request.\n */\n origin: defaulted(string(), 'metamask.io'),\n\n /**\n * The address signing the signature request. Defaults to a randomly generated\n * address.\n */\n from: coerce(StrictHexStruct, optional(BytesLikeStruct), (value) => {\n if (value) {\n return bytesToHex(valueToBytes(value));\n }\n\n return bytesToHex(randomBytes(20));\n }),\n\n /**\n * The data to send with the transaction. The data may be specified as a\n * `string`, an object, or an array of objects. This covers the data types\n * for the supported signature methods. Defaults to `0x`.\n */\n data: defaulted(\n union([\n StrictHexStruct,\n literal('0x'),\n record(string(), any()),\n array(record(string(), any())),\n ]),\n '0x',\n ),\n\n /**\n * The signature method being used.\n */\n signatureMethod: defaulted(\n union([\n literal('personal_sign'),\n literal('eth_signTypedData'),\n literal('eth_signTypedData_v3'),\n literal('eth_signTypedData_v4'),\n ]),\n 'personal_sign',\n ),\n});\n\nexport const BaseNameLookupOptionsStruct = object({\n /**\n * The CAIP-2 chain ID. Defaults to `eip155:1`.\n */\n chainId: defaulted(string(), 'eip155:1'),\n});\n\nexport const NameLookupOptionsStruct = union([\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Address to lookup.\n */\n address: string(),\n }),\n ),\n assign(\n BaseNameLookupOptionsStruct,\n object({\n /**\n * Domain name to lookup.\n */\n domain: string(),\n }),\n ),\n]);\n\nexport const SnapOptionsStruct = object({\n /**\n * The timeout in milliseconds to use for requests to the snap. Defaults to\n * `1000`.\n */\n timeout: defaulted(optional(number()), 1000),\n});\n\nexport const JsonRpcMockOptionsStruct = object({\n method: string(),\n result: JsonStruct,\n});\n\nexport const InterfaceStruct = type({\n content: optional(JSXElementStruct),\n});\n\nexport const SnapResponseWithoutInterfaceStruct = object({\n id: string(),\n\n response: union([\n object({\n result: JsonStruct,\n }),\n object({\n error: JsonStruct,\n }),\n ]),\n\n notifications: array(\n object({\n id: string(),\n message: string(),\n type: union([\n enumValue(NotificationType.InApp),\n enumValue(NotificationType.Native),\n ]),\n title: optional(string()),\n content: optional(string()),\n footerLink: optional(\n object({\n href: string(),\n text: string(),\n }),\n ),\n }),\n ),\n\n tracked: object({\n errors: array(TrackableErrorStruct),\n\n events: array(\n object({\n event: string(),\n properties: optional(record(string(), JsonStruct)),\n sensitiveProperties: optional(record(string(), JsonStruct)),\n }),\n ),\n\n traces: array(\n object({\n id: optional(string()),\n name: string(),\n parentContext: optional(JsonStruct),\n startTime: optional(number()),\n data: optional(\n record(string(), union([string(), number(), boolean()])),\n ),\n tags: optional(\n record(string(), union([string(), number(), boolean()])),\n ),\n }),\n ),\n }),\n});\n\nexport const SnapResponseWithInterfaceStruct = assign(\n SnapResponseWithoutInterfaceStruct,\n object({\n getInterface: func(),\n }),\n);\n\nexport const SnapResponseStruct = union([\n SnapResponseWithoutInterfaceStruct,\n SnapResponseWithInterfaceStruct,\n]);\n\n/**\n * Ensure that the actual response contains `getInterface`.\n *\n * @param response - The response of the handler.\n */\nexport function assertIsResponseWithInterface(\n response: SnapResponse,\n): asserts response is SnapResponseWithInterface {\n assertStruct(response, SnapResponseWithInterfaceStruct);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,YAC1B,iBAAiB,UAClB,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
1
+ {"version":3,"file":"account.d.cts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,GACnC,SAAS,iBAAiB,EAC1B,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,YAC1B,iBAAiB,UAClB,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
1
+ {"version":3,"file":"account.d.mts","sourceRoot":"","sources":["../../src/utils/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAmB;AAEpD,eAAO,MAAM,wBAAwB,GACnC,SAAS,iBAAiB,EAC1B,QAAQ,MAAM;;;;;;;;;;;;;;;;;;;;;;CAiBf,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatTypeErrorMessage = void 0;
3
+ exports.formatTypeErrorMessage = formatTypeErrorMessage;
4
4
  /**
5
5
  * Format types for error messages based on the number of types.
6
6
  *
@@ -21,5 +21,4 @@ function formatTypeErrorMessage(types) {
21
21
  .join(', ');
22
22
  return `${otherTypes} or "${lastType}"`;
23
23
  }
24
- exports.formatTypeErrorMessage = formatTypeErrorMessage;
25
24
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,KAAe;IACpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,KAAK;SACrB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,GAAG,UAAU,QAAQ,QAAQ,GAAG,CAAC;AAC1C,CAAC;AAhBD,wDAgBC","sourcesContent":["/**\n * Format types for error messages based on the number of types.\n *\n * @param types - Array of type names.\n * @returns Formatted string for error message.\n */\nexport function formatTypeErrorMessage(types: string[]): string {\n if (types.length === 1) {\n return `\"${types[0]}\"`;\n }\n\n if (types.length === 2) {\n return `\"${types[0]}\" or \"${types[1]}\"`;\n }\n\n const lastType = types[types.length - 1];\n const otherTypes = types\n .slice(0, -1)\n .map((type) => `\"${type}\"`)\n .join(', ');\n\n return `${otherTypes} or \"${lastType}\"`;\n}\n"]}
1
+ {"version":3,"file":"errors.cjs","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;AAMA,wDAgBC;AAtBD;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,KAAe;IACpD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IACzB,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,UAAU,GAAG,KAAK;SACrB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACZ,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,GAAG,UAAU,QAAQ,QAAQ,GAAG,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * Format types for error messages based on the number of types.\n *\n * @param types - Array of type names.\n * @returns Formatted string for error message.\n */\nexport function formatTypeErrorMessage(types: string[]): string {\n if (types.length === 1) {\n return `\"${types[0]}\"`;\n }\n\n if (types.length === 2) {\n return `\"${types[0]}\" or \"${types[1]}\"`;\n }\n\n const lastType = types[types.length - 1];\n const otherTypes = types\n .slice(0, -1)\n .map((type) => `\"${type}\"`)\n .join(', ');\n\n return `${otherTypes} or \"${lastType}\"`;\n}\n"]}
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertCustomDialogHasNoFooter = exports.assertCustomDialogHasPartialFooter = exports.assertCustomDialogHasFooter = exports.assertIsCustomDialog = exports.assertIsPromptDialog = exports.assertIsConfirmationDialog = exports.assertIsAlertDialog = void 0;
3
+ exports.assertIsAlertDialog = assertIsAlertDialog;
4
+ exports.assertIsConfirmationDialog = assertIsConfirmationDialog;
5
+ exports.assertIsPromptDialog = assertIsPromptDialog;
6
+ exports.assertIsCustomDialog = assertIsCustomDialog;
7
+ exports.assertCustomDialogHasFooter = assertCustomDialogHasFooter;
8
+ exports.assertCustomDialogHasPartialFooter = assertCustomDialogHasPartialFooter;
9
+ exports.assertCustomDialogHasNoFooter = assertCustomDialogHasNoFooter;
4
10
  const snaps_sdk_1 = require("@metamask/snaps-sdk");
5
11
  const snaps_utils_1 = require("@metamask/snaps-utils");
6
12
  const utils_1 = require("@metamask/utils");
@@ -13,7 +19,6 @@ const interface_1 = require("./interface.cjs");
13
19
  function assertIsAlertDialog(ui) {
14
20
  (0, utils_1.assert)((0, utils_1.hasProperty)(ui, 'type') && ui.type === snaps_sdk_1.DialogType.Alert);
15
21
  }
16
- exports.assertIsAlertDialog = assertIsAlertDialog;
17
22
  /**
18
23
  * Ensure that the actual interface is a confirmation dialog.
19
24
  *
@@ -22,7 +27,6 @@ exports.assertIsAlertDialog = assertIsAlertDialog;
22
27
  function assertIsConfirmationDialog(ui) {
23
28
  (0, utils_1.assert)((0, utils_1.hasProperty)(ui, 'type') && ui.type === snaps_sdk_1.DialogType.Confirmation);
24
29
  }
25
- exports.assertIsConfirmationDialog = assertIsConfirmationDialog;
26
30
  /**
27
31
  * Ensure that the actual interface is a Prompt dialog.
28
32
  *
@@ -31,7 +35,6 @@ exports.assertIsConfirmationDialog = assertIsConfirmationDialog;
31
35
  function assertIsPromptDialog(ui) {
32
36
  (0, utils_1.assert)((0, utils_1.hasProperty)(ui, 'type') && ui.type === snaps_sdk_1.DialogType.Prompt);
33
37
  }
34
- exports.assertIsPromptDialog = assertIsPromptDialog;
35
38
  /**
36
39
  * Ensure that the actual interface is a custom dialog.
37
40
  *
@@ -40,7 +43,6 @@ exports.assertIsPromptDialog = assertIsPromptDialog;
40
43
  function assertIsCustomDialog(ui) {
41
44
  (0, utils_1.assert)(!(0, utils_1.hasProperty)(ui, 'type'));
42
45
  }
43
- exports.assertIsCustomDialog = assertIsCustomDialog;
44
46
  /**
45
47
  * Ensure that the actual interface is a custom dialog with a complete footer.
46
48
  *
@@ -50,7 +52,6 @@ function assertCustomDialogHasFooter(ui) {
50
52
  const footer = (0, interface_1.getElementByType)(ui.content, 'Footer');
51
53
  (0, utils_1.assert)(footer && (0, snaps_utils_1.getJsxChildren)(footer).length === 2);
52
54
  }
53
- exports.assertCustomDialogHasFooter = assertCustomDialogHasFooter;
54
55
  /**
55
56
  * Ensure that the actual interface is a custom dialog with a partial footer.
56
57
  *
@@ -60,7 +61,6 @@ function assertCustomDialogHasPartialFooter(ui) {
60
61
  const footer = (0, interface_1.getElementByType)(ui.content, 'Footer');
61
62
  (0, utils_1.assert)(footer && (0, snaps_utils_1.getJsxChildren)(footer).length === 1);
62
63
  }
63
- exports.assertCustomDialogHasPartialFooter = assertCustomDialogHasPartialFooter;
64
64
  /**
65
65
  * Ensure that the actual interface is a custom dialog without a footer.
66
66
  *
@@ -70,5 +70,4 @@ function assertCustomDialogHasNoFooter(ui) {
70
70
  const footer = (0, interface_1.getElementByType)(ui.content, 'Footer');
71
71
  (0, utils_1.assert)(!footer);
72
72
  }
73
- exports.assertCustomDialogHasNoFooter = assertCustomDialogHasNoFooter;
74
73
  //# sourceMappingURL=validation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.cjs","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;;AAAA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IAErE,IAAA,cAAM,EAAC,MAAM,IAAI,IAAA,4BAAc,EAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC;AAND,gFAMC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAC3C,EAA+C;IAE/C,MAAM,MAAM,GAAG,IAAA,4BAAgB,EAAgB,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAErE,IAAA,cAAM,EAAC,CAAC,MAAM,CAAC,CAAC;AAClB,CAAC;AAND,sEAMC","sourcesContent":["import { DialogType } from '@metamask/snaps-sdk';\nimport type { FooterElement } from '@metamask/snaps-sdk/jsx';\nimport { getJsxChildren } from '@metamask/snaps-utils';\nimport { assert, hasProperty } from '@metamask/utils';\n\nimport { getElementByType } from './interface';\nimport type {\n DefaultSnapInterface,\n DefaultSnapInterfaceWithFooter,\n DefaultSnapInterfaceWithoutFooter,\n DefaultSnapInterfaceWithPartialFooter,\n SnapAlertInterface,\n SnapConfirmationInterface,\n SnapInterface,\n SnapInterfaceActions,\n SnapPromptInterface,\n} from './types';\n\n/**\n * Ensure that the actual interface is an alert dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsAlertDialog(\n ui: SnapInterface,\n): asserts ui is SnapAlertInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Alert);\n}\n\n/**\n * Ensure that the actual interface is a confirmation dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsConfirmationDialog(\n ui: SnapInterface,\n): asserts ui is SnapConfirmationInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Confirmation);\n}\n\n/**\n * Ensure that the actual interface is a Prompt dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsPromptDialog(\n ui: SnapInterface,\n): asserts ui is SnapPromptInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Prompt);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsCustomDialog(\n ui: SnapInterface,\n): asserts ui is DefaultSnapInterface & SnapInterfaceActions {\n assert(!hasProperty(ui, 'type'));\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a complete footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 2);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a partial footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasPartialFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithPartialFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 1);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog without a footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasNoFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithoutFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(!footer);\n}\n"]}
1
+ {"version":3,"file":"validation.cjs","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":";;AAuBA,kDAIC;AAOD,gEAIC;AAOD,oDAIC;AAOD,oDAIC;AAOD,kEAMC;AAOD,gFAMC;AAOD,sEAMC;AAnGD,mDAAiD;AAEjD,uDAAuD;AACvD,2CAAsD;AAEtD,+CAA+C;AAa/C;;;;GAIG;AACH,SAAgB,mBAAmB,CACjC,EAAiB;IAEjB,IAAA,cAAM,EAAC,IAAA,mBAAW,EAAC,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK,sBAAU,CAAC,KAAK,CAA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AAC,CAAC;AAClB,CAAC","sourcesContent":["import { DialogType } from '@metamask/snaps-sdk';\nimport type { FooterElement } from '@metamask/snaps-sdk/jsx';\nimport { getJsxChildren } from '@metamask/snaps-utils';\nimport { assert, hasProperty } from '@metamask/utils';\n\nimport { getElementByType } from './interface';\nimport type {\n DefaultSnapInterface,\n DefaultSnapInterfaceWithFooter,\n DefaultSnapInterfaceWithoutFooter,\n DefaultSnapInterfaceWithPartialFooter,\n SnapAlertInterface,\n SnapConfirmationInterface,\n SnapInterface,\n SnapInterfaceActions,\n SnapPromptInterface,\n} from './types';\n\n/**\n * Ensure that the actual interface is an alert dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsAlertDialog(\n ui: SnapInterface,\n): asserts ui is SnapAlertInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Alert);\n}\n\n/**\n * Ensure that the actual interface is a confirmation dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsConfirmationDialog(\n ui: SnapInterface,\n): asserts ui is SnapConfirmationInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Confirmation);\n}\n\n/**\n * Ensure that the actual interface is a Prompt dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsPromptDialog(\n ui: SnapInterface,\n): asserts ui is SnapPromptInterface & SnapInterfaceActions {\n assert(hasProperty(ui, 'type') && ui.type === DialogType.Prompt);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog.\n *\n * @param ui - The interface to verify.\n */\nexport function assertIsCustomDialog(\n ui: SnapInterface,\n): asserts ui is DefaultSnapInterface & SnapInterfaceActions {\n assert(!hasProperty(ui, 'type'));\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a complete footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 2);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog with a partial footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasPartialFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithPartialFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(footer && getJsxChildren(footer).length === 1);\n}\n\n/**\n * Ensure that the actual interface is a custom dialog without a footer.\n *\n * @param ui - The interface to verify.\n */\nexport function assertCustomDialogHasNoFooter(\n ui: DefaultSnapInterface & SnapInterfaceActions,\n): asserts ui is DefaultSnapInterfaceWithoutFooter & SnapInterfaceActions {\n const footer = getElementByType<FooterElement>(ui.content, 'Footer');\n\n assert(!footer);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-simulation",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
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/chain-agnostic-permission": "^1.6.2",
58
+ "@metamask/chain-agnostic-permission": "^1.7.0",
59
59
  "@metamask/json-rpc-engine": "^10.5.0",
60
60
  "@metamask/json-rpc-middleware-stream": "^8.0.8",
61
61
  "@metamask/key-tree": "^10.1.1",
62
62
  "@metamask/messenger": "^2.0.0",
63
63
  "@metamask/permission-controller": "^13.1.1",
64
64
  "@metamask/rpc-errors": "^7.0.3",
65
- "@metamask/snaps-controllers": "^21.0.0",
66
- "@metamask/snaps-execution-environments": "^11.1.1",
67
- "@metamask/snaps-rpc-methods": "^17.1.0",
68
- "@metamask/snaps-sdk": "^11.2.0",
69
- "@metamask/snaps-utils": "^12.3.0",
70
- "@metamask/superstruct": "^3.3.0",
71
- "@metamask/utils": "^11.11.0",
65
+ "@metamask/snaps-controllers": "^22.0.0",
66
+ "@metamask/snaps-execution-environments": "^11.3.2",
67
+ "@metamask/snaps-rpc-methods": "^17.2.0",
68
+ "@metamask/snaps-sdk": "^12.1.0",
69
+ "@metamask/snaps-utils": "^12.6.1",
70
+ "@metamask/superstruct": "^3.4.1",
71
+ "@metamask/utils": "^12.0.0",
72
72
  "@reduxjs/toolkit": "^1.9.5",
73
73
  "ethers": "^6.16.0",
74
74
  "fast-deep-equal": "^3.1.3",
@@ -79,7 +79,7 @@
79
79
  },
80
80
  "devDependencies": {
81
81
  "@lavamoat/allow-scripts": "^4.0.0",
82
- "@metamask/auto-changelog": "^6.1.1",
82
+ "@metamask/auto-changelog": "^6.2.1",
83
83
  "@ts-bridge/cli": "^0.6.1",
84
84
  "@types/express": "^5.0.1",
85
85
  "@types/jest": "^27.5.1",
@@ -94,7 +94,7 @@
94
94
  "jest-silent-reporter": "^0.6.0",
95
95
  "prettier": "^3.3.3",
96
96
  "ts-jest": "^29.1.1",
97
- "typescript": "~5.3.3"
97
+ "typescript": "~5.8.3"
98
98
  },
99
99
  "engines": {
100
100
  "node": "^20 || >=22"