@metamask/utils 11.0.1 → 11.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,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [11.1.0]
10
+ ### Added
11
+ - Add additional CAIP-19 types (`CaipAsset{Namespace,Reference,TokenId}` support ([#227](https://github.com/MetaMask/utils/pull/227))
12
+ - Add CAIP-19 `CaipAssetTypeOrId` ([#229](https://github.com/MetaMask/utils/pull/229))
13
+ - This one combines both `CaipAssetType` and `CaipAssetId` to avoid relying on `superstruct.union`, resulting in better error messages.
14
+ - Add `definePattern` superstruct helper ([#228](https://github.com/MetaMask/utils/pull/228))
15
+ - Allow to define a `superstruct.pattern` while naming the struct and enforcing its type.
16
+
17
+ ### Changed
18
+ - Use named structs for all CAIP types ([#228](https://github.com/MetaMask/utils/pull/228))
19
+
9
20
  ## [11.0.1]
10
21
  ### Fixed
11
22
  - Improve error message for invalid JSON values ([#224](https://github.com/MetaMask/utils/pull/224))
@@ -281,7 +292,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
281
292
  ### Added
282
293
  - Initial release
283
294
 
284
- [Unreleased]: https://github.com/MetaMask/utils/compare/v11.0.1...HEAD
295
+ [Unreleased]: https://github.com/MetaMask/utils/compare/v11.1.0...HEAD
296
+ [11.1.0]: https://github.com/MetaMask/utils/compare/v11.0.1...v11.1.0
285
297
  [11.0.1]: https://github.com/MetaMask/utils/compare/v11.0.0...v11.0.1
286
298
  [11.0.0]: https://github.com/MetaMask/utils/compare/v10.0.1...v11.0.0
287
299
  [10.0.1]: https://github.com/MetaMask/utils/compare/v10.0.0...v10.0.1
@@ -1,42 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toCaipChainId = exports.parseCaipAccountId = exports.parseCaipChainId = exports.isCaipAssetId = exports.isCaipAssetType = exports.isCaipAccountAddress = exports.isCaipAccountId = exports.isCaipReference = exports.isCaipNamespace = exports.isCaipChainId = exports.KnownCaipNamespace = exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = exports.CaipAccountAddressStruct = exports.CaipAccountIdStruct = exports.CaipReferenceStruct = exports.CaipNamespaceStruct = exports.CaipChainIdStruct = exports.CAIP_ASSET_ID_REGEX = exports.CAIP_ASSET_TYPE_REGEX = exports.CAIP_ACCOUNT_ADDRESS_REGEX = exports.CAIP_ACCOUNT_ID_REGEX = exports.CAIP_REFERENCE_REGEX = exports.CAIP_NAMESPACE_REGEX = exports.CAIP_CHAIN_ID_REGEX = void 0;
3
+ exports.toCaipAssetId = exports.toCaipAssetType = exports.toCaipAccountId = exports.toCaipChainId = exports.parseCaipAssetId = exports.parseCaipAssetType = exports.parseCaipAccountId = exports.parseCaipChainId = exports.isCaipAssetId = exports.isCaipAssetType = exports.isCaipTokenId = exports.isCaipAssetReference = exports.isCaipAssetNamespace = exports.isCaipAccountAddress = exports.isCaipAccountId = exports.isCaipReference = exports.isCaipNamespace = exports.isCaipChainId = exports.KnownCaipNamespace = exports.CaipAssetTypeOrIdStruct = exports.CaipAssetIdStruct = exports.CaipAssetTypeStruct = exports.CaipTokenIdStruct = exports.CaipAssetReferenceStruct = exports.CaipAssetNamespaceStruct = exports.CaipAccountAddressStruct = exports.CaipAccountIdStruct = exports.CaipReferenceStruct = exports.CaipNamespaceStruct = exports.CaipChainIdStruct = exports.CAIP_ASSET_ID_REGEX = exports.CAIP_ASSET_TYPE_REGEX = exports.CAIP_TOKEN_ID_REGEX = exports.CAIP_ASSET_REFERENCE_REGEX = exports.CAIP_ASSET_NAMESPACE_REGEX = exports.CAIP_ACCOUNT_ADDRESS_REGEX = exports.CAIP_ACCOUNT_ID_REGEX = exports.CAIP_REFERENCE_REGEX = exports.CAIP_NAMESPACE_REGEX = exports.CAIP_CHAIN_ID_REGEX = void 0;
4
4
  const superstruct_1 = require("@metamask/superstruct");
5
+ const superstruct_2 = require("./superstruct.cjs");
5
6
  exports.CAIP_CHAIN_ID_REGEX = /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u;
6
7
  exports.CAIP_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;
7
8
  exports.CAIP_REFERENCE_REGEX = /^[-_a-zA-Z0-9]{1,32}$/u;
8
9
  exports.CAIP_ACCOUNT_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})):(?<accountAddress>[-.%a-zA-Z0-9]{1,128})$/u;
9
10
  exports.CAIP_ACCOUNT_ADDRESS_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;
11
+ exports.CAIP_ASSET_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;
12
+ exports.CAIP_ASSET_REFERENCE_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;
13
+ exports.CAIP_TOKEN_ID_REGEX = /^[-.%a-zA-Z0-9]{1,78}$/u;
10
14
  exports.CAIP_ASSET_TYPE_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;
11
15
  exports.CAIP_ASSET_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;
16
+ const CAIP_ASSET_TYPE_OR_ID_REGEX = /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})(\/(?<tokenId>[-.%a-zA-Z0-9]{1,78}))?$/u;
12
17
  /**
13
18
  * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.
14
19
  */
15
- exports.CaipChainIdStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_CHAIN_ID_REGEX);
20
+ exports.CaipChainIdStruct = (0, superstruct_2.definePattern)('CaipChainId', exports.CAIP_CHAIN_ID_REGEX);
16
21
  /**
17
22
  * A CAIP-2 namespace, i.e., the first part of a CAIP chain ID.
18
23
  */
19
- exports.CaipNamespaceStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_NAMESPACE_REGEX);
24
+ exports.CaipNamespaceStruct = (0, superstruct_2.definePattern)('CaipNamespace', exports.CAIP_NAMESPACE_REGEX);
20
25
  /**
21
26
  * A CAIP-2 reference, i.e., the second part of a CAIP chain ID.
22
27
  */
23
- exports.CaipReferenceStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_REFERENCE_REGEX);
28
+ exports.CaipReferenceStruct = (0, superstruct_2.definePattern)('CaipReference', exports.CAIP_REFERENCE_REGEX);
24
29
  /**
25
30
  * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address.
26
31
  */
27
- exports.CaipAccountIdStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_ACCOUNT_ID_REGEX);
32
+ exports.CaipAccountIdStruct = (0, superstruct_2.definePattern)('CaipAccountId', exports.CAIP_ACCOUNT_ID_REGEX);
28
33
  /**
29
34
  * A CAIP-10 account address, i.e., the third part of the CAIP account ID.
30
35
  */
31
- exports.CaipAccountAddressStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_ACCOUNT_ADDRESS_REGEX);
36
+ exports.CaipAccountAddressStruct = (0, superstruct_2.definePattern)('CaipAccountAddress', exports.CAIP_ACCOUNT_ADDRESS_REGEX);
37
+ /**
38
+ * A CAIP-19 asset namespace, i.e., a namespace domain of an asset.
39
+ */
40
+ exports.CaipAssetNamespaceStruct = (0, superstruct_2.definePattern)('CaipAssetNamespace', exports.CAIP_ASSET_NAMESPACE_REGEX);
41
+ /**
42
+ * A CAIP-19 asset reference, i.e., an identifier for an asset within a given namespace.
43
+ */
44
+ exports.CaipAssetReferenceStruct = (0, superstruct_2.definePattern)('CaipAssetReference', exports.CAIP_ASSET_REFERENCE_REGEX);
45
+ /**
46
+ * A CAIP-19 asset token ID, i.e., a unique identifier for an addressable asset of a given type
47
+ */
48
+ exports.CaipTokenIdStruct = (0, superstruct_2.definePattern)('CaipTokenId', exports.CAIP_TOKEN_ID_REGEX);
32
49
  /**
33
50
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
34
51
  */
35
- exports.CaipAssetTypeStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_ASSET_TYPE_REGEX);
52
+ exports.CaipAssetTypeStruct = (0, superstruct_2.definePattern)('CaipAssetType', exports.CAIP_ASSET_TYPE_REGEX);
36
53
  /**
37
54
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
38
55
  */
