@metamask/snaps-utils 5.0.1 → 5.1.1
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 +19 -1
- package/dist/cjs/cronjob.js +1 -7
- package/dist/cjs/cronjob.js.map +1 -1
- package/dist/cjs/derivation-paths.js +300 -0
- package/dist/cjs/derivation-paths.js.map +1 -0
- package/dist/cjs/index.browser.js +1 -0
- package/dist/cjs/index.browser.js.map +1 -1
- package/dist/cjs/index.executionenv.js +1 -0
- package/dist/cjs/index.executionenv.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/cronjob.js +2 -8
- package/dist/esm/cronjob.js.map +1 -1
- package/dist/esm/derivation-paths.js +287 -0
- package/dist/esm/derivation-paths.js.map +1 -0
- package/dist/esm/index.browser.js +1 -0
- package/dist/esm/index.browser.js.map +1 -1
- package/dist/esm/index.executionenv.js +1 -0
- package/dist/esm/index.executionenv.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/types/derivation-paths.d.ts +24 -0
- package/dist/types/index.browser.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.executionenv.d.ts +1 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [5.1.1]
|
|
10
|
+
### Changed
|
|
11
|
+
- Fix missing export ([#2045](https://github.com/MetaMask/snaps/pull/2045))
|
|
12
|
+
- Bump `@metamask/permission-controller` from `6.0.0` to `7.0.0` ([#2064](https://github.com/MetaMask/snaps/pull/2064))
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
- Remove support for object-like syntax for cronjobs ([#2057](https://github.com/MetaMask/snaps/pull/2057))
|
|
16
|
+
- Since this never worked in the first place we aren't marking it as breaking.
|
|
17
|
+
|
|
18
|
+
## [5.1.0]
|
|
19
|
+
### Added
|
|
20
|
+
- Add `getSnapDerivationPathName` and `getSlip44ProtocolName` to be shared across clients ([#2033](https://github.com/MetaMask/snaps/pull/2033))
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Bump `snaps-registry` ([#2020](https://hub.com/MetaMask/snaps/pull/2020))
|
|
24
|
+
|
|
9
25
|
## [5.0.1]
|
|
10
26
|
### Changed
|
|
11
27
|
- Improve base64 encoding/decoding speeds ([#1985](https://github.com/MetaMask/snaps/pull/1985))
|
|
@@ -122,7 +138,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
122
138
|
- The version of the package no longer needs to match the version of all other
|
|
123
139
|
MetaMask Snaps packages.
|
|
124
140
|
|
|
125
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.
|
|
141
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.1...HEAD
|
|
142
|
+
[5.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.1.0...@metamask/snaps-utils@5.1.1
|
|
143
|
+
[5.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.1...@metamask/snaps-utils@5.1.0
|
|
126
144
|
[5.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@5.0.0...@metamask/snaps-utils@5.0.1
|
|
127
145
|
[5.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@4.0.1...@metamask/snaps-utils@5.0.0
|
|
128
146
|
[4.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-utils@4.0.0...@metamask/snaps-utils@4.0.1
|
package/dist/cjs/cronjob.js
CHANGED
|
@@ -40,13 +40,7 @@ const CronjobRpcRequestStruct = (0, _superstruct.object)({
|
|
|
40
40
|
method: (0, _superstruct.string)(),
|
|
41
41
|
params: (0, _superstruct.optional)(_utils.JsonRpcParamsStruct)
|
|
42
42
|
});
|
|
43
|
-
const CronExpressionStruct = (0, _superstruct.refine)((0, _superstruct.
|
|
44
|
-
minute: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
45
|
-
hour: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
46
|
-
dayOfMonth: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
47
|
-
month: (0, _superstruct.optional)((0, _superstruct.string)()),
|
|
48
|
-
dayOfWeek: (0, _superstruct.optional)((0, _superstruct.string)())
|
|
49
|
-
}), (value)=>`${value.minute ?? '*'} ${value.hour ?? '*'} ${value.dayOfMonth ?? '*'} ${value.month ?? '*'} ${value.dayOfWeek ?? '*'}`), 'CronExpression', (value)=>{
|
|
43
|
+
const CronExpressionStruct = (0, _superstruct.refine)((0, _superstruct.string)(), 'CronExpression', (value)=>{
|
|
50
44
|
try {
|
|
51
45
|
(0, _cronparser.parseExpression)(value);
|
|
52
46
|
return true;
|
package/dist/cjs/cronjob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import {\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcVersionStruct,\n} from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import {\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcVersionStruct,\n} from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport { array, create, object, optional, refine, string } from 'superstruct';\n\nexport const CronjobRpcRequestStruct = object({\n jsonrpc: optional(JsonRpcVersionStruct),\n id: optional(JsonRpcIdStruct),\n method: string(),\n params: optional(JsonRpcParamsStruct),\n});\n\nexport type CronjobRpcRequest = Infer<typeof CronjobRpcRequestStruct>;\n\nexport const CronExpressionStruct = refine(\n string(),\n 'CronExpression',\n (value) => {\n try {\n parseExpression(value);\n return true;\n } catch {\n return false;\n }\n },\n);\n\nexport type CronExpression = Infer<typeof CronExpressionStruct>;\n\n/**\n * Parses a cron expression.\n *\n * @param expression - Expression to parse.\n * @returns A CronExpression class instance.\n */\nexport function parseCronExpression(expression: string | object) {\n const ensureStringExpression = create(expression, CronExpressionStruct);\n return parseExpression(ensureStringExpression);\n}\n\nexport const CronjobSpecificationStruct = object({\n expression: CronExpressionStruct,\n request: CronjobRpcRequestStruct,\n});\nexport type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;\n\n/**\n * Check if the given value is a {@link CronjobSpecification} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link CronjobSpecification} object.\n */\nexport function isCronjobSpecification(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationStruct);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const CronjobSpecificationArrayStruct = array(\n CronjobSpecificationStruct,\n);\n\n/**\n * Check if the given value is an array of {@link CronjobSpecification} objects.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid array of {@link CronjobSpecification} objects.\n */\nexport function isCronjobSpecificationArray(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationArrayStruct);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["CronjobRpcRequestStruct","CronExpressionStruct","parseCronExpression","CronjobSpecificationStruct","isCronjobSpecification","CronjobSpecificationArrayStruct","isCronjobSpecificationArray","object","jsonrpc","optional","JsonRpcVersionStruct","id","JsonRpcIdStruct","method","string","params","JsonRpcParamsStruct","refine","value","parseExpression","expression","ensureStringExpression","create","request","array"],"mappings":";;;;;;;;;;;IASaA,uBAAuB;eAAvBA;;IASAC,oBAAoB;eAApBA;;IAqBGC,mBAAmB;eAAnBA;;IAKHC,0BAA0B;eAA1BA;;IAYGC,sBAAsB;eAAtBA;;IASHC,+BAA+B;eAA/BA;;IAUGC,2BAA2B;eAA3BA;;;uBAvET;4BACyB;6BAEgC;AAEzD,MAAMN,0BAA0BO,IAAAA,mBAAM,EAAC;IAC5CC,SAASC,IAAAA,qBAAQ,EAACC,2BAAoB;IACtCC,IAAIF,IAAAA,qBAAQ,EAACG,sBAAe;IAC5BC,QAAQC,IAAAA,mBAAM;IACdC,QAAQN,IAAAA,qBAAQ,EAACO,0BAAmB;AACtC;AAIO,MAAMf,uBAAuBgB,IAAAA,mBAAM,EACxCH,IAAAA,mBAAM,KACN,kBACA,CAACI;IACC,IAAI;QACFC,IAAAA,2BAAe,EAACD;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAWK,SAAShB,oBAAoBkB,UAA2B;IAC7D,MAAMC,yBAAyBC,IAAAA,mBAAM,EAACF,YAAYnB;IAClD,OAAOkB,IAAAA,2BAAe,EAACE;AACzB;AAEO,MAAMlB,6BAA6BI,IAAAA,mBAAM,EAAC;IAC/Ca,YAAYnB;IACZsB,SAASvB;AACX;AASO,SAASI,uBAAuBc,KAAc;IACnD,IAAI;QACFI,IAAAA,mBAAM,EAACJ,OAAOf;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEO,MAAME,kCAAkCmB,IAAAA,kBAAK,EAClDrB;AASK,SAASG,4BAA4BY,KAAc;IACxD,IAAI;QACFI,IAAAA,mBAAM,EAACJ,OAAOb;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -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,qBAAq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A,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"}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
_export_star(require("./errors"), exports);
|
|
7
7
|
_export_star(require("./handlers"), exports);
|
|
8
8
|
_export_star(require("./handler-types"), exports);
|
|
9
|
+
_export_star(require("./iframe"), exports);
|
|
9
10
|
_export_star(require("./logging"), exports);
|
|
10
11
|
_export_star(require("./namespace"), exports);
|
|
11
12
|
_export_star(require("./types"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;;;;;qBAC5D;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;;;;;qBAC5D;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);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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"}
|
package/dist/esm/cronjob.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
import { JsonRpcIdStruct, JsonRpcParamsStruct, JsonRpcVersionStruct } from '@metamask/utils';
|
|
2
2
|
import { parseExpression } from 'cron-parser';
|
|
3
|
-
import { array,
|
|
3
|
+
import { array, create, object, optional, refine, string } from 'superstruct';
|
|
4
4
|
export const CronjobRpcRequestStruct = object({
|
|
5
5
|
jsonrpc: optional(JsonRpcVersionStruct),
|
|
6
6
|
id: optional(JsonRpcIdStruct),
|
|
7
7
|
method: string(),
|
|
8
8
|
params: optional(JsonRpcParamsStruct)
|
|
9
9
|
});
|
|
10
|
-
export const CronExpressionStruct = refine(
|
|
11
|
-
minute: optional(string()),
|
|
12
|
-
hour: optional(string()),
|
|
13
|
-
dayOfMonth: optional(string()),
|
|
14
|
-
month: optional(string()),
|
|
15
|
-
dayOfWeek: optional(string())
|
|
16
|
-
}), (value)=>`${value.minute ?? '*'} ${value.hour ?? '*'} ${value.dayOfMonth ?? '*'} ${value.month ?? '*'} ${value.dayOfWeek ?? '*'}`), 'CronExpression', (value)=>{
|
|
10
|
+
export const CronExpressionStruct = refine(string(), 'CronExpression', (value)=>{
|
|
17
11
|
try {
|
|
18
12
|
parseExpression(value);
|
|
19
13
|
return true;
|
package/dist/esm/cronjob.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import {\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcVersionStruct,\n} from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/cronjob.ts"],"sourcesContent":["import {\n JsonRpcIdStruct,\n JsonRpcParamsStruct,\n JsonRpcVersionStruct,\n} from '@metamask/utils';\nimport { parseExpression } from 'cron-parser';\nimport type { Infer } from 'superstruct';\nimport { array, create, object, optional, refine, string } from 'superstruct';\n\nexport const CronjobRpcRequestStruct = object({\n jsonrpc: optional(JsonRpcVersionStruct),\n id: optional(JsonRpcIdStruct),\n method: string(),\n params: optional(JsonRpcParamsStruct),\n});\n\nexport type CronjobRpcRequest = Infer<typeof CronjobRpcRequestStruct>;\n\nexport const CronExpressionStruct = refine(\n string(),\n 'CronExpression',\n (value) => {\n try {\n parseExpression(value);\n return true;\n } catch {\n return false;\n }\n },\n);\n\nexport type CronExpression = Infer<typeof CronExpressionStruct>;\n\n/**\n * Parses a cron expression.\n *\n * @param expression - Expression to parse.\n * @returns A CronExpression class instance.\n */\nexport function parseCronExpression(expression: string | object) {\n const ensureStringExpression = create(expression, CronExpressionStruct);\n return parseExpression(ensureStringExpression);\n}\n\nexport const CronjobSpecificationStruct = object({\n expression: CronExpressionStruct,\n request: CronjobRpcRequestStruct,\n});\nexport type CronjobSpecification = Infer<typeof CronjobSpecificationStruct>;\n\n/**\n * Check if the given value is a {@link CronjobSpecification} object.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid {@link CronjobSpecification} object.\n */\nexport function isCronjobSpecification(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationStruct);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const CronjobSpecificationArrayStruct = array(\n CronjobSpecificationStruct,\n);\n\n/**\n * Check if the given value is an array of {@link CronjobSpecification} objects.\n *\n * @param value - The value to check.\n * @returns Whether the value is a valid array of {@link CronjobSpecification} objects.\n */\nexport function isCronjobSpecificationArray(value: unknown): boolean {\n try {\n create(value, CronjobSpecificationArrayStruct);\n return true;\n } catch {\n return false;\n }\n}\n"],"names":["JsonRpcIdStruct","JsonRpcParamsStruct","JsonRpcVersionStruct","parseExpression","array","create","object","optional","refine","string","CronjobRpcRequestStruct","jsonrpc","id","method","params","CronExpressionStruct","value","parseCronExpression","expression","ensureStringExpression","CronjobSpecificationStruct","request","isCronjobSpecification","CronjobSpecificationArrayStruct","isCronjobSpecificationArray"],"mappings":"AAAA,SACEA,eAAe,EACfC,mBAAmB,EACnBC,oBAAoB,QACf,kBAAkB;AACzB,SAASC,eAAe,QAAQ,cAAc;AAE9C,SAASC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,MAAM,QAAQ,cAAc;AAE9E,OAAO,MAAMC,0BAA0BJ,OAAO;IAC5CK,SAASJ,SAASL;IAClBU,IAAIL,SAASP;IACba,QAAQJ;IACRK,QAAQP,SAASN;AACnB,GAAG;AAIH,OAAO,MAAMc,uBAAuBP,OAClCC,UACA,kBACA,CAACO;IACC,IAAI;QACFb,gBAAgBa;QAChB,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF,GACA;AAIF;;;;;CAKC,GACD,OAAO,SAASC,oBAAoBC,UAA2B;IAC7D,MAAMC,yBAAyBd,OAAOa,YAAYH;IAClD,OAAOZ,gBAAgBgB;AACzB;AAEA,OAAO,MAAMC,6BAA6Bd,OAAO;IAC/CY,YAAYH;IACZM,SAASX;AACX,GAAG;AAGH;;;;;CAKC,GACD,OAAO,SAASY,uBAAuBN,KAAc;IACnD,IAAI;QACFX,OAAOW,OAAOI;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,MAAMG,kCAAkCnB,MAC7CgB,4BACA;AAEF;;;;;CAKC,GACD,OAAO,SAASI,4BAA4BR,KAAc;IACxD,IAAI;QACFX,OAAOW,OAAOO;QACd,OAAO;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF"}
|
|
@@ -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;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,IAAI,CAAC;SAAC;QAC1BC,OAAO;QACPC,MAAM;IACR;IACA;QACEF,MAAM;YAAC;YAAK,CAA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E,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"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|
|
1
|
+
{"version":3,"sources":["../../src/index.executionenv.ts"],"sourcesContent":["// Special entrypoint for execution environments for bundle sizing reasons\nexport * from './errors';\nexport * from './handlers';\nexport * from './handler-types';\nexport * from './iframe';\nexport * from './logging';\nexport * from './namespace';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,UAAU"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -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;
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-utils",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -69,10 +69,11 @@
|
|
|
69
69
|
"@babel/types": "^7.23.0",
|
|
70
70
|
"@metamask/base-controller": "^4.0.0",
|
|
71
71
|
"@metamask/key-tree": "^9.0.0",
|
|
72
|
-
"@metamask/permission-controller": "^
|
|
72
|
+
"@metamask/permission-controller": "^7.0.0",
|
|
73
73
|
"@metamask/rpc-errors": "^6.1.0",
|
|
74
|
-
"@metamask/
|
|
75
|
-
"@metamask/snaps-
|
|
74
|
+
"@metamask/slip44": "^3.1.0",
|
|
75
|
+
"@metamask/snaps-registry": "^3.0.0",
|
|
76
|
+
"@metamask/snaps-sdk": "^1.3.1",
|
|
76
77
|
"@metamask/utils": "^8.2.1",
|
|
77
78
|
"@noble/hashes": "^1.3.1",
|
|
78
79
|
"@scure/base": "^1.1.1",
|