@metamask-previews/multichain-account-service 0.0.0-preview-21df933

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 (76) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +20 -0
  3. package/README.md +17 -0
  4. package/dist/MultichainAccountService.cjs +120 -0
  5. package/dist/MultichainAccountService.cjs.map +1 -0
  6. package/dist/MultichainAccountService.d.cts +55 -0
  7. package/dist/MultichainAccountService.d.cts.map +1 -0
  8. package/dist/MultichainAccountService.d.mts +55 -0
  9. package/dist/MultichainAccountService.d.mts.map +1 -0
  10. package/dist/MultichainAccountService.mjs +116 -0
  11. package/dist/MultichainAccountService.mjs.map +1 -0
  12. package/dist/index.cjs +6 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +3 -0
  15. package/dist/index.d.cts.map +1 -0
  16. package/dist/index.d.mts +3 -0
  17. package/dist/index.d.mts.map +1 -0
  18. package/dist/index.mjs +2 -0
  19. package/dist/index.mjs.map +1 -0
  20. package/dist/providers/BaseAccountProvider.cjs +59 -0
  21. package/dist/providers/BaseAccountProvider.cjs.map +1 -0
  22. package/dist/providers/BaseAccountProvider.d.cts +26 -0
  23. package/dist/providers/BaseAccountProvider.d.cts.map +1 -0
  24. package/dist/providers/BaseAccountProvider.d.mts +26 -0
  25. package/dist/providers/BaseAccountProvider.d.mts.map +1 -0
  26. package/dist/providers/BaseAccountProvider.mjs +54 -0
  27. package/dist/providers/BaseAccountProvider.mjs.map +1 -0
  28. package/dist/providers/EvmAccountProvider.cjs +14 -0
  29. package/dist/providers/EvmAccountProvider.cjs.map +1 -0
  30. package/dist/providers/EvmAccountProvider.d.cts +6 -0
  31. package/dist/providers/EvmAccountProvider.d.cts.map +1 -0
  32. package/dist/providers/EvmAccountProvider.d.mts +6 -0
  33. package/dist/providers/EvmAccountProvider.d.mts.map +1 -0
  34. package/dist/providers/EvmAccountProvider.mjs +10 -0
  35. package/dist/providers/EvmAccountProvider.mjs.map +1 -0
  36. package/dist/providers/SolAccountProvider.cjs +15 -0
  37. package/dist/providers/SolAccountProvider.cjs.map +1 -0
  38. package/dist/providers/SolAccountProvider.d.cts +8 -0
  39. package/dist/providers/SolAccountProvider.d.cts.map +1 -0
  40. package/dist/providers/SolAccountProvider.d.mts +8 -0
  41. package/dist/providers/SolAccountProvider.d.mts.map +1 -0
  42. package/dist/providers/SolAccountProvider.mjs +11 -0
  43. package/dist/providers/SolAccountProvider.mjs.map +1 -0
  44. package/dist/tests/accounts.cjs +179 -0
  45. package/dist/tests/accounts.cjs.map +1 -0
  46. package/dist/tests/accounts.d.cts +82 -0
  47. package/dist/tests/accounts.d.cts.map +1 -0
  48. package/dist/tests/accounts.d.mts +82 -0
  49. package/dist/tests/accounts.d.mts.map +1 -0
  50. package/dist/tests/accounts.mjs +175 -0
  51. package/dist/tests/accounts.mjs.map +1 -0
  52. package/dist/tests/index.cjs +19 -0
  53. package/dist/tests/index.cjs.map +1 -0
  54. package/dist/tests/index.d.cts +3 -0
  55. package/dist/tests/index.d.cts.map +1 -0
  56. package/dist/tests/index.d.mts +3 -0
  57. package/dist/tests/index.d.mts.map +1 -0
  58. package/dist/tests/index.mjs +3 -0
  59. package/dist/tests/index.mjs.map +1 -0
  60. package/dist/tests/messenger.cjs +35 -0
  61. package/dist/tests/messenger.cjs.map +1 -0
  62. package/dist/tests/messenger.d.cts +16 -0
  63. package/dist/tests/messenger.d.cts.map +1 -0
  64. package/dist/tests/messenger.d.mts +16 -0
  65. package/dist/tests/messenger.d.mts.map +1 -0
  66. package/dist/tests/messenger.mjs +30 -0
  67. package/dist/tests/messenger.mjs.map +1 -0
  68. package/dist/types.cjs +3 -0
  69. package/dist/types.cjs.map +1 -0
  70. package/dist/types.d.cts +30 -0
  71. package/dist/types.d.cts.map +1 -0
  72. package/dist/types.d.mts +30 -0
  73. package/dist/types.d.mts.map +1 -0
  74. package/dist/types.mjs +2 -0
  75. package/dist/types.mjs.map +1 -0
  76. package/package.json +89 -0