39
- exports.CaipAssetIdStruct = (0, superstruct_1.pattern)((0, superstruct_1.string)(), exports.CAIP_ASSET_ID_REGEX);
56
+ exports.CaipAssetIdStruct = (0, superstruct_2.definePattern)('CaipAssetId', exports.CAIP_ASSET_ID_REGEX);
57
+ /**
58
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
59
+ */
60
+ exports.CaipAssetTypeOrIdStruct = (0, superstruct_2.definePattern)('CaipAssetTypeOrId', CAIP_ASSET_TYPE_OR_ID_REGEX);
40
61
  /** Known CAIP namespaces. */
41
62
  var KnownCaipNamespace;
42
63
  (function (KnownCaipNamespace) {
@@ -98,6 +119,36 @@ function isCaipAccountAddress(value) {
98
119
  return (0, superstruct_1.is)(value, exports.CaipAccountAddressStruct);
99
120
  }
100
121
  exports.isCaipAccountAddress = isCaipAccountAddress;
122
+ /**
123
+ * Check if the given value is a {@link CaipAssetNamespace}.
124
+ *
125
+ * @param value - The value to check.
126
+ * @returns Whether the value is a {@link CaipAssetNamespace}.
127
+ */
128
+ function isCaipAssetNamespace(value) {
129
+ return (0, superstruct_1.is)(value, exports.CaipAssetNamespaceStruct);
130
+ }
131
+ exports.isCaipAssetNamespace = isCaipAssetNamespace;
132
+ /**
133
+ * Check if the given value is a {@link CaipAssetReference}.
134
+ *
135
+ * @param value - The value to check.
136
+ * @returns Whether the value is a {@link CaipAssetReference}.
137
+ */
138
+ function isCaipAssetReference(value) {
139
+ return (0, superstruct_1.is)(value, exports.CaipAssetReferenceStruct);
140
+ }
141
+ exports.isCaipAssetReference = isCaipAssetReference;
142
+ /**
143
+ * Check if the given value is a {@link CaipTokenId}.
144
+ *
145
+ * @param value - The value to check.
146
+ * @returns Whether the value is a {@link CaipTokenId}.
147
+ */
148
+ function isCaipTokenId(value) {
149
+ return (0, superstruct_1.is)(value, exports.CaipTokenIdStruct);
150
+ }
151
+ exports.isCaipTokenId = isCaipTokenId;
101
152
  /**
102
153
  * Check if the given value is a {@link CaipAssetType}.
103
154
  *
@@ -158,6 +209,57 @@ function parseCaipAccountId(caipAccountId) {
158
209
  };
159
210
  }
160
211
  exports.parseCaipAccountId = parseCaipAccountId;
212
+ /**
213
+ * Parse a CAIP-19 asset type to an object containing the chain ID, parsed chain ID,
214
+ * asset namespace, and asset reference
215
+ *
216
+ * This validates the CAIP-19 asset type before parsing it.
217
+ *
218
+ * @param caipAssetType - The CAIP-19 asset type to validate and parse.
219
+ * @returns The parsed CAIP-19 asset type.
220
+ */
221
+ function parseCaipAssetType(caipAssetType) {
222
+ const match = exports.CAIP_ASSET_TYPE_REGEX.exec(caipAssetType);
223
+ if (!match?.groups) {
224
+ throw new Error('Invalid CAIP asset type.');
225
+ }
226
+ return {
227
+ assetNamespace: match.groups.assetNamespace,
228
+ assetReference: match.groups.assetReference,
229
+ chainId: match.groups.chainId,
230
+ chain: {
231
+ namespace: match.groups.namespace,
232
+ reference: match.groups.reference,
233
+ },
234
+ };
235
+ }
236
+ exports.parseCaipAssetType = parseCaipAssetType;
237
+ /**
238
+ * Parse a CAIP-19 asset ID to an object containing the chain ID, parsed chain ID,
239
+ * asset namespace, asset reference, and token ID.
240
+ *
241
+ * This validates the CAIP-19 asset ID before parsing it.
242
+ *
243
+ * @param caipAssetId - The CAIP-19 asset ID to validate and parse.
244
+ * @returns The parsed CAIP-19 asset ID.
245
+ */
246
+ function parseCaipAssetId(caipAssetId) {
247
+ const match = exports.CAIP_ASSET_ID_REGEX.exec(caipAssetId);
248
+ if (!match?.groups) {
249
+ throw new Error('Invalid CAIP asset ID.');
250
+ }
251
+ return {
252
+ assetNamespace: match.groups.assetNamespace,
253
+ assetReference: match.groups.assetReference,
254
+ tokenId: match.groups.tokenId,
255
+ chainId: match.groups.chainId,
256
+ chain: {
257
+ namespace: match.groups.namespace,
258
+ reference: match.groups.reference,
259
+ },
260
+ };
261
+ }
262
+ exports.parseCaipAssetId = parseCaipAssetId;
161
263
  /**
162
264
  * Chain ID as defined per the CAIP-2
163
265
  * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}.
@@ -183,4 +285,103 @@ function toCaipChainId(namespace, reference) {
183
285
  return `${namespace}:${reference}`;
184
286
  }
185
287
  exports.toCaipChainId = toCaipChainId;
288
+ /**
289
+ * Account ID as defined per the CAIP-10
290
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md}.
291
+ *
292
+ * It defines a way to uniquely identify any blockchain account in a human-readable
293
+ * way.
294
+ *
295
+ * @param namespace - The standard (ecosystem) of similar blockchains.
296
+ * @param reference - Identity of a blockchain within a given namespace.
297
+ * @param accountAddress - The address of the blockchain account.
298
+ * @throws {@link Error}
299
+ * This exception is thrown if the inputs do not comply with the CAIP-10
300
+ * syntax specification
301
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md#syntax}.
302
+ * @returns A CAIP account ID.
303
+ */
304
+ function toCaipAccountId(namespace, reference, accountAddress) {
305
+ if (!isCaipNamespace(namespace)) {
306
+ throw new Error(`Invalid "namespace", must match: ${exports.CAIP_NAMESPACE_REGEX.toString()}`);
307
+ }
308
+ if (!isCaipReference(reference)) {
309
+ throw new Error(`Invalid "reference", must match: ${exports.CAIP_REFERENCE_REGEX.toString()}`);
310
+ }
311
+ if (!isCaipAccountAddress(accountAddress)) {
312
+ throw new Error(`Invalid "accountAddress", must match: ${exports.CAIP_ACCOUNT_ADDRESS_REGEX.toString()}`);
313
+ }
314
+ return `${namespace}:${reference}:${accountAddress}`;
315
+ }
316
+ exports.toCaipAccountId = toCaipAccountId;
317
+ /**
318
+ * Asset Type as defined per the CAIP-19
319
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
320
+ *
321
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
322
+ * way.
323
+ *
324
+ * @param namespace - The standard (ecosystem) of similar blockchains.
325
+ * @param reference - Identity of a blockchain within a given namespace.
326
+ * @param assetNamespace - The namespace domain of an asset.
327
+ * @param assetReference - The identity of an asset within a given namespace.
328
+ * @throws {@link Error}
329
+ * This exception is thrown if the inputs do not comply with the CAIP-19
330
+ * syntax specification
331
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
332
+ * @returns A CAIP asset type.
333
+ */
334
+ function toCaipAssetType(namespace, reference, assetNamespace, assetReference) {
335
+ if (!isCaipNamespace(namespace)) {
336
+ throw new Error(`Invalid "namespace", must match: ${exports.CAIP_NAMESPACE_REGEX.toString()}`);
337
+ }
338
+ if (!isCaipReference(reference)) {
339
+ throw new Error(`Invalid "reference", must match: ${exports.CAIP_REFERENCE_REGEX.toString()}`);
340
+ }
341
+ if (!isCaipAssetNamespace(assetNamespace)) {
342
+ throw new Error(`Invalid "assetNamespace", must match: ${exports.CAIP_ASSET_NAMESPACE_REGEX.toString()}`);
343
+ }
344
+ if (!isCaipAssetReference(assetReference)) {
345
+ throw new Error(`Invalid "assetReference", must match: ${exports.CAIP_ASSET_REFERENCE_REGEX.toString()}`);
346
+ }
347
+ return `${namespace}:${reference}/${assetNamespace}:${assetReference}`;
348
+ }
349
+ exports.toCaipAssetType = toCaipAssetType;
350
+ /**
351
+ * Asset ID as defined per the CAIP-19
352
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
353
+ *
354
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
355
+ * way.
356
+ *
357
+ * @param namespace - The standard (ecosystem) of similar blockchains.
358
+ * @param reference - Identity of a blockchain within a given namespace.
359
+ * @param assetNamespace - The namespace domain of an asset.
360
+ * @param assetReference - The identity of an asset within a given namespace.
361
+ * @param tokenId - The unique identifier for an addressable asset of a given type.
362
+ * @throws {@link Error}
363
+ * This exception is thrown if the inputs do not comply with the CAIP-19
364
+ * syntax specification
365
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
366
+ * @returns A CAIP asset ID.
367
+ */
368
+ function toCaipAssetId(namespace, reference, assetNamespace, assetReference, tokenId) {
369
+ if (!isCaipNamespace(namespace)) {
370
+ throw new Error(`Invalid "namespace", must match: ${exports.CAIP_NAMESPACE_REGEX.toString()}`);
371
+ }
372
+ if (!isCaipReference(reference)) {
373
+ throw new Error(`Invalid "reference", must match: ${exports.CAIP_REFERENCE_REGEX.toString()}`);
374
+ }
375
+ if (!isCaipAssetNamespace(assetNamespace)) {
376
+ throw new Error(`Invalid "assetNamespace", must match: ${exports.CAIP_ASSET_NAMESPACE_REGEX.toString()}`);
377
+ }
378
+ if (!isCaipAssetReference(assetReference)) {
379
+ throw new Error(`Invalid "assetReference", must match: ${exports.CAIP_ASSET_REFERENCE_REGEX.toString()}`);
380
+ }
381
+ if (!isCaipTokenId(tokenId)) {
382
+ throw new Error(`Invalid "tokenId", must match: ${exports.CAIP_TOKEN_ID_REGEX.toString()}`);
383
+ }
384
+ return `${namespace}:${reference}/${assetNamespace}:${assetReference}/${tokenId}`;
385
+ }
386
+ exports.toCaipAssetId = toCaipAssetId;
186
387
  //# sourceMappingURL=caip-types.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"caip-types.cjs","sourceRoot":"","sources":["../src/caip-types.ts"],"names":[],"mappings":";;;AAAA,uDAA4D;AAG/C,QAAA,mBAAmB,GAC9B,mEAAmE,CAAC;AAEzD,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAE3C,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAEhD,QAAA,qBAAqB,GAChC,wHAAwH,CAAC;AAE9G,QAAA,0BAA0B,GAAG,0BAA0B,CAAC;AAExD,QAAA,qBAAqB,GAChC,2JAA2J,CAAC;AAEjJ,QAAA,mBAAmB,GAC9B,6LAA6L,CAAC;AAEhM;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,qBAAO,EACtC,IAAA,oBAAM,GAAE,EACR,2BAAmB,CACS,CAAC;AAG/B;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAO,EAAC,IAAA,oBAAM,GAAE,EAAE,4BAAoB,CAAC,CAAC;AAG3E;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAO,EAAC,IAAA,oBAAM,GAAE,EAAE,4BAAoB,CAAC,CAAC;AAG3E;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAO,EACxC,IAAA,oBAAM,GAAE,EACR,6BAAqB,CACS,CAAC;AAGjC;;GAEG;AACU,QAAA,wBAAwB,GAAG,IAAA,qBAAO,EAC7C,IAAA,oBAAM,GAAE,EACR,kCAA0B,CAC3B,CAAC;AAGF;;GAEG;AACU,QAAA,mBAAmB,GAAG,IAAA,qBAAO,EACxC,IAAA,oBAAM,GAAE,EACR,6BAAqB,CACS,CAAC;AAGjC;;GAEG;AACU,QAAA,iBAAiB,GAAG,IAAA,qBAAO,EACtC,IAAA,oBAAM,GAAE,EACR,2BAAmB,CACS,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CAAC;AAjBD,sCAiBC","sourcesContent":["import { is, pattern, string } from '@metamask/superstruct';\nimport type { Infer, Struct } from '@metamask/superstruct';\n\nexport const CAIP_CHAIN_ID_REGEX =\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u;\n\nexport const CAIP_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;\n\nexport const CAIP_REFERENCE_REGEX = /^[-_a-zA-Z0-9]{1,32}$/u;\n\nexport const CAIP_ACCOUNT_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})):(?<accountAddress>[-.%a-zA-Z0-9]{1,128})$/u;\n\nexport const CAIP_ACCOUNT_ADDRESS_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;\n\nexport const CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nexport const CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\n/**\n * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.\n */\nexport const CaipChainIdStruct = pattern(\n string(),\n CAIP_CHAIN_ID_REGEX,\n) as Struct<CaipChainId, null>;\nexport type CaipChainId = `${string}:${string}`;\n\n/**\n * A CAIP-2 namespace, i.e., the first part of a CAIP chain ID.\n */\nexport const CaipNamespaceStruct = pattern(string(), CAIP_NAMESPACE_REGEX);\nexport type CaipNamespace = Infer<typeof CaipNamespaceStruct>;\n\n/**\n * A CAIP-2 reference, i.e., the second part of a CAIP chain ID.\n */\nexport const CaipReferenceStruct = pattern(string(), CAIP_REFERENCE_REGEX);\nexport type CaipReference = Infer<typeof CaipReferenceStruct>;\n\n/**\n * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address.\n */\nexport const CaipAccountIdStruct = pattern(\n string(),\n CAIP_ACCOUNT_ID_REGEX,\n) as Struct<CaipAccountId, null>;\nexport type CaipAccountId = `${string}:${string}:${string}`;\n\n/**\n * A CAIP-10 account address, i.e., the third part of the CAIP account ID.\n */\nexport const CaipAccountAddressStruct = pattern(\n string(),\n CAIP_ACCOUNT_ADDRESS_REGEX,\n);\nexport type CaipAccountAddress = Infer<typeof CaipAccountAddressStruct>;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct = pattern(\n string(),\n CAIP_ASSET_TYPE_REGEX,\n) as Struct<CaipAssetType, null>;\nexport type CaipAssetType = `${string}:${string}/${string}:${string}`;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct = pattern(\n string(),\n CAIP_ASSET_ID_REGEX,\n) as Struct<CaipAssetId, null>;\nexport type CaipAssetId = `${string}:${string}/${string}:${string}/${string}`;\n\n/** Known CAIP namespaces. */\nexport enum KnownCaipNamespace {\n /** BIP-122 (Bitcoin) compatible chains. */\n Bip122 = 'bip122',\n /** Solana compatible chains */\n Solana = 'solana',\n /** EIP-155 compatible chains. */\n Eip155 = 'eip155',\n Wallet = 'wallet',\n}\n\n/**\n * Check if the given value is a {@link CaipChainId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipChainId}.\n */\nexport function isCaipChainId(value: unknown): value is CaipChainId {\n return is(value, CaipChainIdStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipNamespace}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipNamespace}.\n */\nexport function isCaipNamespace(value: unknown): value is CaipNamespace {\n return is(value, CaipNamespaceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipReference}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipReference}.\n */\nexport function isCaipReference(value: unknown): value is CaipReference {\n return is(value, CaipReferenceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAccountId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAccountId}.\n */\nexport function isCaipAccountId(value: unknown): value is CaipAccountId {\n return is(value, CaipAccountIdStruct);\n}\n\n/**\n * Check if a value is a {@link CaipAccountAddress}.\n *\n * @param value - The value to validate.\n * @returns True if the value is a valid {@link CaipAccountAddress}.\n */\nexport function isCaipAccountAddress(\n value: unknown,\n): value is CaipAccountAddress {\n return is(value, CaipAccountAddressStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n\n/**\n * Parse a CAIP-2 chain ID to an object containing the namespace and reference.\n * This validates the CAIP-2 chain ID before parsing it.\n *\n * @param caipChainId - The CAIP-2 chain ID to validate and parse.\n * @returns The parsed CAIP-2 chain ID.\n */\nexport function parseCaipChainId(caipChainId: CaipChainId): {\n namespace: CaipNamespace;\n reference: CaipReference;\n} {\n const match = CAIP_CHAIN_ID_REGEX.exec(caipChainId);\n if (!match?.groups) {\n throw new Error('Invalid CAIP chain ID.');\n }\n\n return {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n };\n}\n\n/**\n * Parse an CAIP-10 account ID to an object containing the chain ID, parsed chain ID, and account address.\n * This validates the CAIP-10 account ID before parsing it.\n *\n * @param caipAccountId - The CAIP-10 account ID to validate and parse.\n * @returns The parsed CAIP-10 account ID.\n */\nexport function parseCaipAccountId(caipAccountId: CaipAccountId): {\n address: CaipAccountAddress;\n chainId: CaipChainId;\n chain: { namespace: CaipNamespace; reference: CaipReference };\n} {\n const match = CAIP_ACCOUNT_ID_REGEX.exec(caipAccountId);\n if (!match?.groups) {\n throw new Error('Invalid CAIP account ID.');\n }\n\n return {\n address: match.groups.accountAddress as CaipAccountAddress,\n chainId: match.groups.chainId as CaipChainId,\n chain: {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n },\n };\n}\n\n/**\n * Chain ID as defined per the CAIP-2\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}.\n *\n * It defines a way to uniquely identify any blockchain in a human-readable\n * way.\n *\n * @param namespace - The standard (ecosystem) of similar blockchains.\n * @param reference - Identify of a blockchain within a given namespace.\n * @throws {@link Error}\n * This exception is thrown if the inputs does not comply with the CAIP-2\n * syntax specification\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md#syntax}.\n * @returns A CAIP chain ID.\n */\nexport function toCaipChainId(\n namespace: CaipNamespace,\n reference: CaipReference,\n): CaipChainId {\n if (!isCaipNamespace(namespace)) {\n throw new Error(\n `Invalid \"namespace\", must match: ${CAIP_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipReference(reference)) {\n throw new Error(\n `Invalid \"reference\", must match: ${CAIP_REFERENCE_REGEX.toString()}`,\n );\n }\n\n return `${namespace}:${reference}`;\n}\n"]}
1
+ {"version":3,"file":"caip-types.cjs","sourceRoot":"","sources":["../src/caip-types.ts"],"names":[],"mappings":";;;AACA,uDAA2C;AAE3C,mDAA8C;AAEjC,QAAA,mBAAmB,GAC9B,mEAAmE,CAAC;AAEzD,QAAA,oBAAoB,GAAG,mBAAmB,CAAC;AAE3C,QAAA,oBAAoB,GAAG,wBAAwB,CAAC;AAEhD,QAAA,qBAAqB,GAChC,wHAAwH,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AAI,KAAK,CACb,kCAAkC,2BAAmB,CAAC,QAAQ,EAAE,EAAE,CACnE,CAAC;KACH;IAED,OAAO,GAAG,SAAS,IAAI,SAAS,IAAI,cAAc,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC;AACpF,CAAC;AAtCD,sCAsCC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport { is } from '@metamask/superstruct';\n\nimport { definePattern } from './superstruct';\n\nexport const CAIP_CHAIN_ID_REGEX =\n /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u;\n\nexport const CAIP_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;\n\nexport const CAIP_REFERENCE_REGEX = /^[-_a-zA-Z0-9]{1,32}$/u;\n\nexport const CAIP_ACCOUNT_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})):(?<accountAddress>[-.%a-zA-Z0-9]{1,128})$/u;\n\nexport const CAIP_ACCOUNT_ADDRESS_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;\n\nexport const CAIP_ASSET_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;\n\nexport const CAIP_ASSET_REFERENCE_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;\n\nexport const CAIP_TOKEN_ID_REGEX = /^[-.%a-zA-Z0-9]{1,78}$/u;\n\nexport const CAIP_ASSET_TYPE_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})$/u;\n\nexport const CAIP_ASSET_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78})$/u;\n\nconst CAIP_ASSET_TYPE_OR_ID_REGEX =\n /^(?<chainId>(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32}))\\/(?<assetNamespace>[-a-z0-9]{3,8}):(?<assetReference>[-.%a-zA-Z0-9]{1,128})(\\/(?<tokenId>[-.%a-zA-Z0-9]{1,78}))?$/u;\n\n/**\n * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.\n */\nexport const CaipChainIdStruct = definePattern<`${string}:${string}`>(\n 'CaipChainId',\n CAIP_CHAIN_ID_REGEX,\n);\nexport type CaipChainId = Infer<typeof CaipChainIdStruct>;\n\n/**\n * A CAIP-2 namespace, i.e., the first part of a CAIP chain ID.\n */\nexport const CaipNamespaceStruct = definePattern(\n 'CaipNamespace',\n CAIP_NAMESPACE_REGEX,\n);\nexport type CaipNamespace = Infer<typeof CaipNamespaceStruct>;\n\n/**\n * A CAIP-2 reference, i.e., the second part of a CAIP chain ID.\n */\nexport const CaipReferenceStruct = definePattern(\n 'CaipReference',\n CAIP_REFERENCE_REGEX,\n);\nexport type CaipReference = Infer<typeof CaipReferenceStruct>;\n\n/**\n * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address.\n */\nexport const CaipAccountIdStruct =\n definePattern<`${string}:${string}:${string}`>(\n 'CaipAccountId',\n CAIP_ACCOUNT_ID_REGEX,\n );\nexport type CaipAccountId = Infer<typeof CaipAccountIdStruct>;\n\n/**\n * A CAIP-10 account address, i.e., the third part of the CAIP account ID.\n */\nexport const CaipAccountAddressStruct = definePattern(\n 'CaipAccountAddress',\n CAIP_ACCOUNT_ADDRESS_REGEX,\n);\nexport type CaipAccountAddress = Infer<typeof CaipAccountAddressStruct>;\n\n/**\n * A CAIP-19 asset namespace, i.e., a namespace domain of an asset.\n */\nexport const CaipAssetNamespaceStruct = definePattern(\n 'CaipAssetNamespace',\n CAIP_ASSET_NAMESPACE_REGEX,\n);\nexport type CaipAssetNamespace = Infer<typeof CaipAssetNamespaceStruct>;\n\n/**\n * A CAIP-19 asset reference, i.e., an identifier for an asset within a given namespace.\n */\nexport const CaipAssetReferenceStruct = definePattern(\n 'CaipAssetReference',\n CAIP_ASSET_REFERENCE_REGEX,\n);\nexport type CaipAssetReference = Infer<typeof CaipAssetReferenceStruct>;\n\n/**\n * A CAIP-19 asset token ID, i.e., a unique identifier for an addressable asset of a given type\n */\nexport const CaipTokenIdStruct = definePattern(\n 'CaipTokenId',\n CAIP_TOKEN_ID_REGEX,\n);\nexport type CaipTokenId = Infer<typeof CaipTokenIdStruct>;\n\n/**\n * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeStruct =\n definePattern<`${string}:${string}/${string}:${string}`>(\n 'CaipAssetType',\n CAIP_ASSET_TYPE_REGEX,\n );\nexport type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;\n\n/**\n * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.\n */\nexport const CaipAssetIdStruct =\n definePattern<`${string}:${string}/${string}:${string}/${string}`>(\n 'CaipAssetId',\n CAIP_ASSET_ID_REGEX,\n );\nexport type CaipAssetId = Infer<typeof CaipAssetIdStruct>;\n\n/**\n * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.\n */\nexport const CaipAssetTypeOrIdStruct = definePattern<\n CaipAssetType | CaipAssetId\n>('CaipAssetTypeOrId', CAIP_ASSET_TYPE_OR_ID_REGEX);\nexport type CaipAssetTypeOrId = Infer<typeof CaipAssetTypeOrIdStruct>;\n\n/** Known CAIP namespaces. */\nexport enum KnownCaipNamespace {\n /** BIP-122 (Bitcoin) compatible chains. */\n Bip122 = 'bip122',\n /** Solana compatible chains */\n Solana = 'solana',\n /** EIP-155 compatible chains. */\n Eip155 = 'eip155',\n Wallet = 'wallet',\n}\n\n/**\n * Check if the given value is a {@link CaipChainId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipChainId}.\n */\nexport function isCaipChainId(value: unknown): value is CaipChainId {\n return is(value, CaipChainIdStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipNamespace}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipNamespace}.\n */\nexport function isCaipNamespace(value: unknown): value is CaipNamespace {\n return is(value, CaipNamespaceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipReference}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipReference}.\n */\nexport function isCaipReference(value: unknown): value is CaipReference {\n return is(value, CaipReferenceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAccountId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAccountId}.\n */\nexport function isCaipAccountId(value: unknown): value is CaipAccountId {\n return is(value, CaipAccountIdStruct);\n}\n\n/**\n * Check if a value is a {@link CaipAccountAddress}.\n *\n * @param value - The value to validate.\n * @returns True if the value is a valid {@link CaipAccountAddress}.\n */\nexport function isCaipAccountAddress(\n value: unknown,\n): value is CaipAccountAddress {\n return is(value, CaipAccountAddressStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetNamespace}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetNamespace}.\n */\nexport function isCaipAssetNamespace(\n value: unknown,\n): value is CaipAssetNamespace {\n return is(value, CaipAssetNamespaceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetReference}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetReference}.\n */\nexport function isCaipAssetReference(\n value: unknown,\n): value is CaipAssetReference {\n return is(value, CaipAssetReferenceStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipTokenId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipTokenId}.\n */\nexport function isCaipTokenId(value: unknown): value is CaipTokenId {\n return is(value, CaipTokenIdStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetType}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetType}.\n */\nexport function isCaipAssetType(value: unknown): value is CaipAssetType {\n return is(value, CaipAssetTypeStruct);\n}\n\n/**\n * Check if the given value is a {@link CaipAssetId}.\n *\n * @param value - The value to check.\n * @returns Whether the value is a {@link CaipAssetId}.\n */\nexport function isCaipAssetId(value: unknown): value is CaipAssetId {\n return is(value, CaipAssetIdStruct);\n}\n\n/**\n * Parse a CAIP-2 chain ID to an object containing the namespace and reference.\n * This validates the CAIP-2 chain ID before parsing it.\n *\n * @param caipChainId - The CAIP-2 chain ID to validate and parse.\n * @returns The parsed CAIP-2 chain ID.\n */\nexport function parseCaipChainId(caipChainId: CaipChainId): {\n namespace: CaipNamespace;\n reference: CaipReference;\n} {\n const match = CAIP_CHAIN_ID_REGEX.exec(caipChainId);\n if (!match?.groups) {\n throw new Error('Invalid CAIP chain ID.');\n }\n\n return {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n };\n}\n\n/**\n * Parse an CAIP-10 account ID to an object containing the chain ID, parsed chain ID, and account address.\n * This validates the CAIP-10 account ID before parsing it.\n *\n * @param caipAccountId - The CAIP-10 account ID to validate and parse.\n * @returns The parsed CAIP-10 account ID.\n */\nexport function parseCaipAccountId(caipAccountId: CaipAccountId): {\n address: CaipAccountAddress;\n chainId: CaipChainId;\n chain: { namespace: CaipNamespace; reference: CaipReference };\n} {\n const match = CAIP_ACCOUNT_ID_REGEX.exec(caipAccountId);\n if (!match?.groups) {\n throw new Error('Invalid CAIP account ID.');\n }\n\n return {\n address: match.groups.accountAddress as CaipAccountAddress,\n chainId: match.groups.chainId as CaipChainId,\n chain: {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n },\n };\n}\n\n/**\n * Parse a CAIP-19 asset type to an object containing the chain ID, parsed chain ID,\n * asset namespace, and asset reference\n *\n * This validates the CAIP-19 asset type before parsing it.\n *\n * @param caipAssetType - The CAIP-19 asset type to validate and parse.\n * @returns The parsed CAIP-19 asset type.\n */\nexport function parseCaipAssetType(caipAssetType: CaipAssetType): {\n assetNamespace: CaipAssetNamespace;\n assetReference: CaipAssetReference;\n chainId: CaipChainId;\n chain: { namespace: CaipNamespace; reference: CaipReference };\n} {\n const match = CAIP_ASSET_TYPE_REGEX.exec(caipAssetType);\n if (!match?.groups) {\n throw new Error('Invalid CAIP asset type.');\n }\n\n return {\n assetNamespace: match.groups.assetNamespace as CaipAssetNamespace,\n assetReference: match.groups.assetReference as CaipAssetReference,\n chainId: match.groups.chainId as CaipChainId,\n chain: {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n },\n };\n}\n\n/**\n * Parse a CAIP-19 asset ID to an object containing the chain ID, parsed chain ID,\n * asset namespace, asset reference, and token ID.\n *\n * This validates the CAIP-19 asset ID before parsing it.\n *\n * @param caipAssetId - The CAIP-19 asset ID to validate and parse.\n * @returns The parsed CAIP-19 asset ID.\n */\nexport function parseCaipAssetId(caipAssetId: CaipAssetId): {\n assetNamespace: CaipAssetNamespace;\n assetReference: CaipAssetReference;\n tokenId: CaipTokenId;\n chainId: CaipChainId;\n chain: { namespace: CaipNamespace; reference: CaipReference };\n} {\n const match = CAIP_ASSET_ID_REGEX.exec(caipAssetId);\n if (!match?.groups) {\n throw new Error('Invalid CAIP asset ID.');\n }\n\n return {\n assetNamespace: match.groups.assetNamespace as CaipAssetNamespace,\n assetReference: match.groups.assetReference as CaipAssetReference,\n tokenId: match.groups.tokenId as CaipTokenId,\n chainId: match.groups.chainId as CaipChainId,\n chain: {\n namespace: match.groups.namespace as CaipNamespace,\n reference: match.groups.reference as CaipReference,\n },\n };\n}\n\n/**\n * Chain ID as defined per the CAIP-2\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}.\n *\n * It defines a way to uniquely identify any blockchain in a human-readable\n * way.\n *\n * @param namespace - The standard (ecosystem) of similar blockchains.\n * @param reference - Identify of a blockchain within a given namespace.\n * @throws {@link Error}\n * This exception is thrown if the inputs does not comply with the CAIP-2\n * syntax specification\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md#syntax}.\n * @returns A CAIP chain ID.\n */\nexport function toCaipChainId(\n namespace: CaipNamespace,\n reference: CaipReference,\n): CaipChainId {\n if (!isCaipNamespace(namespace)) {\n throw new Error(\n `Invalid \"namespace\", must match: ${CAIP_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipReference(reference)) {\n throw new Error(\n `Invalid \"reference\", must match: ${CAIP_REFERENCE_REGEX.toString()}`,\n );\n }\n\n return `${namespace}:${reference}`;\n}\n\n/**\n * Account ID as defined per the CAIP-10\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md}.\n *\n * It defines a way to uniquely identify any blockchain account in a human-readable\n * way.\n *\n * @param namespace - The standard (ecosystem) of similar blockchains.\n * @param reference - Identity of a blockchain within a given namespace.\n * @param accountAddress - The address of the blockchain account.\n * @throws {@link Error}\n * This exception is thrown if the inputs do not comply with the CAIP-10\n * syntax specification\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md#syntax}.\n * @returns A CAIP account ID.\n */\nexport function toCaipAccountId(\n namespace: CaipNamespace,\n reference: CaipReference,\n accountAddress: CaipAccountAddress,\n): CaipAccountId {\n if (!isCaipNamespace(namespace)) {\n throw new Error(\n `Invalid \"namespace\", must match: ${CAIP_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipReference(reference)) {\n throw new Error(\n `Invalid \"reference\", must match: ${CAIP_REFERENCE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipAccountAddress(accountAddress)) {\n throw new Error(\n `Invalid \"accountAddress\", must match: ${CAIP_ACCOUNT_ADDRESS_REGEX.toString()}`,\n );\n }\n\n return `${namespace}:${reference}:${accountAddress}`;\n}\n\n/**\n * Asset Type as defined per the CAIP-19\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.\n *\n * It defines a way to uniquely identify any blockchain asset in a human-readable\n * way.\n *\n * @param namespace - The standard (ecosystem) of similar blockchains.\n * @param reference - Identity of a blockchain within a given namespace.\n * @param assetNamespace - The namespace domain of an asset.\n * @param assetReference - The identity of an asset within a given namespace.\n * @throws {@link Error}\n * This exception is thrown if the inputs do not comply with the CAIP-19\n * syntax specification\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.\n * @returns A CAIP asset type.\n */\nexport function toCaipAssetType(\n namespace: CaipNamespace,\n reference: CaipReference,\n assetNamespace: CaipAssetNamespace,\n assetReference: CaipAssetReference,\n): CaipAssetType {\n if (!isCaipNamespace(namespace)) {\n throw new Error(\n `Invalid \"namespace\", must match: ${CAIP_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipReference(reference)) {\n throw new Error(\n `Invalid \"reference\", must match: ${CAIP_REFERENCE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipAssetNamespace(assetNamespace)) {\n throw new Error(\n `Invalid \"assetNamespace\", must match: ${CAIP_ASSET_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipAssetReference(assetReference)) {\n throw new Error(\n `Invalid \"assetReference\", must match: ${CAIP_ASSET_REFERENCE_REGEX.toString()}`,\n );\n }\n\n return `${namespace}:${reference}/${assetNamespace}:${assetReference}`;\n}\n\n/**\n * Asset ID as defined per the CAIP-19\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.\n *\n * It defines a way to uniquely identify any blockchain asset in a human-readable\n * way.\n *\n * @param namespace - The standard (ecosystem) of similar blockchains.\n * @param reference - Identity of a blockchain within a given namespace.\n * @param assetNamespace - The namespace domain of an asset.\n * @param assetReference - The identity of an asset within a given namespace.\n * @param tokenId - The unique identifier for an addressable asset of a given type.\n * @throws {@link Error}\n * This exception is thrown if the inputs do not comply with the CAIP-19\n * syntax specification\n * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.\n * @returns A CAIP asset ID.\n */\nexport function toCaipAssetId(\n namespace: CaipNamespace,\n reference: CaipReference,\n assetNamespace: CaipAssetNamespace,\n assetReference: CaipAssetReference,\n tokenId: CaipTokenId,\n): CaipAssetId {\n if (!isCaipNamespace(namespace)) {\n throw new Error(\n `Invalid \"namespace\", must match: ${CAIP_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipReference(reference)) {\n throw new Error(\n `Invalid \"reference\", must match: ${CAIP_REFERENCE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipAssetNamespace(assetNamespace)) {\n throw new Error(\n `Invalid \"assetNamespace\", must match: ${CAIP_ASSET_NAMESPACE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipAssetReference(assetReference)) {\n throw new Error(\n `Invalid \"assetReference\", must match: ${CAIP_ASSET_REFERENCE_REGEX.toString()}`,\n );\n }\n\n if (!isCaipTokenId(tokenId)) {\n throw new Error(\n `Invalid \"tokenId\", must match: ${CAIP_TOKEN_ID_REGEX.toString()}`,\n );\n }\n\n return `${namespace}:${reference}/${assetNamespace}:${assetReference}/${tokenId}`;\n}\n"]}
@@ -1,46 +1,69 @@
1
- import type { Infer, Struct } from "@metamask/superstruct";
1
+ import type { Infer } from "@metamask/superstruct";
2
2
  export declare const CAIP_CHAIN_ID_REGEX: RegExp;
3
3
  export declare const CAIP_NAMESPACE_REGEX: RegExp;
4
4
  export declare const CAIP_REFERENCE_REGEX: RegExp;
5
5
  export declare const CAIP_ACCOUNT_ID_REGEX: RegExp;
6
6
  export declare const CAIP_ACCOUNT_ADDRESS_REGEX: RegExp;
7
+ export declare const CAIP_ASSET_NAMESPACE_REGEX: RegExp;
8
+ export declare const CAIP_ASSET_REFERENCE_REGEX: RegExp;
9
+ export declare const CAIP_TOKEN_ID_REGEX: RegExp;
7
10
  export declare const CAIP_ASSET_TYPE_REGEX: RegExp;
8
11
  export declare const CAIP_ASSET_ID_REGEX: RegExp;
9
12
  /**
10
13
  * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.
11
14
  */
12
- export declare const CaipChainIdStruct: Struct<`${string}:${string}`, null>;
13
- export type CaipChainId = `${string}:${string}`;
15
+ export declare const CaipChainIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}`, null>;
16
+ export type CaipChainId = Infer<typeof CaipChainIdStruct>;
14
17
  /**
15
18
  * A CAIP-2 namespace, i.e., the first part of a CAIP chain ID.
16
19
  */
17
- export declare const CaipNamespaceStruct: Struct<string, null>;
20
+ export declare const CaipNamespaceStruct: import("@metamask/superstruct").Struct<string, null>;
18
21
  export type CaipNamespace = Infer<typeof CaipNamespaceStruct>;
19
22
  /**
20
23
  * A CAIP-2 reference, i.e., the second part of a CAIP chain ID.
21
24
  */
22
- export declare const CaipReferenceStruct: Struct<string, null>;
25
+ export declare const CaipReferenceStruct: import("@metamask/superstruct").Struct<string, null>;
23
26
  export type CaipReference = Infer<typeof CaipReferenceStruct>;
24
27
  /**
25
28
  * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address.
26
29
  */
27
- export declare const CaipAccountIdStruct: Struct<`${string}:${string}:${string}`, null>;
28
- export type CaipAccountId = `${string}:${string}:${string}`;
30
+ export declare const CaipAccountIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}:${string}`, null>;
31
+ export type CaipAccountId = Infer<typeof CaipAccountIdStruct>;
29
32
  /**
30
33
  * A CAIP-10 account address, i.e., the third part of the CAIP account ID.
31
34
  */
