@metamask/snaps-utils 9.0.1 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/account.cjs +3 -0
  3. package/dist/account.cjs.map +1 -0
  4. package/dist/account.d.cts +22 -0
  5. package/dist/account.d.cts.map +1 -0
  6. package/dist/account.d.mts +22 -0
  7. package/dist/account.d.mts.map +1 -0
  8. package/dist/account.mjs +2 -0
  9. package/dist/account.mjs.map +1 -0
  10. package/dist/cronjob.d.cts +9 -9
  11. package/dist/cronjob.d.mts +9 -9
  12. package/dist/eval-worker.cjs +2 -2
  13. package/dist/eval-worker.cjs.map +1 -1
  14. package/dist/eval-worker.mjs +1 -1
  15. package/dist/eval-worker.mjs.map +1 -1
  16. package/dist/handlers/asset-historical-price.cjs +25 -0
  17. package/dist/handlers/asset-historical-price.cjs.map +1 -0
  18. package/dist/handlers/asset-historical-price.d.cts +37 -0
  19. package/dist/handlers/asset-historical-price.d.cts.map +1 -0
  20. package/dist/handlers/asset-historical-price.d.mts +37 -0
  21. package/dist/handlers/asset-historical-price.d.mts.map +1 -0
  22. package/dist/handlers/asset-historical-price.mjs +22 -0
  23. package/dist/handlers/asset-historical-price.mjs.map +1 -0
  24. package/dist/handlers/assets-conversion.cjs +38 -0
  25. package/dist/handlers/assets-conversion.cjs.map +1 -0
  26. package/dist/handlers/assets-conversion.d.cts +90 -0
  27. package/dist/handlers/assets-conversion.d.cts.map +1 -0
  28. package/dist/handlers/assets-conversion.d.mts +90 -0
  29. package/dist/handlers/assets-conversion.d.mts.map +1 -0
  30. package/dist/handlers/assets-conversion.mjs +35 -0
  31. package/dist/handlers/assets-conversion.mjs.map +1 -0
  32. package/dist/handlers/exports.cjs +113 -0
  33. package/dist/handlers/exports.cjs.map +1 -0
  34. package/dist/handlers/exports.d.cts +81 -0
  35. package/dist/handlers/exports.d.cts.map +1 -0
  36. package/dist/handlers/exports.d.mts +81 -0
  37. package/dist/handlers/exports.d.mts.map +1 -0
  38. package/dist/{handlers.mjs → handlers/exports.mjs} +10 -45
  39. package/dist/handlers/exports.mjs.map +1 -0
  40. package/dist/handlers/home-page.cjs +16 -0
  41. package/dist/handlers/home-page.cjs.map +1 -0
  42. package/dist/handlers/home-page.d.cts +268 -0
  43. package/dist/handlers/home-page.d.cts.map +1 -0
  44. package/dist/handlers/home-page.d.mts +268 -0
  45. package/dist/handlers/home-page.d.mts.map +1 -0
  46. package/dist/handlers/home-page.mjs +13 -0
  47. package/dist/handlers/home-page.mjs.map +1 -0
  48. package/dist/handlers/index.cjs +26 -0
  49. package/dist/handlers/index.cjs.map +1 -0
  50. package/dist/handlers/index.d.cts +10 -0
  51. package/dist/handlers/index.d.cts.map +1 -0
  52. package/dist/handlers/index.d.mts +10 -0
  53. package/dist/handlers/index.d.mts.map +1 -0
  54. package/dist/handlers/index.mjs +10 -0
  55. package/dist/handlers/index.mjs.map +1 -0
  56. package/dist/handlers/name-lookup.cjs +21 -0
  57. package/dist/handlers/name-lookup.cjs.map +1 -0
  58. package/dist/handlers/name-lookup.d.cts +67 -0
  59. package/dist/handlers/name-lookup.d.cts.map +1 -0
  60. package/dist/handlers/name-lookup.d.mts +67 -0
  61. package/dist/handlers/name-lookup.d.mts.map +1 -0
  62. package/dist/handlers/name-lookup.mjs +18 -0
  63. package/dist/handlers/name-lookup.mjs.map +1 -0
  64. package/dist/handlers/settings-page.cjs +6 -0
  65. package/dist/handlers/settings-page.cjs.map +1 -0
  66. package/dist/handlers/settings-page.d.cts +90 -0
  67. package/dist/handlers/settings-page.d.cts.map +1 -0
  68. package/dist/handlers/settings-page.d.mts +90 -0
  69. package/dist/handlers/settings-page.d.mts.map +1 -0
  70. package/dist/handlers/settings-page.mjs +3 -0
  71. package/dist/handlers/settings-page.mjs.map +1 -0
  72. package/dist/handlers/signature.cjs +6 -0
  73. package/dist/handlers/signature.cjs.map +1 -0
  74. package/dist/handlers/signature.d.cts +92 -0
  75. package/dist/handlers/signature.d.cts.map +1 -0
  76. package/dist/handlers/signature.d.mts +92 -0
  77. package/dist/handlers/signature.d.mts.map +1 -0
  78. package/dist/handlers/signature.mjs +3 -0
  79. package/dist/handlers/signature.mjs.map +1 -0
  80. package/dist/handlers/transaction.cjs +19 -0
  81. package/dist/handlers/transaction.cjs.map +1 -0
  82. package/dist/handlers/transaction.d.cts +280 -0
  83. package/dist/handlers/transaction.d.cts.map +1 -0
  84. package/dist/handlers/transaction.d.mts +280 -0
  85. package/dist/handlers/transaction.d.mts.map +1 -0
  86. package/dist/handlers/transaction.mjs +16 -0
  87. package/dist/handlers/transaction.mjs.map +1 -0
  88. package/dist/{handler-types.cjs → handlers/types.cjs} +3 -3
  89. package/dist/handlers/types.cjs.map +1 -0
  90. package/dist/{handler-types.d.mts → handlers/types.d.cts} +22 -2
  91. package/dist/handlers/types.d.cts.map +1 -0
  92. package/dist/{handler-types.d.cts → handlers/types.d.mts} +22 -2
  93. package/dist/handlers/types.d.mts.map +1 -0
  94. package/dist/{handler-types.mjs → handlers/types.mjs} +2 -2
  95. package/dist/handlers/types.mjs.map +1 -0
  96. package/dist/iframe.test.browser.cjs +20 -19
  97. package/dist/iframe.test.browser.cjs.map +1 -1
  98. package/dist/iframe.test.browser.mjs +2 -1
  99. package/dist/iframe.test.browser.mjs.map +1 -1
  100. package/dist/index.cjs +2 -2
  101. package/dist/index.cjs.map +1 -1
  102. package/dist/index.d.cts +3 -2
  103. package/dist/index.d.cts.map +1 -1
  104. package/dist/index.d.mts +3 -2
  105. package/dist/index.d.mts.map +1 -1
  106. package/dist/index.executionenv.cjs +2 -2
  107. package/dist/index.executionenv.cjs.map +1 -1
  108. package/dist/index.executionenv.d.cts +2 -2
  109. package/dist/index.executionenv.d.cts.map +1 -1
  110. package/dist/index.executionenv.d.mts +2 -2
  111. package/dist/index.executionenv.d.mts.map +1 -1
  112. package/dist/index.executionenv.mjs +2 -2
  113. package/dist/index.executionenv.mjs.map +1 -1
  114. package/dist/index.mjs +2 -2
  115. package/dist/index.mjs.map +1 -1
  116. package/dist/localization.d.cts +5 -5
  117. package/dist/localization.d.mts +5 -5
  118. package/dist/manifest/validation.d.cts +12 -12
  119. package/dist/manifest/validation.d.mts +12 -12
  120. package/dist/time.cjs +34 -0
  121. package/dist/time.cjs.map +1 -0
  122. package/dist/time.d.cts +9 -0
  123. package/dist/time.d.cts.map +1 -0
  124. package/dist/time.d.mts +9 -0
  125. package/dist/time.d.mts.map +1 -0
  126. package/dist/time.mjs +31 -0
  127. package/dist/time.mjs.map +1 -0
  128. package/dist/types.d.cts +2 -2
  129. package/dist/types.d.cts.map +1 -1
  130. package/dist/types.d.mts +2 -2
  131. package/dist/types.d.mts.map +1 -1
  132. package/dist/ui.cjs +34 -10
  133. package/dist/ui.cjs.map +1 -1
  134. package/dist/ui.d.cts +22 -6
  135. package/dist/ui.d.cts.map +1 -1
  136. package/dist/ui.d.mts +22 -6
  137. package/dist/ui.d.mts.map +1 -1
  138. package/dist/ui.mjs +31 -8
  139. package/dist/ui.mjs.map +1 -1
  140. package/package.json +16 -24
  141. package/dist/handler-types.cjs.map +0 -1
  142. package/dist/handler-types.d.cts.map +0 -1
  143. package/dist/handler-types.d.mts.map +0 -1
  144. package/dist/handler-types.mjs.map +0 -1
  145. package/dist/handlers.cjs +0 -148
  146. package/dist/handlers.cjs.map +0 -1
  147. package/dist/handlers.d.cts +0 -887
  148. package/dist/handlers.d.cts.map +0 -1
  149. package/dist/handlers.d.mts +0 -887
  150. package/dist/handlers.d.mts.map +0 -1
  151. package/dist/handlers.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler-types.d.mts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,aAAa,kBAAkB;IAC/B,SAAS,cAAc;IACvB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,YAAY,iBAAiB;IAC7B,gBAAgB,qBAAqB;IACrC,UAAU,eAAe;IACzB,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAElB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAA6B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"handler-types.mjs","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,8CAA+B,CAAA;IAC/B,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,oCAAqB,CAAA;IACrB,4CAA6B,CAAA;IAC7B,oDAAqC,CAAA;IACrC,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,0CAA2B,CAAA;IAC3B,gDAAiC,CAAA;IACjC,wDAAyC,CAAA;IACzC,sDAAuC,CAAA;AACzC,CAAC,EAfW,WAAW,KAAX,WAAW,QAetB;AA0BD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["export enum HandlerType {\n OnRpcRequest = 'onRpcRequest',\n OnSignature = 'onSignature',\n OnTransaction = 'onTransaction',\n OnCronjob = 'onCronjob',\n OnInstall = 'onInstall',\n OnUpdate = 'onUpdate',\n OnNameLookup = 'onNameLookup',\n OnKeyringRequest = 'onKeyringRequest',\n OnHomePage = 'onHomePage',\n OnSettingsPage = 'onSettingsPage',\n OnUserInput = 'onUserInput',\n OnAssetsLookup = 'onAssetsLookup',\n OnAssetsConversion = 'onAssetsConversion',\n OnProtocolRequest = 'onProtocolRequest',\n}\n\nexport type SnapHandler = {\n /**\n * The type of handler.\n */\n type: HandlerType;\n\n /**\n * Whether the handler is required, i.e., whether the request will fail if the\n * handler is called, but the snap does not export it.\n *\n * This is primarily used for the lifecycle handlers, which are optional.\n */\n required: boolean;\n\n /**\n * Validate the given snap export. This should return a type guard for the\n * handler type.\n *\n * @param snapExport - The export to validate.\n * @returns Whether the export is valid.\n */\n validator: (snapExport: unknown) => boolean;\n};\n\nexport const SNAP_EXPORT_NAMES = Object.values(HandlerType);\n"]}