@@ -0,0 +1,175 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _MockAccountBuilder_account;
13
+ import { EthAccountType, EthMethod, EthScope, KeyringAccountEntropyTypeOption, SolAccountType, SolMethod, SolScope } from "@metamask/keyring-api";
14
+ import { KeyringTypes } from "@metamask/keyring-controller";
15
+ import { isBip44Account } from "../providers/BaseAccountProvider.mjs";
16
+ const ETH_EOA_METHODS = [
17
+ EthMethod.PersonalSign,
18
+ EthMethod.Sign,
19
+ EthMethod.SignTransaction,
20
+ EthMethod.SignTypedDataV1,
21
+ EthMethod.SignTypedDataV3,
22
+ EthMethod.SignTypedDataV4,
23
+ ];
24
+ const SOL_METHODS = Object.values(SolMethod);
25
+ export const MOCK_SNAP_1 = {
26
+ id: 'local:mock-snap-id-1',
27
+ name: 'Mock Snap 1',
28
+ enabled: true,
29
+ manifest: {
30
+ proposedName: 'Mock Snap 1',
31
+ },
32
+ };
33
+ export const MOCK_SNAP_2 = {
34
+ id: 'local:mock-snap-id-2',
35
+ name: 'Mock Snap 2',
36
+ enabled: true,
37
+ manifest: {
38
+ proposedName: 'Mock Snap 2',
39
+ },
40
+ };
41
+ export const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';
42
+ export const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';
43
+ export const MOCK_HD_KEYRING_1 = {
44
+ type: KeyringTypes.hd,
45
+ metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },
46
+ accounts: ['0x123'],
47
+ };
48
+ export const MOCK_HD_KEYRING_2 = {
49
+ type: KeyringTypes.hd,
50
+ metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },
51
+ accounts: ['0x456'],
52
+ };
53
+ export const MOCK_HD_ACCOUNT_1 = {
54
+ id: 'mock-id-1',
55
+ address: '0x123',
56
+ options: {
57
+ entropy: {
58
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
59
+ id: MOCK_HD_KEYRING_1.metadata.id,
60
+ groupIndex: 0,
61
+ derivationPath: '',
62
+ },
63
+ },
64
+ methods: [...ETH_EOA_METHODS],
65
+ type: EthAccountType.Eoa,
66
+ scopes: [EthScope.Eoa],
67
+ metadata: {
68
+ name: 'Account 1',
69
+ keyring: { type: KeyringTypes.hd },
70
+ importTime: 0,
71
+ lastSelected: 0,
72
+ nameLastUpdatedAt: 0,
73
+ },
74
+ };
75
+ export const MOCK_HD_ACCOUNT_2 = {
76
+ id: 'mock-id-2',
77
+ address: '0x456',
78
+ options: {
79
+ entropy: {
80
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
81
+ id: MOCK_HD_KEYRING_2.metadata.id,
82
+ groupIndex: 0,
83
+ derivationPath: '',
84
+ },
85
+ },
86
+ methods: [...ETH_EOA_METHODS],
87
+ type: EthAccountType.Eoa,
88
+ scopes: [EthScope.Eoa],
89
+ metadata: {
90
+ name: 'Account 2',
91
+ keyring: { type: KeyringTypes.hd },
92
+ importTime: 0,
93
+ lastSelected: 0,
94
+ nameLastUpdatedAt: 0,
95
+ },
96
+ };
97
+ export const MOCK_SNAP_ACCOUNT_1 = {
98
+ id: 'mock-snap-id-1',
99
+ address: 'aabbccdd',
100
+ options: {
101
+ entropy: {
102
+ type: KeyringAccountEntropyTypeOption.Mnemonic,
103
+ // NOTE: shares entropy with MOCK_HD_ACCOUNT_2
104
+ id: MOCK_HD_KEYRING_2.metadata.id,
105
+ groupIndex: 0,
106
+ derivationPath: '',
107
+ },
108
+ },
109
+ methods: SOL_METHODS,
110
+ type: SolAccountType.DataAccount,
111
+ scopes: [SolScope.Mainnet],
112
+ metadata: {
113
+ name: 'Snap Account 1',
114
+ keyring: { type: KeyringTypes.snap },
115
+ snap: MOCK_SNAP_1,
116
+ importTime: 0,
117
+ lastSelected: 0,
118
+ },
119
+ };
120
+ export const MOCK_SNAP_ACCOUNT_2 = {
121
+ id: 'mock-snap-id-2',
122
+ address: '0x789',
123
+ options: {},
124
+ methods: [...ETH_EOA_METHODS],
125
+ type: EthAccountType.Eoa,
126
+ scopes: [EthScope.Eoa],
127
+ metadata: {
128
+ name: 'Snap Acc 2',
129
+ keyring: { type: KeyringTypes.snap },
130
+ snap: MOCK_SNAP_2,
131
+ importTime: 0,
132
+ lastSelected: 0,
133
+ },
134
+ };
135
+ export const MOCK_HARDWARE_ACCOUNT_1 = {
136
+ id: 'mock-hardware-id-1',
137
+ address: '0xABC',
138
+ options: {},
139
+ methods: [...ETH_EOA_METHODS],
140
+ type: EthAccountType.Eoa,
141
+ scopes: [EthScope.Eoa],
142
+ metadata: {
143
+ name: 'Hardware Acc 1',
144
+ keyring: { type: KeyringTypes.ledger },
145
+ importTime: 0,
146
+ lastSelected: 0,
147
+ },
148
+ };
149
+ export class MockAccountBuilder {
150
+ constructor(account) {
151
+ _MockAccountBuilder_account.set(this, void 0);
152
+ // Make a deep-copy to avoid mutating the same ref.
153
+ __classPrivateFieldSet(this, _MockAccountBuilder_account, JSON.parse(JSON.stringify(account)), "f");
154
+ }
155
+ static from(account) {
156
+ return new MockAccountBuilder(account);
157
+ }
158
+ withEntropySource(entropySource) {
159
+ if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
160
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.id = entropySource;
161
+ }
162
+ return this;
163
+ }
164
+ withGroupIndex(groupIndex) {
165
+ if (isBip44Account(__classPrivateFieldGet(this, _MockAccountBuilder_account, "f"))) {
166
+ __classPrivateFieldGet(this, _MockAccountBuilder_account, "f").options.entropy.groupIndex = groupIndex;
167
+ }
168
+ return this;
169
+ }
170
+ get() {
171
+ return __classPrivateFieldGet(this, _MockAccountBuilder_account, "f");
172
+ }
173
+ }
174
+ _MockAccountBuilder_account = new WeakMap();
175
+ //# sourceMappingURL=accounts.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.mjs","sourceRoot":"","sources":["../../src/tests/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,cAAc,EACd,SAAS,EACT,QAAQ,EACR,+BAA+B,EAC/B,cAAc,EACd,SAAS,EACT,QAAQ,EACT,8BAA8B;AAC/B,OAAO,EAAE,YAAY,EAAE,qCAAqC;AAG5D,OAAO,EAAE,cAAc,EAAE,6CAAyC;AAElE,MAAM,eAAe,GAAG;IACtB,SAAS,CAAC,YAAY;IACtB,SAAS,CAAC,IAAI;IACd,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;IACzB,SAAS,CAAC,eAAe;CACjB,CAAC;AAEX,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE;QACR,YAAY,EAAE,aAAa;KAC5B;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,sBAAsB;IAC1B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,IAAI;IACb,Q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kB;QAC/B,IAAI,cAAc,CAAC,uBAAA,IAAI,mCAAS,CAAC,EAAE;YACjC,uBAAA,IAAI,mCAAS,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;SACvD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,GAAG;QACD,OAAO,uBAAA,IAAI,mCAAS,CAAC;IACvB,CAAC;CACF","sourcesContent":["import type { EntropySourceId } from '@metamask/keyring-api';\nimport {\n EthAccountType,\n EthMethod,\n EthScope,\n KeyringAccountEntropyTypeOption,\n SolAccountType,\n SolMethod,\n SolScope,\n} from '@metamask/keyring-api';\nimport { KeyringTypes } from '@metamask/keyring-controller';\nimport type { InternalAccount } from '@metamask/keyring-internal-api';\n\nimport { isBip44Account } from '../providers/BaseAccountProvider';\n\nconst ETH_EOA_METHODS = [\n EthMethod.PersonalSign,\n EthMethod.Sign,\n EthMethod.SignTransaction,\n EthMethod.SignTypedDataV1,\n EthMethod.SignTypedDataV3,\n EthMethod.SignTypedDataV4,\n] as const;\n\nconst SOL_METHODS = Object.values(SolMethod);\n\nexport const MOCK_SNAP_1 = {\n id: 'local:mock-snap-id-1',\n name: 'Mock Snap 1',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 1',\n },\n};\n\nexport const MOCK_SNAP_2 = {\n id: 'local:mock-snap-id-2',\n name: 'Mock Snap 2',\n enabled: true,\n manifest: {\n proposedName: 'Mock Snap 2',\n },\n};\n\nexport const MOCK_ENTROPY_SOURCE_1 = 'mock-keyring-id-1';\nexport const MOCK_ENTROPY_SOURCE_2 = 'mock-keyring-id-2';\n\nexport const MOCK_HD_KEYRING_1 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_1, name: 'HD Keyring 1' },\n accounts: ['0x123'],\n};\n\nexport const MOCK_HD_KEYRING_2 = {\n type: KeyringTypes.hd,\n metadata: { id: MOCK_ENTROPY_SOURCE_2, name: 'HD Keyring 2' },\n accounts: ['0x456'],\n};\n\nexport const MOCK_HD_ACCOUNT_1: InternalAccount = {\n id: 'mock-id-1',\n address: '0x123',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_1.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 1',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_HD_ACCOUNT_2: InternalAccount = {\n id: 'mock-id-2',\n address: '0x456',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Account 2',\n keyring: { type: KeyringTypes.hd },\n importTime: 0,\n lastSelected: 0,\n nameLastUpdatedAt: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_1: InternalAccount = {\n id: 'mock-snap-id-1',\n address: 'aabbccdd',\n options: {\n entropy: {\n type: KeyringAccountEntropyTypeOption.Mnemonic,\n // NOTE: shares entropy with MOCK_HD_ACCOUNT_2\n id: MOCK_HD_KEYRING_2.metadata.id,\n groupIndex: 0,\n derivationPath: '',\n },\n },\n methods: SOL_METHODS,\n type: SolAccountType.DataAccount,\n scopes: [SolScope.Mainnet],\n metadata: {\n name: 'Snap Account 1',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_1,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_SNAP_ACCOUNT_2: InternalAccount = {\n id: 'mock-snap-id-2',\n address: '0x789',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Snap Acc 2',\n keyring: { type: KeyringTypes.snap },\n snap: MOCK_SNAP_2,\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport const MOCK_HARDWARE_ACCOUNT_1: InternalAccount = {\n id: 'mock-hardware-id-1',\n address: '0xABC',\n options: {},\n methods: [...ETH_EOA_METHODS],\n type: EthAccountType.Eoa,\n scopes: [EthScope.Eoa],\n metadata: {\n name: 'Hardware Acc 1',\n keyring: { type: KeyringTypes.ledger },\n importTime: 0,\n lastSelected: 0,\n },\n};\n\nexport class MockAccountBuilder {\n readonly #account: InternalAccount;\n\n constructor(account: InternalAccount) {\n // Make a deep-copy to avoid mutating the same ref.\n this.#account = JSON.parse(JSON.stringify(account));\n }\n\n static from(account: InternalAccount): MockAccountBuilder {\n return new MockAccountBuilder(account);\n }\n\n withEntropySource(entropySource: EntropySourceId) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.id = entropySource;\n }\n return this;\n }\n\n withGroupIndex(groupIndex: number) {\n if (isBip44Account(this.#account)) {\n this.#account.options.entropy.groupIndex = groupIndex;\n }\n return this;\n }\n\n get() {\n return this.#account;\n }\n}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./accounts.cjs"), exports);
18
+ __exportStar(require("./messenger.cjs"), exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA2B;AAC3B,kDAA4B","sourcesContent":["export * from './accounts';\nexport * from './messenger';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./accounts.cjs";
2
+ export * from "./messenger.cjs";
3
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,+BAA2B;AAC3B,gCAA4B"}
@@ -0,0 +1,3 @@
1
+ export * from "./accounts.mjs";
2
+ export * from "./messenger.mjs";
3
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,+BAA2B;AAC3B,gCAA4B"}
@@ -0,0 +1,3 @@
1
+ export * from "./accounts.mjs";
2
+ export * from "./messenger.mjs";
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/tests/index.ts"],"names":[],"mappings":"AAAA,+BAA2B;AAC3B,gCAA4B","sourcesContent":["export * from './accounts';\nexport * from './messenger';\n"]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMultichainAccountServiceMessenger = exports.getRootMessenger = void 0;
4
+ const base_controller_1 = require("@metamask/base-controller");
5
+ /**
6
+ * Creates a new root messenger instance for testing.
7
+ *
8
+ * @returns A new Messenger instance.
9
+ */
10
+ function getRootMessenger() {
11
+ return new base_controller_1.Messenger();
12
+ }
13
+ exports.getRootMessenger = getRootMessenger;
14
+ /**
15
+ * Retrieves a restricted messenger for the MultichainAccountService.
16
+ *
17
+ * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().
18
+ * @returns The restricted messenger for the MultichainAccountService.
19
+ */
20
+ function getMultichainAccountServiceMessenger(messenger) {
21
+ return messenger.getRestricted({
22
+ name: 'MultichainAccountService',
23
+ allowedEvents: ['KeyringController:stateChange'],
24
+ allowedActions: [
25
+ 'AccountsController:getAccount',
26
+ 'AccountsController:getAccountByAddress',
27
+ 'AccountsController:listMultichainAccounts',
28
+ 'SnapController:handleRequest',
29
+ 'KeyringController:withKeyring',
30
+ 'KeyringController:getState',
31
+ ],
32
+ });
33
+ }
34
+ exports.getMultichainAccountServiceMessenger = getMultichainAccountServiceMessenger;
35
+ //# sourceMappingURL=messenger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messenger.cjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":";;;AAAA,+DAAsD;AAUtD;;;;GAIG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,2BAAS,EAGjB,CAAC;AACN,CAAC;AALD,4CAKC;AAED;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC;AAfD,oFAeC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { Messenger } from "@metamask/base-controller";
2
+ import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.cjs";
3
+ /**
4
+ * Creates a new root messenger instance for testing.
5
+ *
6
+ * @returns A new Messenger instance.
7
+ */
8
+ export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
9
+ /**
10
+ * Retrieves a restricted messenger for the MultichainAccountService.
11
+ *
12
+ * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().
13
+ * @returns The restricted messenger for the MultichainAccountService.
14
+ */
15
+ export declare function getMultichainAccountServiceMessenger(messenger: ReturnType<typeof getRootMessenger>): MultichainAccountServiceMessenger;
16
+ //# sourceMappingURL=messenger.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messenger.d.cts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
@@ -0,0 +1,16 @@
1
+ import { Messenger } from "@metamask/base-controller";
2
+ import type { AllowedActions, MultichainAccountServiceMessenger } from "../types.mjs";
3
+ /**
4
+ * Creates a new root messenger instance for testing.
5
+ *
6
+ * @returns A new Messenger instance.
7
+ */
8
+ export declare function getRootMessenger(): Messenger<AllowedActions, import("@metamask/keyring-controller").KeyringControllerStateChangeEvent>;
9
+ /**
10
+ * Retrieves a restricted messenger for the MultichainAccountService.
11
+ *
12
+ * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().
13
+ * @returns The restricted messenger for the MultichainAccountService.
14
+ */
15
+ export declare function getMultichainAccountServiceMessenger(messenger: ReturnType<typeof getRootMessenger>): MultichainAccountServiceMessenger;
16
+ //# sourceMappingURL=messenger.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messenger.d.mts","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAEtD,OAAO,KAAK,EACV,cAAc,EAId,iCAAiC,EAClC,qBAAiB;AAElB;;;;GAIG;AACH,wBAAgB,gBAAgB,wGAK/B;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,SAAS,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC7C,iCAAiC,CAanC"}
@@ -0,0 +1,30 @@
1
+ import { Messenger } from "@metamask/base-controller";
2
+ /**
3
+ * Creates a new root messenger instance for testing.
4
+ *
5
+ * @returns A new Messenger instance.
6
+ */
7
+ export function getRootMessenger() {
8
+ return new Messenger();
9
+ }
10
+ /**
11
+ * Retrieves a restricted messenger for the MultichainAccountService.
12
+ *
13
+ * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().
14
+ * @returns The restricted messenger for the MultichainAccountService.
15
+ */
16
+ export function getMultichainAccountServiceMessenger(messenger) {
17
+ return messenger.getRestricted({
18
+ name: 'MultichainAccountService',
19
+ allowedEvents: ['KeyringController:stateChange'],
20
+ allowedActions: [
21
+ 'AccountsController:getAccount',
22
+ 'AccountsController:getAccountByAddress',
23
+ 'AccountsController:listMultichainAccounts',
24
+ 'SnapController:handleRequest',
25
+ 'KeyringController:withKeyring',
26
+ 'KeyringController:getState',
27
+ ],
28
+ });
29
+ }
30
+ //# sourceMappingURL=messenger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messenger.mjs","sourceRoot":"","sources":["../../src/tests/messenger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kCAAkC;AAUtD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,EAGjB,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAClD,SAA8C;IAE9C,OAAO,SAAS,CAAC,aAAa,CAAC;QAC7B,IAAI,EAAE,0BAA0B;QAChC,aAAa,EAAE,CAAC,+BAA+B,CAAC;QAChD,cAAc,EAAE;YACd,+BAA+B;YAC/B,wCAAwC;YACxC,2CAA2C;YAC3C,8BAA8B;YAC9B,+BAA+B;YAC/B,4BAA4B;SAC7B;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Messenger } from '@metamask/base-controller';\n\nimport type {\n AllowedActions,\n AllowedEvents,\n MultichainAccountServiceActions,\n MultichainAccountServiceEvents,\n MultichainAccountServiceMessenger,\n} from '../types';\n\n/**\n * Creates a new root messenger instance for testing.\n *\n * @returns A new Messenger instance.\n */\nexport function getRootMessenger() {\n return new Messenger<\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents\n >();\n}\n\n/**\n * Retrieves a restricted messenger for the MultichainAccountService.\n *\n * @param messenger - The root messenger instance. Defaults to a new Messenger created by getRootMessenger().\n * @returns The restricted messenger for the MultichainAccountService.\n */\nexport function getMultichainAccountServiceMessenger(\n messenger: ReturnType<typeof getRootMessenger>,\n): MultichainAccountServiceMessenger {\n return messenger.getRestricted({\n name: 'MultichainAccountService',\n allowedEvents: ['KeyringController:stateChange'],\n allowedActions: [\n 'AccountsController:getAccount',\n 'AccountsController:getAccountByAddress',\n 'AccountsController:listMultichainAccounts',\n 'SnapController:handleRequest',\n 'KeyringController:withKeyring',\n 'KeyringController:getState',\n ],\n });\n}\n"]}
package/dist/types.cjs ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents = KeyringControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
@@ -0,0 +1,30 @@
1
+ import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
2
+ import type { RestrictedMessenger } from "@metamask/base-controller";
3
+ import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
4
+ import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
5
+ /**
6
+ * All actions that {@link MultichainAccountService} registers so that other
7
+ * modules can call them.
8
+ */
9
+ export type MultichainAccountServiceActions = never;
10
+ /**
11
+ * All events that {@link MultichainAccountService} publishes so that other modules
12
+ * can subscribe to them.
13
+ */
14
+ export type MultichainAccountServiceEvents = never;
15
+ /**
16
+ * All actions registered by other modules that {@link MultichainAccountService}
17
+ * calls.
18
+ */
19
+ export type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction;
20
+ /**
21
+ * All events published by other modules that {@link MultichainAccountService}
22
+ * subscribes to.
23
+ */
24
+ export type AllowedEvents = KeyringControllerStateChangeEvent;
25
+ /**
26
+ * The messenger restricted to actions and events that
27
+ * {@link MultichainAccountService} needs to access.
28
+ */
29
+ export type MultichainAccountServiceMessenger = RestrictedMessenger<'MultichainAccountService', MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
30
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { AccountsControllerGetAccountAction, AccountsControllerGetAccountByAddressAction, AccountsControllerListMultichainAccountsAction } from "@metamask/accounts-controller";
2
+ import type { RestrictedMessenger } from "@metamask/base-controller";
3
+ import type { KeyringControllerGetStateAction, KeyringControllerStateChangeEvent, KeyringControllerWithKeyringAction } from "@metamask/keyring-controller";
4
+ import type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from "@metamask/snaps-controllers";
5
+ /**
6
+ * All actions that {@link MultichainAccountService} registers so that other
7
+ * modules can call them.
8
+ */
9
+ export type MultichainAccountServiceActions = never;
10
+ /**
11
+ * All events that {@link MultichainAccountService} publishes so that other modules
12
+ * can subscribe to them.
13
+ */
14
+ export type MultichainAccountServiceEvents = never;
15
+ /**
16
+ * All actions registered by other modules that {@link MultichainAccountService}
17
+ * calls.
18
+ */
19
+ export type AllowedActions = AccountsControllerListMultichainAccountsAction | AccountsControllerGetAccountAction | AccountsControllerGetAccountByAddressAction | SnapControllerHandleSnapRequestAction | KeyringControllerWithKeyringAction | KeyringControllerGetStateAction;
20
+ /**
21
+ * All events published by other modules that {@link MultichainAccountService}
22
+ * subscribes to.
23
+ */
24
+ export type AllowedEvents = KeyringControllerStateChangeEvent;
25
+ /**
26
+ * The messenger restricted to actions and events that
27
+ * {@link MultichainAccountService} needs to access.
28
+ */
29
+ export type MultichainAccountServiceMessenger = RestrictedMessenger<'MultichainAccountService', MultichainAccountServiceActions | AllowedActions, MultichainAccountServiceEvents | AllowedEvents, AllowedActions['type'], AllowedEvents['type']>;
30
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,8CAA8C,EAC/C,sCAAsC;AACvC,OAAO,KAAK,EAAE,mBAAmB,EAAE,kCAAkC;AACrE,OAAO,KAAK,EACV,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,EACnC,qCAAqC;AACtC,OAAO,KAAK,EAAE,iBAAiB,IAAI,qCAAqC,EAAE,oCAAoC;AAE9G;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,KAAK,CAAC;AACpD;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,CAAC;AAEnD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,8CAA8C,GAC9C,kCAAkC,GAClC,2CAA2C,GAC3C,qCAAqC,GACrC,kCAAkC,GAClC,+BAA+B,CAAC;AAEpC;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,iCAAiC,GAAG,mBAAmB,CACjE,0BAA0B,EAC1B,+BAA+B,GAAG,cAAc,EAChD,8BAA8B,GAAG,aAAa,EAC9C,cAAc,CAAC,MAAM,CAAC,EACtB,aAAa,CAAC,MAAM,CAAC,CACtB,CAAC"}
package/dist/types.mjs ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AccountsControllerGetAccountAction,\n AccountsControllerGetAccountByAddressAction,\n AccountsControllerListMultichainAccountsAction,\n} from '@metamask/accounts-controller';\nimport type { RestrictedMessenger } from '@metamask/base-controller';\nimport type {\n KeyringControllerGetStateAction,\n KeyringControllerStateChangeEvent,\n KeyringControllerWithKeyringAction,\n} from '@metamask/keyring-controller';\nimport type { HandleSnapRequest as SnapControllerHandleSnapRequestAction } from '@metamask/snaps-controllers';\n\n/**\n * All actions that {@link MultichainAccountService} registers so that other\n * modules can call them.\n */\nexport type MultichainAccountServiceActions = never;\n/**\n * All events that {@link MultichainAccountService} publishes so that other modules\n * can subscribe to them.\n */\nexport type MultichainAccountServiceEvents = never;\n\n/**\n * All actions registered by other modules that {@link MultichainAccountService}\n * calls.\n */\nexport type AllowedActions =\n | AccountsControllerListMultichainAccountsAction\n | AccountsControllerGetAccountAction\n | AccountsControllerGetAccountByAddressAction\n | SnapControllerHandleSnapRequestAction\n | KeyringControllerWithKeyringAction\n | KeyringControllerGetStateAction;\n\n/**\n * All events published by other modules that {@link MultichainAccountService}\n * subscribes to.\n */\nexport type AllowedEvents = KeyringControllerStateChangeEvent;\n\n/**\n * The messenger restricted to actions and events that\n * {@link MultichainAccountService} needs to access.\n */\nexport type MultichainAccountServiceMessenger = RestrictedMessenger<\n 'MultichainAccountService',\n MultichainAccountServiceActions | AllowedActions,\n MultichainAccountServiceEvents | AllowedEvents,\n AllowedActions['type'],\n AllowedEvents['type']\n>;\n"]}
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@metamask-previews/multichain-account-service",
3
+ "version": "0.0.0-preview-21df933",
4
+ "description": "Service to manage multichain accounts",
5
+ "keywords": [
6
+ "MetaMask",
7
+ "Ethereum"
8
+ ],
9
+ "homepage": "https://github.com/MetaMask/core/tree/main/packages/multichain-account-service#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/MetaMask/core/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/MetaMask/core.git"
16
+ },
17
+ "license": "MIT",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
34
+ "files": [
35
+ "dist/"
36
+ ],
37
+ "scripts": {
38
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
39
+ "build:docs": "typedoc",
40
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/multichain-account-service",
41
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/multichain-account-service",
42
+ "publish:preview": "yarn npm publish --tag preview",
43
+ "since-latest-release": "../../scripts/since-latest-release.sh",
44
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
45
+ "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
46
+ "test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
47
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
48
+ },
49
+ "dependencies": {
50
+ "@metamask/account-api": "^0.2.0",
51
+ "@metamask/base-controller": "^8.0.1",
52
+ "@metamask/keyring-api": "^19.0.0",
53
+ "@metamask/keyring-internal-api": "^7.0.0",
54
+ "@metamask/keyring-snap-client": "^6.0.0",
55
+ "@metamask/snaps-sdk": "^9.0.0",
56
+ "@metamask/snaps-utils": "^11.0.0",
57
+ "@metamask/superstruct": "^3.1.0"
58
+ },
59
+ "devDependencies": {
60
+ "@metamask/accounts-controller": "^31.0.0",
61
+ "@metamask/auto-changelog": "^3.4.4",
62
+ "@metamask/eth-snap-keyring": "^14.0.0",
63
+ "@metamask/keyring-controller": "^22.1.0",
64
+ "@metamask/providers": "^22.1.0",
65
+ "@metamask/snaps-controllers": "^14.0.1",
66
+ "@types/jest": "^27.4.1",
67
+ "deepmerge": "^4.2.2",
68
+ "jest": "^27.5.1",
69
+ "ts-jest": "^27.1.4",
70
+ "typedoc": "^0.24.8",
71
+ "typedoc-plugin-missing-exports": "^2.0.0",
72
+ "typescript": "~5.2.2",
73
+ "webextension-polyfill": "^0.12.0"
74
+ },
75
+ "peerDependencies": {
76
+ "@metamask/accounts-controller": "^31.0.0",
77
+ "@metamask/keyring-controller": "^22.0.0",
78
+ "@metamask/providers": "^22.0.0",
79
+ "@metamask/snaps-controllers": "^14.0.0",
80
+ "webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0"
81
+ },
82
+ "engines": {
83
+ "node": "^18.18 || >=20"
84
+ },
85
+ "publishConfig": {
86
+ "access": "public",
87
+ "registry": "https://registry.npmjs.org/"
88
+ }
89
+ }