@metamask/utils 11.0.1 → 11.2.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.
@@ -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.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"caip-types.d.mts","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,QAC2H,CAAC;AAE9J,eAAO,MAAM,mBAAmB,QAC+J,CAAC;AAEhM;;GAEG;AACH,eAAO,MAAM,iBAAiB,qCAGA,CAAC;AAC/B,MAAM,MAAM,WAAW,GAAG,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,mBAAmB,sBAA0C,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,sBAA0C,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,+CAGA,CAAC;AACjC,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,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AO,EAAE,WAAW,GACnB,WAAW,CAgCb"}
@@ -1,39 +1,60 @@
1
- import { is, pattern, string } from "@metamask/superstruct";
1
+ import { is } from "@metamask/superstruct";
2
+ import { definePattern } from "./superstruct.mjs";
2
3
  export const CAIP_CHAIN_ID_REGEX = /^(?<namespace>[-a-z0-9]{3,8}):(?<reference>[-_a-zA-Z0-9]{1,32})$/u;
3
4
  export const CAIP_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;
4
5
  export const CAIP_REFERENCE_REGEX = /^[-_a-zA-Z0-9]{1,32}$/u;
5
6
  export const 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;
6
7
  export const CAIP_ACCOUNT_ADDRESS_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;
8
+ export const CAIP_ASSET_NAMESPACE_REGEX = /^[-a-z0-9]{3,8}$/u;
9
+ export const CAIP_ASSET_REFERENCE_REGEX = /^[-.%a-zA-Z0-9]{1,128}$/u;
10
+ export const CAIP_TOKEN_ID_REGEX = /^[-.%a-zA-Z0-9]{1,78}$/u;
7
11
  export const 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;
8
12
  export const 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;
13
+ 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;
9
14
  /**
10
15
  * A CAIP-2 chain ID, i.e., a human-readable namespace and reference.
11
16
  */
12
- export const CaipChainIdStruct = pattern(string(), CAIP_CHAIN_ID_REGEX);
17
+ export const CaipChainIdStruct = definePattern('CaipChainId', CAIP_CHAIN_ID_REGEX);
13
18
  /**
14
19
  * A CAIP-2 namespace, i.e., the first part of a CAIP chain ID.
15
20
  */
16
- export const CaipNamespaceStruct = pattern(string(), CAIP_NAMESPACE_REGEX);
21
+ export const CaipNamespaceStruct = definePattern('CaipNamespace', CAIP_NAMESPACE_REGEX);
17
22
  /**
18
23
  * A CAIP-2 reference, i.e., the second part of a CAIP chain ID.
19
24
  */
20
- export const CaipReferenceStruct = pattern(string(), CAIP_REFERENCE_REGEX);
25
+ export const CaipReferenceStruct = definePattern('CaipReference', CAIP_REFERENCE_REGEX);
21
26
  /**
22
27
  * A CAIP-10 account ID, i.e., a human-readable namespace, reference, and account address.
23
28
  */
24
- export const CaipAccountIdStruct = pattern(string(), CAIP_ACCOUNT_ID_REGEX);
29
+ export const CaipAccountIdStruct = definePattern('CaipAccountId', CAIP_ACCOUNT_ID_REGEX);
25
30
  /**
26
31
  * A CAIP-10 account address, i.e., the third part of the CAIP account ID.
27
32
  */