package/dist/handlers.cjs DELETED
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnNameLookupResponseStruct = exports.DomainResolutionResponseStruct = exports.AddressResolutionResponseStruct = exports.DomainResolutionStruct = exports.AddressResolutionStruct = exports.OnSettingsPageResponseStruct = exports.OnHomePageResponseStruct = exports.OnHomePageResponseWithIdStruct = exports.OnHomePageResponseWithContentStruct = exports.OnSignatureResponseStruct = exports.OnTransactionResponseStruct = exports.OnTransactionResponseWithContentStruct = exports.OnTransactionResponseWithIdStruct = exports.OnTransactionSeverityResponseStruct = exports.SNAP_EXPORTS = void 0;
4
- const snaps_sdk_1 = require("@metamask/snaps-sdk");
5
- const superstruct_1 = require("@metamask/superstruct");
6
- const handler_types_1 = require("./handler-types.cjs");
7
- exports.SNAP_EXPORTS = {
8
- [handler_types_1.HandlerType.OnRpcRequest]: {
9
- type: handler_types_1.HandlerType.OnRpcRequest,
10
- required: true,
11
- validator: (snapExport) => {
12
- return typeof snapExport === 'function';
13
- },
14
- },
15
- [handler_types_1.HandlerType.OnTransaction]: {
16
- type: handler_types_1.HandlerType.OnTransaction,
17
- required: true,
18
- validator: (snapExport) => {
19
- return typeof snapExport === 'function';
20
- },
21
- },
22
- [handler_types_1.HandlerType.OnCronjob]: {
23
- type: handler_types_1.HandlerType.OnCronjob,
24
- required: true,
25
- validator: (snapExport) => {
26
- return typeof snapExport === 'function';
27
- },
28
- },
29
- [handler_types_1.HandlerType.OnNameLookup]: {
30
- type: handler_types_1.HandlerType.OnNameLookup,
31
- required: true,
32
- validator: (snapExport) => {
33
- return typeof snapExport === 'function';
34
- },
35
- },
36
- [handler_types_1.HandlerType.OnInstall]: {
37
- type: handler_types_1.HandlerType.OnInstall,
38
- required: false,
39
- validator: (snapExport) => {
40
- return typeof snapExport === 'function';
41
- },
42
- },
43
- [handler_types_1.HandlerType.OnUpdate]: {
44
- type: handler_types_1.HandlerType.OnUpdate,
45
- required: false,
46
- validator: (snapExport) => {
47
- return typeof snapExport === 'function';
48
- },
49
- },
50
- [handler_types_1.HandlerType.OnKeyringRequest]: {
51
- type: handler_types_1.HandlerType.OnKeyringRequest,
52
- required: true,
53
- validator: (snapExport) => {
54
- return typeof snapExport === 'function';
55
- },
56
- },
57
- [handler_types_1.HandlerType.OnHomePage]: {
58
- type: handler_types_1.HandlerType.OnHomePage,
59
- required: true,
60
- validator: (snapExport) => {
61
- return typeof snapExport === 'function';
62
- },
63
- },
64
- [handler_types_1.HandlerType.OnSettingsPage]: {
65
- type: handler_types_1.HandlerType.OnSettingsPage,
66
- required: true,
67
- validator: (snapExport) => {
68
- return typeof snapExport === 'function';
69
- },
70
- },
71
- [handler_types_1.HandlerType.OnSignature]: {
72
- type: handler_types_1.HandlerType.OnSignature,
73
- required: true,
74
- validator: (snapExport) => {
75
- return typeof snapExport === 'function';
76
- },
77
- },
78
- [handler_types_1.HandlerType.OnUserInput]: {
79
- type: handler_types_1.HandlerType.OnUserInput,
80
- required: false,
81
- validator: (snapExport) => {
82
- return typeof snapExport === 'function';
83
- },
84
- },
85
- [handler_types_1.HandlerType.OnAssetsLookup]: {
86
- type: handler_types_1.HandlerType.OnAssetsLookup,
87
- required: true,
88
- validator: (snapExport) => {
89
- return typeof snapExport === 'function';
90
- },
91
- },
92
- [handler_types_1.HandlerType.OnAssetsConversion]: {
93
- type: handler_types_1.HandlerType.OnAssetsConversion,
94
- required: true,
95
- validator: (snapExport) => {
96
- return typeof snapExport === 'function';
97
- },
98
- },
99
- [handler_types_1.HandlerType.OnProtocolRequest]: {
100
- type: handler_types_1.HandlerType.OnProtocolRequest,
101
- required: true,
102
- validator: (snapExport) => {
103
- return typeof snapExport === 'function';
104
- },
105
- },
106
- };
107
- exports.OnTransactionSeverityResponseStruct = (0, superstruct_1.object)({
108
- severity: (0, superstruct_1.optional)((0, superstruct_1.literal)(snaps_sdk_1.SeverityLevel.Critical)),
109
- });
110
- exports.OnTransactionResponseWithIdStruct = (0, superstruct_1.assign)(exports.OnTransactionSeverityResponseStruct, (0, superstruct_1.object)({
111
- id: (0, superstruct_1.string)(),
112
- }));
113
- exports.OnTransactionResponseWithContentStruct = (0, superstruct_1.assign)(exports.OnTransactionSeverityResponseStruct, (0, superstruct_1.object)({
114
- content: snaps_sdk_1.ComponentOrElementStruct,
115
- }));
116
- exports.OnTransactionResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.union)([
117
- exports.OnTransactionResponseWithContentStruct,
118
- exports.OnTransactionResponseWithIdStruct,
119
- ]));
120
- exports.OnSignatureResponseStruct = exports.OnTransactionResponseStruct;
121
- exports.OnHomePageResponseWithContentStruct = (0, superstruct_1.object)({
122
- content: snaps_sdk_1.ComponentOrElementStruct,
123
- });
124
- exports.OnHomePageResponseWithIdStruct = (0, superstruct_1.object)({
125
- id: (0, superstruct_1.string)(),
126
- });
127
- exports.OnHomePageResponseStruct = (0, superstruct_1.union)([
128
- exports.OnHomePageResponseWithContentStruct,
129
- exports.OnHomePageResponseWithIdStruct,
130
- ]);
131
- exports.OnSettingsPageResponseStruct = exports.OnHomePageResponseStruct;
132
- exports.AddressResolutionStruct = (0, superstruct_1.object)({
133
- protocol: (0, superstruct_1.string)(),
134
- resolvedDomain: (0, superstruct_1.string)(),
135
- });
136
- exports.DomainResolutionStruct = (0, superstruct_1.object)({
137
- protocol: (0, superstruct_1.string)(),
138
- resolvedAddress: (0, superstruct_1.string)(),
139
- domainName: (0, superstruct_1.string)(),
140
- });
141
- exports.AddressResolutionResponseStruct = (0, superstruct_1.object)({
142
- resolvedDomains: (0, superstruct_1.size)((0, superstruct_1.array)(exports.AddressResolutionStruct), 1, Infinity),
143
- });
144
- exports.DomainResolutionResponseStruct = (0, superstruct_1.object)({
145
- resolvedAddresses: (0, superstruct_1.size)((0, superstruct_1.array)(exports.DomainResolutionStruct), 1, Infinity),
146
- });
147
- exports.OnNameLookupResponseStruct = (0, superstruct_1.nullable)((0, superstruct_1.union)([exports.AddressResolutionResponseStruct, exports.DomainResolutionResponseStruct]));
148
- //# sourceMappingURL=handlers.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"handlers.cjs","sourceRoot":"","sources":["../src/handlers.ts"],"names":[],"mappings":";;;AAgBA,mDAA8E;AAC9E,uDAU+B;AAG/B,uDAA8C;AAQjC,QAAA,YAAY,GAAG;IAC1B,CAAC,2BAAW,CAAC,YAAY,CAAC,EAAE;QAC1B,IAAI,EAAE,2BAAW,CAAC,YAAY;QAC9B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAqC,EAAE;YACpE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,2BAAW,CAAC,aAAa,CAAC,EAAE;QAC3B,IAAI,EAAE,2BAAW,CAAC,aAAa;QAC/B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAsC,EAAE;YACrE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;IACD,CAAC,2BAAW,CAAC,SAAS,CAAC,EAAE;QACvB,IAAI,EAAE,2BAAW,CAAC,SAAS;QAC3B,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAAC,UAAmB,EAAkC,EAAE;YACjE,OAAO,OAAO,UAAU,KAAK,UAAU,CAAC;QAC1C,CAAC;KACF;I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AC;CACnE,CAAC,CAAC;AAEU,QAAA,8BAA8B,GAAG,IAAA,oBAAM,EAAC;IACnD,iBAAiB,EAAE,IAAA,kBAAI,EAAC,IAAA,mBAAK,EAAC,8BAAsB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC;CACpE,CAAC,CAAC;AAEU,QAAA,0BAA0B,GAAG,IAAA,sBAAQ,EAChD,IAAA,mBAAK,EAAC,CAAC,uCAA+B,EAAE,sCAA8B,CAAC,CAAC,CACzE,CAAC","sourcesContent":["import type {\n OnAssetsConversionHandler,\n OnAssetsLookupHandler,\n OnCronjobHandler,\n OnHomePageHandler,\n OnInstallHandler,\n OnKeyringRequestHandler,\n OnNameLookupHandler,\n OnProtocolRequestHandler,\n OnRpcRequestHandler,\n OnSettingsPageHandler,\n OnSignatureHandler,\n OnTransactionHandler,\n OnUpdateHandler,\n OnUserInputHandler,\n} from '@metamask/snaps-sdk';\nimport { ComponentOrElementStruct, SeverityLevel } from '@metamask/snaps-sdk';\nimport {\n assign,\n literal,\n nullable,\n object,\n optional,\n string,\n array,\n size,\n union,\n} from '@metamask/superstruct';\n\nimport type { SnapHandler } from './handler-types';\nimport { HandlerType } from './handler-types';\n\nexport type SnapRpcHookArgs = {\n origin: string;\n handler: HandlerType;\n request: Record<string, unknown>;\n};\n\nexport const SNAP_EXPORTS = {\n [HandlerType.OnRpcRequest]: {\n type: HandlerType.OnRpcRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnRpcRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnTransaction]: {\n type: HandlerType.OnTransaction,\n required: true,\n validator: (snapExport: unknown): snapExport is OnTransactionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnCronjob]: {\n type: HandlerType.OnCronjob,\n required: true,\n validator: (snapExport: unknown): snapExport is OnCronjobHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnNameLookup]: {\n type: HandlerType.OnNameLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnNameLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnInstall]: {\n type: HandlerType.OnInstall,\n required: false,\n validator: (snapExport: unknown): snapExport is OnInstallHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUpdate]: {\n type: HandlerType.OnUpdate,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUpdateHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnKeyringRequest]: {\n type: HandlerType.OnKeyringRequest,\n required: true,\n validator: (snapExport: unknown): snapExport is OnKeyringRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnHomePage]: {\n type: HandlerType.OnHomePage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnHomePageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSettingsPage]: {\n type: HandlerType.OnSettingsPage,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSettingsPageHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnSignature]: {\n type: HandlerType.OnSignature,\n required: true,\n validator: (snapExport: unknown): snapExport is OnSignatureHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnUserInput]: {\n type: HandlerType.OnUserInput,\n required: false,\n validator: (snapExport: unknown): snapExport is OnUserInputHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsLookup]: {\n type: HandlerType.OnAssetsLookup,\n required: true,\n validator: (snapExport: unknown): snapExport is OnAssetsLookupHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnAssetsConversion]: {\n type: HandlerType.OnAssetsConversion,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnAssetsConversionHandler => {\n return typeof snapExport === 'function';\n },\n },\n [HandlerType.OnProtocolRequest]: {\n type: HandlerType.OnProtocolRequest,\n required: true,\n validator: (\n snapExport: unknown,\n ): snapExport is OnProtocolRequestHandler => {\n return typeof snapExport === 'function';\n },\n },\n} as const;\n\nexport const OnTransactionSeverityResponseStruct = object({\n severity: optional(literal(SeverityLevel.Critical)),\n});\n\nexport const OnTransactionResponseWithIdStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n id: string(),\n }),\n);\n\nexport const OnTransactionResponseWithContentStruct = assign(\n OnTransactionSeverityResponseStruct,\n object({\n content: ComponentOrElementStruct,\n }),\n);\n\nexport const OnTransactionResponseStruct = nullable(\n union([\n OnTransactionResponseWithContentStruct,\n OnTransactionResponseWithIdStruct,\n ]),\n);\n\nexport const OnSignatureResponseStruct = OnTransactionResponseStruct;\n\nexport const OnHomePageResponseWithContentStruct = object({\n content: ComponentOrElementStruct,\n});\n\nexport const OnHomePageResponseWithIdStruct = object({\n id: string(),\n});\n\nexport const OnHomePageResponseStruct = union([\n OnHomePageResponseWithContentStruct,\n OnHomePageResponseWithIdStruct,\n]);\n\nexport const OnSettingsPageResponseStruct = OnHomePageResponseStruct;\n\nexport const AddressResolutionStruct = object({\n protocol: string(),\n resolvedDomain: string(),\n});\n\nexport const DomainResolutionStruct = object({\n protocol: string(),\n resolvedAddress: string(),\n domainName: string(),\n});\n\nexport const AddressResolutionResponseStruct = object({\n resolvedDomains: size(array(AddressResolutionStruct), 1, Infinity),\n});\n\nexport const DomainResolutionResponseStruct = object({\n resolvedAddresses: size(array(DomainResolutionStruct), 1, Infinity),\n});\n\nexport const OnNameLookupResponseStruct = nullable(\n union([AddressResolutionResponseStruct, DomainResolutionResponseStruct]),\n);\n\n/**\n * Utility type for getting the handler function type from a handler type.\n */\nexport type HandlerFunction<Type extends SnapHandler> =\n Type['validator'] extends (snapExport: unknown) => snapExport is infer Handler\n ? Handler\n : never;\n\n/**\n * All the function-based handlers that a snap can implement.\n */\nexport type SnapFunctionExports = {\n [Key in keyof typeof SNAP_EXPORTS]?: HandlerFunction<\n (typeof SNAP_EXPORTS)[Key]\n >;\n};\n\n/**\n * All handlers that a snap can implement.\n */\nexport type SnapExports = SnapFunctionExports;\n"]}