@metamask/snaps-sdk 0.0.0 → 1.0.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 (237) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/dist/cjs/errors.js +157 -0
  3. package/dist/cjs/errors.js.map +1 -0
  4. package/dist/cjs/index.js +44 -2
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/internals/errors.js +59 -0
  7. package/dist/cjs/internals/errors.js.map +1 -0
  8. package/dist/cjs/internals/helpers.js +6 -0
  9. package/dist/cjs/internals/helpers.js.map +1 -0
  10. package/dist/cjs/internals/index.js +21 -0
  11. package/dist/cjs/internals/index.js.map +1 -0
  12. package/dist/cjs/types/caip.js +10 -0
  13. package/dist/cjs/types/caip.js.map +1 -0
  14. package/dist/cjs/types/global.js +6 -0
  15. package/dist/cjs/types/global.js.map +1 -0
  16. package/dist/cjs/types/handlers/cronjob.js +6 -0
  17. package/dist/cjs/types/handlers/cronjob.js.map +1 -0
  18. package/dist/cjs/types/handlers/home-page.js +6 -0
  19. package/dist/cjs/types/handlers/home-page.js.map +1 -0
  20. package/dist/cjs/types/handlers/index.js +26 -0
  21. package/dist/cjs/types/handlers/index.js.map +1 -0
  22. package/dist/cjs/types/handlers/keyring.js +6 -0
  23. package/dist/cjs/types/handlers/keyring.js.map +1 -0
  24. package/dist/cjs/types/handlers/lifecycle.js +6 -0
  25. package/dist/cjs/types/handlers/lifecycle.js.map +1 -0
  26. package/dist/cjs/types/handlers/name-lookup.js +6 -0
  27. package/dist/cjs/types/handlers/name-lookup.js.map +1 -0
  28. package/dist/cjs/types/handlers/rpc-request.js +6 -0
  29. package/dist/cjs/types/handlers/rpc-request.js.map +1 -0
  30. package/dist/cjs/types/handlers/transaction.js +16 -0
  31. package/dist/cjs/types/handlers/transaction.js.map +1 -0
  32. package/dist/cjs/types/index.js +28 -0
  33. package/dist/cjs/types/index.js.map +1 -0
  34. package/dist/cjs/types/methods/dialog.js +18 -0
  35. package/dist/cjs/types/methods/dialog.js.map +1 -0
  36. package/dist/cjs/types/methods/get-bip32-entropy.js +6 -0
  37. package/dist/cjs/types/methods/get-bip32-entropy.js.map +1 -0
  38. package/dist/cjs/types/methods/get-bip32-public-key.js +6 -0
  39. package/dist/cjs/types/methods/get-bip32-public-key.js.map +1 -0
  40. package/dist/cjs/types/methods/get-bip44-entropy.js +6 -0
  41. package/dist/cjs/types/methods/get-bip44-entropy.js.map +1 -0
  42. package/dist/cjs/types/methods/get-entropy.js +6 -0
  43. package/dist/cjs/types/methods/get-entropy.js.map +1 -0
  44. package/dist/cjs/types/methods/get-file.js +18 -0
  45. package/dist/cjs/types/methods/get-file.js.map +1 -0
  46. package/dist/cjs/types/methods/get-locale.js +10 -0
  47. package/dist/cjs/types/methods/get-locale.js.map +1 -0
  48. package/dist/cjs/types/methods/get-snaps.js +6 -0
  49. package/dist/cjs/types/methods/get-snaps.js.map +1 -0
  50. package/dist/cjs/types/methods/index.js +34 -0
  51. package/dist/cjs/types/methods/index.js.map +1 -0
  52. package/dist/cjs/types/methods/invoke-keyring.js +6 -0
  53. package/dist/cjs/types/methods/invoke-keyring.js.map +1 -0
  54. package/dist/cjs/types/methods/invoke-snap.js +6 -0
  55. package/dist/cjs/types/methods/invoke-snap.js.map +1 -0
  56. package/dist/cjs/types/methods/manage-accounts.js +6 -0
  57. package/dist/cjs/types/methods/manage-accounts.js.map +1 -0
  58. package/dist/cjs/types/methods/manage-state.js +18 -0
  59. package/dist/cjs/types/methods/manage-state.js.map +1 -0
  60. package/dist/cjs/types/methods/methods.js +6 -0
  61. package/dist/cjs/types/methods/methods.js.map +1 -0
  62. package/dist/cjs/types/methods/notify.js +17 -0
  63. package/dist/cjs/types/methods/notify.js.map +1 -0
  64. package/dist/cjs/types/methods/request-snaps.js +6 -0
  65. package/dist/cjs/types/methods/request-snaps.js.map +1 -0
  66. package/dist/cjs/types/permissions.js +6 -0
  67. package/dist/cjs/types/permissions.js.map +1 -0
  68. package/dist/cjs/types/provider.js +6 -0
  69. package/dist/cjs/types/provider.js.map +1 -0
  70. package/dist/cjs/types/snap.js +6 -0
  71. package/dist/cjs/types/snap.js.map +1 -0
  72. package/dist/cjs/ui/builder.js +44 -0
  73. package/dist/cjs/ui/builder.js.map +1 -0
  74. package/dist/cjs/ui/component.js +29 -0
  75. package/dist/cjs/ui/component.js.map +1 -0
  76. package/dist/cjs/ui/components/copyable.js +32 -0
  77. package/dist/cjs/ui/components/copyable.js.map +1 -0
  78. package/dist/cjs/ui/components/divider.js +27 -0
  79. package/dist/cjs/ui/components/divider.js.map +1 -0
  80. package/dist/cjs/ui/components/heading.js +30 -0
  81. package/dist/cjs/ui/components/heading.js.map +1 -0
  82. package/dist/cjs/ui/components/image.js +47 -0
  83. package/dist/cjs/ui/components/image.js.map +1 -0
  84. package/dist/cjs/ui/components/index.js +49 -0
  85. package/dist/cjs/ui/components/index.js.map +1 -0
  86. package/dist/cjs/ui/components/panel.js +55 -0
  87. package/dist/cjs/ui/components/panel.js.map +1 -0
  88. package/dist/cjs/ui/components/spinner.js +27 -0
  89. package/dist/cjs/ui/components/spinner.js.map +1 -0
  90. package/dist/cjs/ui/components/text.js +32 -0
  91. package/dist/cjs/ui/components/text.js.map +1 -0
  92. package/dist/cjs/ui/index.js +28 -0
  93. package/dist/cjs/ui/index.js.map +1 -0
  94. package/dist/cjs/ui/nodes.js +41 -0
  95. package/dist/cjs/ui/nodes.js.map +1 -0
  96. package/dist/esm/errors.js +150 -0
  97. package/dist/esm/errors.js.map +1 -0
  98. package/dist/esm/index.js +5 -2
  99. package/dist/esm/index.js.map +1 -1
  100. package/dist/esm/internals/errors.js +58 -0
  101. package/dist/esm/internals/errors.js.map +1 -0
  102. package/dist/esm/internals/helpers.js +3 -0
  103. package/dist/esm/internals/helpers.js.map +1 -0
  104. package/dist/esm/internals/index.js +4 -0
  105. package/dist/esm/internals/index.js.map +1 -0
  106. package/dist/esm/types/caip.js +7 -0
  107. package/dist/esm/types/caip.js.map +1 -0
  108. package/dist/esm/types/global.js +3 -0
  109. package/dist/esm/types/global.js.map +1 -0
  110. package/dist/esm/types/handlers/cronjob.js +3 -0
  111. package/dist/esm/types/handlers/cronjob.js.map +1 -0
  112. package/dist/esm/types/handlers/home-page.js +3 -0
  113. package/dist/esm/types/handlers/home-page.js.map +1 -0
  114. package/dist/esm/types/handlers/index.js +9 -0
  115. package/dist/esm/types/handlers/index.js.map +1 -0
  116. package/dist/esm/types/handlers/keyring.js +3 -0
  117. package/dist/esm/types/handlers/keyring.js.map +1 -0
  118. package/dist/esm/types/handlers/lifecycle.js +3 -0
  119. package/dist/esm/types/handlers/lifecycle.js.map +1 -0
  120. package/dist/esm/types/handlers/name-lookup.js +3 -0
  121. package/dist/esm/types/handlers/name-lookup.js.map +1 -0
  122. package/dist/esm/types/handlers/rpc-request.js +3 -0
  123. package/dist/esm/types/handlers/rpc-request.js.map +1 -0
  124. package/dist/esm/types/handlers/transaction.js +6 -0
  125. package/dist/esm/types/handlers/transaction.js.map +1 -0
  126. package/dist/esm/types/index.js +11 -0
  127. package/dist/esm/types/index.js.map +1 -0
  128. package/dist/esm/types/methods/dialog.js +8 -0
  129. package/dist/esm/types/methods/dialog.js.map +1 -0
  130. package/dist/esm/types/methods/get-bip32-entropy.js +3 -0
  131. package/dist/esm/types/methods/get-bip32-entropy.js.map +1 -0
  132. package/dist/esm/types/methods/get-bip32-public-key.js +3 -0
  133. package/dist/esm/types/methods/get-bip32-public-key.js.map +1 -0
  134. package/dist/esm/types/methods/get-bip44-entropy.js +3 -0
  135. package/dist/esm/types/methods/get-bip44-entropy.js.map +1 -0
  136. package/dist/esm/types/methods/get-entropy.js +3 -0
  137. package/dist/esm/types/methods/get-entropy.js.map +1 -0
  138. package/dist/esm/types/methods/get-file.js +8 -0
  139. package/dist/esm/types/methods/get-file.js.map +1 -0
  140. package/dist/esm/types/methods/get-locale.js +7 -0
  141. package/dist/esm/types/methods/get-locale.js.map +1 -0
  142. package/dist/esm/types/methods/get-snaps.js +3 -0
  143. package/dist/esm/types/methods/get-snaps.js.map +1 -0
  144. package/dist/esm/types/methods/index.js +17 -0
  145. package/dist/esm/types/methods/index.js.map +1 -0
  146. package/dist/esm/types/methods/invoke-keyring.js +3 -0
  147. package/dist/esm/types/methods/invoke-keyring.js.map +1 -0
  148. package/dist/esm/types/methods/invoke-snap.js +3 -0
  149. package/dist/esm/types/methods/invoke-snap.js.map +1 -0
  150. package/dist/esm/types/methods/manage-accounts.js +3 -0
  151. package/dist/esm/types/methods/manage-accounts.js.map +1 -0
  152. package/dist/esm/types/methods/manage-state.js +8 -0
  153. package/dist/esm/types/methods/manage-state.js.map +1 -0
  154. package/dist/esm/types/methods/methods.js +3 -0
  155. package/dist/esm/types/methods/methods.js.map +1 -0
  156. package/dist/esm/types/methods/notify.js +7 -0
  157. package/dist/esm/types/methods/notify.js.map +1 -0
  158. package/dist/esm/types/methods/request-snaps.js +3 -0
  159. package/dist/esm/types/methods/request-snaps.js.map +1 -0
  160. package/dist/esm/types/permissions.js +3 -0
  161. package/dist/esm/types/permissions.js.map +1 -0
  162. package/dist/esm/types/provider.js +3 -0
  163. package/dist/esm/types/provider.js.map +1 -0
  164. package/dist/esm/types/snap.js +3 -0
  165. package/dist/esm/types/snap.js.map +1 -0
  166. package/dist/esm/ui/builder.js +50 -0
  167. package/dist/esm/ui/builder.js.map +1 -0
  168. package/dist/esm/ui/component.js +23 -0
  169. package/dist/esm/ui/component.js.map +1 -0
  170. package/dist/esm/ui/components/copyable.js +27 -0
  171. package/dist/esm/ui/components/copyable.js.map +1 -0
  172. package/dist/esm/ui/components/divider.js +15 -0
  173. package/dist/esm/ui/components/divider.js.map +1 -0
  174. package/dist/esm/ui/components/heading.js +22 -0
  175. package/dist/esm/ui/components/heading.js.map +1 -0
  176. package/dist/esm/ui/components/image.js +37 -0
  177. package/dist/esm/ui/components/image.js.map +1 -0
  178. package/dist/esm/ui/components/index.js +9 -0
  179. package/dist/esm/ui/components/index.js.map +1 -0
  180. package/dist/esm/ui/components/panel.js +56 -0
  181. package/dist/esm/ui/components/panel.js.map +1 -0
  182. package/dist/esm/ui/components/spinner.js +15 -0
  183. package/dist/esm/ui/components/spinner.js.map +1 -0
  184. package/dist/esm/ui/components/text.js +29 -0
  185. package/dist/esm/ui/components/text.js.map +1 -0
  186. package/dist/esm/ui/index.js +5 -0
  187. package/dist/esm/ui/index.js.map +1 -0
  188. package/dist/esm/ui/nodes.js +24 -0
  189. package/dist/esm/ui/nodes.js.map +1 -0
  190. package/dist/types/errors.d.ts +88 -0
  191. package/dist/types/index.d.ts +6 -0
  192. package/dist/types/internals/errors.d.ts +41 -0
  193. package/dist/types/internals/helpers.d.ts +36 -0
  194. package/dist/types/internals/index.d.ts +2 -0
  195. package/dist/types/types/caip.d.ts +12 -0
  196. package/dist/types/types/global.d.ts +8 -0
  197. package/dist/types/types/handlers/cronjob.d.ts +14 -0
  198. package/dist/types/types/handlers/home-page.d.ts +19 -0
  199. package/dist/types/types/handlers/index.d.ts +7 -0
  200. package/dist/types/types/handlers/keyring.d.ts +20 -0
  201. package/dist/types/types/handlers/lifecycle.d.ts +41 -0
  202. package/dist/types/types/handlers/name-lookup.d.ts +59 -0
  203. package/dist/types/types/handlers/rpc-request.d.ts +21 -0
  204. package/dist/types/types/handlers/transaction.d.ts +110 -0
  205. package/dist/types/types/index.d.ts +7 -0
  206. package/dist/types/types/methods/dialog.d.ts +67 -0
  207. package/dist/types/types/methods/get-bip32-entropy.d.ts +15 -0
  208. package/dist/types/types/methods/get-bip32-public-key.d.ts +19 -0
  209. package/dist/types/types/methods/get-bip44-entropy.d.ts +14 -0
  210. package/dist/types/types/methods/get-entropy.d.ts +16 -0
  211. package/dist/types/types/methods/get-file.d.ts +23 -0
  212. package/dist/types/types/methods/get-locale.d.ts +12 -0
  213. package/dist/types/types/methods/get-snaps.d.ts +16 -0
  214. package/dist/types/types/methods/index.d.ts +15 -0
  215. package/dist/types/types/methods/invoke-keyring.d.ts +14 -0
  216. package/dist/types/types/methods/invoke-snap.d.ts +16 -0
  217. package/dist/types/types/methods/manage-accounts.d.ts +18 -0
  218. package/dist/types/types/methods/manage-state.d.ts +69 -0
  219. package/dist/types/types/methods/methods.d.ts +62 -0
  220. package/dist/types/types/methods/notify.d.ts +27 -0
  221. package/dist/types/types/methods/request-snaps.d.ts +18 -0
  222. package/dist/types/types/permissions.d.ts +46 -0
  223. package/dist/types/types/provider.d.ts +14 -0
  224. package/dist/types/types/snap.d.ts +12 -0
  225. package/dist/types/ui/builder.d.ts +42 -0
  226. package/dist/types/ui/component.d.ts +17 -0
  227. package/dist/types/ui/components/copyable.d.ts +49 -0
  228. package/dist/types/ui/components/divider.d.ts +21 -0
  229. package/dist/types/ui/components/heading.d.ts +36 -0
  230. package/dist/types/ui/components/image.d.ts +42 -0
  231. package/dist/types/ui/components/index.d.ts +9 -0
  232. package/dist/types/ui/components/panel.d.ts +153 -0
  233. package/dist/types/ui/components/spinner.d.ts +22 -0
  234. package/dist/types/ui/components/text.d.ts +46 -0
  235. package/dist/types/ui/index.d.ts +3 -0
  236. package/dist/types/ui/nodes.d.ts +51 -0
  237. package/package.json +10 -2
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ TextStruct: function() {
13
+ return TextStruct;
14
+ },
15
+ text: function() {
16
+ return text;
17
+ }
18
+ });
19
+ const _superstruct = require("superstruct");
20
+ const _builder = require("../builder");
21
+ const _nodes = require("../nodes");
22
+ const TextStruct = (0, _superstruct.assign)(_nodes.LiteralStruct, (0, _superstruct.object)({
23
+ type: (0, _superstruct.literal)(_nodes.NodeType.Text),
24
+ value: (0, _superstruct.string)(),
25
+ markdown: (0, _superstruct.optional)((0, _superstruct.boolean)())
26
+ }));
27
+ const text = (0, _builder.createBuilder)(_nodes.NodeType.Text, TextStruct, [
28
+ 'value',
29
+ 'markdown'
30
+ ]);
31
+
32
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/ui/components/text.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport {\n assign,\n boolean,\n literal,\n object,\n optional,\n string,\n} from 'superstruct';\n\nimport { createBuilder } from '../builder';\nimport { LiteralStruct, NodeType } from '../nodes';\n\nexport const TextStruct = assign(\n LiteralStruct,\n object({\n type: literal(NodeType.Text),\n value: string(),\n markdown: optional(boolean()),\n }),\n);\n\n/**\n * A text node, that renders the text as one or more paragraphs.\n *\n * @property type - The type of the node, must be the string 'text'.\n * @property value - The text content of the node, either as plain text, or as a\n * markdown string.\n * @property markdown - A flag to enable/disable markdown, if nothing is specified\n * markdown will be enabled.\n */\nexport type Text = Infer<typeof TextStruct>;\n\n/**\n * Create a {@link Text} node.\n *\n * @param args - The node arguments. This can be either a string\n * and a boolean, or an object with a `value` property\n * and an optional `markdown` property.\n * @param args.value - The text content of the node.\n * @param args.markdown - An optional flag to enable or disable markdown. This\n * is enabled by default.\n * @returns The text node as object.\n * @example\n * const node = text({ value: 'Hello, world!' });\n * const node = text('Hello, world!');\n * const node = text({ value: 'Hello, world!', markdown: false });\n * const node = text('Hello, world!', false);\n */\nexport const text = createBuilder(NodeType.Text, TextStruct, [\n 'value',\n 'markdown',\n]);\n"],"names":["TextStruct","text","assign","LiteralStruct","object","type","literal","NodeType","Text","value","string","markdown","optional","boolean","createBuilder"],"mappings":";;;;;;;;;;;IAaaA,UAAU;eAAVA;;IAoCAC,IAAI;eAAJA;;;6BAzCN;yBAEuB;uBACU;AAEjC,MAAMD,aAAaE,IAAAA,mBAAM,EAC9BC,oBAAa,EACbC,IAAAA,mBAAM,EAAC;IACLC,MAAMC,IAAAA,oBAAO,EAACC,eAAQ,CAACC,IAAI;IAC3BC,OAAOC,IAAAA,mBAAM;IACbC,UAAUC,IAAAA,qBAAQ,EAACC,IAAAA,oBAAO;AAC5B;AA8BK,MAAMZ,OAAOa,IAAAA,sBAAa,EAACP,eAAQ,CAACC,IAAI,EAAER,YAAY;IAC3D;IACA;CACD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "NodeType", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _nodes.NodeType;
9
+ }
10
+ });
11
+ _export_star(require("./components"), exports);
12
+ _export_star(require("./component"), exports);
13
+ const _nodes = require("./nodes");
14
+ function _export_star(from, to) {
15
+ Object.keys(from).forEach(function(k) {
16
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
17
+ Object.defineProperty(to, k, {
18
+ enumerable: true,
19
+ get: function() {
20
+ return from[k];
21
+ }
22
+ });
23
+ }
24
+ });
25
+ return from;
26
+ }
27
+
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/index.ts"],"sourcesContent":["export * from './components';\nexport * from './component';\nexport { NodeType } from './nodes';\n"],"names":["NodeType"],"mappings":";;;;+BAESA;;;eAAAA,eAAQ;;;qBAFH;qBACA;uBACW"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ NodeType: function() {
13
+ return NodeType;
14
+ },
15
+ NodeStruct: function() {
16
+ return NodeStruct;
17
+ },
18
+ LiteralStruct: function() {
19
+ return LiteralStruct;
20
+ }
21
+ });
22
+ const _superstruct = require("superstruct");
23
+ var NodeType;
24
+ (function(NodeType) {
25
+ NodeType["Copyable"] = 'copyable';
26
+ NodeType["Divider"] = 'divider';
27
+ NodeType["Heading"] = 'heading';
28
+ NodeType["Panel"] = 'panel';
29
+ NodeType["Spinner"] = 'spinner';
30
+ NodeType[// eslint-disable-next-line @typescript-eslint/no-shadow
31
+ "Text"] = 'text';
32
+ NodeType["Image"] = 'image';
33
+ })(NodeType || (NodeType = {}));
34
+ const NodeStruct = (0, _superstruct.object)({
35
+ type: (0, _superstruct.string)()
36
+ });
37
+ const LiteralStruct = (0, _superstruct.assign)(NodeStruct, (0, _superstruct.object)({
38
+ value: (0, _superstruct.unknown)()
39
+ }));
40
+
41
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/ui/nodes.ts"],"sourcesContent":["import type { Infer } from 'superstruct';\nimport { assign, object, string, unknown } from 'superstruct';\n\n/**\n * The supported node types. This is based on SIP-7.\n *\n * @see https://metamask.github.io/SIPs/SIPS/sip-7\n */\nexport enum NodeType {\n Copyable = 'copyable',\n Divider = 'divider',\n Heading = 'heading',\n Panel = 'panel',\n Spinner = 'spinner',\n // eslint-disable-next-line @typescript-eslint/no-shadow\n Text = 'text',\n Image = 'image',\n}\n\n/**\n * @internal\n */\nexport const NodeStruct = object({\n type: string(),\n});\n\n/**\n * The base node type. All nodes extend this type.\n *\n * @property type - The type of the node. See {@link NodeType} for the supported\n * node types.\n * @internal\n */\nexport type Node = Infer<typeof NodeStruct>;\n\n/**\n * @internal\n */\nexport const LiteralStruct = assign(\n NodeStruct,\n object({\n value: unknown(),\n }),\n);\n\n/**\n * A node with a value. This is used for nodes that render a value, such as\n * {@link Text}.\n *\n * @property type - The type of the node.\n * @property value - The value of the node. The type of the value depends on the\n * node type.\n * @internal\n */\nexport type Literal = Infer<typeof LiteralStruct>;\n"],"names":["NodeStruct","LiteralStruct","NodeType","Copyable","Divider","Heading","Panel","Spinner","Text","Image","object","type","string","assign","value","unknown"],"mappings":";;;;;;;;;;;;;;IAsBaA,UAAU;eAAVA;;IAgBAC,aAAa;eAAbA;;;6BArCmC;IAOzC;UAAKC,QAAQ;IAARA,SACVC,cAAW;IADDD,SAEVE,aAAU;IAFAF,SAGVG,aAAU;IAHAH,SAIVI,WAAQ;IAJEJ,SAKVK,aAAU;IALAL,SAMV,wDAAwD;IACxDM,UAAO;IAPGN,SAQVO,WAAQ;GAREP,aAAAA;AAcL,MAAMF,aAAaU,IAAAA,mBAAM,EAAC;IAC/BC,MAAMC,IAAAA,mBAAM;AACd;AAcO,MAAMX,gBAAgBY,IAAAA,mBAAM,EACjCb,YACAU,IAAAA,mBAAM,EAAC;IACLI,OAAOC,IAAAA,oBAAO;AAChB"}
@@ -0,0 +1,150 @@
1
+ function _check_private_redeclaration(obj, privateCollection) {
2
+ if (privateCollection.has(obj)) {
3
+ throw new TypeError("Cannot initialize the same private elements twice on an object");
4
+ }
5
+ }
6
+ function _class_apply_descriptor_get(receiver, descriptor) {
7
+ if (descriptor.get) {
8
+ return descriptor.get.call(receiver);
9
+ }
10
+ return descriptor.value;
11
+ }
12
+ function _class_apply_descriptor_set(receiver, descriptor, value) {
13
+ if (descriptor.set) {
14
+ descriptor.set.call(receiver, value);
15
+ } else {
16
+ if (!descriptor.writable) {
17
+ throw new TypeError("attempted to set read only private field");
18
+ }
19
+ descriptor.value = value;
20
+ }
21
+ }
22
+ function _class_extract_field_descriptor(receiver, privateMap, action) {
23
+ if (!privateMap.has(receiver)) {
24
+ throw new TypeError("attempted to " + action + " private field on non-instance");
25
+ }
26
+ return privateMap.get(receiver);
27
+ }
28
+ function _class_private_field_get(receiver, privateMap) {
29
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
30
+ return _class_apply_descriptor_get(receiver, descriptor);
31
+ }
32
+ function _class_private_field_init(obj, privateMap, value) {
33
+ _check_private_redeclaration(obj, privateMap);
34
+ privateMap.set(obj, value);
35
+ }
36
+ function _class_private_field_set(receiver, privateMap, value) {
37
+ var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
38
+ _class_apply_descriptor_set(receiver, descriptor, value);
39
+ return value;
40
+ }
41
+ import { getErrorCode, getErrorData, getErrorMessage, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from './internals';
42
+ var _code = /*#__PURE__*/ new WeakMap(), _message = /*#__PURE__*/ new WeakMap(), _data = /*#__PURE__*/ new WeakMap(), _stack = /*#__PURE__*/ new WeakMap();
43
+ /**
44
+ * A generic error which can be thrown by a Snap, without it causing the Snap to
45
+ * crash.
46
+ */ export class SnapError extends Error {
47
+ /**
48
+ * The error name.
49
+ *
50
+ * @returns The error name.
51
+ */ get name() {
52
+ return 'SnapError';
53
+ }
54
+ /**
55
+ * The error code.
56
+ *
57
+ * @returns The error code.
58
+ */ get code() {
59
+ return _class_private_field_get(this, _code);
60
+ }
61
+ /**
62
+ * The error message.
63
+ *
64
+ * @returns The error message.
65
+ */ // This line is covered, but Jest doesn't pick it up for some reason.
66
+ /* istanbul ignore next */ get message() {
67
+ return _class_private_field_get(this, _message);
68
+ }
69
+ /**
70
+ * Additional data for the error.
71
+ *
72
+ * @returns Additional data for the error.
73
+ */ get data() {
74
+ return _class_private_field_get(this, _data);
75
+ }
76
+ /**
77
+ * The error stack.
78
+ *
79
+ * @returns The error stack.
80
+ */ // This line is covered, but Jest doesn't pick it up for some reason.
81
+ /* istanbul ignore next */ get stack() {
82
+ return _class_private_field_get(this, _stack);
83
+ }
84
+ /**
85
+ * Convert the error to a JSON object.
86
+ *
87
+ * @returns The JSON object.
88
+ */ toJSON() {
89
+ return {
90
+ code: SNAP_ERROR_CODE,
91
+ message: SNAP_ERROR_MESSAGE,
92
+ data: {
93
+ cause: {
94
+ code: this.code,
95
+ message: this.message,
96
+ stack: this.stack,
97
+ data: this.data
98
+ }
99
+ }
100
+ };
101
+ }
102
+ /**
103
+ * Serialize the error to a JSON object. This is called by
104
+ * `@metamask/rpc-errors` when serializing the error.
105
+ *
106
+ * @returns The JSON object.
107
+ */ serialize() {
108
+ return this.toJSON();
109
+ }
110
+ /**
111
+ * Create a new `SnapError`.
112
+ *
113
+ * @param error - The error to create the `SnapError` from. If this is a
114
+ * `string`, it will be used as the error message. If this is an `Error`, its
115
+ * `message` property will be used as the error message. If this is a
116
+ * `JsonRpcError`, its `message` property will be used as the error message
117
+ * and its `code` property will be used as the error code. Otherwise, the
118
+ * error will be converted to a string and used as the error message.
119
+ * @param data - Additional data to include in the error. This will be merged
120
+ * with the error data, if any.
121
+ */ constructor(error, data = {}){
122
+ const message = getErrorMessage(error);
123
+ super(message);
124
+ _class_private_field_init(this, _code, {
125
+ writable: true,
126
+ value: void 0
127
+ });
128
+ _class_private_field_init(this, _message, {
129
+ writable: true,
130
+ value: void 0
131
+ });
132
+ _class_private_field_init(this, _data, {
133
+ writable: true,
134
+ value: void 0
135
+ });
136
+ _class_private_field_init(this, _stack, {
137
+ writable: true,
138
+ value: void 0
139
+ });
140
+ _class_private_field_set(this, _message, message);
141
+ _class_private_field_set(this, _code, getErrorCode(error));
142
+ _class_private_field_set(this, _data, {
143
+ ...getErrorData(error),
144
+ ...data
145
+ });
146
+ _class_private_field_set(this, _stack, super.stack);
147
+ }
148
+ }
149
+
150
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/errors.ts"],"sourcesContent":["import type { Json, JsonRpcError } from '@metamask/utils';\n\nimport {\n getErrorCode,\n getErrorData,\n getErrorMessage,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n/**\n * A generic error which can be thrown by a Snap, without it causing the Snap to\n * crash.\n */\nexport class SnapError extends Error {\n readonly #code: number;\n\n readonly #message: string;\n\n readonly #data: Record<string, Json>;\n\n readonly #stack?: string;\n\n /**\n * Create a new `SnapError`.\n *\n * @param error - The error to create the `SnapError` from. If this is a\n * `string`, it will be used as the error message. If this is an `Error`, its\n * `message` property will be used as the error message. If this is a\n * `JsonRpcError`, its `message` property will be used as the error message\n * and its `code` property will be used as the error code. Otherwise, the\n * error will be converted to a string and used as the error message.\n * @param data - Additional data to include in the error. This will be merged\n * with the error data, if any.\n */\n constructor(\n error: string | Error | JsonRpcError,\n data: Record<string, Json> = {},\n ) {\n const message = getErrorMessage(error);\n super(message);\n\n this.#message = message;\n this.#code = getErrorCode(error);\n this.#data = { ...getErrorData(error), ...data };\n this.#stack = super.stack;\n }\n\n /**\n * The error name.\n *\n * @returns The error name.\n */\n get name() {\n return 'SnapError';\n }\n\n /**\n * The error code.\n *\n * @returns The error code.\n */\n get code() {\n return this.#code;\n }\n\n /**\n * The error message.\n *\n * @returns The error message.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get message() {\n return this.#message;\n }\n\n /**\n * Additional data for the error.\n *\n * @returns Additional data for the error.\n */\n get data() {\n return this.#data;\n }\n\n /**\n * The error stack.\n *\n * @returns The error stack.\n */\n // This line is covered, but Jest doesn't pick it up for some reason.\n /* istanbul ignore next */\n get stack() {\n return this.#stack;\n }\n\n /**\n * Convert the error to a JSON object.\n *\n * @returns The JSON object.\n */\n toJSON(): SerializedSnapError {\n return {\n code: SNAP_ERROR_CODE,\n message: SNAP_ERROR_MESSAGE,\n data: {\n cause: {\n code: this.code,\n message: this.message,\n stack: this.stack,\n data: this.data,\n },\n },\n };\n }\n\n /**\n * Serialize the error to a JSON object. This is called by\n * `@metamask/rpc-errors` when serializing the error.\n *\n * @returns The JSON object.\n */\n serialize() {\n return this.toJSON();\n }\n}\n\n/**\n * A serialized {@link SnapError}. It's JSON-serializable, so it can be sent\n * over the RPC. The original error is wrapped in the `cause` property.\n *\n * @property code - The error code. This is always `-31002`.\n * @property message - The error message. This is always `'Snap Error'`.\n * @property data - The error data.\n * @property data.cause - The cause of the error.\n * @property data.cause.code - The error code.\n * @property data.cause.message - The error message.\n * @property data.cause.stack - The error stack.\n * @property data.cause.data - Additional data for the error.\n * @see SnapError\n */\nexport type SerializedSnapError = {\n code: typeof SNAP_ERROR_CODE;\n message: typeof SNAP_ERROR_MESSAGE;\n data: {\n cause: JsonRpcError & {\n data: Record<string, Json>;\n };\n };\n};\n"],"names":["getErrorCode","getErrorData","getErrorMessage","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","SnapError","Error","name","code","message","data","stack","toJSON","cause","serialize","constructor","error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SACEA,YAAY,EACZC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,QACb,cAAc;IAOV,qCAEA,wCAEA,qCAEA;AAXX;;;CAGC,GACD,OAAO,MAAMC,kBAAkBC;IAkC7B;;;;GAIC,GACD,IAAIC,OAAO;QACT,OAAO;IACT;IAEA;;;;GAIC,GACD,IAAIC,OAAO;QACT,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,qEAAqE;IACrE,wBAAwB,GACxB,IAAIC,UAAU;QACZ,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,IAAIC,OAAO;QACT,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACD,qEAAqE;IACrE,wBAAwB,GACxB,IAAIC,QAAQ;QACV,gCAAO,IAAI,EAAEA;IACf;IAEA;;;;GAIC,GACDC,SAA8B;QAC5B,OAAO;YACLJ,MAAML;YACNM,SAASL;YACTM,MAAM;gBACJG,OAAO;oBACLL,MAAM,IAAI,CAACA,IAAI;oBACfC,SAAS,IAAI,CAACA,OAAO;oBACrBE,OAAO,IAAI,CAACA,KAAK;oBACjBD,MAAM,IAAI,CAACA,IAAI;gBACjB;YACF;QACF;IACF;IAEA;;;;;GAKC,GACDI,YAAY;QACV,OAAO,IAAI,CAACF,MAAM;IACpB;IAtGA;;;;;;;;;;;GAWC,GACDG,YACEC,KAAoC,EACpCN,OAA6B,CAAC,CAAC,CAC/B;QACA,MAAMD,UAAUP,gBAAgBc;QAChC,KAAK,CAACP;QAzBR,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;QAEA,gCAAS;;mBAAT,KAAA;;uCAqBQA,UAAUA;uCACVD,OAAOR,aAAagB;uCACpBN,OAAO;YAAE,GAAGT,aAAae,MAAM;YAAE,GAAGN,IAAI;QAAC;uCACzCC,QAAQ,KAAK,CAACA;IACtB;AAgFF"}
package/dist/esm/index.js CHANGED
@@ -1,4 +1,7 @@
1
- // TODO: Add SDK exports here, and remove these comments.
2
- // eslint-disable-next-line import/unambiguous
1
+ // Only internals that are used by other Snaps packages should be exported here.
2
+ export { getErrorData, getErrorMessage, getErrorStack, SNAP_ERROR_CODE, SNAP_ERROR_MESSAGE } from './internals';
3
+ export * from './errors';
4
+ export * from './types';
5
+ export * from './ui';
3
6
 
4
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// TODO: Add SDK exports here, and remove these comments.\n// eslint-disable-next-line import/unambiguous\n"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,8CAA8C"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Only internals that are used by other Snaps packages should be exported here.\nexport type { EnumToUnion } from './internals';\nexport {\n getErrorData,\n getErrorMessage,\n getErrorStack,\n SNAP_ERROR_CODE,\n SNAP_ERROR_MESSAGE,\n} from './internals';\n\n// Re-exported from `@metamask/utils` for convenience.\nexport type {\n Json,\n JsonRpcError,\n JsonRpcRequest,\n JsonRpcParams,\n} from '@metamask/utils';\n\nexport * from './errors';\nexport * from './types';\nexport * from './ui';\n"],"names":["getErrorData","getErrorMessage","getErrorStack","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE"],"mappings":"AAAA,gFAAgF;AAEhF,SACEA,YAAY,EACZC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,QACb,cAAc;AAUrB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,OAAO"}
@@ -0,0 +1,58 @@
1
+ import { hasProperty, isObject, isValidJson } from '@metamask/utils';
2
+ export const SNAP_ERROR_CODE = -31002;
3
+ export const SNAP_ERROR_MESSAGE = 'Snap Error';
4
+ /**
5
+ * Get the error message from an unknown error type.
6
+ *
7
+ * - If the error is an object with a `message` property, return the message.
8
+ * - Otherwise, return the error converted to a string.
9
+ *
10
+ * @param error - The error to get the message from.
11
+ * @returns The error message.
12
+ * @internal
13
+ */ export function getErrorMessage(error) {
14
+ if (isObject(error) && hasProperty(error, 'message') && typeof error.message === 'string') {
15
+ return error.message;
16
+ }
17
+ return String(error);
18
+ }
19
+ /**
20
+ * Get the error stack from an unknown error type.
21
+ *
22
+ * @param error - The error to get the stack from.
23
+ * @returns The error stack, or undefined if the error does not have a valid
24
+ * stack.
25
+ * @internal
26
+ */ export function getErrorStack(error) {
27
+ if (isObject(error) && hasProperty(error, 'stack') && typeof error.stack === 'string') {
28
+ return error.stack;
29
+ }
30
+ return undefined;
31
+ }
32
+ /**
33
+ * Get the error code from an unknown error type.
34
+ *
35
+ * @param error - The error to get the code from.
36
+ * @returns The error code, or `-32603` if the error does not have a valid code.
37
+ * @internal
38
+ */ export function getErrorCode(error) {
39
+ if (isObject(error) && hasProperty(error, 'code') && typeof error.code === 'number' && Number.isInteger(error.code)) {
40
+ return error.code;
41
+ }
42
+ return -32603;
43
+ }
44
+ /**
45
+ * Get the error data from an unknown error type.
46
+ *
47
+ * @param error - The error to get the data from.
48
+ * @returns The error data, or an empty object if the error does not have valid
49
+ * data.
50
+ * @internal
51
+ */ export function getErrorData(error) {
52
+ if (isObject(error) && hasProperty(error, 'data') && typeof error.data === 'object' && error.data !== null && isValidJson(error.data) && !Array.isArray(error.data)) {
53
+ return error.data;
54
+ }
55
+ return {};
56
+ }
57
+
58
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/internals/errors.ts"],"sourcesContent":["import { hasProperty, isObject, isValidJson } from '@metamask/utils';\n\nexport const SNAP_ERROR_CODE = -31002;\nexport const SNAP_ERROR_MESSAGE = 'Snap Error';\n\n/**\n * Get the error message from an unknown error type.\n *\n * - If the error is an object with a `message` property, return the message.\n * - Otherwise, return the error converted to a string.\n *\n * @param error - The error to get the message from.\n * @returns The error message.\n * @internal\n */\nexport function getErrorMessage(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'message') &&\n typeof error.message === 'string'\n ) {\n return error.message;\n }\n\n return String(error);\n}\n\n/**\n * Get the error stack from an unknown error type.\n *\n * @param error - The error to get the stack from.\n * @returns The error stack, or undefined if the error does not have a valid\n * stack.\n * @internal\n */\nexport function getErrorStack(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'stack') &&\n typeof error.stack === 'string'\n ) {\n return error.stack;\n }\n\n return undefined;\n}\n\n/**\n * Get the error code from an unknown error type.\n *\n * @param error - The error to get the code from.\n * @returns The error code, or `-32603` if the error does not have a valid code.\n * @internal\n */\nexport function getErrorCode(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'code') &&\n typeof error.code === 'number' &&\n Number.isInteger(error.code)\n ) {\n return error.code;\n }\n\n return -32603;\n}\n\n/**\n * Get the error data from an unknown error type.\n *\n * @param error - The error to get the data from.\n * @returns The error data, or an empty object if the error does not have valid\n * data.\n * @internal\n */\nexport function getErrorData(error: unknown) {\n if (\n isObject(error) &&\n hasProperty(error, 'data') &&\n typeof error.data === 'object' &&\n error.data !== null &&\n isValidJson(error.data) &&\n !Array.isArray(error.data)\n ) {\n return error.data;\n }\n\n return {};\n}\n"],"names":["hasProperty","isObject","isValidJson","SNAP_ERROR_CODE","SNAP_ERROR_MESSAGE","getErrorMessage","error","message","String","getErrorStack","stack","undefined","getErrorCode","code","Number","isInteger","getErrorData","data","Array","isArray"],"mappings":"AAAA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,kBAAkB;AAErE,OAAO,MAAMC,kBAAkB,CAAC,MAAM;AACtC,OAAO,MAAMC,qBAAqB,aAAa;AAE/C;;;;;;;;;CASC,GACD,OAAO,SAASC,gBAAgBC,KAAc;IAC5C,IACEL,SAASK,UACTN,YAAYM,OAAO,cACnB,OAAOA,MAAMC,OAAO,KAAK,UACzB;QACA,OAAOD,MAAMC,OAAO;IACtB;IAEA,OAAOC,OAAOF;AAChB;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,cAAcH,KAAc;IAC1C,IACEL,SAASK,UACTN,YAAYM,OAAO,YACnB,OAAOA,MAAMI,KAAK,KAAK,UACvB;QACA,OAAOJ,MAAMI,KAAK;IACpB;IAEA,OAAOC;AACT;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,aAAaN,KAAc;IACzC,IACEL,SAASK,UACTN,YAAYM,OAAO,WACnB,OAAOA,MAAMO,IAAI,KAAK,YACtBC,OAAOC,SAAS,CAACT,MAAMO,IAAI,GAC3B;QACA,OAAOP,MAAMO,IAAI;IACnB;IAEA,OAAO,CAAC;AACV;AAEA;;;;;;;CAOC,GACD,OAAO,SAASG,aAAaV,KAAc;IACzC,IACEL,SAASK,UACTN,YAAYM,OAAO,WACnB,OAAOA,MAAMW,IAAI,KAAK,YACtBX,MAAMW,IAAI,KAAK,QACff,YAAYI,MAAMW,IAAI,KACtB,CAACC,MAAMC,OAAO,CAACb,MAAMW,IAAI,GACzB;QACA,OAAOX,MAAMW,IAAI;IACnB;IAEA,OAAO,CAAC;AACV"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/internals/helpers.ts"],"sourcesContent":["import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\n/**\n * Get the enum values as union type. This allows using both the enum string\n * values and the enum itself as values.\n *\n * Note: This only works for string enums.\n *\n * @example\n * enum Foo {\n * Bar = 'bar',\n * Baz = 'baz',\n * }\n *\n * // FooValue is 'bar' | 'baz'\n * type FooValue = EnumToUnion<Foo>;\n *\n * const foo: FooValue = Foo.Bar; // Works\n * const foo: FooValue = 'bar'; // Also works\n * @internal\n */\nexport type EnumToUnion<Type extends string> = `${Type}`;\n\n/**\n * Get a JSON-RPC method with the given name and parameters. If params extends\n * `never`, then the `params` property is omitted.\n *\n * @example\n * // MyMethod is { method: 'my_method', params: { foo: string } }\n * type MyMethod = Method<'my_method', { foo: string }>;\n * @internal\n */\nexport type Method<\n MethodName extends string,\n Params extends JsonRpcParams,\n> = Partial<JsonRpcRequest> & Params extends never\n ? {\n method: MethodName;\n }\n : {\n method: MethodName;\n params: Params;\n };\n"],"names":[],"mappings":"AAAA,WA0CM"}
@@ -0,0 +1,4 @@
1
+ export * from './errors';
2
+ export * from './helpers';
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/internals/index.ts"],"sourcesContent":["export * from './errors';\nexport * from './helpers';\n"],"names":[],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,YAAY"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.
3
+ *
4
+ * @see https://chainagnostic.org/CAIPs/caip-2
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=caip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/caip.ts"],"sourcesContent":["/**\n * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.\n *\n * @see https://chainagnostic.org/CAIPs/caip-2\n */\nexport type ChainId = `${string}:${string}`;\n\n/**\n * A CAIP-10 account ID, i.e., a chain ID and an account address.\n *\n * @see https://chainagnostic.org/CAIPs/caip-10\n */\nexport type AccountId = `${ChainId}:${string}`;\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAO+C"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/global.ts"],"sourcesContent":["import type { SnapsEthereumProvider, SnapsProvider } from './provider';\n\n/**\n * Constants that are available globally in the Snap.\n */\ndeclare global {\n const ethereum: SnapsEthereumProvider;\n const snap: SnapsProvider;\n}\n"],"names":[],"mappings":"AAAA,WAQC"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=cronjob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/cronjob.ts"],"sourcesContent":["import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\n/**\n * The `onCronjob` handler. This is called on a regular interval, as defined by\n * the Snap's manifest.\n *\n * Note that using this handler requires the `endowment:cronjob` permission.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the snap. The parameters\n * are defined by the Snap's manifest.\n */\nexport type OnCronjobHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: { request: JsonRpcRequest<Params> }) => Promise<unknown>;\n"],"names":[],"mappings":"AAAA,WAakE"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=home-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/home-page.ts"],"sourcesContent":["import type { Component } from '../../ui';\n\n/**\n * The `onHomePage` handler. This is called when the user navigates to the\n * Snap's home page in the MetaMask UI.\n *\n * This function does not receive any arguments.\n *\n * @returns The content to display on the home page. See\n * {@link OnHomePageResponse}.\n */\nexport type OnHomePageHandler = () => Promise<OnHomePageResponse>;\n\n/**\n * The content to display on the home page.\n *\n * @property content - A custom UI component, that will be shown in MetaMask.\n */\nexport type OnHomePageResponse = {\n content: Component;\n};\n"],"names":[],"mappings":"AAAA,WAoBE"}
@@ -0,0 +1,9 @@
1
+ export * from './cronjob';
2
+ export * from './home-page';
3
+ export * from './keyring';
4
+ export * from './lifecycle';
5
+ export * from './name-lookup';
6
+ export * from './rpc-request';
7
+ export * from './transaction';
8
+
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=keyring.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/keyring.ts"],"sourcesContent":["import type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\n/**\n * The `onKeyringRequest` handler, which is called when a Snap receives a\n * keyring request.\n *\n * Note that using this handler requires the `endowment:keyring` permission.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * Snap, or the URL of a website.\n * @param args.request - The keyring request sent to the Snap. This includes\n * the method name and parameters.\n * @returns The response to the keyring request. This must be a\n * JSON-serializable value. In order to return an error, throw a `SnapError`\n * instead.\n */\nexport type OnKeyringRequestHandler<\n Params extends JsonRpcParams = JsonRpcParams,\n> = (args: {\n origin: string;\n request: JsonRpcRequest<Params>;\n}) => Promise<Json>;\n"],"names":[],"mappings":"AAAA,WAsBoB"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/lifecycle.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\n/**\n * A lifecycle event handler. This is called whenever a lifecycle event occurs,\n * such as the Snap being installed or updated.\n *\n * Note that using this handler requires the `endowment:lifecycle-hooks`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the Snap. This does not\n * contain any parameters.\n */\nexport type LifecycleEventHandler = (args: {\n request: JsonRpcRequest;\n}) => Promise<unknown>;\n\n/**\n * The `onInstall` handler. This is called after the Snap is installed.\n *\n * Note that using this handler requires the `endowment:lifecycle-hooks`\n * permission.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the Snap. This does not\n * contain any parameters.\n */\nexport type OnInstallHandler = LifecycleEventHandler;\n\n/**\n * The `onUpdate` handler. This is called after the Snap is updated.\n *\n * Note that using this handler requires the `endowment:lifecycle-hooks`\n * permission.\n *\n * This type is an alias for {@link LifecycleEventHandler}.\n *\n * @param args - The request arguments.\n * @param args.request - The JSON-RPC request sent to the Snap. This does not\n * contain any parameters.\n */\nexport type OnUpdateHandler = LifecycleEventHandler;\n"],"names":[],"mappings":"AAAA,WA2CoD"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=name-lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/name-lookup.ts"],"sourcesContent":["import type { ChainId } from '../caip';\n\ntype BaseOnNameLookupArgs = {\n chainId: ChainId;\n};\n\n/**\n * The arguments for a domain lookup.\n *\n * @property domain - The human-readable domain name that is to be resolved.\n */\nexport type DomainLookupArgs = BaseOnNameLookupArgs & {\n domain: string;\n address?: never;\n};\n\n/**\n * The result of a domain lookup.\n *\n * @property resolvedAddress - The resolved address.\n */\nexport type DomainLookupResult = {\n resolvedAddress: string;\n resolvedDomain?: never;\n};\n\n/**\n * The arguments for an address lookup.\n *\n * @property address - The address that is to be resolved.\n */\nexport type AddressLookupArgs = BaseOnNameLookupArgs & {\n address: string;\n domain?: never;\n};\n\n/**\n * The result of an address lookup.\n *\n * @property resolvedDomain - The resolved domain name.\n */\nexport type AddressLookupResult = {\n resolvedDomain: string;\n resolvedAddress?: never;\n};\n\n/**\n * The `onNameLookup` handler, which is called when MetaMask needs to resolve an\n * address or domain.\n *\n * Note that using this handler requires the `endowment:name-lookup` permission.\n *\n * @param args - The request arguments.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.domain - The human-readable address that is to be resolved. This\n * is mutually exclusive with `args.address`.\n * @param args.address - The address that is to be resolved. This is mutually\n * exclusive with `args.domain`.\n * @returns The resolved domain or address from the lookup. Must be either\n * {@link AddressLookupResult}, {@link DomainLookupResult}, or `null` if the\n * address or domain could not be resolved.\n */\nexport type OnNameLookupHandler = (\n args: AddressLookupArgs | DomainLookupArgs,\n) => Promise<AddressLookupResult | DomainLookupResult | null>;\n"],"names":[],"mappings":"AAAA,WAiE8D"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=rpc-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/rpc-request.ts"],"sourcesContent":["import type { Json, JsonRpcParams, JsonRpcRequest } from '@metamask/utils';\n\n/**\n * The `onRpcRequest` handler, which is called when a Snap receives a JSON-RPC\n * request. This can be called from another Snap, or from a website, depending\n * on the Snap's `endowment:rpc` permission.\n *\n * Note that using this handler requires the `endowment:rpc` permission.\n *\n * @param args - The request arguments.\n * @param args.origin - The origin of the request. This can be the ID of another\n * Snap, or the URL of a website.\n * @param args.request - The JSON-RPC request sent to the snap. This includes\n * the method name and parameters.\n * @returns The response to the JSON-RPC request. This must be a\n * JSON-serializable value. In order to return an error, throw a `SnapError`\n * instead.\n */\nexport type OnRpcRequestHandler<Params extends JsonRpcParams = JsonRpcParams> =\n (args: { origin: string; request: JsonRpcRequest<Params> }) => Promise<Json>;\n"],"names":[],"mappings":"AAAA,WAmB+E"}
@@ -0,0 +1,6 @@
1
+ export var SeverityLevel;
2
+ (function(SeverityLevel) {
3
+ SeverityLevel["Critical"] = 'critical';
4
+ })(SeverityLevel || (SeverityLevel = {}));
5
+
6
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/handlers/transaction.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { ChainId } from '../caip';\n\n/**\n * The severity level of content being returned from a transaction insight.\n * Currently only one level is supported:\n *\n * - `critical` - The transaction is critical and should not be submitted by the\n * user.\n */\nexport enum SeverityLevel {\n Critical = 'critical',\n}\n\n/**\n * An EIP-1559 (type 2) transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property maxFeePerGas - The maximum fee per gas of the transaction.\n * @property maxPriorityFeePerGas - The maximum priority fee per gas of the\n * transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n * @see https://eips.ethereum.org/EIPS/eip-1559\n */\nexport type EIP1559Transaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n maxFeePerGas: string;\n maxPriorityFeePerGas: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A legacy (type \"0\") transaction object.\n *\n * @property from - The address the transaction is being sent from.\n * @property to - The address the transaction is being sent to.\n * @property nonce - The nonce of the transaction.\n * @property value - The value of the transaction.\n * @property data - The data of the transaction.\n * @property gas - The gas limit of the transaction.\n * @property gasPrice - The gas price of the transaction.\n * @property estimateSuggested - The suggested gas price for the transaction.\n * @property estimateUsed - The gas price used for the transaction.\n */\nexport type LegacyTransaction = {\n from: string;\n to: string;\n nonce: string;\n value: string;\n data: string;\n gas: string;\n gasPrice: string;\n estimateSuggested: string;\n estimateUsed: string;\n};\n\n/**\n * A transaction object. This can be either an EIP-1559 transaction or a legacy\n * transaction.\n *\n * @see EIP1559Transaction\n * @see LegacyTransaction\n */\nexport type Transaction = EIP1559Transaction | LegacyTransaction;\n\n/**\n * The `onTransaction` handler. This is called whenever a transaction is\n * submitted to the snap. It can return insights about the transaction, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:transaction-insights`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.transaction - The transaction object, containing the address,\n * value, data, and other properties of the transaction.\n * @param args.chainId - The CAIP-2 {@link ChainId} of the network the\n * transaction is being submitted to.\n * @param args.transactionOrigin - The origin of the transaction. This is the\n * URL of the website that submitted the transaction. This is only available if\n * the Snap has enabled the `allowTransactionOrigin` option in the\n * `endowment:transaction-insight` permission.\n * @returns An object containing insights about the transaction. See\n * {@link OnTransactionResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnTransactionHandler = (args: {\n transaction: Transaction;\n chainId: ChainId;\n transactionOrigin?: string;\n}) => Promise<OnTransactionResponse | null>;\n\n/**\n * The response from a Snap's `onTransaction` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnTransactionResponse = {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n};\n"],"names":["SeverityLevel","Critical"],"mappings":"WAWO;UAAKA,aAAa;IAAbA,cACVC,cAAW;GADDD,kBAAAA"}
@@ -0,0 +1,11 @@
1
+ // This is intentionally imported, rather than re-exported.
2
+ // eslint-disable-next-line import/no-unassigned-import
3
+ import './global';
4
+ export * from './caip';
5
+ export * from './handlers';
6
+ export * from './methods';
7
+ export * from './permissions';
8
+ export * from './provider';
9
+ export * from './snap';
10
+
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/types/index.ts"],"sourcesContent":["// This is intentionally imported, rather than re-exported.\n// eslint-disable-next-line import/no-unassigned-import\nimport './global';\n\nexport * from './caip';\nexport * from './handlers';\nexport * from './methods';\nexport * from './permissions';\nexport * from './provider';\nexport * from './snap';\n"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,uDAAuD;AACvD,OAAO,WAAW;AAElB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,SAAS"}
@@ -0,0 +1,8 @@
1
+ export var DialogType;
2
+ (function(DialogType) {
3
+ DialogType["Alert"] = 'alert';
4
+ DialogType["Confirmation"] = 'confirmation';
5
+ DialogType["Prompt"] = 'prompt';
6
+ })(DialogType || (DialogType = {}));
7
+
8
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/dialog.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\n\n/**\n * The type of dialog to display.\n *\n * - `alert` - A dialog with a single button.\n * - `confirmation` - A dialog with two buttons, one to confirm and one to\n * cancel.\n * - `prompt` - A dialog with two buttons and a text input.\n */\nexport enum DialogType {\n Alert = 'alert',\n Confirmation = 'confirmation',\n Prompt = 'prompt',\n}\n\n/**\n * An alert dialog.\n *\n * @property type - The type of dialog. Must be `alert`.\n * @property content - The content to display in the dialog.\n */\nexport type AlertDialog = {\n type: EnumToUnion<DialogType.Alert>;\n content: Component;\n};\n\n/**\n * A confirmation dialog.\n *\n * @property type - The type of dialog. Must be `confirmation`.\n * @property content - The content to display in the dialog.\n */\nexport type ConfirmationDialog = {\n type: EnumToUnion<DialogType.Confirmation>;\n content: Component;\n};\n\n/**\n * A prompt dialog.\n *\n * @property type - The type of dialog. Must be `prompt`.\n * @property content - The content to display in the dialog.\n * @property placeholder - An optional placeholder text to display in the text\n * input.\n */\nexport type PromptDialog = {\n type: EnumToUnion<DialogType.Prompt>;\n content: Component;\n placeholder?: string;\n};\n\n/**\n * The request parameters for the `snap_dialog` method.\n *\n * @property type - The type of dialog to display.\n * @property content - The content to display in the dialog.\n * @property placeholder - The placeholder text to display in the dialog. Only\n * applicable for the `prompt` dialog.\n */\nexport type DialogParams = AlertDialog | ConfirmationDialog | PromptDialog;\n\n/**\n * The result returned by the `snap_dialog` method.\n *\n * - If the dialog is an `alert`, the result is `null`.\n * - If the dialog is a `confirmation`, the result is a boolean indicating\n * whether the user confirmed the dialog.\n * - If the dialog is a `prompt`, the result is the value entered by\n * the user.\n */\nexport type DialogResult = null | boolean | string;\n"],"names":["DialogType","Alert","Confirmation","Prompt"],"mappings":"WAWO;UAAKA,UAAU;IAAVA,WACVC,WAAQ;IADED,WAEVE,kBAAe;IAFLF,WAGVG,YAAS;GAHCH,eAAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=get-bip32-entropy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-bip32-entropy.ts"],"sourcesContent":["import type { JsonSLIP10Node } from '@metamask/key-tree';\n\nimport type { Bip32Entropy } from '../permissions';\n\n/**\n * The request parameters for the `snap_getBip32Entropy` method.\n *\n * @property path - The BIP-32 path to derive the entropy from.\n * @property curve - The curve to use when deriving the entropy.\n */\nexport type GetBip32EntropyParams = Bip32Entropy;\n\n/**\n * The result returned by the `snap_getBip32Entropy` method.\n *\n * @see https://github.com/MetaMask/key-tree#usage\n */\nexport type GetBip32EntropyResult = JsonSLIP10Node;\n"],"names":[],"mappings":"AAAA,WAiBmD"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=get-bip32-public-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-bip32-public-key.ts"],"sourcesContent":["import type { Bip32Entropy } from '../permissions';\n\n/**\n * The request parameters for the `snap_getBip32PublicKey` method.\n *\n * @property path - The BIP-32 path to derive the public key from.\n * @property curve - The curve to use when deriving the public key.\n * @property compressed - Whether to return the compressed public key. Defaults\n * to `false`.\n */\nexport type GetBip32PublicKeyParams = Bip32Entropy & {\n compressed?: boolean;\n};\n\n/**\n * The result returned by the `snap_getBip32PublicKey` method.\n *\n * It is the public key in hexadecimal format, in either compressed or\n * uncompressed format, depending on the `compressed` parameter.\n */\nexport type GetBip32PublicKeyResult = string;\n"],"names":[],"mappings":"AAAA,WAoB6C"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=get-bip44-entropy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-bip44-entropy.ts"],"sourcesContent":["import type { JsonBIP44CoinTypeNode } from '@metamask/key-tree';\n\nimport type { Bip44Entropy } from '../permissions';\n\n/**\n * The request parameters for the `snap_getBip44Entropy` method.\n *\n * @property coinType - The BIP-44 coin type to derive the entropy from.\n */\nexport type GetBip44EntropyParams = Bip44Entropy;\n\n/**\n * The result returned by the `snap_getBip44Entropy` method.\n *\n * @see https://github.com/MetaMask/key-tree#usage\n */\nexport type GetBip44EntropyResult = JsonBIP44CoinTypeNode;\n"],"names":[],"mappings":"AAAA,WAgB0D"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=get-entropy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-entropy.ts"],"sourcesContent":["import type { Hex } from '@metamask/utils';\n\n/**\n * The request parameters for the `snap_getEntropy` method.\n *\n * @property version - The version of the entropy to retrieve. This is used for\n * backwards compatibility. As of now, only version 1 is supported.\n * @property salt - The optional salt to use when deriving the entropy.\n */\nexport type GetEntropyParams = {\n version: 1;\n salt?: string;\n};\n\n/**\n * The result returned by the `snap_getEntropy` method.\n */\nexport type GetEntropyResult = Hex;\n"],"names":[],"mappings":"AAAA,WAiBmC"}
@@ -0,0 +1,8 @@
1
+ export var AuxiliaryFileEncoding;
2
+ (function(AuxiliaryFileEncoding) {
3
+ AuxiliaryFileEncoding["Base64"] = 'base64';
4
+ AuxiliaryFileEncoding["Hex"] = 'hex';
5
+ AuxiliaryFileEncoding["Utf8"] = 'utf8';
6
+ })(AuxiliaryFileEncoding || (AuxiliaryFileEncoding = {}));
7
+
8
+ //# sourceMappingURL=get-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-file.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\n\n/**\n * The encoding to use when retrieving the file. Defaults to `Base64`.\n */\nexport enum AuxiliaryFileEncoding {\n Base64 = 'base64',\n Hex = 'hex',\n Utf8 = 'utf8',\n}\n\n/**\n * The request parameters for the `snap_getFile` method.\n *\n * @property path - The path to the file to retrieve.\n * @property encoding - The encoding to use when retrieving the file.\n */\nexport type GetFileParams = {\n path: string;\n encoding?: EnumToUnion<AuxiliaryFileEncoding>;\n};\n\n/**\n * The result returned by the `snap_getFile` method.\n */\nexport type GetFileResult = string;\n"],"names":["AuxiliaryFileEncoding","Base64","Hex","Utf8"],"mappings":"WAKO;UAAKA,qBAAqB;IAArBA,sBACVC,YAAS;IADCD,sBAEVE,SAAM;IAFIF,sBAGVG,UAAO;GAHGH,0BAAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The request parameters for the `snap_getLocale` method.
3
+ *
4
+ * This method does not accept any parameters.
5
+ */ export { };
6
+
7
+ //# sourceMappingURL=get-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/types/methods/get-locale.ts"],"sourcesContent":["/**\n * The request parameters for the `snap_getLocale` method.\n *\n * This method does not accept any parameters.\n */\nexport type GetLocaleParams = never;\n\n/**\n * The result returned by the `snap_getLocale` method.\n *\n * It is the locale of the user's MetaMask extension.\n */\nexport type GetLocaleResult = string;\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAOqC"}