28
- export const CaipAccountAddressStruct = pattern(string(), CAIP_ACCOUNT_ADDRESS_REGEX);
33
+ export const CaipAccountAddressStruct = definePattern('CaipAccountAddress', CAIP_ACCOUNT_ADDRESS_REGEX);
34
+ /**
35
+ * A CAIP-19 asset namespace, i.e., a namespace domain of an asset.
36
+ */
37
+ export const CaipAssetNamespaceStruct = definePattern('CaipAssetNamespace', CAIP_ASSET_NAMESPACE_REGEX);
38
+ /**
39
+ * A CAIP-19 asset reference, i.e., an identifier for an asset within a given namespace.
40
+ */
41
+ export const CaipAssetReferenceStruct = definePattern('CaipAssetReference', CAIP_ASSET_REFERENCE_REGEX);
42
+ /**
43
+ * A CAIP-19 asset token ID, i.e., a unique identifier for an addressable asset of a given type
44
+ */
45
+ export const CaipTokenIdStruct = definePattern('CaipTokenId', CAIP_TOKEN_ID_REGEX);
29
46
  /**
30
47
  * A CAIP-19 asset type identifier, i.e., a human-readable type of asset identifier.
31
48
  */
32
- export const CaipAssetTypeStruct = pattern(string(), CAIP_ASSET_TYPE_REGEX);
49
+ export const CaipAssetTypeStruct = definePattern('CaipAssetType', CAIP_ASSET_TYPE_REGEX);
33
50
  /**
34
51
  * A CAIP-19 asset ID identifier, i.e., a human-readable type of asset ID.
35
52
  */
36
- export const CaipAssetIdStruct = pattern(string(), CAIP_ASSET_ID_REGEX);
53
+ export const CaipAssetIdStruct = definePattern('CaipAssetId', CAIP_ASSET_ID_REGEX);
54
+ /**
55
+ * A CAIP-19 asset type or asset ID identifier, i.e., a human-readable type of asset identifier.
56
+ */
57
+ export const CaipAssetTypeOrIdStruct = definePattern('CaipAssetTypeOrId', CAIP_ASSET_TYPE_OR_ID_REGEX);
37
58
  /** Known CAIP namespaces. */
38
59
  export var KnownCaipNamespace;