32
- export declare const CaipAccountAddressStruct: Struct<string, null>;
35
+ export declare const CaipAccountAddressStruct: import("@metamask/superstruct").Struct<string, null>;
33
36
  export type CaipAccountAddress = Infer<typeof CaipAccountAddressStruct>;
37
+ /**
38
+ * A CAIP-19 asset namespace, i.e., a namespace domain of an asset.
39
+ */
40
+ export declare const CaipAssetNamespaceStruct: import("@metamask/superstruct").Struct<string, null>;
41
+ export type CaipAssetNamespace = Infer<typeof CaipAssetNamespaceStruct>;
42
+ /**
43
+ * A CAIP-19 asset reference, i.e., an identifier for an asset within a given namespace.
44
+ */
45
+ export declare const CaipAssetReferenceStruct: import("@metamask/superstruct").Struct<string, null>;
46
+ export type CaipAssetReference = Infer<typeof CaipAssetReferenceStruct>;
47
+ /**
48
+ * A CAIP-19 asset token ID, i.e., a unique identifier for an addressable asset of a given type
49
+ */
50
+ export declare const CaipTokenIdStruct: import("@metamask/superstruct").Struct<string, null>;
51
+ export type CaipTokenId = Infer<typeof CaipTokenIdStruct>;
34
52
  /**
35
53
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
36
54
  */
