@metamask/snaps-simulation 2.2.0 → 2.4.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 (92) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/dist/constants.cjs +6 -1
  3. package/dist/constants.cjs.map +1 -1
  4. package/dist/constants.d.cts +5 -0
  5. package/dist/constants.d.cts.map +1 -1
  6. package/dist/constants.d.mts +5 -0
  7. package/dist/constants.d.mts.map +1 -1
  8. package/dist/constants.mjs +5 -0
  9. package/dist/constants.mjs.map +1 -1
  10. package/dist/helpers.cjs +10 -0
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts.map +1 -1
  13. package/dist/helpers.d.mts.map +1 -1
  14. package/dist/helpers.mjs +10 -0
  15. package/dist/helpers.mjs.map +1 -1
  16. package/dist/index.cjs +0 -1
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +1 -1
  19. package/dist/index.d.cts.map +1 -1
  20. package/dist/index.d.mts +1 -1
  21. package/dist/index.d.mts.map +1 -1
  22. package/dist/index.mjs +0 -1
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/interface.cjs +10 -2
  25. package/dist/interface.cjs.map +1 -1
  26. package/dist/interface.d.cts +3 -2
  27. package/dist/interface.d.cts.map +1 -1
  28. package/dist/interface.d.mts +3 -2
  29. package/dist/interface.d.mts.map +1 -1
  30. package/dist/interface.mjs +10 -2
  31. package/dist/interface.mjs.map +1 -1
  32. package/dist/methods/hooks/get-entropy-sources.cjs +30 -0
  33. package/dist/methods/hooks/get-entropy-sources.cjs.map +1 -0
  34. package/dist/methods/hooks/get-entropy-sources.d.cts +14 -0
  35. package/dist/methods/hooks/get-entropy-sources.d.cts.map +1 -0
  36. package/dist/methods/hooks/get-entropy-sources.d.mts +14 -0
  37. package/dist/methods/hooks/get-entropy-sources.d.mts.map +1 -0
  38. package/dist/methods/hooks/get-entropy-sources.mjs +26 -0
  39. package/dist/methods/hooks/get-entropy-sources.mjs.map +1 -0
  40. package/dist/methods/hooks/get-mnemonic-seed.cjs +29 -0
  41. package/dist/methods/hooks/get-mnemonic-seed.cjs.map +1 -0
  42. package/dist/methods/hooks/get-mnemonic-seed.d.cts +9 -0
  43. package/dist/methods/hooks/get-mnemonic-seed.d.cts.map +1 -0
  44. package/dist/methods/hooks/get-mnemonic-seed.d.mts +9 -0
  45. package/dist/methods/hooks/get-mnemonic-seed.d.mts.map +1 -0
  46. package/dist/methods/hooks/get-mnemonic-seed.mjs +25 -0
  47. package/dist/methods/hooks/get-mnemonic-seed.mjs.map +1 -0
  48. package/dist/methods/hooks/get-mnemonic.cjs +29 -0
  49. package/dist/methods/hooks/get-mnemonic.cjs.map +1 -0
  50. package/dist/methods/hooks/get-mnemonic.d.cts +9 -0
  51. package/dist/methods/hooks/get-mnemonic.d.cts.map +1 -0
  52. package/dist/methods/hooks/get-mnemonic.d.mts +9 -0
  53. package/dist/methods/hooks/get-mnemonic.d.mts.map +1 -0
  54. package/dist/methods/hooks/get-mnemonic.mjs +25 -0
  55. package/dist/methods/hooks/get-mnemonic.mjs.map +1 -0
  56. package/dist/methods/hooks/index.cjs +2 -0
  57. package/dist/methods/hooks/index.cjs.map +1 -1
  58. package/dist/methods/hooks/index.d.cts +2 -0
  59. package/dist/methods/hooks/index.d.cts.map +1 -1
  60. package/dist/methods/hooks/index.d.mts +2 -0
  61. package/dist/methods/hooks/index.d.mts.map +1 -1
  62. package/dist/methods/hooks/index.mjs +2 -0
  63. package/dist/methods/hooks/index.mjs.map +1 -1
  64. package/dist/methods/specifications.cjs.map +1 -1
  65. package/dist/methods/specifications.d.cts.map +1 -1
  66. package/dist/methods/specifications.d.mts.map +1 -1
  67. package/dist/methods/specifications.mjs.map +1 -1
  68. package/dist/middleware/engine.cjs +1 -1
  69. package/dist/middleware/engine.cjs.map +1 -1
  70. package/dist/middleware/engine.d.cts.map +1 -1
  71. package/dist/middleware/engine.d.mts.map +1 -1
  72. package/dist/middleware/engine.mjs +1 -1
  73. package/dist/middleware/engine.mjs.map +1 -1
  74. package/dist/simulation.cjs +4 -2
  75. package/dist/simulation.cjs.map +1 -1
  76. package/dist/simulation.d.cts +17 -3
  77. package/dist/simulation.d.cts.map +1 -1
  78. package/dist/simulation.d.mts +17 -3
  79. package/dist/simulation.d.mts.map +1 -1
  80. package/dist/simulation.mjs +5 -3
  81. package/dist/simulation.mjs.map +1 -1
  82. package/dist/store/store.cjs.map +1 -1
  83. package/dist/store/store.d.cts.map +1 -1
  84. package/dist/store/store.d.mts.map +1 -1
  85. package/dist/store/store.mjs.map +1 -1
  86. package/dist/types.cjs.map +1 -1
  87. package/dist/types.d.cts +20 -2
  88. package/dist/types.d.cts.map +1 -1
  89. package/dist/types.d.mts +20 -2
  90. package/dist/types.d.mts.map +1 -1
  91. package/dist/types.mjs.map +1 -1
  92. package/package.json +14 -28
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entropy-sources.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-entropy-sources.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,kCAAkC;IAChD,OAAO,GAAG,EAAE;QACV,OAAO;YACL;gBACE,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,gCAAgC;gBACtC,IAAI,EAAE,UAAmB;gBACzB,OAAO,EAAE,IAAI;aACd;YACD;gBACE,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,oCAAoC;gBAC1C,IAAI,EAAE,UAAmB;gBACzB,OAAO,EAAE,KAAK;aACf;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAjBD,gFAiBC","sourcesContent":["/**\n * Get the implementation of the `getEntropySources` hook.\n *\n * @returns The implementation of the `getEntropySources` hook. Right now, it\n * only returns two hard coded entropy source. In the future, it could return a\n * configurable list of entropy sources.\n */\nexport function getGetEntropySourcesImplementation() {\n return () => {\n return [\n {\n id: 'default',\n name: 'Default Secret Recovery Phrase',\n type: 'mnemonic' as const,\n primary: true,\n },\n {\n id: 'alternative',\n name: 'Alternative Secret Recovery Phrase',\n type: 'mnemonic' as const,\n primary: false,\n },\n ];\n };\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Get the implementation of the `getEntropySources` hook.
3
+ *
4
+ * @returns The implementation of the `getEntropySources` hook. Right now, it
5
+ * only returns two hard coded entropy source. In the future, it could return a
6
+ * configurable list of entropy sources.
7
+ */
8
+ export declare function getGetEntropySourcesImplementation(): () => {
9
+ id: string;
10
+ name: string;
11
+ type: "mnemonic";
12
+ primary: boolean;
13
+ }[];
14
+ //# sourceMappingURL=get-entropy-sources.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entropy-sources.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-entropy-sources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kCAAkC;;;;;IAiBjD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Get the implementation of the `getEntropySources` hook.
3
+ *
4
+ * @returns The implementation of the `getEntropySources` hook. Right now, it
5
+ * only returns two hard coded entropy source. In the future, it could return a
6
+ * configurable list of entropy sources.
7
+ */
8
+ export declare function getGetEntropySourcesImplementation(): () => {
9
+ id: string;
10
+ name: string;
11
+ type: "mnemonic";
12
+ primary: boolean;
13
+ }[];
14
+ //# sourceMappingURL=get-entropy-sources.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entropy-sources.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-entropy-sources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kCAAkC;;;;;IAiBjD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Get the implementation of the `getEntropySources` hook.
3
+ *
4
+ * @returns The implementation of the `getEntropySources` hook. Right now, it
5
+ * only returns two hard coded entropy source. In the future, it could return a
6
+ * configurable list of entropy sources.
7
+ */
8
+ export function getGetEntropySourcesImplementation() {
9
+ return () => {
10
+ return [
11
+ {
12
+ id: 'default',
13
+ name: 'Default Secret Recovery Phrase',
14
+ type: 'mnemonic',
15
+ primary: true,
16
+ },
17
+ {
18
+ id: 'alternative',
19
+ name: 'Alternative Secret Recovery Phrase',
20
+ type: 'mnemonic',
21
+ primary: false,
22
+ },
23
+ ];
24
+ };
25
+ }
26
+ //# sourceMappingURL=get-entropy-sources.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-entropy-sources.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-entropy-sources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC;IAChD,OAAO,GAAG,EAAE;QACV,OAAO;YACL;gBACE,EAAE,EAAE,SAAS;gBACb,IAAI,EAAE,gCAAgC;gBACtC,IAAI,EAAE,UAAmB;gBACzB,OAAO,EAAE,IAAI;aACd;YACD;gBACE,EAAE,EAAE,aAAa;gBACjB,IAAI,EAAE,oCAAoC;gBAC1C,IAAI,EAAE,UAAmB;gBACzB,OAAO,EAAE,KAAK;aACf;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Get the implementation of the `getEntropySources` hook.\n *\n * @returns The implementation of the `getEntropySources` hook. Right now, it\n * only returns two hard coded entropy source. In the future, it could return a\n * configurable list of entropy sources.\n */\nexport function getGetEntropySourcesImplementation() {\n return () => {\n return [\n {\n id: 'default',\n name: 'Default Secret Recovery Phrase',\n type: 'mnemonic' as const,\n primary: true,\n },\n {\n id: 'alternative',\n name: 'Alternative Secret Recovery Phrase',\n type: 'mnemonic' as const,\n primary: false,\n },\n ];\n };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGetMnemonicSeedImplementation = void 0;
4
+ const key_tree_1 = require("@metamask/key-tree");
5
+ const constants_1 = require("../../constants.cjs");
6
+ /**
7
+ * Get the implementation of the `getMnemonicSeed` method.
8
+ *
9
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
10
+ * use.
11
+ * @returns The implementation of the `getMnemonicSeed` method.
12
+ */
13
+ function getGetMnemonicSeedImplementation(defaultSecretRecoveryPhrase = constants_1.DEFAULT_SRP) {
14
+ return async (source) => {
15
+ if (!source) {
16
+ return (0, key_tree_1.mnemonicToSeed)(defaultSecretRecoveryPhrase);
17
+ }
18
+ switch (source) {
19
+ case 'default':
20
+ return (0, key_tree_1.mnemonicToSeed)(defaultSecretRecoveryPhrase);
21
+ case 'alternative':
22
+ return (0, key_tree_1.mnemonicToSeed)(constants_1.DEFAULT_ALTERNATIVE_SRP);
23
+ default:
24
+ throw new Error(`Entropy source with ID "${source}" not found.`);
25
+ }
26
+ };
27
+ }
28
+ exports.getGetMnemonicSeedImplementation = getGetMnemonicSeedImplementation;
29
+ //# sourceMappingURL=get-mnemonic-seed.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic-seed.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic-seed.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAEpD,mDAAuE;AAEvE;;;;;;GAMG;AACH,SAAgB,gCAAgC,CAC9C,8BAAsC,uBAAW;IAEjD,OAAO,KAAK,EAAE,MAA2B,EAAuB,EAAE;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAA,yBAAc,EAAC,2BAA2B,CAAC,CAAC;QACrD,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,IAAA,yBAAc,EAAC,2BAA2B,CAAC,CAAC;YACrD,KAAK,aAAa;gBAChB,OAAO,IAAA,yBAAc,EAAC,mCAAuB,CAAC,CAAC;YACjD;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAjBD,4EAiBC","sourcesContent":["import { mnemonicToSeed } from '@metamask/key-tree';\n\nimport { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from '../../constants';\n\n/**\n * Get the implementation of the `getMnemonicSeed` method.\n *\n * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to\n * use.\n * @returns The implementation of the `getMnemonicSeed` method.\n */\nexport function getGetMnemonicSeedImplementation(\n defaultSecretRecoveryPhrase: string = DEFAULT_SRP,\n) {\n return async (source?: string | undefined): Promise<Uint8Array> => {\n if (!source) {\n return mnemonicToSeed(defaultSecretRecoveryPhrase);\n }\n\n switch (source) {\n case 'default':\n return mnemonicToSeed(defaultSecretRecoveryPhrase);\n case 'alternative':\n return mnemonicToSeed(DEFAULT_ALTERNATIVE_SRP);\n default:\n throw new Error(`Entropy source with ID \"${source}\" not found.`);\n }\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the implementation of the `getMnemonicSeed` method.
3
+ *
4
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
5
+ * use.
6
+ * @returns The implementation of the `getMnemonicSeed` method.
7
+ */
8
+ export declare function getGetMnemonicSeedImplementation(defaultSecretRecoveryPhrase?: string): (source?: string | undefined) => Promise<Uint8Array>;
9
+ //# sourceMappingURL=get-mnemonic-seed.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic-seed.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic-seed.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,2BAA2B,GAAE,MAAoB,aAE1B,MAAM,GAAG,SAAS,KAAG,QAAQ,UAAU,CAAC,CAchE"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the implementation of the `getMnemonicSeed` method.
3
+ *
4
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
5
+ * use.
6
+ * @returns The implementation of the `getMnemonicSeed` method.
7
+ */
8
+ export declare function getGetMnemonicSeedImplementation(defaultSecretRecoveryPhrase?: string): (source?: string | undefined) => Promise<Uint8Array>;
9
+ //# sourceMappingURL=get-mnemonic-seed.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic-seed.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic-seed.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,2BAA2B,GAAE,MAAoB,aAE1B,MAAM,GAAG,SAAS,KAAG,QAAQ,UAAU,CAAC,CAchE"}
@@ -0,0 +1,25 @@
1
+ import { mnemonicToSeed } from "@metamask/key-tree";
2
+ import { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from "../../constants.mjs";
3
+ /**
4
+ * Get the implementation of the `getMnemonicSeed` method.
5
+ *
6
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
7
+ * use.
8
+ * @returns The implementation of the `getMnemonicSeed` method.
9
+ */
10
+ export function getGetMnemonicSeedImplementation(defaultSecretRecoveryPhrase = DEFAULT_SRP) {
11
+ return async (source) => {
12
+ if (!source) {
13
+ return mnemonicToSeed(defaultSecretRecoveryPhrase);
14
+ }
15
+ switch (source) {
16
+ case 'default':
17
+ return mnemonicToSeed(defaultSecretRecoveryPhrase);
18
+ case 'alternative':
19
+ return mnemonicToSeed(DEFAULT_ALTERNATIVE_SRP);
20
+ default:
21
+ throw new Error(`Entropy source with ID "${source}" not found.`);
22
+ }
23
+ };
24
+ }
25
+ //# sourceMappingURL=get-mnemonic-seed.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic-seed.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic-seed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,2BAA2B;AAEpD,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,4BAAwB;AAEvE;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,8BAAsC,WAAW;IAEjD,OAAO,KAAK,EAAE,MAA2B,EAAuB,EAAE;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,cAAc,CAAC,2BAA2B,CAAC,CAAC;QACrD,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,cAAc,CAAC,2BAA2B,CAAC,CAAC;YACrD,KAAK,aAAa;gBAChB,OAAO,cAAc,CAAC,uBAAuB,CAAC,CAAC;YACjD;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { mnemonicToSeed } from '@metamask/key-tree';\n\nimport { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from '../../constants';\n\n/**\n * Get the implementation of the `getMnemonicSeed` method.\n *\n * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to\n * use.\n * @returns The implementation of the `getMnemonicSeed` method.\n */\nexport function getGetMnemonicSeedImplementation(\n defaultSecretRecoveryPhrase: string = DEFAULT_SRP,\n) {\n return async (source?: string | undefined): Promise<Uint8Array> => {\n if (!source) {\n return mnemonicToSeed(defaultSecretRecoveryPhrase);\n }\n\n switch (source) {\n case 'default':\n return mnemonicToSeed(defaultSecretRecoveryPhrase);\n case 'alternative':\n return mnemonicToSeed(DEFAULT_ALTERNATIVE_SRP);\n default:\n throw new Error(`Entropy source with ID \"${source}\" not found.`);\n }\n };\n}\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGetMnemonicImplementation = void 0;
4
+ const key_tree_1 = require("@metamask/key-tree");
5
+ const constants_1 = require("../../constants.cjs");
6
+ /**
7
+ * Get the implementation of the `getMnemonic` method.
8
+ *
9
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
10
+ * use.
11
+ * @returns The implementation of the `getMnemonic` method.
12
+ */
13
+ function getGetMnemonicImplementation(defaultSecretRecoveryPhrase = constants_1.DEFAULT_SRP) {
14
+ return async (source) => {
15
+ if (!source) {
16
+ return (0, key_tree_1.mnemonicPhraseToBytes)(defaultSecretRecoveryPhrase);
17
+ }
18
+ switch (source) {
19
+ case 'default':
20
+ return (0, key_tree_1.mnemonicPhraseToBytes)(defaultSecretRecoveryPhrase);
21
+ case 'alternative':
22
+ return (0, key_tree_1.mnemonicPhraseToBytes)(constants_1.DEFAULT_ALTERNATIVE_SRP);
23
+ default:
24
+ throw new Error(`Entropy source with ID "${source}" not found.`);
25
+ }
26
+ };
27
+ }
28
+ exports.getGetMnemonicImplementation = getGetMnemonicImplementation;
29
+ //# sourceMappingURL=get-mnemonic.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":";;;AAAA,iDAA2D;AAE3D,mDAAuE;AAEvE;;;;;;GAMG;AACH,SAAgB,4BAA4B,CAC1C,8BAAsC,uBAAW;IAEjD,OAAO,KAAK,EAAE,MAA2B,EAAuB,EAAE;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,IAAA,gCAAqB,EAAC,2BAA2B,CAAC,CAAC;QAC5D,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,IAAA,gCAAqB,EAAC,2BAA2B,CAAC,CAAC;YAC5D,KAAK,aAAa;gBAChB,OAAO,IAAA,gCAAqB,EAAC,mCAAuB,CAAC,CAAC;YACxD;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAjBD,oEAiBC","sourcesContent":["import { mnemonicPhraseToBytes } from '@metamask/key-tree';\n\nimport { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from '../../constants';\n\n/**\n * Get the implementation of the `getMnemonic` method.\n *\n * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to\n * use.\n * @returns The implementation of the `getMnemonic` method.\n */\nexport function getGetMnemonicImplementation(\n defaultSecretRecoveryPhrase: string = DEFAULT_SRP,\n) {\n return async (source?: string | undefined): Promise<Uint8Array> => {\n if (!source) {\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n }\n\n switch (source) {\n case 'default':\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n case 'alternative':\n return mnemonicPhraseToBytes(DEFAULT_ALTERNATIVE_SRP);\n default:\n throw new Error(`Entropy source with ID \"${source}\" not found.`);\n }\n };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the implementation of the `getMnemonic` method.
3
+ *
4
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
5
+ * use.
6
+ * @returns The implementation of the `getMnemonic` method.
7
+ */
8
+ export declare function getGetMnemonicImplementation(defaultSecretRecoveryPhrase?: string): (source?: string | undefined) => Promise<Uint8Array>;
9
+ //# sourceMappingURL=get-mnemonic.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,aAE1B,MAAM,GAAG,SAAS,KAAG,QAAQ,UAAU,CAAC,CAchE"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the implementation of the `getMnemonic` method.
3
+ *
4
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
5
+ * use.
6
+ * @returns The implementation of the `getMnemonic` method.
7
+ */
8
+ export declare function getGetMnemonicImplementation(defaultSecretRecoveryPhrase?: string): (source?: string | undefined) => Promise<Uint8Array>;
9
+ //# sourceMappingURL=get-mnemonic.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,2BAA2B,GAAE,MAAoB,aAE1B,MAAM,GAAG,SAAS,KAAG,QAAQ,UAAU,CAAC,CAchE"}
@@ -0,0 +1,25 @@
1
+ import { mnemonicPhraseToBytes } from "@metamask/key-tree";
2
+ import { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from "../../constants.mjs";
3
+ /**
4
+ * Get the implementation of the `getMnemonic` method.
5
+ *
6
+ * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to
7
+ * use.
8
+ * @returns The implementation of the `getMnemonic` method.
9
+ */
10
+ export function getGetMnemonicImplementation(defaultSecretRecoveryPhrase = DEFAULT_SRP) {
11
+ return async (source) => {
12
+ if (!source) {
13
+ return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);
14
+ }
15
+ switch (source) {
16
+ case 'default':
17
+ return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);
18
+ case 'alternative':
19
+ return mnemonicPhraseToBytes(DEFAULT_ALTERNATIVE_SRP);
20
+ default:
21
+ throw new Error(`Entropy source with ID "${source}" not found.`);
22
+ }
23
+ };
24
+ }
25
+ //# sourceMappingURL=get-mnemonic.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-mnemonic.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/get-mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,2BAA2B;AAE3D,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,4BAAwB;AAEvE;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,8BAAsC,WAAW;IAEjD,OAAO,KAAK,EAAE,MAA2B,EAAuB,EAAE;QAChE,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,qBAAqB,CAAC,2BAA2B,CAAC,CAAC;QAC5D,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,SAAS;gBACZ,OAAO,qBAAqB,CAAC,2BAA2B,CAAC,CAAC;YAC5D,KAAK,aAAa;gBAChB,OAAO,qBAAqB,CAAC,uBAAuB,CAAC,CAAC;YACxD;gBACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,cAAc,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { mnemonicPhraseToBytes } from '@metamask/key-tree';\n\nimport { DEFAULT_ALTERNATIVE_SRP, DEFAULT_SRP } from '../../constants';\n\n/**\n * Get the implementation of the `getMnemonic` method.\n *\n * @param defaultSecretRecoveryPhrase - The default secret recovery phrase to\n * use.\n * @returns The implementation of the `getMnemonic` method.\n */\nexport function getGetMnemonicImplementation(\n defaultSecretRecoveryPhrase: string = DEFAULT_SRP,\n) {\n return async (source?: string | undefined): Promise<Uint8Array> => {\n if (!source) {\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n }\n\n switch (source) {\n case 'default':\n return mnemonicPhraseToBytes(defaultSecretRecoveryPhrase);\n case 'alternative':\n return mnemonicPhraseToBytes(DEFAULT_ALTERNATIVE_SRP);\n default:\n throw new Error(`Entropy source with ID \"${source}\" not found.`);\n }\n };\n}\n"]}
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./get-entropy-sources.cjs"), exports);
18
+ __exportStar(require("./get-mnemonic.cjs"), exports);
17
19
  __exportStar(require("./get-preferences.cjs"), exports);
18
20
  __exportStar(require("./interface.cjs"), exports);
19
21
  __exportStar(require("./notifications.cjs"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAkC;AAClC,kDAA4B;AAC5B,sDAAgC;AAChC,wDAA4B;AAC5B,8DAAwC;AACxC,8CAAwB","sourcesContent":["export * from './get-preferences';\nexport * from './interface';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './state';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,qDAA+B;AAC/B,wDAAkC;AAClC,kDAA4B;AAC5B,sDAAgC;AAChC,wDAA4B;AAC5B,8DAAwC;AACxC,8CAAwB","sourcesContent":["export * from './get-entropy-sources';\nexport * from './get-mnemonic';\nexport * from './get-preferences';\nexport * from './interface';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './state';\n"]}
@@ -1,3 +1,5 @@
1
+ export * from "./get-entropy-sources.cjs";
2
+ export * from "./get-mnemonic.cjs";
1
3
  export * from "./get-preferences.cjs";
2
4
  export * from "./interface.cjs";
3
5
  export * from "./notifications.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,0CAAsC;AACtC,mCAA+B;AAC/B,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB"}
@@ -1,3 +1,5 @@
1
+ export * from "./get-entropy-sources.mjs";
2
+ export * from "./get-mnemonic.mjs";
1
3
  export * from "./get-preferences.mjs";
2
4
  export * from "./interface.mjs";
3
5
  export * from "./notifications.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,0CAAsC;AACtC,mCAA+B;AAC/B,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB"}
@@ -1,3 +1,5 @@
1
+ export * from "./get-entropy-sources.mjs";
2
+ export * from "./get-mnemonic.mjs";
1
3
  export * from "./get-preferences.mjs";
2
4
  export * from "./interface.mjs";
3
5
  export * from "./notifications.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB","sourcesContent":["export * from './get-preferences';\nexport * from './interface';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './state';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/methods/hooks/index.ts"],"names":[],"mappings":"AAAA,0CAAsC;AACtC,mCAA+B;AAC/B,sCAAkC;AAClC,gCAA4B;AAC5B,oCAAgC;AAChC,sCAA4B;AAC5B,4CAAwC;AACxC,4BAAwB","sourcesContent":["export * from './get-entropy-sources';\nexport * from './get-mnemonic';\nexport * from './get-preferences';\nexport * from './interface';\nexport * from './notifications';\nexport * from './permitted';\nexport * from './request-user-approval';\nexport * from './state';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"specifications.cjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":";;;AACA,mEAIqC;AAErC,uDAA2D;AAK3D,+CAGqB;AACrB,6CAUiB;AAkBjB;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,MAAe;IACrC,OAAO,GAAG,EAAE,CA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E,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;QAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;QAClC,IAAI,oBAAoB,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,aAAa,CACzD,MAAM,EACN,cAAc,CACf,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,WAAW,CAAC,MAAM,CAAC,UAAsB,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,gCAAkB,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC;AAvBD,sCAuBC","sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\n} from './hooks';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve<Type>(result?: Type) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getPreferences: getGetPreferencesMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n requestUserApproval: getRequestUserApprovalImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"]}
1
+ {"version":3,"file":"specifications.cjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":";;;AACA,mEAIqC;AAErC,uDAA2D;AAE3D,+CAGqB;AACrB,6CAUiB;AAqBjB;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,MAAe;IACrC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;AACtB,CAAC;AAFD,0BAEC;AAED;;;;;;GAMG;AACH,SAAgB,YAAY,CAAO,MAAa;IAC9C,OAAO,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC;AAC5B,CAAC;AAFD,oCAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,2BAA2B,CAAC,EAC1C,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,OAAO,GAC4B;IACnC,OAAO;QACL,GAAG,IAAA,oDAAgC,EAAC,oCAAwB,CAAC;QAC7D,GAAG,IAAA,2DAAuC,EAAC,qCAAyB,EAAE;YACpE,gBAAgB;YAChB,GAAG,KAAK;YAER,wBAAwB;YACxB,cAAc,EAAE,IAAA,6CAAqC,EAAC,OAAO,CAAC;YAC9D,cAAc,EAAE,IAAA,6CAAqC,EAAC,OAAO,CAAC;YAC9D,YAAY,EAAE,IAAA,2CAAmC,EAAC,OAAO,CAAC;YAC1D,gBAAgB,EAAE,YAAY,CAAC,IAAI,CAAC;YA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\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\n} from './hooks';\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve<Type>(result?: Type) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getPreferences: getGetPreferencesMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n requestUserApproval: getRequestUserApprovalImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"specifications.d.cts","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,wCAAwC;AAMnF,OAAO,KAAK,EAAE,MAAM,EAAE,4BAA4B;AAGlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,2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,EAAE,2BAA2B,EACjD,MAAM,EAAE,MAAM,qBAqBf"}
@@ -1 +1 @@
1
- {"version":3,"file":"specifications.mjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,uCAAuC,EACxC,oCAAoC;AAErC,OAAO,EAAE,kBAAkB,EAAE,8BAA8B;AAK3D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EAC1B,wBAAoB;AACrB,OAAO,EACL,qCAAqC,EACrC,qCAAqC,EACrC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,uCAAuC,EACvC,gCAAgC,EAChC,6BAA6B,EAC7B,oCAAoC,EACrC,0BAAgB;AAkBjB;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,MAAe;IACrC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAO,MAAa;IAC9C,OAAO,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAC1C,mBAAmB,EACnB,KAAK,EACL,OAAO,EACP,OAAO,GAC4B;IACnC,OAAO;QACL,GAAG,gCAAgC,CAAC,wBAAwB,CAAC;QAC7D,GAAG,uCAAuC,CAAC,yBAAyB,EAAE;YACpE,gBAAgB;YAChB,GAAG,KAAK;YAER,wBAAwB;YACxB,cAAc,EAAE,qCAAqC,CAAC,OAAO,CAAC;YAC9D,cAAc,EAAE,qCAAqC,CAAC,OAAO,CAAC;YAC9D,YAAY,EAAE,mCAAmC,CAAC,OAAO,CAAC;YAC1D,gBAAgB,EAAE,YAAY,CAAC,IAAI,CAAC;YAEpC,+DAA+D;YAC/D,gBAAgB,EAAE,OAAO,CAAC,KAAK,CAAC;YAEhC,uBAAuB,EAAE,YAAY,EAAE;YACvC,mBAAmB,EAAE,oCAAoC,CAAC,OAAO,CAAC;YAClE,qBAAqB,EAAE,sCAAsC,CAAC,OAAO,CAAC;YACtE,sBAAsB,EAAE,uCAAuC,CAAC,OAAO,CAAC;YACxE,eAAe,EAAE,sCAAsC,CAAC,OAAO,CAAC;YAChE,eAAe,EAAE,gCAAgC,CAAC,mBAAmB,CAAC;YACtE,YAAY,EAAE,6BAA6B,CAAC,mBAAmB,CAAC;SACjE,CAAC;KACH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,oBAAiD,EACjD,MAAc;IAEd,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,MAAM,CAEzE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;QAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;QAClC,IAAI,oBAAoB,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,aAAa,CACzD,MAAM,EACN,cAAc,CACf,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,WAAW,CAAC,MAAM,CAAC,UAAsB,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,kBAAkB,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\n} from './hooks';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve<Type>(result?: Type) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getPreferences: getGetPreferencesMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n requestUserApproval: getRequestUserApprovalImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"]}
1
+ {"version":3,"file":"specifications.mjs","sourceRoot":"","sources":["../../src/methods/specifications.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,uCAAuC,EACxC,oCAAoC;AAErC,OAAO,EAAE,kBAAkB,EAAE,8BAA8B;AAE3D,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EAC1B,wBAAoB;AACrB,OAAO,EACL,qCAAqC,EACrC,qCAAqC,EACrC,mCAAmC,EACnC,sCAAsC,EACtC,sCAAsC,EACtC,uCAAuC,EACvC,gCAAgC,EAChC,6BAA6B,EAC7B,oCAAoC,EACrC,0BAAg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AAK,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;QAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC;QAClC,IAAI,oBAAoB,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YAC/D,MAAM,UAAU,GAAG,MAAM,oBAAoB,CAAC,aAAa,CACzD,MAAM,EACN,cAAc,CACf,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,WAAW,CAAC,MAAM,CAAC,UAAsB,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,kBAAkB,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import type { GenericPermissionController } from '@metamask/permission-controller';\nimport {\n endowmentPermissionBuilders,\n buildSnapEndowmentSpecifications,\n buildSnapRestrictedMethodSpecifications,\n} from '@metamask/snaps-rpc-methods';\nimport type { SnapId } from '@metamask/snaps-sdk';\nimport { DEFAULT_ENDOWMENTS } from '@metamask/snaps-utils';\n\nimport {\n EXCLUDED_SNAP_ENDOWMENTS,\n EXCLUDED_SNAP_PERMISSIONS,\n} from './constants';\nimport {\n getGetPreferencesMethodImplementation,\n getClearSnapStateMethodImplementation,\n getGetSnapStateMethodImplementation,\n getUpdateSnapStateMethodImplementation,\n getShowInAppNotificationImplementation,\n getShowNativeNotificationImplementation,\n getCreateInterfaceImplementation,\n getGetInterfaceImplementation,\n getRequestUserApprovalImplementation,\n} from './hooks';\nimport type { RootControllerMessenger } from '../controllers';\nimport type { SimulationOptions } from '../options';\nimport type { RunSagaFunction } from '../store';\n\nexport type PermissionSpecificationsHooks = {\n /**\n * A hook that returns the user's secret recovery phrase.\n *\n * @returns The user's secret recovery phrase.\n */\n getMnemonic: () => Promise<Uint8Array>;\n};\n\nexport type GetPermissionSpecificationsOptions = {\n controllerMessenger: RootControllerMessenger;\n hooks: PermissionSpecificationsHooks;\n runSaga: RunSagaFunction;\n options: SimulationOptions;\n};\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return.\n * @returns The function implementation.\n */\nexport function resolve(result: unknown) {\n return () => result;\n}\n\n/**\n * Get a function which resolves with the specified result.\n *\n * @param result - The result to return. If not specified, the function will\n * resolve with `undefined`.\n * @returns The function implementation.\n */\nexport function asyncResolve<Type>(result?: Type) {\n return async () => result;\n}\n\n/**\n * Get the permission specifications for the Snap.\n *\n * @param options - The options.\n * @param options.controllerMessenger - The controller messenger.\n * @param options.hooks - The hooks.\n * @param options.runSaga - The function to run a saga outside the usual Redux\n * flow.\n * @param options.options - The simulation options.\n * @returns The permission specifications for the Snap.\n */\nexport function getPermissionSpecifications({\n controllerMessenger,\n hooks,\n runSaga,\n options,\n}: GetPermissionSpecificationsOptions) {\n return {\n ...buildSnapEndowmentSpecifications(EXCLUDED_SNAP_ENDOWMENTS),\n ...buildSnapRestrictedMethodSpecifications(EXCLUDED_SNAP_PERMISSIONS, {\n // Shared hooks.\n ...hooks,\n\n // Snaps-specific hooks.\n clearSnapState: getClearSnapStateMethodImplementation(runSaga),\n getPreferences: getGetPreferencesMethodImplementation(options),\n getSnapState: getGetSnapStateMethodImplementation(runSaga),\n getUnlockPromise: asyncResolve(true),\n\n // TODO: Allow the user to specify the result of this function.\n isOnPhishingList: resolve(false),\n\n maybeUpdatePhishingList: asyncResolve(),\n requestUserApproval: getRequestUserApprovalImplementation(runSaga),\n showInAppNotification: getShowInAppNotificationImplementation(runSaga),\n showNativeNotification: getShowNativeNotificationImplementation(runSaga),\n updateSnapState: getUpdateSnapStateMethodImplementation(runSaga),\n createInterface: getCreateInterfaceImplementation(controllerMessenger),\n getInterface: getGetInterfaceImplementation(controllerMessenger),\n }),\n };\n}\n\n/**\n * Get the endowments for the Snap.\n *\n * @param permissionController - The permission controller.\n * @param snapId - The ID of the Snap.\n * @returns The endowments for the Snap.\n */\nexport async function getEndowments(\n permissionController: GenericPermissionController,\n snapId: SnapId,\n) {\n const allEndowments = await Object.keys(endowmentPermissionBuilders).reduce<\n Promise<string[]>\n >(async (promise, permissionName) => {\n const accumulator = await promise;\n if (permissionController.hasPermission(snapId, permissionName)) {\n const endowments = await permissionController.getEndowments(\n snapId,\n permissionName,\n );\n\n if (endowments) {\n return accumulator.concat(endowments as string[]);\n }\n }\n\n return accumulator;\n }, Promise.resolve([]));\n\n return [...new Set([...DEFAULT_ENDOWMENTS, ...allEndowments])];\n}\n"]}
@@ -4,9 +4,9 @@ exports.createJsonRpcEngine = void 0;
4
4
  const eth_json_rpc_middleware_1 = require("@metamask/eth-json-rpc-middleware");
5
5
  const json_rpc_engine_1 = require("@metamask/json-rpc-engine");
6
6
  const snaps_rpc_methods_1 = require("@metamask/snaps-rpc-methods");
7
- const constants_1 = require("../constants.cjs");
8
7
  const internal_methods_1 = require("./internal-methods/index.cjs");
9
8
  const mock_1 = require("./mock.cjs");
9
+ const constants_1 = require("../constants.cjs");
10
10
  /**
11
11
  * Create a JSON-RPC engine for use in a simulated environment. This engine
12
12
  * should be used to handle all JSON-RPC requests. It is set up to handle
@@ -1 +1 @@
1
- {"version":3,"file":"engine.cjs","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":";;;AAAA,+EAA0E;AAE1E,+DAA0D;AAE1D,mEAA0E;AAG1E,gDAAyD;AAMzD,mEAAqE;AACrE,qCAA8C;AAU9C;;;;;;;;;;;;;GAaG;AACH,SAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,GAAG,qCAAyB,GACT;IAC3B,MAAM,MAAM,GAAG,IAAI,+BAAa,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC,IAAA,2BAAoB,EAAC,KAAK,CAAC,CAAC,CAAC;IAEzC,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,CAAC,IAAI,CAAC,IAAA,kDAA+B,EAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,CAAC,IAAA,+CAA2B,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAClC,MAAM,CAAC,IAAI,CACT,IAAA,+CAAqB,EAAC;QACpB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,QAAQ;KACjB,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAzBD,kDAyBC","sourcesContent":["import { createFetchMiddleware } from '@metamask/eth-json-rpc-middleware';\nimport type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport { JsonRpcEngine } from '@metamask/json-rpc-engine';\nimport type { RestrictedMethodParameters } from '@metamask/permission-controller';\nimport { createSnapsMethodMiddleware } from '@metamask/snaps-rpc-methods';\nimport type { Json } from '@metamask/utils';\n\nimport { DEFAULT_JSON_RPC_ENDPOINT } from '../constants';\nimport type {\n PermittedMiddlewareHooks,\n RestrictedMiddlewareHooks,\n} from '../simulation';\nimport type { Store } from '../store';\nimport { createInternalMethodsMiddleware } from './internal-methods';\nimport { createMockMiddleware } from './mock';\n\nexport type CreateJsonRpcEngineOptions = {\n store: Store;\n restrictedHooks: RestrictedMiddlewareHooks;\n permittedHooks: PermittedMiddlewareHooks;\n permissionMiddleware: JsonRpcMiddleware<RestrictedMethodParameters, Json>;\n endpoint?: string;\n};\n\n/**\n * Create a JSON-RPC engine for use in a simulated environment. This engine\n * should be used to handle all JSON-RPC requests. It is set up to handle\n * requests that would normally be handled internally by the MetaMask client, as\n * well as Snap-specific requests.\n *\n * @param options - The options to use when creating the engine.\n * @param options.store - The Redux store to use.\n * @param options.restrictedHooks - Any hooks used by the middleware handlers.\n * @param options.permittedHooks - Any hooks used by the middleware handlers.\n * @param options.permissionMiddleware - The permission middleware to use.\n * @param options.endpoint - The JSON-RPC endpoint to use for Ethereum requests.\n * @returns A JSON-RPC engine.\n */\nexport function createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n endpoint = DEFAULT_JSON_RPC_ENDPOINT,\n}: CreateJsonRpcEngineOptions) {\n const engine = new JsonRpcEngine();\n engine.push(createMockMiddleware(store));\n\n // The hooks here do not match the hooks used by the clients, so this\n // middleware should not be used outside of the simulation environment.\n engine.push(createInternalMethodsMiddleware(restrictedHooks));\n engine.push(createSnapsMethodMiddleware(true, permittedHooks));\n\n engine.push(permissionMiddleware);\n engine.push(\n createFetchMiddleware({\n btoa: globalThis.btoa,\n fetch: globalThis.fetch,\n rpcUrl: endpoint,\n }),\n );\n\n return engine;\n}\n"]}
1
+ {"version":3,"file":"engine.cjs","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":";;;AAAA,+EAA0E;AAE1E,+DAA0D;AAE1D,mEAA0E;AAG1E,mEAAqE;AACrE,qCAA8C;AAC9C,gDAAyD;AAezD;;;;;;;;;;;;;GAaG;AACH,SAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,GAAG,qCAAyB,GACT;IAC3B,MAAM,MAAM,GAAG,IAAI,+BAAa,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC,IAAA,2BAAoB,EAAC,KAAK,CAAC,CAAC,CAAC;IAEzC,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,CAAC,IAAI,CAAC,IAAA,kDAA+B,EAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,CAAC,IAAA,+CAA2B,EAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAClC,MAAM,CAAC,IAAI,CACT,IAAA,+CAAqB,EAAC;QACpB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,QAAQ;KACjB,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAzBD,kDAyBC","sourcesContent":["import { createFetchMiddleware } from '@metamask/eth-json-rpc-middleware';\nimport type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport { JsonRpcEngine } from '@metamask/json-rpc-engine';\nimport type { RestrictedMethodParameters } from '@metamask/permission-controller';\nimport { createSnapsMethodMiddleware } from '@metamask/snaps-rpc-methods';\nimport type { Json } from '@metamask/utils';\n\nimport { createInternalMethodsMiddleware } from './internal-methods';\nimport { createMockMiddleware } from './mock';\nimport { DEFAULT_JSON_RPC_ENDPOINT } from '../constants';\nimport type {\n PermittedMiddlewareHooks,\n RestrictedMiddlewareHooks,\n} from '../simulation';\nimport type { Store } from '../store';\n\nexport type CreateJsonRpcEngineOptions = {\n store: Store;\n restrictedHooks: RestrictedMiddlewareHooks;\n permittedHooks: PermittedMiddlewareHooks;\n permissionMiddleware: JsonRpcMiddleware<RestrictedMethodParameters, Json>;\n endpoint?: string;\n};\n\n/**\n * Create a JSON-RPC engine for use in a simulated environment. This engine\n * should be used to handle all JSON-RPC requests. It is set up to handle\n * requests that would normally be handled internally by the MetaMask client, as\n * well as Snap-specific requests.\n *\n * @param options - The options to use when creating the engine.\n * @param options.store - The Redux store to use.\n * @param options.restrictedHooks - Any hooks used by the middleware handlers.\n * @param options.permittedHooks - Any hooks used by the middleware handlers.\n * @param options.permissionMiddleware - The permission middleware to use.\n * @param options.endpoint - The JSON-RPC endpoint to use for Ethereum requests.\n * @returns A JSON-RPC engine.\n */\nexport function createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n endpoint = DEFAULT_JSON_RPC_ENDPOINT,\n}: CreateJsonRpcEngineOptions) {\n const engine = new JsonRpcEngine();\n engine.push(createMockMiddleware(store));\n\n // The hooks here do not match the hooks used by the clients, so this\n // middleware should not be used outside of the simulation environment.\n engine.push(createInternalMethodsMiddleware(restrictedHooks));\n engine.push(createSnapsMethodMiddleware(true, permittedHooks));\n\n engine.push(permissionMiddleware);\n engine.push(\n createFetchMiddleware({\n btoa: globalThis.btoa,\n fetch: globalThis.fetch,\n rpcUrl: endpoint,\n }),\n );\n\n return engine;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.cts","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kCAAkC;AACnE,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,wCAAwC;AAElF,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAG5C,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,0BAAsB;AACvB,OAAO,KAAK,EAAE,KAAK,EAAE,2BAAiB;AAItC,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,yBAAyB,CAAC;IAC3C,cAAc,EAAE,wBAAwB,CAAC;IACzC,oBAAoB,EAAE,iBAAiB,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAoC,GACrC,EAAE,0BAA0B,iBAmB5B"}
1
+ {"version":3,"file":"engine.d.cts","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kCAAkC;AACnE,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,wCAAwC;AAElF,OAAO,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AAc,EACd,oBAAoB,EACpB,QAAoC,GACrC,EAAE,0BAA0B,iBAmB5B"}
1
+ {"version":3,"file":"engine.d.mts","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kCAAkC;AACnE,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAC1D,OAAO,KAAK,EAAE,0BAA0B,EAAE,wCAAwC;AAElF,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAK5C,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,0BAAsB;AACvB,OAAO,KAAK,EAAE,KAAK,EAAE,2BAAiB;AAEtC,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,KAAK,CAAC;IACb,eAAe,EAAE,yBAAyB,CAAC;IAC3C,cAAc,EAAE,wBAAwB,CAAC;IACzC,oBAAoB,EAAE,iBAAiB,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAC;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAoC,GACrC,EAAE,0BAA0B,iBAmB5B"}
@@ -1,9 +1,9 @@
1
1
  import { createFetchMiddleware } from "@metamask/eth-json-rpc-middleware";
2
2
  import { JsonRpcEngine } from "@metamask/json-rpc-engine";
3
3
  import { createSnapsMethodMiddleware } from "@metamask/snaps-rpc-methods";
4
- import { DEFAULT_JSON_RPC_ENDPOINT } from "../constants.mjs";
5
4
  import { createInternalMethodsMiddleware } from "./internal-methods/index.mjs";
6
5
  import { createMockMiddleware } from "./mock.mjs";
6
+ import { DEFAULT_JSON_RPC_ENDPOINT } from "../constants.mjs";
7
7
  /**
8
8
  * Create a JSON-RPC engine for use in a simulated environment. This engine
9
9
  * should be used to handle all JSON-RPC requests. It is set up to handle
@@ -1 +1 @@
1
- {"version":3,"file":"engine.mjs","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,0CAA0C;AAE1E,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,oCAAoC;AAG1E,OAAO,EAAE,yBAAyB,EAAE,yBAAqB;AAMzD,OAAO,EAAE,+BAA+B,EAAE,qCAA2B;AACrE,OAAO,EAAE,oBAAoB,EAAE,mBAAe;AAU9C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,GAAG,yBAAyB,GACT;IAC3B,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzC,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAClC,MAAM,CAAC,IAAI,CACT,qBAAqB,CAAC;QACpB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,QAAQ;KACjB,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createFetchMiddleware } from '@metamask/eth-json-rpc-middleware';\nimport type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport { JsonRpcEngine } from '@metamask/json-rpc-engine';\nimport type { RestrictedMethodParameters } from '@metamask/permission-controller';\nimport { createSnapsMethodMiddleware } from '@metamask/snaps-rpc-methods';\nimport type { Json } from '@metamask/utils';\n\nimport { DEFAULT_JSON_RPC_ENDPOINT } from '../constants';\nimport type {\n PermittedMiddlewareHooks,\n RestrictedMiddlewareHooks,\n} from '../simulation';\nimport type { Store } from '../store';\nimport { createInternalMethodsMiddleware } from './internal-methods';\nimport { createMockMiddleware } from './mock';\n\nexport type CreateJsonRpcEngineOptions = {\n store: Store;\n restrictedHooks: RestrictedMiddlewareHooks;\n permittedHooks: PermittedMiddlewareHooks;\n permissionMiddleware: JsonRpcMiddleware<RestrictedMethodParameters, Json>;\n endpoint?: string;\n};\n\n/**\n * Create a JSON-RPC engine for use in a simulated environment. This engine\n * should be used to handle all JSON-RPC requests. It is set up to handle\n * requests that would normally be handled internally by the MetaMask client, as\n * well as Snap-specific requests.\n *\n * @param options - The options to use when creating the engine.\n * @param options.store - The Redux store to use.\n * @param options.restrictedHooks - Any hooks used by the middleware handlers.\n * @param options.permittedHooks - Any hooks used by the middleware handlers.\n * @param options.permissionMiddleware - The permission middleware to use.\n * @param options.endpoint - The JSON-RPC endpoint to use for Ethereum requests.\n * @returns A JSON-RPC engine.\n */\nexport function createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n endpoint = DEFAULT_JSON_RPC_ENDPOINT,\n}: CreateJsonRpcEngineOptions) {\n const engine = new JsonRpcEngine();\n engine.push(createMockMiddleware(store));\n\n // The hooks here do not match the hooks used by the clients, so this\n // middleware should not be used outside of the simulation environment.\n engine.push(createInternalMethodsMiddleware(restrictedHooks));\n engine.push(createSnapsMethodMiddleware(true, permittedHooks));\n\n engine.push(permissionMiddleware);\n engine.push(\n createFetchMiddleware({\n btoa: globalThis.btoa,\n fetch: globalThis.fetch,\n rpcUrl: endpoint,\n }),\n );\n\n return engine;\n}\n"]}
1
+ {"version":3,"file":"engine.mjs","sourceRoot":"","sources":["../../src/middleware/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,0CAA0C;AAE1E,OAAO,EAAE,aAAa,EAAE,kCAAkC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,oCAAoC;AAG1E,OAAO,EAAE,+BAA+B,EAAE,qCAA2B;AACrE,OAAO,EAAE,oBAAoB,EAAE,mBAAe;AAC9C,OAAO,EAAE,yBAAyB,EAAE,yBAAqB;AAezD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,KAAK,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,QAAQ,GAAG,yBAAyB,GACT;IAC3B,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAEzC,qEAAqE;IACrE,uEAAuE;IACvE,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAE/D,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAClC,MAAM,CAAC,IAAI,CACT,qBAAqB,CAAC;QACpB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,QAAQ;KACjB,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createFetchMiddleware } from '@metamask/eth-json-rpc-middleware';\nimport type { JsonRpcMiddleware } from '@metamask/json-rpc-engine';\nimport { JsonRpcEngine } from '@metamask/json-rpc-engine';\nimport type { RestrictedMethodParameters } from '@metamask/permission-controller';\nimport { createSnapsMethodMiddleware } from '@metamask/snaps-rpc-methods';\nimport type { Json } from '@metamask/utils';\n\nimport { createInternalMethodsMiddleware } from './internal-methods';\nimport { createMockMiddleware } from './mock';\nimport { DEFAULT_JSON_RPC_ENDPOINT } from '../constants';\nimport type {\n PermittedMiddlewareHooks,\n RestrictedMiddlewareHooks,\n} from '../simulation';\nimport type { Store } from '../store';\n\nexport type CreateJsonRpcEngineOptions = {\n store: Store;\n restrictedHooks: RestrictedMiddlewareHooks;\n permittedHooks: PermittedMiddlewareHooks;\n permissionMiddleware: JsonRpcMiddleware<RestrictedMethodParameters, Json>;\n endpoint?: string;\n};\n\n/**\n * Create a JSON-RPC engine for use in a simulated environment. This engine\n * should be used to handle all JSON-RPC requests. It is set up to handle\n * requests that would normally be handled internally by the MetaMask client, as\n * well as Snap-specific requests.\n *\n * @param options - The options to use when creating the engine.\n * @param options.store - The Redux store to use.\n * @param options.restrictedHooks - Any hooks used by the middleware handlers.\n * @param options.permittedHooks - Any hooks used by the middleware handlers.\n * @param options.permissionMiddleware - The permission middleware to use.\n * @param options.endpoint - The JSON-RPC endpoint to use for Ethereum requests.\n * @returns A JSON-RPC engine.\n */\nexport function createJsonRpcEngine({\n store,\n restrictedHooks,\n permittedHooks,\n permissionMiddleware,\n endpoint = DEFAULT_JSON_RPC_ENDPOINT,\n}: CreateJsonRpcEngineOptions) {\n const engine = new JsonRpcEngine();\n engine.push(createMockMiddleware(store));\n\n // The hooks here do not match the hooks used by the clients, so this\n // middleware should not be used outside of the simulation environment.\n engine.push(createInternalMethodsMiddleware(restrictedHooks));\n engine.push(createSnapsMethodMiddleware(true, permittedHooks));\n\n engine.push(permissionMiddleware);\n engine.push(\n createFetchMiddleware({\n btoa: globalThis.btoa,\n fetch: globalThis.fetch,\n rpcUrl: endpoint,\n }),\n );\n\n return engine;\n}\n"]}
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerActions = exports.getPermittedHooks = exports.getRestrictedHooks = exports.installSnap = void 0;
4
4
  const base_controller_1 = require("@metamask/base-controller");
5
5
  const json_rpc_middleware_stream_1 = require("@metamask/json-rpc-middleware-stream");
6
- const key_tree_1 = require("@metamask/key-tree");
7
6
  const phishing_controller_1 = require("@metamask/phishing-controller");
8
7
  const node_1 = require("@metamask/snaps-controllers/node");
9
8
  const snaps_rpc_methods_1 = require("@metamask/snaps-rpc-methods");
@@ -16,6 +15,7 @@ const helpers_1 = require("./helpers.cjs");
16
15
  const interface_1 = require("./interface.cjs");
17
16
  const methods_1 = require("./methods/index.cjs");
18
17
  const hooks_1 = require("./methods/hooks/index.cjs");
18
+ const get_mnemonic_seed_1 = require("./methods/hooks/get-mnemonic-seed.cjs");
19
19
  const middleware_1 = require("./middleware/index.cjs");
20
20
  const options_1 = require("./options.cjs");
21
21
  const store_1 = require("./store/index.cjs");
@@ -122,7 +122,8 @@ exports.installSnap = installSnap;
122
122
  */
123
123
  function getRestrictedHooks(options) {
124
124
  return {
125
- getMnemonic: async () => Promise.resolve((0, key_tree_1.mnemonicPhraseToBytes)(options.secretRecoveryPhrase)),
125
+ getMnemonic: (0, hooks_1.getGetMnemonicImplementation)(options.secretRecoveryPhrase),
126
+ getMnemonicSeed: (0, get_mnemonic_seed_1.getGetMnemonicSeedImplementation)(options.secretRecoveryPhrase),
126
127
  getIsLocked: () => false,
127
128
  getClientCryptography: () => ({}),
128
129
  };
@@ -148,6 +149,7 @@ function getPermittedHooks(snapId, snapFiles, controllerMessenger, runSaga) {
148
149
  getInterfaceState: (...args) => controllerMessenger.call('SnapInterfaceController:getInterface', snapId, ...args).state,
149
150
  getInterfaceContext: (...args) => controllerMessenger.call('SnapInterfaceController:getInterface', snapId, ...args).context,
150
151
  resolveInterface: async (...args) => controllerMessenger.call('SnapInterfaceController:resolveInterface', snapId, ...args),
152
+ getEntropySources: (0, hooks_1.getGetEntropySourcesImplementation)(),
151
153
  getSnapState: (0, hooks_1.getPermittedGetSnapStateMethodImplementation)(runSaga),
152
154
  updateSnapState: (0, hooks_1.getPermittedUpdateSnapStateMethodImplementation)(runSaga),
153
155
  clearSnapState: (0, hooks_1.getPermittedClearSnapStateMethodImplementation)(runSaga),