enssdk 1.10.1 → 1.11.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/dist/{evm-2UZlELOe.d.ts → evm-Dhdhx057.d.ts} +67 -60
- package/dist/index.d.ts +85 -6
- package/dist/index.js +82 -71
- package/dist/index.js.map +1 -1
- package/dist/omnigraph/index.d.ts +718 -296
- package/dist/omnigraph/index.js +793 -296
- package/dist/omnigraph/index.js.map +1 -1
- package/package.json +2 -2
- package/src/omnigraph/generated/schema.graphql +206 -61
|
@@ -139,6 +139,24 @@ type LiteralName = Name & {
|
|
|
139
139
|
type InterpretedName = Name & {
|
|
140
140
|
__brand: "InterpretedName";
|
|
141
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* A Beautified Name is a Name produced for presentation in a UI from an {@link InterpretedName}.
|
|
144
|
+
*
|
|
145
|
+
* Each label is either:
|
|
146
|
+
* a) an Encoded LabelHash, preserved verbatim from the source InterpretedName, or
|
|
147
|
+
* b) a Label produced by passing a normalized Label through ENSIP-15 beautification, which is
|
|
148
|
+
* guaranteed to be normalizable back to the original normalized Label but is itself NOT
|
|
149
|
+
* necessarily normalized (e.g. `"♾"` → `"♾️"`).
|
|
150
|
+
*
|
|
151
|
+
* Because (b) is not guaranteed to be normalized, a BeautifiedName is NOT an InterpretedName and
|
|
152
|
+
* MUST NOT be used as a navigation target, lookup key, or anywhere else that expects an
|
|
153
|
+
* InterpretedName.
|
|
154
|
+
*
|
|
155
|
+
* @dev nominally typed to enforce usage & enhance codebase clarity
|
|
156
|
+
*/
|
|
157
|
+
type BeautifiedName = Name & {
|
|
158
|
+
__brand: "BeautifiedName";
|
|
159
|
+
};
|
|
142
160
|
/**
|
|
143
161
|
* A Subgraph Interpreted Label is a Literal Label that is either:
|
|
144
162
|
* a) (if subgraph-indexable): a Literal Label, of unknown normalization status, guaranteed to not
|
|
@@ -247,62 +265,34 @@ type DNSEncodedPartiallyInterpretedName = DNSEncodedName & {
|
|
|
247
265
|
};
|
|
248
266
|
|
|
249
267
|
/**
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
* Represents the number of seconds that have elapsed
|
|
253
|
-
* since January 1, 1970 (midnight UTC/GMT).
|
|
254
|
-
*
|
|
255
|
-
* Guaranteed to be an integer. May be zero or negative to represent a time at or
|
|
256
|
-
* before Jan 1, 1970.
|
|
257
|
-
*/
|
|
258
|
-
type UnixTimestamp = number;
|
|
259
|
-
/**
|
|
260
|
-
* Duration
|
|
261
|
-
*
|
|
262
|
-
* Representing a duration in seconds.
|
|
268
|
+
* An ID that uniquely identifies a concrete ENSv1 Registry contract.
|
|
263
269
|
*
|
|
264
|
-
*
|
|
270
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
265
271
|
*/
|
|
266
|
-
type
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
**/
|
|
270
|
-
type ChainIdString = string;
|
|
271
|
-
/**
|
|
272
|
-
* Datetime value following the ISO 8601 standard.
|
|
273
|
-
*
|
|
274
|
-
* @see https://www.iso.org/iso-8601-date-and-time-format.html
|
|
275
|
-
*/
|
|
276
|
-
type DatetimeISO8601 = string;
|
|
277
|
-
/**
|
|
278
|
-
* Serialized representation of a {@link URL}.
|
|
279
|
-
*/
|
|
280
|
-
type UrlString = string;
|
|
272
|
+
type ENSv1RegistryId = string & {
|
|
273
|
+
__brand: "ENSv1RegistryId";
|
|
274
|
+
};
|
|
281
275
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
* Formatted as a fully lowercase CAIP-10 AccountId.
|
|
276
|
+
* An ID that uniquely identifies an ENSv2 Registry contract.
|
|
285
277
|
*
|
|
286
|
-
* @see
|
|
278
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
287
279
|
*/
|
|
288
|
-
type
|
|
280
|
+
type ENSv2RegistryId = string & {
|
|
281
|
+
__brand: "ENSv2RegistryId";
|
|
282
|
+
};
|
|
289
283
|
/**
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* Formatted as a fully lowercase CAIP-19 AssetId.
|
|
284
|
+
* An ID that uniquely identifies an ENSv1 Virtual Registry — a virtual registry managed by an
|
|
285
|
+
* ENSv1 domain that has children.
|
|
293
286
|
*
|
|
294
|
-
* @see
|
|
295
|
-
* @example "eip155:1/erc721:0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85/0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc"
|
|
296
|
-
* for vitalik.eth in the eth base registrar on mainnet.
|
|
287
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
297
288
|
*/
|
|
298
|
-
type
|
|
299
|
-
|
|
289
|
+
type ENSv1VirtualRegistryId = string & {
|
|
290
|
+
__brand: "ENSv1VirtualRegistryId";
|
|
291
|
+
};
|
|
300
292
|
/**
|
|
301
|
-
*
|
|
293
|
+
* A RegistryId is one of ENSv1RegistryId, ENSv1VirtualRegistryId, or ENSv2RegistryId.
|
|
302
294
|
*/
|
|
303
|
-
type RegistryId =
|
|
304
|
-
__brand: "RegistryContractId";
|
|
305
|
-
};
|
|
295
|
+
type RegistryId = ENSv1RegistryId | ENSv1VirtualRegistryId | ENSv2RegistryId;
|
|
306
296
|
/**
|
|
307
297
|
* A Label's Storage Id is uint256(labelHash) with lower (right-most) 32 bits zero'd.
|
|
308
298
|
*
|
|
@@ -313,14 +303,17 @@ type StorageId = bigint & {
|
|
|
313
303
|
__brand: "StorageId";
|
|
314
304
|
};
|
|
315
305
|
/**
|
|
316
|
-
*
|
|
306
|
+
* An ID that uniquely identifies an ENSv1 Domain.
|
|
307
|
+
*
|
|
308
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
317
309
|
*/
|
|
318
|
-
type ENSv1DomainId =
|
|
310
|
+
type ENSv1DomainId = string & {
|
|
319
311
|
__brand: "ENSv1DomainId";
|
|
320
312
|
};
|
|
321
313
|
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
314
|
+
* An ID that uniquely identifies an ENSv2 Domain.
|
|
315
|
+
*
|
|
316
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
324
317
|
*/
|
|
325
318
|
type ENSv2DomainId = string & {
|
|
326
319
|
__brand: "ENSv2DomainId";
|
|
@@ -330,43 +323,57 @@ type ENSv2DomainId = string & {
|
|
|
330
323
|
*/
|
|
331
324
|
type DomainId = ENSv1DomainId | ENSv2DomainId;
|
|
332
325
|
/**
|
|
333
|
-
*
|
|
326
|
+
* An ID that uniquely identifies a Permissions entity.
|
|
327
|
+
*
|
|
328
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
334
329
|
*/
|
|
335
|
-
type PermissionsId =
|
|
330
|
+
type PermissionsId = string & {
|
|
336
331
|
__brand: "PermissionsId";
|
|
337
332
|
};
|
|
338
333
|
/**
|
|
339
|
-
*
|
|
334
|
+
* An ID that uniquely identifies a PermissionsResource entity.
|
|
335
|
+
*
|
|
336
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
340
337
|
*/
|
|
341
338
|
type PermissionsResourceId = string & {
|
|
342
339
|
__brand: "PermissionsResourceId";
|
|
343
340
|
};
|
|
344
341
|
/**
|
|
345
|
-
*
|
|
342
|
+
* An ID that uniquely identifies a PermissionsUser entity.
|
|
343
|
+
*
|
|
344
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
346
345
|
*/
|
|
347
346
|
type PermissionsUserId = string & {
|
|
348
347
|
__brand: "PermissionsUserId";
|
|
349
348
|
};
|
|
350
349
|
/**
|
|
351
|
-
*
|
|
350
|
+
* An ID that uniquely identifies a Resolver entity.
|
|
351
|
+
*
|
|
352
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
352
353
|
*/
|
|
353
|
-
type ResolverId =
|
|
354
|
+
type ResolverId = string & {
|
|
354
355
|
__brand: "ResolverId";
|
|
355
356
|
};
|
|
356
357
|
/**
|
|
357
|
-
*
|
|
358
|
+
* An ID that uniquely identifies a ResolverRecords entity.
|
|
359
|
+
*
|
|
360
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
358
361
|
*/
|
|
359
362
|
type ResolverRecordsId = string & {
|
|
360
363
|
__brand: "ResolverRecordsId";
|
|
361
364
|
};
|
|
362
365
|
/**
|
|
363
|
-
*
|
|
366
|
+
* An ID that uniquely identifies a Registration entity.
|
|
367
|
+
*
|
|
368
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
364
369
|
*/
|
|
365
370
|
type RegistrationId = string & {
|
|
366
371
|
__brand: "RegistrationId";
|
|
367
372
|
};
|
|
368
373
|
/**
|
|
369
|
-
*
|
|
374
|
+
* An ID that uniquely identifies a Renewal entity.
|
|
375
|
+
*
|
|
376
|
+
* @dev see packages/enssdk/src/lib/ids.ts for context
|
|
370
377
|
*/
|
|
371
378
|
type RenewalId = string & {
|
|
372
379
|
__brand: "RenewalId";
|
|
@@ -471,4 +478,4 @@ interface AssetId {
|
|
|
471
478
|
tokenId: TokenId;
|
|
472
479
|
}
|
|
473
480
|
|
|
474
|
-
export { type Address as A, type
|
|
481
|
+
export { type Address as A, type BeautifiedName as B, type ChainId as C, type DNSEncodedLiteralName as D, type ENSv1RegistryId as E, type DurationBigInt as F, type RegistryId as G, type Hex as H, type InterpretedName as I, type SubgraphInterpretedLabel as J, type SubgraphInterpretedName as K, type LiteralLabel as L, type NormalizedAddress as N, type PermissionsId as P, type RegistrationId as R, type StorageId as S, type TokenId as T, type UnixTimestampBigInt as U, type Wei as W, type AccountId as a, type AssetId as b, type Node as c, type DNSEncodedName as d, type ENSv2RegistryId as e, type ENSv1DomainId as f, type ENSv1VirtualRegistryId as g, type ENSv2DomainId as h, type PermissionsResourceId as i, type PermissionsUserId as j, type DomainId as k, type RenewalId as l, type ResolverId as m, type ResolverRecordsId as n, type LabelHash as o, type Label as p, type InterpretedLabel as q, type Name as r, type LiteralName as s, type LabelHashPath as t, type EncodedLabelHash as u, type AssetNamespace as v, AssetNamespaces as w, type CanonicalPath as x, type DNSEncodedPartiallyInterpretedName as y, type DefaultableChainId as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as Hex, A as Address, N as NormalizedAddress,
|
|
2
|
-
export { v as AssetNamespace, w as AssetNamespaces, x as CanonicalPath, y as
|
|
1
|
+
import { H as Hex, A as Address, N as NormalizedAddress, I as InterpretedName, B as BeautifiedName, a as AccountId, b as AssetId, C as ChainId, c as Node, D as DNSEncodedLiteralName, L as LiteralLabel, d as DNSEncodedName, E as ENSv1RegistryId, e as ENSv2RegistryId, f as ENSv1DomainId, g as ENSv1VirtualRegistryId, S as StorageId, h as ENSv2DomainId, P as PermissionsId, i as PermissionsResourceId, j as PermissionsUserId, k as DomainId, R as RegistrationId, l as RenewalId, m as ResolverId, n as ResolverRecordsId, T as TokenId, o as LabelHash, p as Label, q as InterpretedLabel, r as Name, s as LiteralName, t as LabelHashPath, u as EncodedLabelHash } from './evm-Dhdhx057.js';
|
|
2
|
+
export { v as AssetNamespace, w as AssetNamespaces, x as CanonicalPath, y as DNSEncodedPartiallyInterpretedName, z as DefaultableChainId, F as DurationBigInt, G as RegistryId, J as SubgraphInterpretedLabel, K as SubgraphInterpretedName, U as UnixTimestampBigInt, W as Wei } from './evm-Dhdhx057.js';
|
|
3
3
|
import { EvmCoinType, CoinType } from '@ensdomains/address-encoder';
|
|
4
4
|
export { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
|
|
5
5
|
import 'viem';
|
|
@@ -43,6 +43,57 @@ type InterfaceId = Hex;
|
|
|
43
43
|
*/
|
|
44
44
|
type RecordVersion = bigint;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Unix timestamp value
|
|
48
|
+
*
|
|
49
|
+
* Represents the number of seconds that have elapsed
|
|
50
|
+
* since January 1, 1970 (midnight UTC/GMT).
|
|
51
|
+
*
|
|
52
|
+
* Guaranteed to be an integer. May be zero or negative to represent a time at or
|
|
53
|
+
* before Jan 1, 1970.
|
|
54
|
+
*/
|
|
55
|
+
type UnixTimestamp = number;
|
|
56
|
+
/**
|
|
57
|
+
* Duration
|
|
58
|
+
*
|
|
59
|
+
* Representing a duration in seconds.
|
|
60
|
+
*
|
|
61
|
+
* Guaranteed to be a non-negative integer.
|
|
62
|
+
*/
|
|
63
|
+
type Duration = number;
|
|
64
|
+
/**
|
|
65
|
+
* Serialized representation of {@link ChainId}.
|
|
66
|
+
**/
|
|
67
|
+
type ChainIdString = string;
|
|
68
|
+
/**
|
|
69
|
+
* Datetime value following the ISO 8601 standard.
|
|
70
|
+
*
|
|
71
|
+
* @see https://www.iso.org/iso-8601-date-and-time-format.html
|
|
72
|
+
*/
|
|
73
|
+
type DatetimeISO8601 = string;
|
|
74
|
+
/**
|
|
75
|
+
* Serialized representation of a {@link URL}.
|
|
76
|
+
*/
|
|
77
|
+
type UrlString = string;
|
|
78
|
+
/**
|
|
79
|
+
* String representation of {@link AccountId}.
|
|
80
|
+
*
|
|
81
|
+
* Formatted as a fully lowercase CAIP-10 AccountId.
|
|
82
|
+
*
|
|
83
|
+
* @see https://chainagnostic.org/CAIPs/caip-10
|
|
84
|
+
*/
|
|
85
|
+
type AccountIdString = string;
|
|
86
|
+
/**
|
|
87
|
+
* String representation of {@link AssetId}.
|
|
88
|
+
*
|
|
89
|
+
* Formatted as a fully lowercase CAIP-19 AssetId.
|
|
90
|
+
*
|
|
91
|
+
* @see https://chainagnostic.org/CAIPs/caip-19
|
|
92
|
+
* @example "eip155:1/erc721:0x57f1887a8bf19b14fc0df6fd9b2acc9af147ea85/0xaf2caa1c2ca1d027f1ac823b529d0a67cd144264b2789fa2ea4d63a67c7103cc"
|
|
93
|
+
* for vitalik.eth in the eth base registrar on mainnet.
|
|
94
|
+
*/
|
|
95
|
+
type AssetIdString = string;
|
|
96
|
+
|
|
46
97
|
/**
|
|
47
98
|
* Determines whether an {@link Address} is a {@link NormalizedAddress}.
|
|
48
99
|
*/
|
|
@@ -60,6 +111,26 @@ declare function toNormalizedAddress(maybeAddress: string): NormalizedAddress;
|
|
|
60
111
|
*/
|
|
61
112
|
declare function asNormalizedAddress(address: Address): NormalizedAddress;
|
|
62
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Converts an {@link InterpretedName} into a {@link BeautifiedName} suitable for presentation in a UI.
|
|
116
|
+
*
|
|
117
|
+
* Each label of the InterpretedName is either an Encoded LabelHash or a normalized Label:
|
|
118
|
+
* - Encoded LabelHash labels are preserved verbatim.
|
|
119
|
+
* - Normalized Labels are passed through {@link ens_beautify}, producing a Label that is
|
|
120
|
+
* normalizable (and normalizes back to the input) but may itself be unnormalized.
|
|
121
|
+
*
|
|
122
|
+
* The resulting BeautifiedName is suitable for display but is NOT an InterpretedName, and the
|
|
123
|
+
* branded return type prevents it from being passed to APIs that expect one. Continue to use the
|
|
124
|
+
* source InterpretedName for navigation targets, lookup keys, and anywhere else that expects an
|
|
125
|
+
* InterpretedName.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* beautifyInterpretedName("♾♾♾♾.eth" as InterpretedName) // → "♾️♾️♾️♾️.eth"
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare const beautifyInterpretedName: (name: InterpretedName) => BeautifiedName;
|
|
133
|
+
|
|
63
134
|
/**
|
|
64
135
|
* Stringify an {@link AccountId} as a fully lowercase CAIP-10 AccountId string.
|
|
65
136
|
*
|
|
@@ -174,14 +245,22 @@ declare function decodeDNSEncodedLiteralName(packet: DNSEncodedLiteralName): Lit
|
|
|
174
245
|
*/
|
|
175
246
|
declare function decodeDNSEncodedName(packet: DNSEncodedName): string[];
|
|
176
247
|
|
|
177
|
-
declare const
|
|
248
|
+
declare const makeENSv1RegistryId: (accountId: AccountId) => ENSv1RegistryId;
|
|
249
|
+
declare const makeENSv2RegistryId: (accountId: AccountId) => ENSv2RegistryId;
|
|
250
|
+
declare const makeENSv1VirtualRegistryId: (accountId: AccountId, node: Node) => ENSv1VirtualRegistryId;
|
|
251
|
+
/**
|
|
252
|
+
* Stringifies an {@link AccountId} as the id of a concrete Registry — either an
|
|
253
|
+
* {@link ENSv1RegistryId} or an {@link ENSv2RegistryId}, but never an
|
|
254
|
+
* {@link ENSv1VirtualRegistryId}.
|
|
255
|
+
*/
|
|
256
|
+
declare const makeConcreteRegistryId: (accountId: AccountId) => ENSv1RegistryId | ENSv2RegistryId;
|
|
178
257
|
declare const makeResolverId: (contract: AccountId) => ResolverId;
|
|
179
|
-
declare const makeENSv1DomainId: (node: Node) => ENSv1DomainId;
|
|
258
|
+
declare const makeENSv1DomainId: (accountId: AccountId, node: Node) => ENSv1DomainId;
|
|
180
259
|
declare const makeENSv2DomainId: (registry: AccountId, storageId: StorageId) => ENSv2DomainId;
|
|
181
260
|
/**
|
|
182
261
|
* Computes a Label's {@link StorageId} given its TokenId or LabelHash.
|
|
183
262
|
*/
|
|
184
|
-
declare const makeStorageId: (
|
|
263
|
+
declare const makeStorageId: (tokenIdOrLabelHash: TokenId | LabelHash) => StorageId;
|
|
185
264
|
declare const makePermissionsId: (contract: AccountId) => PermissionsId;
|
|
186
265
|
declare const makePermissionsResourceId: (contract: AccountId, resource: EACResource) => PermissionsResourceId;
|
|
187
266
|
declare const makePermissionsUserId: (contract: AccountId, resource: EACResource, user: NormalizedAddress) => PermissionsUserId;
|
|
@@ -616,4 +695,4 @@ declare const coinTypeReverseLabel: (coinType: CoinType) => LiteralLabel;
|
|
|
616
695
|
*/
|
|
617
696
|
declare function reverseName(address: NormalizedAddress, coinType: CoinType): LiteralName;
|
|
618
697
|
|
|
619
|
-
export { ADDR_REVERSE_NODE, AccountId, AccountIdString, Address, AssetId, AssetIdString, ChainId, type ContentType, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, DNSEncodedLiteralName, DNSEncodedName, DomainId, type EACResource, type EACRoleBitmap, ENS_ROOT_NAME, ENS_ROOT_NODE, ENSv1DomainId, ENSv2DomainId, ETH_COIN_TYPE, ETH_NODE, EncodedLabelHash, Hex, type InterfaceId, InterpretedLabel, InterpretedName, Label, LabelHash, LabelHashPath, LiteralLabel, LiteralName, Name, Node, NormalizedAddress, PermissionsId, PermissionsResourceId, PermissionsUserId, ROOT_RESOURCE, type RecordVersion, RegistrationId,
|
|
698
|
+
export { ADDR_REVERSE_NODE, AccountId, type AccountIdString, Address, AssetId, type AssetIdString, BeautifiedName, ChainId, type ChainIdString, type ContentType, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, DNSEncodedLiteralName, DNSEncodedName, type DatetimeISO8601, DomainId, type Duration, type EACResource, type EACRoleBitmap, ENS_ROOT_NAME, ENS_ROOT_NODE, ENSv1DomainId, ENSv1RegistryId, ENSv1VirtualRegistryId, ENSv2DomainId, ENSv2RegistryId, ETH_COIN_TYPE, ETH_NODE, EncodedLabelHash, Hex, type InterfaceId, InterpretedLabel, InterpretedName, Label, LabelHash, LabelHashPath, LiteralLabel, LiteralName, Name, Node, NormalizedAddress, PermissionsId, PermissionsResourceId, PermissionsUserId, ROOT_RESOURCE, type RecordVersion, RegistrationId, RenewalId, ResolverId, ResolverRecordsId, StorageId, TokenId, type UnixTimestamp, type UrlString, addrReverseLabel, asInterpretedLabel, asInterpretedName, asLiteralLabel, asLiteralName, asNormalizedAddress, beautifyInterpretedName, beautifyName, bigintToCoinType, coinTypeReverseLabel, coinTypeToEvmChainId, constructSubInterpretedName, decodeDNSEncodedLiteralName, decodeDNSEncodedName, decodeEncodedLabelHash, encodeLabelHash, ensureInterpretedLabel, evmChainIdToCoinType, getNameHierarchy, getParentInterpretedName, interpretTokenIdAsLabelHash, interpretTokenIdAsNode, interpretedLabelsToInterpretedName, interpretedLabelsToLabelHashPath, interpretedNameToInterpretedLabels, isEncodedLabelHash, isInterfaceId, isInterpretedLabel, isInterpretedName, isLabelHash, isNormalizedAddress, isNormalizedLabel, isNormalizedName, labelhashInterpretedLabel, labelhashLiteralLabel, literalLabelToInterpretedLabel, literalLabelsToInterpretedName, literalLabelsToLiteralName, literalNameToInterpretedName, literalNameToLiteralLabels, makeConcreteRegistryId, makeENSv1DomainId, makeENSv1RegistryId, makeENSv1VirtualRegistryId, makeENSv2DomainId, makeENSv2RegistryId, makePermissionsId, makePermissionsResourceId, makePermissionsUserId, makeRegistrationId, makeRenewalId, makeResolverId, makeResolverRecordsId, makeStorageId, makeSubdomainNode, namehashInterpretedName, normalizeLabel, normalizeName, parseEncodedLabelHash, parseLabelHash, parseLabelHashOrEncodedLabelHash, parsePartialInterpretedName, parseReverseName, reinterpretLabel, reinterpretName, reverseName, stringifyAccountId, stringifyAssetId, toNormalizedAddress };
|
package/dist/index.js
CHANGED
|
@@ -15,48 +15,8 @@ function asNormalizedAddress(address) {
|
|
|
15
15
|
throw new Error(`Not a NormalizedAddress: '${address}'`);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
// src/lib/
|
|
19
|
-
import {
|
|
20
|
-
function stringifyAccountId({ chainId, address }) {
|
|
21
|
-
return CaipAccountId.format({
|
|
22
|
-
chainId: { namespace: "eip155", reference: chainId.toString() },
|
|
23
|
-
address
|
|
24
|
-
}).toLowerCase();
|
|
25
|
-
}
|
|
26
|
-
function stringifyAssetId({
|
|
27
|
-
assetNamespace,
|
|
28
|
-
contract: { chainId, address },
|
|
29
|
-
tokenId
|
|
30
|
-
}) {
|
|
31
|
-
return CaipAssetId.format({
|
|
32
|
-
chainId: { namespace: "eip155", reference: chainId.toString() },
|
|
33
|
-
assetName: { namespace: assetNamespace, reference: address },
|
|
34
|
-
tokenId: tokenId.toString()
|
|
35
|
-
}).toLowerCase();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// src/lib/coin-type.ts
|
|
39
|
-
import {
|
|
40
|
-
coinTypeToEvmChainId as _coinTypeToEvmChainId,
|
|
41
|
-
evmChainIdToCoinType as _evmChainIdToCoinType
|
|
42
|
-
} from "@ensdomains/address-encoder/utils";
|
|
43
|
-
var ETH_COIN_TYPE = 60;
|
|
44
|
-
var DEFAULT_EVM_CHAIN_ID = 0;
|
|
45
|
-
var DEFAULT_EVM_COIN_TYPE = 2147483648;
|
|
46
|
-
var coinTypeToEvmChainId = (coinType) => {
|
|
47
|
-
if (coinType === ETH_COIN_TYPE) return 1;
|
|
48
|
-
return _coinTypeToEvmChainId(coinType);
|
|
49
|
-
};
|
|
50
|
-
var evmChainIdToCoinType = (chainId) => {
|
|
51
|
-
if (chainId === 1) return ETH_COIN_TYPE;
|
|
52
|
-
return _evmChainIdToCoinType(chainId);
|
|
53
|
-
};
|
|
54
|
-
var bigintToCoinType = (value) => {
|
|
55
|
-
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
56
|
-
throw new Error(`'${value}' cannot represent as CoinType, it is too large.`);
|
|
57
|
-
}
|
|
58
|
-
return Number(value);
|
|
59
|
-
};
|
|
18
|
+
// src/lib/beautify.ts
|
|
19
|
+
import { ens_beautify } from "@adraffy/ens-normalize";
|
|
60
20
|
|
|
61
21
|
// src/lib/namehash.ts
|
|
62
22
|
import { concat, keccak256, namehash as viemNamehash } from "viem";
|
|
@@ -70,9 +30,6 @@ var ETH_NODE = namehashInterpretedName("eth");
|
|
|
70
30
|
var ADDR_REVERSE_NODE = namehashInterpretedName("addr.reverse");
|
|
71
31
|
var ROOT_RESOURCE = 0n;
|
|
72
32
|
|
|
73
|
-
// src/lib/dns-encoded-name.ts
|
|
74
|
-
import { bytesToString, hexToBytes } from "viem";
|
|
75
|
-
|
|
76
33
|
// src/lib/labelhash.ts
|
|
77
34
|
import { isHex, keccak256 as keccak2562, stringToBytes } from "viem";
|
|
78
35
|
import { labelhash as viemLabelhash } from "viem/ens";
|
|
@@ -256,7 +213,57 @@ function asInterpretedName(name) {
|
|
|
256
213
|
throw new Error(`Not a valid InterpretedName: '${name}'`);
|
|
257
214
|
}
|
|
258
215
|
|
|
216
|
+
// src/lib/beautify.ts
|
|
217
|
+
var beautifyInterpretedName = (name) => {
|
|
218
|
+
if (name === ENS_ROOT_NAME) return name;
|
|
219
|
+
return interpretedNameToInterpretedLabels(name).map((label) => isEncodedLabelHash(label) ? label : ens_beautify(label)).join(".");
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// src/lib/caip.ts
|
|
223
|
+
import { AccountId as CaipAccountId, AssetId as CaipAssetId } from "caip";
|
|
224
|
+
function stringifyAccountId({ chainId, address }) {
|
|
225
|
+
return CaipAccountId.format({
|
|
226
|
+
chainId: { namespace: "eip155", reference: chainId.toString() },
|
|
227
|
+
address
|
|
228
|
+
}).toLowerCase();
|
|
229
|
+
}
|
|
230
|
+
function stringifyAssetId({
|
|
231
|
+
assetNamespace,
|
|
232
|
+
contract: { chainId, address },
|
|
233
|
+
tokenId
|
|
234
|
+
}) {
|
|
235
|
+
return CaipAssetId.format({
|
|
236
|
+
chainId: { namespace: "eip155", reference: chainId.toString() },
|
|
237
|
+
assetName: { namespace: assetNamespace, reference: address },
|
|
238
|
+
tokenId: tokenId.toString()
|
|
239
|
+
}).toLowerCase();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/lib/coin-type.ts
|
|
243
|
+
import {
|
|
244
|
+
coinTypeToEvmChainId as _coinTypeToEvmChainId,
|
|
245
|
+
evmChainIdToCoinType as _evmChainIdToCoinType
|
|
246
|
+
} from "@ensdomains/address-encoder/utils";
|
|
247
|
+
var ETH_COIN_TYPE = 60;
|
|
248
|
+
var DEFAULT_EVM_CHAIN_ID = 0;
|
|
249
|
+
var DEFAULT_EVM_COIN_TYPE = 2147483648;
|
|
250
|
+
var coinTypeToEvmChainId = (coinType) => {
|
|
251
|
+
if (coinType === ETH_COIN_TYPE) return 1;
|
|
252
|
+
return _coinTypeToEvmChainId(coinType);
|
|
253
|
+
};
|
|
254
|
+
var evmChainIdToCoinType = (chainId) => {
|
|
255
|
+
if (chainId === 1) return ETH_COIN_TYPE;
|
|
256
|
+
return _evmChainIdToCoinType(chainId);
|
|
257
|
+
};
|
|
258
|
+
var bigintToCoinType = (value) => {
|
|
259
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
260
|
+
throw new Error(`'${value}' cannot represent as CoinType, it is too large.`);
|
|
261
|
+
}
|
|
262
|
+
return Number(value);
|
|
263
|
+
};
|
|
264
|
+
|
|
259
265
|
// src/lib/dns-encoded-name.ts
|
|
266
|
+
import { bytesToString, hexToBytes } from "viem";
|
|
260
267
|
function decodeDNSEncodedLiteralName(packet) {
|
|
261
268
|
return decodeDNSEncodedName(packet).map(asLiteralLabel);
|
|
262
269
|
}
|
|
@@ -291,31 +298,25 @@ import { hexToBigInt } from "viem";
|
|
|
291
298
|
// src/_lib/zeroLower32Bits.ts
|
|
292
299
|
var zeroLower32Bits = (num) => num ^ num & 0xffffffffn;
|
|
293
300
|
|
|
294
|
-
// src/lib/types/evm.ts
|
|
295
|
-
var AssetNamespaces = {
|
|
296
|
-
ERC721: "erc721",
|
|
297
|
-
ERC1155: "erc1155"
|
|
298
|
-
};
|
|
299
|
-
|
|
300
301
|
// src/lib/ids.ts
|
|
301
|
-
var
|
|
302
|
-
var
|
|
303
|
-
var
|
|
304
|
-
var
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
var makeStorageId = (
|
|
310
|
-
|
|
311
|
-
return zeroLower32Bits(
|
|
302
|
+
var _stringifyAccountId = ({ chainId, address }) => [chainId, address].join("-");
|
|
303
|
+
var makeENSv1RegistryId = (accountId) => _stringifyAccountId(accountId);
|
|
304
|
+
var makeENSv2RegistryId = (accountId) => _stringifyAccountId(accountId);
|
|
305
|
+
var makeENSv1VirtualRegistryId = (accountId, node) => [_stringifyAccountId(accountId), node].join("-");
|
|
306
|
+
var makeConcreteRegistryId = (accountId) => _stringifyAccountId(accountId);
|
|
307
|
+
var makeResolverId = (contract) => _stringifyAccountId(contract);
|
|
308
|
+
var makeENSv1DomainId = (accountId, node) => [_stringifyAccountId(accountId), node].join("-");
|
|
309
|
+
var makeENSv2DomainId = (registry, storageId) => [_stringifyAccountId(registry), storageId.toString()].join("-");
|
|
310
|
+
var makeStorageId = (tokenIdOrLabelHash) => {
|
|
311
|
+
const tokenId = typeof tokenIdOrLabelHash === "bigint" ? tokenIdOrLabelHash : hexToBigInt(tokenIdOrLabelHash);
|
|
312
|
+
return zeroLower32Bits(tokenId);
|
|
312
313
|
};
|
|
313
|
-
var makePermissionsId = (contract) =>
|
|
314
|
-
var makePermissionsResourceId = (contract, resource) =>
|
|
315
|
-
var makePermissionsUserId = (contract, resource, user) =>
|
|
316
|
-
var makeResolverRecordsId = (resolver, node) =>
|
|
317
|
-
var makeRegistrationId = (domainId, registrationIndex) =>
|
|
318
|
-
var makeRenewalId = (domainId, registrationIndex, index) =>
|
|
314
|
+
var makePermissionsId = (contract) => _stringifyAccountId(contract);
|
|
315
|
+
var makePermissionsResourceId = (contract, resource) => [makePermissionsId(contract), resource].join("-");
|
|
316
|
+
var makePermissionsUserId = (contract, resource, user) => [makePermissionsResourceId(contract, resource), user].join("-");
|
|
317
|
+
var makeResolverRecordsId = (resolver, node) => [makeResolverId(resolver), node].join("-");
|
|
318
|
+
var makeRegistrationId = (domainId, registrationIndex) => [domainId, registrationIndex].join("-");
|
|
319
|
+
var makeRenewalId = (domainId, registrationIndex, index) => [makeRegistrationId(domainId, registrationIndex), index].join("-");
|
|
319
320
|
|
|
320
321
|
// src/lib/interface-id.ts
|
|
321
322
|
import { isHex as isHex2, size } from "viem";
|
|
@@ -332,7 +333,7 @@ var interpretTokenIdAsLabelHash = (tokenId) => uint256ToHex32(tokenId);
|
|
|
332
333
|
var interpretTokenIdAsNode = (tokenId) => uint256ToHex32(tokenId);
|
|
333
334
|
|
|
334
335
|
// src/lib/names.ts
|
|
335
|
-
import { ens_beautify } from "@adraffy/ens-normalize";
|
|
336
|
+
import { ens_beautify as ens_beautify2 } from "@adraffy/ens-normalize";
|
|
336
337
|
var getNameHierarchy = (name) => {
|
|
337
338
|
if (name === ENS_ROOT_NAME) return [];
|
|
338
339
|
return interpretedNameToInterpretedLabels(name).map(
|
|
@@ -347,7 +348,7 @@ var getParentInterpretedName = (name) => {
|
|
|
347
348
|
};
|
|
348
349
|
var beautifyName = (name) => name.split(".").map((label) => {
|
|
349
350
|
if (isNormalizedLabel(label)) {
|
|
350
|
-
return
|
|
351
|
+
return ens_beautify2(label);
|
|
351
352
|
} else {
|
|
352
353
|
return label;
|
|
353
354
|
}
|
|
@@ -448,6 +449,12 @@ function reverseName(address, coinType) {
|
|
|
448
449
|
})();
|
|
449
450
|
return literalLabelsToLiteralName([label, middle, REVERSE_LABEL]);
|
|
450
451
|
}
|
|
452
|
+
|
|
453
|
+
// src/lib/types/evm.ts
|
|
454
|
+
var AssetNamespaces = {
|
|
455
|
+
ERC721: "erc721",
|
|
456
|
+
ERC1155: "erc1155"
|
|
457
|
+
};
|
|
451
458
|
export {
|
|
452
459
|
ADDR_REVERSE_NODE,
|
|
453
460
|
AssetNamespaces,
|
|
@@ -464,6 +471,7 @@ export {
|
|
|
464
471
|
asLiteralLabel,
|
|
465
472
|
asLiteralName,
|
|
466
473
|
asNormalizedAddress,
|
|
474
|
+
beautifyInterpretedName,
|
|
467
475
|
beautifyName,
|
|
468
476
|
bigintToCoinType,
|
|
469
477
|
coinTypeReverseLabel,
|
|
@@ -497,13 +505,16 @@ export {
|
|
|
497
505
|
literalLabelsToLiteralName,
|
|
498
506
|
literalNameToInterpretedName,
|
|
499
507
|
literalNameToLiteralLabels,
|
|
508
|
+
makeConcreteRegistryId,
|
|
500
509
|
makeENSv1DomainId,
|
|
510
|
+
makeENSv1RegistryId,
|
|
511
|
+
makeENSv1VirtualRegistryId,
|
|
501
512
|
makeENSv2DomainId,
|
|
513
|
+
makeENSv2RegistryId,
|
|
502
514
|
makePermissionsId,
|
|
503
515
|
makePermissionsResourceId,
|
|
504
516
|
makePermissionsUserId,
|
|
505
517
|
makeRegistrationId,
|
|
506
|
-
makeRegistryId,
|
|
507
518
|
makeRenewalId,
|
|
508
519
|
makeResolverId,
|
|
509
520
|
makeResolverRecordsId,
|