@metamask/snaps-utils 5.0.1 → 5.1.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.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [5.1.0]
10
+ ### Added
11
+ - Add `getSnapDerivationPathName` and `getSlip44ProtocolName` to be shared across clients ([#2033](https://github.com/MetaMask/snaps/pull/2033))
12
+
13
+ ### Changed
14
+ - Bump `snaps-registry` ([#2020](https://hub.com/MetaMask/snaps/pull/2020))
15
+
9
16
  ## [5.0.1]
10
17
  ### Changed
11
18
  - Improve base64 encoding/decoding speeds ([#1985](https://github.com/MetaMask/snaps/pull/1985))
@@ -122,7 +129,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
122
129
  - The version of the package no longer needs to match the version of all other
123
130
  MetaMask Snaps packages.
124
131
 
125
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.1...HEAD
132
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.0...HEAD
133
+ [5.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.1...@metamask/snaps-utils@5.1.0
126
134
  [5.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.0...@metamask/snaps-utils@5.0.1
127
135
  [5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@4.0.1...@metamask/snaps-utils@5.0.0
128
136
  [4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@4.0.0...@metamask/snaps-utils@4.0.1
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ SNAPS_DERIVATION_PATHS: function() {
13
+ return SNAPS_DERIVATION_PATHS;
14
+ },
15
+ getSnapDerivationPathName: function() {
16
+ return getSnapDerivationPathName;
17
+ },
18
+ getSlip44ProtocolName: function() {
19
+ return getSlip44ProtocolName;
20
+ }
21
+ });
22
+ const _slip44 = /*#__PURE__*/ _interop_require_default(require("@metamask/slip44"));
23
+ const _array = require("./array");
24
+ function _interop_require_default(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ const SNAPS_DERIVATION_PATHS = [
30
+ {
31
+ path: [
32
+ 'm',
33
+ `44'`,
34
+ `0'`
35
+ ],
36
+ curve: 'ed25519',
37
+ name: 'Test BIP-32 Path (ed25519)'
38
+ },
39
+ {
40
+ path: [
41
+ 'm',
42
+ `44'`,
43
+ `1'`
44
+ ],
45
+ curve: 'secp256k1',
46
+ name: 'Testnet'
47
+ },
48
+ {
49
+ path: [
50
+ 'm',
51
+ `44'`,
52
+ `0'`
53
+ ],
54
+ curve: 'secp256k1',
55
+ name: 'Bitcoin Legacy'
56
+ },
57
+ {
58
+ path: [
59
+ 'm',
60
+ `49'`,
61
+ `0'`
62
+ ],
63
+ curve: 'secp256k1',
64
+ name: 'Bitcoin Nested SegWit'
65
+ },
66
+ {
67
+ path: [
68
+ 'm',
69
+ `49'`,
70
+ `1'`
71
+ ],
72
+ curve: 'secp256k1',
73
+ name: 'Bitcoin Testnet Nested SegWit'
74
+ },
75
+ {
76
+ path: [
77
+ 'm',
78
+ `84'`,
79
+ `0'`
80
+ ],
81
+ curve: 'secp256k1',
82
+ name: 'Bitcoin Native SegWit'
83
+ },
84
+ {
85
+ path: [
86
+ 'm',
87
+ `84'`,
88
+ `1'`
89
+ ],
90
+ curve: 'secp256k1',
91
+ name: 'Bitcoin Testnet Native SegWit'
92
+ },
93
+ {
94
+ path: [
95
+ 'm',
96
+ `44'`,
97
+ `501'`
98
+ ],
99
+ curve: 'ed25519',
100
+ name: 'Solana'
101
+ },
102
+ {
103
+ path: [
104
+ 'm',
105
+ `44'`,
106
+ `501'`,
107
+ "0'",
108
+ "0'"
109
+ ],
110
+ curve: 'ed25519',
111
+ name: 'Solana'
112
+ },
113
+ {
114
+ path: [
115
+ 'm',
116
+ `44'`,
117
+ `2'`
118
+ ],
119
+ curve: 'secp256k1',
120
+ name: 'Litecoin'
121
+ },
122
+ {
123
+ path: [
124
+ 'm',
125
+ `44'`,
126
+ `3'`
127
+ ],
128
+ curve: 'secp256k1',
129
+ name: 'Dogecoin'
130
+ },
131
+ {
132
+ path: [
133
+ 'm',
134
+ `44'`,
135
+ `60'`
136
+ ],
137
+ curve: 'secp256k1',
138
+ name: 'Ethereum'
139
+ },
140
+ {
141
+ path: [
142
+ 'm',
143
+ `44'`,
144
+ `118'`
145
+ ],
146
+ curve: 'secp256k1',
147
+ name: 'Atom'
148
+ },
149
+ {
150
+ path: [
151
+ 'm',
152
+ `44'`,
153
+ `145'`
154
+ ],
155
+ curve: 'secp256k1',
156
+ name: 'Bitcoin Cash'
157
+ },
158
+ {
159
+ path: [
160
+ 'm',
161
+ `44'`,
162
+ `637'`
163
+ ],
164
+ curve: 'ed25519',
165
+ name: 'Aptos'
166
+ },
167
+ {
168
+ path: [
169
+ 'm',
170
+ `44'`,
171
+ `714'`
172
+ ],
173
+ curve: 'secp256k1',
174
+ name: 'Binance (BNB)'
175
+ },
176
+ {
177
+ path: [
178
+ 'm',
179
+ `44'`,
180
+ `784'`
181
+ ],
182
+ curve: 'ed25519',
183
+ name: 'Sui'
184
+ },
185
+ {
186
+ path: [
187
+ 'm',
188
+ `44'`,
189
+ `931'`
190
+ ],
191
+ curve: 'secp256k1',
192
+ name: 'THORChain (RUNE)'
193
+ },
194
+ {
195
+ path: [
196
+ 'm',
197
+ `44'`,
198
+ `330'`
199
+ ],
200
+ curve: 'secp256k1',
201
+ name: 'Terra (LUNA)'
202
+ },
203
+ {
204
+ path: [
205
+ 'm',
206
+ `44'`,
207
+ `459'`
208
+ ],
209
+ curve: 'secp256k1',
210
+ name: 'Kava'
211
+ },
212
+ {
213
+ path: [
214
+ 'm',
215
+ `44'`,
216
+ `529'`
217
+ ],
218
+ curve: 'secp256k1',
219
+ name: 'Secret Network'
220
+ },
221
+ {
222
+ path: [
223
+ 'm',
224
+ `44'`,
225
+ `397'`,
226
+ `0'`
227
+ ],
228
+ curve: 'ed25519',
229
+ name: 'NEAR Protocol'
230
+ },
231
+ {
232
+ path: [
233
+ 'm',
234
+ `44'`,
235
+ `1'`,
236
+ `0'`
237
+ ],
238
+ curve: 'ed25519',
239
+ name: 'Testnet'
240
+ },
241
+ {
242
+ path: [
243
+ 'm',
244
+ `44'`,
245
+ `472'`
246
+ ],
247
+ curve: 'ed25519',
248
+ name: 'Arweave'
249
+ },
250
+ {
251
+ path: [
252
+ 'm',
253
+ `44'`,
254
+ `12586'`
255
+ ],
256
+ curve: 'secp256k1',
257
+ name: 'Mina'
258
+ },
259
+ {
260
+ path: [
261
+ 'm',
262
+ `44'`,
263
+ `1729'`,
264
+ `0'`,
265
+ `0'`
266
+ ],
267
+ curve: 'ed25519',
268
+ name: 'Tezos'
269
+ },
270
+ {
271
+ path: [
272
+ 'm',
273
+ `1789'`,
274
+ `0'`
275
+ ],
276
+ curve: 'ed25519',
277
+ name: 'Vega'
278
+ }
279
+ ];
280
+ function getSnapDerivationPathName(path, curve) {
281
+ const pathMetadata = SNAPS_DERIVATION_PATHS.find((derivationPath)=>derivationPath.curve === curve && (0, _array.isEqual)(derivationPath.path, path));
282
+ if (pathMetadata) {
283
+ return pathMetadata.name;
284
+ }
285
+ // If the curve is secp256k1 and the path is a valid BIP44 path
286
+ // we try looking for the network/protocol name in SLIP44
287
+ if (curve === 'secp256k1' && path[0] === 'm' && path[1] === `44'` && path[2].endsWith(`'`)) {
288
+ const coinType = path[2].slice(0, -1);
289
+ return getSlip44ProtocolName(coinType) ?? null;
290
+ }
291
+ return null;
292
+ }
293
+ function getSlip44ProtocolName(coinType) {
294
+ if (String(coinType) === '1') {
295
+ return 'Test Networks';
296
+ }
297
+ return _slip44.default[coinType]?.name ?? null;
298
+ }
299
+
300
+ //# sourceMappingURL=derivation-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/derivation-paths.ts"],"sourcesContent":["import type { SupportedCurve } from '@metamask/key-tree';\nimport slip44 from '@metamask/slip44';\n\nimport { isEqual } from './array';\n\nexport type SnapsDerivationPath = {\n path: ['m', ...string[]];\n curve: SupportedCurve;\n name: string;\n};\n\nexport const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[] = [\n {\n path: ['m', `44'`, `0'`],\n curve: 'ed25519',\n name: 'Test BIP-32 Path (ed25519)',\n },\n {\n path: ['m', `44'`, `1'`],\n curve: 'secp256k1',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Legacy',\n },\n {\n path: ['m', `49'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Nested SegWit',\n },\n {\n path: ['m', `49'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Nested SegWit',\n },\n {\n path: ['m', `84'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Native SegWit',\n },\n {\n path: ['m', `84'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Native SegWit',\n },\n {\n path: ['m', `44'`, `501'`],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `501'`, \"0'\", \"0'\"],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `2'`],\n curve: 'secp256k1',\n name: 'Litecoin',\n },\n {\n path: ['m', `44'`, `3'`],\n curve: 'secp256k1',\n name: 'Dogecoin',\n },\n {\n path: ['m', `44'`, `60'`],\n curve: 'secp256k1',\n name: 'Ethereum',\n },\n {\n path: ['m', `44'`, `118'`],\n curve: 'secp256k1',\n name: 'Atom',\n },\n {\n path: ['m', `44'`, `145'`],\n curve: 'secp256k1',\n name: 'Bitcoin Cash',\n },\n {\n path: ['m', `44'`, `637'`],\n curve: 'ed25519',\n name: 'Aptos',\n },\n {\n path: ['m', `44'`, `714'`],\n curve: 'secp256k1',\n name: 'Binance (BNB)',\n },\n {\n path: ['m', `44'`, `784'`],\n curve: 'ed25519',\n name: 'Sui',\n },\n {\n path: ['m', `44'`, `931'`],\n curve: 'secp256k1',\n name: 'THORChain (RUNE)',\n },\n {\n path: ['m', `44'`, `330'`],\n curve: 'secp256k1',\n name: 'Terra (LUNA)',\n },\n {\n path: ['m', `44'`, `459'`],\n curve: 'secp256k1',\n name: 'Kava',\n },\n {\n path: ['m', `44'`, `529'`],\n curve: 'secp256k1',\n name: 'Secret Network',\n },\n {\n path: ['m', `44'`, `397'`, `0'`],\n curve: 'ed25519',\n name: 'NEAR Protocol',\n },\n {\n path: ['m', `44'`, `1'`, `0'`],\n curve: 'ed25519',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `472'`],\n curve: 'ed25519',\n name: 'Arweave',\n },\n {\n path: ['m', `44'`, `12586'`],\n curve: 'secp256k1',\n name: 'Mina',\n },\n {\n path: ['m', `44'`, `1729'`, `0'`, `0'`],\n curve: 'ed25519',\n name: 'Tezos',\n },\n {\n path: ['m', `1789'`, `0'`],\n curve: 'ed25519',\n name: 'Vega',\n },\n];\n\n/**\n * Gets the name of a derivation path supported by snaps.\n *\n * @param path - The derivation path.\n * @param curve - The curve used to derive the keys.\n * @returns The name of the derivation path, otherwise null.\n */\nexport function getSnapDerivationPathName(\n path: SnapsDerivationPath['path'],\n curve: SupportedCurve,\n): string | null {\n const pathMetadata = SNAPS_DERIVATION_PATHS.find(\n (derivationPath) =>\n derivationPath.curve === curve && isEqual(derivationPath.path, path),\n );\n\n if (pathMetadata) {\n return pathMetadata.name;\n }\n\n // If the curve is secp256k1 and the path is a valid BIP44 path\n // we try looking for the network/protocol name in SLIP44\n if (\n curve === 'secp256k1' &&\n path[0] === 'm' &&\n path[1] === `44'` &&\n path[2].endsWith(`'`)\n ) {\n const coinType = path[2].slice(0, -1);\n return getSlip44ProtocolName(coinType) ?? null;\n }\n\n return null;\n}\n\n/**\n * Gets the name of the SLIP-44 protocol corresponding to the specified\n * `coin_type`.\n *\n * @param coinType - The SLIP-44 `coin_type` value whose name\n * to retrieve.\n * @returns The name of the protocol, otherwise null.\n */\nexport function getSlip44ProtocolName(coinType: number | string) {\n if (String(coinType) === '1') {\n return 'Test Networks';\n }\n\n return slip44[coinType as keyof typeof slip44]?.name ?? null;\n}\n"],"names":["SNAPS_DERIVATION_PATHS","getSnapDerivationPathName","getSlip44ProtocolName","path","curve","name","pathMetadata","find","derivationPath","isEqual","endsWith","coinType","slice","String","slip44"],"mappings":";;;;;;;;;;;IAWaA,sBAAsB;eAAtBA;;IAiJGC,yBAAyB;eAAzBA;;IAoCAC,qBAAqB;eAArBA;;;+DA/LG;uBAEK;;;;;;AAQjB,MAAMF,yBAAgD;IAC3D;QACEG,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAA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BO,IAAI,CAC9C,CAACC,iBACCA,eAAeJ,KAAK,KAAKA,SAASK,IAAAA,cAAO,EAACD,eAAeL,IAAI,EAAEA;IAGnE,IAAIG,cAAc;QAChB,OAAOA,aAAaD,IAAI;IAC1B;IAEA,+DAA+D;IAC/D,yDAAyD;IACzD,IACED,UAAU,eACVD,IAAI,CAAC,EAAE,KAAK,OACZA,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IACjBA,IAAI,CAAC,EAAE,CAACO,QAAQ,CAAC,CAAC,CAAC,CAAC,GACpB;QACA,MAAMC,WAAWR,IAAI,CAAC,EAAE,CAACS,KAAK,CAAC,GAAG,CAAC;QACnC,OAAOV,sBAAsBS,aAAa;IAC5C;IAEA,OAAO;AACT;AAUO,SAAST,sBAAsBS,QAAyB;IAC7D,IAAIE,OAAOF,cAAc,KAAK;QAC5B,OAAO;IACT;IAEA,OAAOG,eAAM,CAACH,SAAgC,EAAEN,QAAQ;AAC1D"}
@@ -11,6 +11,7 @@ _export_star(require("./checksum"), exports);
11
11
  _export_star(require("./cronjob"), exports);
12
12
  _export_star(require("./deep-clone"), exports);
13
13
  _export_star(require("./default-endowments"), exports);
14
+ _export_star(require("./derivation-paths"), exports);
14
15
  _export_star(require("./entropy"), exports);
15
16
  _export_star(require("./errors"), exports);
16
17
  _export_star(require("./handlers"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
package/dist/cjs/index.js CHANGED
@@ -11,6 +11,7 @@ _export_star(require("./cronjob"), exports);
11
11
  _export_star(require("./checksum"), exports);
12
12
  _export_star(require("./deep-clone"), exports);
13
13
  _export_star(require("./default-endowments"), exports);
14
+ _export_star(require("./derivation-paths"), exports);
14
15
  _export_star(require("./entropy"), exports);
15
16
  _export_star(require("./eval"), exports);
16
17
  _export_star(require("./errors"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
@@ -0,0 +1,287 @@
1
+ import slip44 from '@metamask/slip44';
2
+ import { isEqual } from './array';
3
+ export const SNAPS_DERIVATION_PATHS = [
4
+ {
5
+ path: [
6
+ 'm',
7
+ `44'`,
8
+ `0'`
9
+ ],
10
+ curve: 'ed25519',
11
+ name: 'Test BIP-32 Path (ed25519)'
12
+ },
13
+ {
14
+ path: [
15
+ 'm',
16
+ `44'`,
17
+ `1'`
18
+ ],
19
+ curve: 'secp256k1',
20
+ name: 'Testnet'
21
+ },
22
+ {
23
+ path: [
24
+ 'm',
25
+ `44'`,
26
+ `0'`
27
+ ],
28
+ curve: 'secp256k1',
29
+ name: 'Bitcoin Legacy'
30
+ },
31
+ {
32
+ path: [
33
+ 'm',
34
+ `49'`,
35
+ `0'`
36
+ ],
37
+ curve: 'secp256k1',
38
+ name: 'Bitcoin Nested SegWit'
39
+ },
40
+ {
41
+ path: [
42
+ 'm',
43
+ `49'`,
44
+ `1'`
45
+ ],
46
+ curve: 'secp256k1',
47
+ name: 'Bitcoin Testnet Nested SegWit'
48
+ },
49
+ {
50
+ path: [
51
+ 'm',
52
+ `84'`,
53
+ `0'`
54
+ ],
55
+ curve: 'secp256k1',
56
+ name: 'Bitcoin Native SegWit'
57
+ },
58
+ {
59
+ path: [
60
+ 'm',
61
+ `84'`,
62
+ `1'`
63
+ ],
64
+ curve: 'secp256k1',
65
+ name: 'Bitcoin Testnet Native SegWit'
66
+ },
67
+ {
68
+ path: [
69
+ 'm',
70
+ `44'`,
71
+ `501'`
72
+ ],
73
+ curve: 'ed25519',
74
+ name: 'Solana'
75
+ },
76
+ {
77
+ path: [
78
+ 'm',
79
+ `44'`,
80
+ `501'`,
81
+ "0'",
82
+ "0'"
83
+ ],
84
+ curve: 'ed25519',
85
+ name: 'Solana'
86
+ },
87
+ {
88
+ path: [
89
+ 'm',
90
+ `44'`,
91
+ `2'`
92
+ ],
93
+ curve: 'secp256k1',
94
+ name: 'Litecoin'
95
+ },
96
+ {
97
+ path: [
98
+ 'm',
99
+ `44'`,
100
+ `3'`
101
+ ],
102
+ curve: 'secp256k1',
103
+ name: 'Dogecoin'
104
+ },
105
+ {
106
+ path: [
107
+ 'm',
108
+ `44'`,
109
+ `60'`
110
+ ],
111
+ curve: 'secp256k1',
112
+ name: 'Ethereum'
113
+ },
114
+ {
115
+ path: [
116
+ 'm',
117
+ `44'`,
118
+ `118'`
119
+ ],
120
+ curve: 'secp256k1',
121
+ name: 'Atom'
122
+ },
123
+ {
124
+ path: [
125
+ 'm',
126
+ `44'`,
127
+ `145'`
128
+ ],
129
+ curve: 'secp256k1',
130
+ name: 'Bitcoin Cash'
131
+ },
132
+ {
133
+ path: [
134
+ 'm',
135
+ `44'`,
136
+ `637'`
137
+ ],
138
+ curve: 'ed25519',
139
+ name: 'Aptos'
140
+ },
141
+ {
142
+ path: [
143
+ 'm',
144
+ `44'`,
145
+ `714'`
146
+ ],
147
+ curve: 'secp256k1',
148
+ name: 'Binance (BNB)'
149
+ },
150
+ {
151
+ path: [
152
+ 'm',
153
+ `44'`,
154
+ `784'`
155
+ ],
156
+ curve: 'ed25519',
157
+ name: 'Sui'
158
+ },
159
+ {
160
+ path: [
161
+ 'm',
162
+ `44'`,
163
+ `931'`
164
+ ],
165
+ curve: 'secp256k1',
166
+ name: 'THORChain (RUNE)'
167
+ },
168
+ {
169
+ path: [
170
+ 'm',
171
+ `44'`,
172
+ `330'`
173
+ ],
174
+ curve: 'secp256k1',
175
+ name: 'Terra (LUNA)'
176
+ },
177
+ {
178
+ path: [
179
+ 'm',
180
+ `44'`,
181
+ `459'`
182
+ ],
183
+ curve: 'secp256k1',
184
+ name: 'Kava'
185
+ },
186
+ {
187
+ path: [
188
+ 'm',
189
+ `44'`,
190
+ `529'`
191
+ ],
192
+ curve: 'secp256k1',
193
+ name: 'Secret Network'
194
+ },
195
+ {
196
+ path: [
197
+ 'm',
198
+ `44'`,
199
+ `397'`,
200
+ `0'`
201
+ ],
202
+ curve: 'ed25519',
203
+ name: 'NEAR Protocol'
204
+ },
205
+ {
206
+ path: [
207
+ 'm',
208
+ `44'`,
209
+ `1'`,
210
+ `0'`
211
+ ],
212
+ curve: 'ed25519',
213
+ name: 'Testnet'
214
+ },
215
+ {
216
+ path: [
217
+ 'm',
218
+ `44'`,
219
+ `472'`
220
+ ],
221
+ curve: 'ed25519',
222
+ name: 'Arweave'
223
+ },
224
+ {
225
+ path: [
226
+ 'm',
227
+ `44'`,
228
+ `12586'`
229
+ ],
230
+ curve: 'secp256k1',
231
+ name: 'Mina'
232
+ },
233
+ {
234
+ path: [
235
+ 'm',
236
+ `44'`,
237
+ `1729'`,
238
+ `0'`,
239
+ `0'`
240
+ ],
241
+ curve: 'ed25519',
242
+ name: 'Tezos'
243
+ },
244
+ {
245
+ path: [
246
+ 'm',
247
+ `1789'`,
248
+ `0'`
249
+ ],
250
+ curve: 'ed25519',
251
+ name: 'Vega'
252
+ }
253
+ ];
254
+ /**
255
+ * Gets the name of a derivation path supported by snaps.
256
+ *
257
+ * @param path - The derivation path.
258
+ * @param curve - The curve used to derive the keys.
259
+ * @returns The name of the derivation path, otherwise null.
260
+ */ export function getSnapDerivationPathName(path, curve) {
261
+ const pathMetadata = SNAPS_DERIVATION_PATHS.find((derivationPath)=>derivationPath.curve === curve && isEqual(derivationPath.path, path));
262
+ if (pathMetadata) {
263
+ return pathMetadata.name;
264
+ }
265
+ // If the curve is secp256k1 and the path is a valid BIP44 path
266
+ // we try looking for the network/protocol name in SLIP44
267
+ if (curve === 'secp256k1' && path[0] === 'm' && path[1] === `44'` && path[2].endsWith(`'`)) {
268
+ const coinType = path[2].slice(0, -1);
269
+ return getSlip44ProtocolName(coinType) ?? null;
270
+ }
271
+ return null;
272
+ }
273
+ /**
274
+ * Gets the name of the SLIP-44 protocol corresponding to the specified
275
+ * `coin_type`.
276
+ *
277
+ * @param coinType - The SLIP-44 `coin_type` value whose name
278
+ * to retrieve.
279
+ * @returns The name of the protocol, otherwise null.
280
+ */ export function getSlip44ProtocolName(coinType) {
281
+ if (String(coinType) === '1') {
282
+ return 'Test Networks';
283
+ }
284
+ return slip44[coinType]?.name ?? null;
285
+ }
286
+
287
+ //# sourceMappingURL=derivation-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/derivation-paths.ts"],"sourcesContent":["import type { SupportedCurve } from '@metamask/key-tree';\nimport slip44 from '@metamask/slip44';\n\nimport { isEqual } from './array';\n\nexport type SnapsDerivationPath = {\n path: ['m', ...string[]];\n curve: SupportedCurve;\n name: string;\n};\n\nexport const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[] = [\n {\n path: ['m', `44'`, `0'`],\n curve: 'ed25519',\n name: 'Test BIP-32 Path (ed25519)',\n },\n {\n path: ['m', `44'`, `1'`],\n curve: 'secp256k1',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Legacy',\n },\n {\n path: ['m', `49'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Nested SegWit',\n },\n {\n path: ['m', `49'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Nested SegWit',\n },\n {\n path: ['m', `84'`, `0'`],\n curve: 'secp256k1',\n name: 'Bitcoin Native SegWit',\n },\n {\n path: ['m', `84'`, `1'`],\n curve: 'secp256k1',\n name: 'Bitcoin Testnet Native SegWit',\n },\n {\n path: ['m', `44'`, `501'`],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `501'`, \"0'\", \"0'\"],\n curve: 'ed25519',\n name: 'Solana',\n },\n {\n path: ['m', `44'`, `2'`],\n curve: 'secp256k1',\n name: 'Litecoin',\n },\n {\n path: ['m', `44'`, `3'`],\n curve: 'secp256k1',\n name: 'Dogecoin',\n },\n {\n path: ['m', `44'`, `60'`],\n curve: 'secp256k1',\n name: 'Ethereum',\n },\n {\n path: ['m', `44'`, `118'`],\n curve: 'secp256k1',\n name: 'Atom',\n },\n {\n path: ['m', `44'`, `145'`],\n curve: 'secp256k1',\n name: 'Bitcoin Cash',\n },\n {\n path: ['m', `44'`, `637'`],\n curve: 'ed25519',\n name: 'Aptos',\n },\n {\n path: ['m', `44'`, `714'`],\n curve: 'secp256k1',\n name: 'Binance (BNB)',\n },\n {\n path: ['m', `44'`, `784'`],\n curve: 'ed25519',\n name: 'Sui',\n },\n {\n path: ['m', `44'`, `931'`],\n curve: 'secp256k1',\n name: 'THORChain (RUNE)',\n },\n {\n path: ['m', `44'`, `330'`],\n curve: 'secp256k1',\n name: 'Terra (LUNA)',\n },\n {\n path: ['m', `44'`, `459'`],\n curve: 'secp256k1',\n name: 'Kava',\n },\n {\n path: ['m', `44'`, `529'`],\n curve: 'secp256k1',\n name: 'Secret Network',\n },\n {\n path: ['m', `44'`, `397'`, `0'`],\n curve: 'ed25519',\n name: 'NEAR Protocol',\n },\n {\n path: ['m', `44'`, `1'`, `0'`],\n curve: 'ed25519',\n name: 'Testnet',\n },\n {\n path: ['m', `44'`, `472'`],\n curve: 'ed25519',\n name: 'Arweave',\n },\n {\n path: ['m', `44'`, `12586'`],\n curve: 'secp256k1',\n name: 'Mina',\n },\n {\n path: ['m', `44'`, `1729'`, `0'`, `0'`],\n curve: 'ed25519',\n name: 'Tezos',\n },\n {\n path: ['m', `1789'`, `0'`],\n curve: 'ed25519',\n name: 'Vega',\n },\n];\n\n/**\n * Gets the name of a derivation path supported by snaps.\n *\n * @param path - The derivation path.\n * @param curve - The curve used to derive the keys.\n * @returns The name of the derivation path, otherwise null.\n */\nexport function getSnapDerivationPathName(\n path: SnapsDerivationPath['path'],\n curve: SupportedCurve,\n): string | null {\n const pathMetadata = SNAPS_DERIVATION_PATHS.find(\n (derivationPath) =>\n derivationPath.curve === curve && isEqual(derivationPath.path, path),\n );\n\n if (pathMetadata) {\n return pathMetadata.name;\n }\n\n // If the curve is secp256k1 and the path is a valid BIP44 path\n // we try looking for the network/protocol name in SLIP44\n if (\n curve === 'secp256k1' &&\n path[0] === 'm' &&\n path[1] === `44'` &&\n path[2].endsWith(`'`)\n ) {\n const coinType = path[2].slice(0, -1);\n return getSlip44ProtocolName(coinType) ?? null;\n }\n\n return null;\n}\n\n/**\n * Gets the name of the SLIP-44 protocol corresponding to the specified\n * `coin_type`.\n *\n * @param coinType - The SLIP-44 `coin_type` value whose name\n * to retrieve.\n * @returns The name of the protocol, otherwise null.\n */\nexport function getSlip44ProtocolName(coinType: number | string) {\n if (String(coinType) === '1') {\n return 'Test Networks';\n }\n\n return slip44[coinType as keyof typeof slip44]?.name ?? null;\n}\n"],"names":["slip44","isEqual","SNAPS_DERIVATION_PATHS","path","curve","name","getSnapDerivationPathName","pathMetadata","find","derivationPath","endsWith","coinType","slice","getSlip44ProtocolName","String"],"mappings":"AACA,OAAOA,YAAY,mBAAmB;AAEtC,SAASC,OAAO,QAAQ,UAAU;AAQlC,OAAO,MAAMC,yBAAgD;IAC3D;QACEC,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAAC,GAAG,CAAC;YAAE,CAAC,EAAE,CAAC;SAAC;QACxBC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM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;CACD,CAAC;AAEF;;;;;;CAMC,GACD,OAAO,SAASC,0BACdH,IAAiC,EACjCC,KAAqB;IAErB,MAAMG,eAAeL,uBAAuBM,IAAI,CAC9C,CAACC,iBACCA,eAAeL,KAAK,KAAKA,SAASH,QAAQQ,eAAeN,IAAI,EAAEA;IAGnE,IAAII,cAAc;QAChB,OAAOA,aAAaF,IAAI;IAC1B;IAEA,+DAA+D;IAC/D,yDAAyD;IACzD,IACED,UAAU,eACVD,IAAI,CAAC,EAAE,KAAK,OACZA,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,IACjBA,IAAI,CAAC,EAAE,CAACO,QAAQ,CAAC,CAAC,CAAC,CAAC,GACpB;QACA,MAAMC,WAAWR,IAAI,CAAC,EAAE,CAACS,KAAK,CAAC,GAAG,CAAC;QACnC,OAAOC,sBAAsBF,aAAa;IAC5C;IAEA,OAAO;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASE,sBAAsBF,QAAyB;IAC7D,IAAIG,OAAOH,cAAc,KAAK;QAC5B,OAAO;IACT;IAEA,OAAOX,MAAM,CAACW,SAAgC,EAAEN,QAAQ;AAC1D"}
@@ -7,6 +7,7 @@ export * from './checksum';
7
7
  export * from './cronjob';
8
8
  export * from './deep-clone';
9
9
  export * from './default-endowments';
10
+ export * from './derivation-paths';
10
11
  export * from './entropy';
11
12
  export * from './errors';
12
13
  export * from './handlers';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
1
+ {"version":3,"sources":["../../src/index.browser.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './checksum';\nexport * from './cronjob';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest/index.browser';\nexport * from './namespace';\nexport * from './path';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file/index.browser';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,2BAA2B;AACzC,cAAc,cAAc;AAC5B,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,+BAA+B"}
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './cronjob';
7
7
  export * from './checksum';
8
8
  export * from './deep-clone';
9
9
  export * from './default-endowments';
10
+ export * from './derivation-paths';
10
11
  export * from './entropy';
11
12
  export * from './eval';
12
13
  export * from './errors';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './entropy';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './array';\nexport * from './auxiliary-files';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caveats';\nexport * from './cronjob';\nexport * from './checksum';\nexport * from './deep-clone';\nexport * from './default-endowments';\nexport * from './derivation-paths';\nexport * from './entropy';\nexport * from './eval';\nexport * from './errors';\nexport * from './fs';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './json';\nexport * from './json-rpc';\nexport * from './localization';\nexport * from './logging';\nexport * from './manifest';\nexport * from './mock';\nexport * from './namespace';\nexport * from './npm';\nexport * from './path';\nexport * from './post-process';\nexport * from './snaps';\nexport * from './strings';\nexport * from './structs';\nexport * from './types';\nexport * from './ui';\nexport * from './validation';\nexport * from './versions';\nexport * from './virtual-file';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,OAAO;AACrB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,QAAQ;AACtB,cAAc,SAAS;AACvB,cAAc,iBAAiB;AAC/B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,OAAO;AACrB,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB"}
@@ -0,0 +1,24 @@
1
+ import type { SupportedCurve } from '@metamask/key-tree';
2
+ export declare type SnapsDerivationPath = {
3
+ path: ['m', ...string[]];
4
+ curve: SupportedCurve;
5
+ name: string;
6
+ };
7
+ export declare const SNAPS_DERIVATION_PATHS: SnapsDerivationPath[];
8
+ /**
9
+ * Gets the name of a derivation path supported by snaps.
10
+ *
11
+ * @param path - The derivation path.
12
+ * @param curve - The curve used to derive the keys.
13
+ * @returns The name of the derivation path, otherwise null.
14
+ */
15
+ export declare function getSnapDerivationPathName(path: SnapsDerivationPath['path'], curve: SupportedCurve): string | null;
16
+ /**
17
+ * Gets the name of the SLIP-44 protocol corresponding to the specified
18
+ * `coin_type`.
19
+ *
20
+ * @param coinType - The SLIP-44 `coin_type` value whose name
21
+ * to retrieve.
22
+ * @returns The name of the protocol, otherwise null.
23
+ */
24
+ export declare function getSlip44ProtocolName(coinType: number | string): string;
@@ -7,6 +7,7 @@ export * from './checksum';
7
7
  export * from './cronjob';
8
8
  export * from './deep-clone';
9
9
  export * from './default-endowments';
10
+ export * from './derivation-paths';
10
11
  export * from './entropy';
11
12
  export * from './errors';
12
13
  export * from './handlers';
@@ -7,6 +7,7 @@ export * from './cronjob';
7
7
  export * from './checksum';
8
8
  export * from './deep-clone';
9
9
  export * from './default-endowments';
10
+ export * from './derivation-paths';
10
11
  export * from './entropy';
11
12
  export * from './eval';
12
13
  export * from './errors';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-utils",
3
- "version": "5.0.1",
3
+ "version": "5.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/MetaMask/snaps.git"
@@ -71,7 +71,8 @@
71
71
  "@metamask/key-tree": "^9.0.0",
72
72
  "@metamask/permission-controller": "^6.0.0",
73
73
  "@metamask/rpc-errors": "^6.1.0",
74
- "@metamask/snaps-registry": "^2.1.1",
74
+ "@metamask/slip44": "^3.1.0",
75
+ "@metamask/snaps-registry": "^3.0.0",
75
76
  "@metamask/snaps-sdk": "^1.3.0",
76
77
  "@metamask/utils": "^8.2.1",
77
78
  "@noble/hashes": "^1.3.1",