39
60
  (function (KnownCaipNamespace) {
@@ -90,6 +111,33 @@ export function isCaipAccountId(value) {
90
111
  export function isCaipAccountAddress(value) {
91
112
  return is(value, CaipAccountAddressStruct);
92
113
  }
114
+ /**
115
+ * Check if the given value is a {@link CaipAssetNamespace}.
116
+ *
117
+ * @param value - The value to check.
118
+ * @returns Whether the value is a {@link CaipAssetNamespace}.
119
+ */
120
+ export function isCaipAssetNamespace(value) {
121
+ return is(value, CaipAssetNamespaceStruct);
122
+ }
123
+ /**
124
+ * Check if the given value is a {@link CaipAssetReference}.
125
+ *
126
+ * @param value - The value to check.
127
+ * @returns Whether the value is a {@link CaipAssetReference}.
128
+ */
129
+ export function isCaipAssetReference(value) {
130
+ return is(value, CaipAssetReferenceStruct);
131
+ }
132
+ /**
133
+ * Check if the given value is a {@link CaipTokenId}.
134
+ *
135
+ * @param value - The value to check.
136
+ * @returns Whether the value is a {@link CaipTokenId}.
137
+ */
138
+ export function isCaipTokenId(value) {
139
+ return is(value, CaipTokenIdStruct);
140
+ }
93
141
  /**
94
142
  * Check if the given value is a {@link CaipAssetType}.
95
143
  *
@@ -146,6 +194,55 @@ export function parseCaipAccountId(caipAccountId) {
146
194
  },
147
195
  };
148
196
  }
197
+ /**
198
+ * Parse a CAIP-19 asset type to an object containing the chain ID, parsed chain ID,
199
+ * asset namespace, and asset reference
200
+ *
201
+ * This validates the CAIP-19 asset type before parsing it.
202
+ *
203
+ * @param caipAssetType - The CAIP-19 asset type to validate and parse.
204
+ * @returns The parsed CAIP-19 asset type.
205
+ */
206
+ export function parseCaipAssetType(caipAssetType) {
207
+ const match = CAIP_ASSET_TYPE_REGEX.exec(caipAssetType);
208
+ if (!match?.groups) {
209
+ throw new Error('Invalid CAIP asset type.');
210
+ }
211
+ return {
212
+ assetNamespace: match.groups.assetNamespace,
213
+ assetReference: match.groups.assetReference,
214
+ chainId: match.groups.chainId,
215
+ chain: {
216
+ namespace: match.groups.namespace,
217
+ reference: match.groups.reference,
218
+ },
219
+ };
220
+ }
221
+ /**
222
+ * Parse a CAIP-19 asset ID to an object containing the chain ID, parsed chain ID,
223
+ * asset namespace, asset reference, and token ID.
224
+ *
225
+ * This validates the CAIP-19 asset ID before parsing it.
226
+ *
227
+ * @param caipAssetId - The CAIP-19 asset ID to validate and parse.
228
+ * @returns The parsed CAIP-19 asset ID.
229
+ */
230
+ export function parseCaipAssetId(caipAssetId) {
231
+ const match = CAIP_ASSET_ID_REGEX.exec(caipAssetId);
232
+ if (!match?.groups) {
233
+ throw new Error('Invalid CAIP asset ID.');
234
+ }
235
+ return {
236
+ assetNamespace: match.groups.assetNamespace,
237
+ assetReference: match.groups.assetReference,
238
+ tokenId: match.groups.tokenId,
239
+ chainId: match.groups.chainId,
240
+ chain: {
241
+ namespace: match.groups.namespace,
242
+ reference: match.groups.reference,
243
+ },
244
+ };
245
+ }
149
246
  /**
150
247
  * Chain ID as defined per the CAIP-2
151
248
  * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}.
@@ -170,4 +267,100 @@ export function toCaipChainId(namespace, reference) {
170
267
  }
171
268
  return `${namespace}:${reference}`;
172
269
  }
270
+ /**
271
+ * Account ID as defined per the CAIP-10
272
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md}.
273
+ *
274
+ * It defines a way to uniquely identify any blockchain account in a human-readable
275
+ * way.
276
+ *
277
+ * @param namespace - The standard (ecosystem) of similar blockchains.
278
+ * @param reference - Identity of a blockchain within a given namespace.
279
+ * @param accountAddress - The address of the blockchain account.
280
+ * @throws {@link Error}
281
+ * This exception is thrown if the inputs do not comply with the CAIP-10
282
+ * syntax specification
283
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-10.md#syntax}.
284
+ * @returns A CAIP account ID.
285
+ */
286
+ export function toCaipAccountId(namespace, reference, accountAddress) {
287
+ if (!isCaipNamespace(namespace)) {
288
+ throw new Error(`Invalid "namespace", must match: ${CAIP_NAMESPACE_REGEX.toString()}`);
289
+ }
290
+ if (!isCaipReference(reference)) {
291
+ throw new Error(`Invalid "reference", must match: ${CAIP_REFERENCE_REGEX.toString()}`);
292
+ }
293
+ if (!isCaipAccountAddress(accountAddress)) {
294
+ throw new Error(`Invalid "accountAddress", must match: ${CAIP_ACCOUNT_ADDRESS_REGEX.toString()}`);
295
+ }
296
+ return `${namespace}:${reference}:${accountAddress}`;
297
+ }
298
+ /**
299
+ * Asset Type as defined per the CAIP-19
300
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
301
+ *
302
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
303
+ * way.
304
+ *
305
+ * @param namespace - The standard (ecosystem) of similar blockchains.
306
+ * @param reference - Identity of a blockchain within a given namespace.
307
+ * @param assetNamespace - The namespace domain of an asset.
308
+ * @param assetReference - The identity of an asset within a given namespace.
309
+ * @throws {@link Error}
310
+ * This exception is thrown if the inputs do not comply with the CAIP-19
311
+ * syntax specification
312
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
313
+ * @returns A CAIP asset type.
314
+ */
315
+ export function toCaipAssetType(namespace, reference, assetNamespace, assetReference) {
316
+ if (!isCaipNamespace(namespace)) {
317
+ throw new Error(`Invalid "namespace", must match: ${CAIP_NAMESPACE_REGEX.toString()}`);
318
+ }
319
+ if (!isCaipReference(reference)) {
320
+ throw new Error(`Invalid "reference", must match: ${CAIP_REFERENCE_REGEX.toString()}`);
321
+ }
322
+ if (!isCaipAssetNamespace(assetNamespace)) {
323
+ throw new Error(`Invalid "assetNamespace", must match: ${CAIP_ASSET_NAMESPACE_REGEX.toString()}`);
324
+ }
325
+ if (!isCaipAssetReference(assetReference)) {
326
+ throw new Error(`Invalid "assetReference", must match: ${CAIP_ASSET_REFERENCE_REGEX.toString()}`);
327
+ }
328
+ return `${namespace}:${reference}/${assetNamespace}:${assetReference}`;
329
+ }
330
+ /**
331
+ * Asset ID as defined per the CAIP-19
332
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md}.
333
+ *
334
+ * It defines a way to uniquely identify any blockchain asset in a human-readable
335
+ * way.
336
+ *
337
+ * @param namespace - The standard (ecosystem) of similar blockchains.
338
+ * @param reference - Identity of a blockchain within a given namespace.
339
+ * @param assetNamespace - The namespace domain of an asset.
340
+ * @param assetReference - The identity of an asset within a given namespace.
341
+ * @param tokenId - The unique identifier for an addressable asset of a given type.
342
+ * @throws {@link Error}
343
+ * This exception is thrown if the inputs do not comply with the CAIP-19
344
+ * syntax specification
345
+ * {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-19.md#syntax}.
346
+ * @returns A CAIP asset ID.
347
+ */
348
+ export function toCaipAssetId(namespace, reference, assetNamespace, assetReference, tokenId) {
349
+ if (!isCaipNamespace(namespace)) {
350
+ throw new Error(`Invalid "namespace", must match: ${CAIP_NAMESPACE_REGEX.toString()}`);
351
+ }
352
+ if (!isCaipReference(reference)) {
353
+ throw new Error(`Invalid "reference", must match: ${CAIP_REFERENCE_REGEX.toString()}`);
354
+ }
355
+ if (!isCaipAssetNamespace(assetNamespace)) {
356
+ throw new Error(`Invalid "assetNamespace", must match: ${CAIP_ASSET_NAMESPACE_REGEX.toString()}`);
357
+ }
358
+ if (!isCaipAssetReference(assetReference)) {
359
+ throw new Error(`Invalid "assetReference", must match: ${CAIP_ASSET_REFERENCE_REGEX.toString()}`);
360
+ }
361
+ if (!isCaipTokenId(tokenId)) {
362
+ throw new Error(`Invalid "tokenId", must match: ${CAIP_TOKEN_ID_REGEX.toString()}`);
363
+ }
364
+ return `${namespace}:${reference}/${assetNamespace}:${assetReference}/${tokenId}`;
365
+ }
173
366
  //# sourceMappingURL=caip-types.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"caip-types.mjs","sourceRoot":"","sources":["../src/caip-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAG5D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,mEAAmE,CAAC;AAEtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAChC,wHAAwH,CAAC;AAE3H,MAAM,CAAC,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAErE,MAAM,CAAC,MAAM,qBAAqB,GAChC,2JAA2J,CAAC;AAE9J,MAAM,CAAC,MAAM,mBAAmB,GAC9B,6LAA6L,CAAC;AAEhM;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CACtC,MAAM,EAAE,EACR,mBAAmB,CACS,CAAC;AAG/B;;GAEG;AACH,MAAM,CAA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K,CAAC,MAAM,CAAC,SAA0B;SACnD;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAC3B,SAAwB,EACxB,SAAwB;IAExB,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CACb,oCAAoC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,CACtE,CAAC;KACH;IAED,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CACb,oCAAoC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,CACtE,CAAC;KACH;IAED,OAAO,GAAG,SAAS,IAAI,SAAS,EAAE,CAAC;AACrC,CAAC","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.mjs","sourceRoot":"","sources":["../src/caip-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,8BAA8B;AAE3C,OAAO,EAAE,aAAa,EAAE,0BAAsB;AAE9C,MAAM,CAAC,MAAM,mBAAmB,GAC9B,mEAAmE,CAAC;AAEtE,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAChC,wHAAwH,CAAC;AAE3H,MAAM,CAAC,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAErE,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAAmB,CAAC;AAE9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,0BAA0B,CAAC;AAErE,MAAM,CAAC,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE7D,MAAM,CAAC,MAAM,qBAAqB,GAChC,2JAA2J,CAAC;AAE9J,MAAM,CAAC,MAAM,mBAAmB,GAC9B,6LAA6L,CAAC;AAEhM,MAAM,2BAA2B,GAC/B,gMAAgM,CAAC;AAEnM;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC5C,aAAa,EACb,mBAAmB,CACpB,CAAC;AAGF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC9C,eAAe,EACf,oBAAoB,CACrB,CAAC;AAGF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC9C,eAAe,EACf,oBAAoB,CACrB,CAAC;AAGF;;GAEG;AACH,MAAM,CAAC,MAAM,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CAAC,SAAS,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CACb,oCAAoC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,CACtE,CAAC;KACH;IAED,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CACb,yCAAyC,0BAA0B,CAAC,QAAQ,EAAE,EAAE,CACjF,CAAC;KACH;IAED,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CACb,yCAAyC,0BAA0B,CAAC,QAAQ,EAAE,EAAE,CACjF,CAAC;KACH;IAED,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,kCAAkC,mBAAmB,CAAC,QAAQ,EAAE,EAAE,CACnE,CAAC;KACH;IAED,OAAO,GAAG,SAAS,IAAI,SAAS,IAAI,cAAc,IAAI,cAAc,IAAI,OAAO,EAAE,CAAC;AACpF,CAAC","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"]}
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ __exportStar(require("./misc.cjs"), exports);
31
31
  __exportStar(require("./number.cjs"), exports);
32
32
  __exportStar(require("./opaque.cjs"), exports);
33
33
  __exportStar(require("./promise.cjs"), exports);
34
+ __exportStar(require("./superstruct.cjs"), exports);
34
35
  __exportStar(require("./time.cjs"), exports);
35
36
  __exportStar(require("./transaction-types.cjs"), exports);
36
37
  __exportStar(require("./versions.cjs"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,8CAAwB;AACxB,mDAA6B;AAC7B,iDAA2B;AAC3B,iDAA2B;AAC3B,oDAA8B;AAC9B,yDAAmC;AACnC,+CAAyB;AACzB,4CAAsB;AACtB,6CAAuB;AACvB,gDAA0B;AAC1B,gDAA0B;AAC1B,6CAAuB;AACvB,+CAAyB;AACzB,+CAAyB;AACzB,gDAA0B;AAC1B,6CAAuB;AACvB,0DAAoC;AACpC,iDAA2B","sourcesContent":["export * from './assert';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caip-types';\nexport * from './checksum';\nexport * from './coercers';\nexport * from './collections';\nexport * from './encryption-types';\nexport * from './errors';\nexport * from './hex';\nexport * from './json';\nexport * from './keyring';\nexport * from './logging';\nexport * from './misc';\nexport * from './number';\nexport * from './opaque';\nexport * from './promise';\nexport * from './time';\nexport * from './transaction-types';\nexport * from './versions';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,8CAAwB;AACxB,mDAA6B;AAC7B,iDAA2B;AAC3B,iDAA2B;AAC3B,oDAA8B;AAC9B,yDAAmC;AACnC,+CAAyB;AACzB,4CAAsB;AACtB,6CAAuB;AACvB,gDAA0B;AAC1B,gDAA0B;AAC1B,6CAAuB;AACvB,+CAAyB;AACzB,+CAAyB;AACzB,gDAA0B;AAC1B,oDAA8B;AAC9B,6CAAuB;AACvB,0DAAoC;AACpC,iDAA2B","sourcesContent":["export * from './assert';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caip-types';\nexport * from './checksum';\nexport * from './coercers';\nexport * from './collections';\nexport * from './encryption-types';\nexport * from './errors';\nexport * from './hex';\nexport * from './json';\nexport * from './keyring';\nexport * from './logging';\nexport * from './misc';\nexport * from './number';\nexport * from './opaque';\nexport * from './promise';\nexport * from './superstruct';\nexport * from './time';\nexport * from './transaction-types';\nexport * from './versions';\n"]}
package/dist/index.d.cts CHANGED
@@ -15,6 +15,7 @@ export * from "./misc.cjs";
15
15
  export * from "./number.cjs";
16
16
  export * from "./opaque.cjs";
17
17
  export * from "./promise.cjs";
18
+ export * from "./superstruct.cjs";
18
19
  export * from "./time.cjs";
19
20
  export * from "./transaction-types.cjs";
20
21
  export * from "./versions.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,kCAA8B;AAC9B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B"}
package/dist/index.d.mts CHANGED
@@ -15,6 +15,7 @@ export * from "./misc.mjs";
15
15
  export * from "./number.mjs";
16
16
  export * from "./opaque.mjs";
17
17
  export * from "./promise.mjs";
18
+ export * from "./superstruct.mjs";
18
19
  export * from "./time.mjs";
19
20
  export * from "./transaction-types.mjs";
20
21
  export * from "./versions.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,kCAA8B;AAC9B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B"}
package/dist/index.mjs CHANGED
@@ -15,6 +15,7 @@ export * from "./misc.mjs";
15
15
  export * from "./number.mjs";
16
16
  export * from "./opaque.mjs";
17
17
  export * from "./promise.mjs";
18
+ export * from "./superstruct.mjs";
18
19
  export * from "./time.mjs";
19
20
  export * from "./transaction-types.mjs";
20
21
  export * from "./versions.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B","sourcesContent":["export * from './assert';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caip-types';\nexport * from './checksum';\nexport * from './coercers';\nexport * from './collections';\nexport * from './encryption-types';\nexport * from './errors';\nexport * from './hex';\nexport * from './json';\nexport * from './keyring';\nexport * from './logging';\nexport * from './misc';\nexport * from './number';\nexport * from './opaque';\nexport * from './promise';\nexport * from './time';\nexport * from './transaction-types';\nexport * from './versions';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,4BAAwB;AACxB,iCAA6B;AAC7B,+BAA2B;AAC3B,+BAA2B;AAC3B,kCAA8B;AAC9B,uCAAmC;AACnC,6BAAyB;AACzB,0BAAsB;AACtB,2BAAuB;AACvB,8BAA0B;AAC1B,8BAA0B;AAC1B,2BAAuB;AACvB,6BAAyB;AACzB,6BAAyB;AACzB,8BAA0B;AAC1B,kCAA8B;AAC9B,2BAAuB;AACvB,wCAAoC;AACpC,+BAA2B","sourcesContent":["export * from './assert';\nexport * from './base64';\nexport * from './bytes';\nexport * from './caip-types';\nexport * from './checksum';\nexport * from './coercers';\nexport * from './collections';\nexport * from './encryption-types';\nexport * from './errors';\nexport * from './hex';\nexport * from './json';\nexport * from './keyring';\nexport * from './logging';\nexport * from './misc';\nexport * from './number';\nexport * from './opaque';\nexport * from './promise';\nexport * from './superstruct';\nexport * from './time';\nexport * from './transaction-types';\nexport * from './versions';\n"]}