37
- export declare const CaipAssetTypeStruct: Struct<`${string}:${string}/${string}:${string}`, null>;
38
- export type CaipAssetType = `${string}:${string}/${string}:${string}`;
55
+ export declare const CaipAssetTypeStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}`, null>;
56
+ export type CaipAssetType = Infer<typeof CaipAssetTypeStruct>;
39
57
  /**
40
58
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
41
59
  */
42
- export declare const CaipAssetIdStruct: Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
43
- export type CaipAssetId = `${string}:${string}/${string}:${string}/${string}`;
60
+ export declare const CaipAssetIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}/${string}`, null>;
61
+ export type CaipAssetId = Infer<typeof CaipAssetIdStruct>;
62
+ /**
63
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
64
+ */
65
+ export declare const CaipAssetTypeOrIdStruct: import("@metamask/superstruct").Struct<`${string}:${string}/${string}:${string}` | `${string}:${string}/${string}:${string}/${string}`, null>;
66
+ export type CaipAssetTypeOrId = Infer<typeof CaipAssetTypeOrIdStruct>;
44
67
  /** Known CAIP namespaces. */
45
68
  export declare enum KnownCaipNamespace {
46
69
  /** BIP-122 (Bitcoin) compatible chains. */
@@ -86,6 +109,27 @@ export declare function isCaipAccountId(value: unknown): value is CaipAccountId;
86
109
  * @returns True if the value is a valid {@link CaipAccountAddress}.
87
110
  */
88
111
  export declare function isCaipAccountAddress(value: unknown): value is CaipAccountAddress;
112
+ /**
113
+ * Check if the given value is a {@link CaipAssetNamespace}.
114
+ *
115
+ * @param value - The value to check.
116
+ * @returns Whether the value is a {@link CaipAssetNamespace}.
117
+ */
118
+ export declare function isCaipAssetNamespace(value: unknown): value is CaipAssetNamespace;
119
+ /**
120
+ * Check if the given value is a {@link CaipAssetReference}.
121
+ *
122
+ * @param value - The value to check.
123
+ * @returns Whether the value is a {@link CaipAssetReference}.
124
+ */
125
+ export declare function isCaipAssetReference(value: unknown): value is CaipAssetReference;
126
+ /**
127
+ * Check if the given value is a {@link CaipTokenId}.
128
+ *
129
+ * @param value - The value to check.
130
+ * @returns Whether the value is a {@link CaipTokenId}.
131
+ */
132
+ export declare function isCaipTokenId(value: unknown): value is CaipTokenId;
89
133
  /**
90
134
  * Check if the given value is a {@link CaipAssetType}.
91
135
  *
@@ -126,6 +170,43 @@ export declare function parseCaipAccountId(caipAccountId: CaipAccountId): {
126
170
  reference: CaipReference;
127
171
  };
128
172
  };
173
+ /**
174
+ * Parse a CAIP-19 asset type to an object containing the chain ID, parsed chain ID,
175
+ * asset namespace, and asset reference
176
+ *
177
+ * This validates the CAIP-19 asset type before parsing it.
178
+ *
179
+ * @param caipAssetType - The CAIP-19 asset type to validate and parse.
180
+ * @returns The parsed CAIP-19 asset type.
181
+ */
182
+ export declare function parseCaipAssetType(caipAssetType: CaipAssetType): {
183
+ assetNamespace: CaipAssetNamespace;
184
+ assetReference: CaipAssetReference;
185
+ chainId: CaipChainId;
186
+ chain: {
187
+ namespace: CaipNamespace;
188
+ reference: CaipReference;
189
+ };
190
+ };
191
+ /**
192
+ * Parse a CAIP-19 asset ID to an object containing the chain ID, parsed chain ID,
193
+ * asset namespace, asset reference, and token ID.
194
+ *
195
+ * This validates the CAIP-19 asset ID before parsing it.
196
+ *
197
+ * @param caipAssetId - The CAIP-19 asset ID to validate and parse.
198
+ * @returns The parsed CAIP-19 asset ID.
199
+ */
200
+ export declare function parseCaipAssetId(caipAssetId: CaipAssetId): {
201
+ assetNamespace: CaipAssetNamespace;
202
+ assetReference: CaipAssetReference;
203
+ tokenId: CaipTokenId;
204
+ chainId: CaipChainId;
205
+ chain: {
206
+ namespace: CaipNamespace;
207
+ reference: CaipReference;
208
+ };
209
+ };
129
210
  /**
130
211
  * Chain ID as defined per the CAIP-2
131
212
  * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}.
@@ -142,4 +223,58 @@ export declare function parseCaipAccountId(caipAccountId: CaipAccountId): {
142
223
  * @returns A CAIP chain ID.
143
224
  */
144
225
  export declare function toCaipChainId(namespace: CaipNamespace, reference: CaipReference): CaipChainId;
226
+ /**
227
+ * Account ID as defined per the CAIP-10
228
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md}.
229
+ *
230
+ * It defines a way to uniquely identify any blockchain account in a human-readable
231
+ * way.
232
+ *
233
+ * @param namespace - The standard (ecosystem) of similar blockchains.
234
+ * @param reference - Identity of a blockchain within a given namespace.
235
+ * @param accountAddress - The address of the blockchain account.
236
+ * @throws {@link Error}
237
+ * This exception is thrown if the inputs do not comply with the CAIP-10
238
+ * syntax specification
239
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md#syntax}.
240
+ * @returns A CAIP account ID.
241
+ */
242
+ export declare function toCaipAccountId(namespace: CaipNamespace, reference: CaipReference, accountAddress: CaipAccountAddress): CaipAccountId;
243
+ /**
244
+ * Asset Type as defined per the CAIP-19
245
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
246
+ *
247
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
248
+ * way.
249
+ *
250
+ * @param namespace - The standard (ecosystem) of similar blockchains.
251
+ * @param reference - Identity of a blockchain within a given namespace.
252
+ * @param assetNamespace - The namespace domain of an asset.
253
+ * @param assetReference - The identity of an asset within a given namespace.
254
+ * @throws {@link Error}
255
+ * This exception is thrown if the inputs do not comply with the CAIP-19
256
+ * syntax specification
257
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
258
+ * @returns A CAIP asset type.
259
+ */
260
+ export declare function toCaipAssetType(namespace: CaipNamespace, reference: CaipReference, assetNamespace: CaipAssetNamespace, assetReference: CaipAssetReference): CaipAssetType;
261
+ /**
262
+ * Asset ID as defined per the CAIP-19
263
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
264
+ *
265
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
266
+ * way.
267
+ *
268
+ * @param namespace - The standard (ecosystem) of similar blockchains.
269
+ * @param reference - Identity of a blockchain within a given namespace.
270
+ * @param assetNamespace - The namespace domain of an asset.
271
+ * @param assetReference - The identity of an asset within a given namespace.
272
+ * @param tokenId - The unique identifier for an addressable asset of a given type.
273
+ * @throws {@link Error}
274
+ * This exception is thrown if the inputs do not comply with the CAIP-19
275
+ * syntax specification
276
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
277
+ * @returns A CAIP asset ID.
278
+ */
279
+ export declare function toCaipAssetId(namespace: CaipNamespace, reference: CaipReference, assetNamespace: CaipAssetNamespace, assetReference: CaipAssetReference, tokenId: CaipTokenId): CaipAssetId;
145
280
  //# sourceMappingURL=caip-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"caip-types.d.cts","sourceRoot":"","sources":["../src/caip-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,8BAA8B;AAE3D,eAAO,MAAM,mBAAmB,QACqC,CAAC;AAEtE,eAAO,MAAM,oBAAoB,QAAsB,CAAC;AAExD,eAAO,MAAM,oBAAoB,QAA2B,CAAC;AAE7D,eAAO,MAAM,qBAAqB,QACwF,CAAC;AAE3H,eAAO,MAAM,0BAA0B,QAA6B,CAAC;AAErE,eAAO,MAAM,qBAAqB,QAC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