enssdk 1.15.1 → 1.16.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 NameHash
3
+ Copyright (c) 2026 NameHash Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -10,10 +10,10 @@ Learn more about [ENSNode](https://ensnode.io/) from [the ENSNode docs](https://
10
10
  npm install enssdk
11
11
  ```
12
12
 
13
- > **Version compatibility:** Our hosted ENSNode instances currently run ENSNode v1.13. If you are querying them from your own app, you **must** use `enssdk@1.13.1`. The latest published version (`1.14.0+`) contains breaking changes in the Omnigraph API data model not yet deployed to our hosted infrastructure. This notice will be removed once the hosted instances are upgraded.
13
+ > **Version compatibility:** Our hosted ENSNode instances currently run ENSNode v1.15. If you are querying them from your own app, pin `enssdk` to the matching version the Omnigraph API data model can change between versions.
14
14
  >
15
15
  > ```bash
16
- > npm install enssdk@1.13.1
16
+ > npm install enssdk@1.15.2
17
17
  > ```
18
18
 
19
19
  ## Usage
@@ -32,14 +32,19 @@ const client = createEnsNodeClient({ url: "https://api.alpha.ensnode.io" });
32
32
  import { createEnsNodeClient } from "enssdk/core";
33
33
  import { omnigraph, graphql } from "enssdk/omnigraph";
34
34
 
35
- const client = createEnsNodeClient({ url: "https://api.alpha.ensnode.io" })
36
- .extend(omnigraph);
35
+ const client = createEnsNodeClient({ url: "https://api.alpha.ensnode.io" }).extend(omnigraph);
37
36
 
38
37
  const MyQuery = graphql(`
39
38
  query MyQuery($name: Name!) {
40
39
  domain(by: { name: $name }) {
41
- canonical { name { interpreted } }
42
- registration { expiry }
40
+ canonical {
41
+ name {
42
+ interpreted
43
+ }
44
+ }
45
+ registration {
46
+ expiry
47
+ }
43
48
  }
44
49
  }
45
50
  `);
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { H as Hex, A as Address, N as NormalizedAddress, I as InterpretedLabel, B as BeautifiedLabel, a as InterpretedName, b as BeautifiedName, c as AccountId, d as AssetId, C as ChainId, e as Node, D as DNSEncodedLiteralName, L as LiteralLabel, f as DNSEncodedName, E as ENSv1RegistryId, g as ENSv2RegistryId, h as ENSv1DomainId, i as ENSv1VirtualRegistryId, S as StorageId, j as ENSv2DomainId, P as PermissionsId, k as PermissionsResourceId, l as PermissionsUserId, m as DomainId, R as RegistrationId, n as RenewalId, o as ResolverId, p as ResolverRecordsId, T as TokenId, q as LabelHash, r as Label, s as Name, t as LiteralName, u as LabelHashPath, v as EncodedLabelHash } from './evm-Dd4Y60SN.js';
2
- export { w as AssetNamespace, x as AssetNamespaces, y as CanonicalPath, z as DNSEncodedPartiallyInterpretedName, F as DefaultableChainId, G as DurationBigInt, J as RegistryId, K as SubgraphInterpretedLabel, M as SubgraphInterpretedName, U as UnixTimestampBigInt, W as Wei } from './evm-Dd4Y60SN.js';
1
+ import { A as Address, N as NormalizedAddress, I as InterpretedLabel, B as BeautifiedLabel, a as InterpretedName, b as BeautifiedName, c as AccountId, d as AccountIdString, e as AssetId, f as AssetIdString, C as ChainId, g as Node, D as DNSEncodedLiteralName, L as LiteralLabel, h as DNSEncodedName, i as Name, E as ENSv1RegistryId, j as ENSv2RegistryId, k as ENSv1DomainId, l as ENSv1VirtualRegistryId, S as StorageId, m as ENSv2DomainId, P as PermissionsId, n as PermissionsResourceId, o as PermissionsUserId, p as DomainId, R as RegistrationId, q as RenewalId, r as ResolverId, s as ResolverRecordsId, T as TokenId, t as LabelHash, u as RegistryId, U as UnindexedDomainId, v as InterfaceId, w as Label, x as LiteralName, y as LabelHashPath, z as EncodedLabelHash } from './shared-CZeZrvuq.js';
2
+ export { F as AssetNamespace, G as AssetNamespaces, H as BinanceAddress, J as BitcoinAddress, K as BitcoinCashAddress, M as CanonicalPath, O as ChainIdString, Q as ContentType, V as DNSEncodedPartiallyInterpretedName, W as DatetimeISO8601, X as DefaultableChainId, Y as DogecoinAddress, Z as Duration, _ as DurationBigInt, $ as Email, a0 as Hex, a1 as JsonValue, a2 as LitecoinAddress, a3 as MonacoinAddress, a4 as RecordVersion, a5 as RippleAddress, a6 as RootstockAddress, a7 as SolanaAddress, a8 as SubgraphInterpretedLabel, a9 as SubgraphInterpretedName, aa as UnixTimestamp, ab as UnixTimestampBigInt, ac as UrlString, ad as Wei } from './shared-CZeZrvuq.js';
3
3
  import { EvmCoinType, CoinType } from '@ensdomains/address-encoder';
4
4
  export { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
5
5
  import 'viem';
@@ -17,83 +17,6 @@ type EACResource = bigint;
17
17
  */
18
18
  type EACRoleBitmap = bigint;
19
19
 
20
- /**
21
- * ABI content type per ENSIP-4.
22
- *
23
- * Single-bit values (1=JSON, 2=zlib-JSON, 4=CBOR, 8=URI) identify a stored ABI encoding.
24
- * `setABI` requires a power-of-2 value.
25
- *
26
- * Bitmask unions of those bits are used when reading via `ABI(node, contentTypes)`; the
27
- * resolver returns the first stored ABI whose bit is present in the mask (lowest bit first).
28
- *
29
- * @see https://github.com/ensdomains/ens-contracts/blob/91c966febd7b55494269df830fc6775f040b927b/contracts/resolvers/profiles/ABIResolver.sol
30
- */
31
- type ContentType = bigint;
32
- /**
33
- * ERC-165 4-byte interface selector.
34
- *
35
- * @see https://github.com/ensdomains/ens-contracts/blob/91c966febd7b55494269df830fc6775f040b927b/contracts/resolvers/profiles/InterfaceResolver.sol
36
- */
37
- type InterfaceId = Hex;
38
- /**
39
- * IVersionableResolver record version. Bumped by `VersionChanged`, which invalidates all prior
40
- * records for the node.
41
- *
42
- * @see https://github.com/ensdomains/ens-contracts/blob/91c966febd7b55494269df830fc6775f040b927b/contracts/resolvers/profiles/IVersionableResolver.sol
43
- */
44
- type RecordVersion = bigint;
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
-
97
20
  /**
98
21
  * Determines whether an {@link Address} is a {@link NormalizedAddress}.
99
22
  */
@@ -258,6 +181,18 @@ declare function decodeDNSEncodedLiteralName(packet: DNSEncodedLiteralName): Lit
258
181
  */
259
182
  declare function decodeDNSEncodedName(packet: DNSEncodedName): string[];
260
183
 
184
+ /** ENS text record types supported by the ENS Metadata Service image endpoints. */
185
+ type EnsMetadataImageRecord = "avatar" | "header";
186
+ /**
187
+ * Build an HTTP-compatible image URL for a name on the given ENS namespace that (once fetched)
188
+ * loads the requested profile image record from the ENS Metadata Service
189
+ * (https://metadata.ens.domains/docs).
190
+ *
191
+ * The returned URL is dynamically built based on the provided ENS namespace. Not all ENS
192
+ * namespaces are supported by the ENS Metadata Service. Therefore, the returned URL may be null.
193
+ */
194
+ declare function getEnsMetadataServiceImageUrl(name: Name, namespaceId: string, record: EnsMetadataImageRecord): URL | null;
195
+
261
196
  declare const makeENSv1RegistryId: (accountId: AccountId) => ENSv1RegistryId;
262
197
  declare const makeENSv2RegistryId: (accountId: AccountId) => ENSv2RegistryId;
263
198
  declare const makeENSv1VirtualRegistryId: (accountId: AccountId, node: Node) => ENSv1VirtualRegistryId;
@@ -270,6 +205,15 @@ declare const makeConcreteRegistryId: (accountId: AccountId) => ENSv1RegistryId
270
205
  declare const makeResolverId: (contract: AccountId) => ResolverId;
271
206
  declare const makeENSv1DomainId: (accountId: AccountId, node: Node) => ENSv1DomainId;
272
207
  declare const makeENSv2DomainId: (registry: AccountId, storageId: StorageId) => ENSv2DomainId;
208
+ /**
209
+ * Stringifies the id of a resolvable-but-unindexed Domain from the {@link RegistryId} of the
210
+ * Registry that manages the ancestor Domain bearing the wildcard Resolver, and the `node` (namehash)
211
+ * of the unindexed name. See {@link UnindexedDomainId}.
212
+ *
213
+ * @dev Prefixed with `unindexed-` to unambiguously disambiguate from an {@link ENSv1DomainId}, which
214
+ * shares the same `${registryId}-${node}` tail shape.
215
+ */
216
+ declare const makeUnindexedDomainId: (registryId: RegistryId, node: Node) => UnindexedDomainId;
273
217
  /**
274
218
  * Computes a Label's {@link StorageId} given its TokenId or LabelHash.
275
219
  */
@@ -662,6 +606,31 @@ declare function reinterpretLabel(label: InterpretedLabel): InterpretedLabel;
662
606
  */
663
607
  declare function reinterpretName(name: InterpretedName): InterpretedName;
664
608
 
609
+ /**
610
+ * A {@link ResolvableName} is an {@link InterpretedName} that can actually be resolved via the ENS
611
+ * protocol — i.e. it can be DNS-encoded and passed to a Resolver. It requires that every label:
612
+ * - is normalized,
613
+ * - is a known literal label (NOT an Encoded LabelHash — an unknown label cannot be DNS-encoded), and
614
+ * - DNS-encodes to fewer than {@link MAX_RESOLVABLE_LABEL_BYTE_LENGTH} bytes.
615
+ *
616
+ * @dev technically names with unnormalized labels are resolvable by the UniversalResolver (which
617
+ * does not check normalization), but to reduce edge cases and avoid footguns, we intentionally
618
+ * include this additional constraint. This also enforces that a ResolvableName within ENSNode is
619
+ * a strict subset of InterpretedName and InterpretedName-based operations (like {@link namehashInterpretedName})
620
+ * function identically on ResolvableNames.
621
+ */
622
+ type ResolvableName = InterpretedName & {
623
+ __brand: "ResolvableName";
624
+ };
625
+ /**
626
+ * Determines whether `name` is a {@link ResolvableName}.
627
+ */
628
+ declare function isResolvableName(name: InterpretedName): name is ResolvableName;
629
+ /**
630
+ * Asserts that `name` is a {@link ResolvableName}, returning it, or throws.
631
+ */
632
+ declare function asResolvableName(name: InterpretedName): ResolvableName;
633
+
665
634
  /**
666
635
  * Gets the Label used for the reverse names of subnames as per ENSIP-11 & ENSIP-19.
667
636
  *
@@ -693,4 +662,4 @@ declare const coinTypeReverseLabel: (coinType: CoinType) => LiteralLabel;
693
662
  */
694
663
  declare function reverseName(address: NormalizedAddress, coinType: CoinType): LiteralName;
695
664
 
696
- export { ADDR_REVERSE_NODE, AccountId, type AccountIdString, Address, AssetId, type AssetIdString, BeautifiedLabel, 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, beautifyInterpretedLabel, 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, parseReverseName, reinterpretLabel, reinterpretName, reverseName, stringifyAccountId, stringifyAssetId, toNormalizedAddress };
665
+ export { ADDR_REVERSE_NODE, AccountId, AccountIdString, Address, AssetId, AssetIdString, BeautifiedLabel, BeautifiedName, ChainId, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, DNSEncodedLiteralName, DNSEncodedName, DomainId, type EACResource, type EACRoleBitmap, ENS_ROOT_NAME, ENS_ROOT_NODE, ENSv1DomainId, ENSv1RegistryId, ENSv1VirtualRegistryId, ENSv2DomainId, ENSv2RegistryId, ETH_COIN_TYPE, ETH_NODE, EncodedLabelHash, type EnsMetadataImageRecord, InterfaceId, InterpretedLabel, InterpretedName, Label, LabelHash, LabelHashPath, LiteralLabel, LiteralName, Name, Node, NormalizedAddress, PermissionsId, PermissionsResourceId, PermissionsUserId, ROOT_RESOURCE, RegistrationId, RegistryId, RenewalId, type ResolvableName, ResolverId, ResolverRecordsId, StorageId, TokenId, UnindexedDomainId, addrReverseLabel, asInterpretedLabel, asInterpretedName, asLiteralLabel, asLiteralName, asNormalizedAddress, asResolvableName, beautifyInterpretedLabel, beautifyInterpretedName, beautifyName, bigintToCoinType, coinTypeReverseLabel, coinTypeToEvmChainId, constructSubInterpretedName, decodeDNSEncodedLiteralName, decodeDNSEncodedName, decodeEncodedLabelHash, encodeLabelHash, ensureInterpretedLabel, evmChainIdToCoinType, getEnsMetadataServiceImageUrl, getNameHierarchy, getParentInterpretedName, interpretTokenIdAsLabelHash, interpretTokenIdAsNode, interpretedLabelsToInterpretedName, interpretedLabelsToLabelHashPath, interpretedNameToInterpretedLabels, isEncodedLabelHash, isInterfaceId, isInterpretedLabel, isInterpretedName, isLabelHash, isNormalizedAddress, isNormalizedLabel, isNormalizedName, isResolvableName, labelhashInterpretedLabel, labelhashLiteralLabel, literalLabelToInterpretedLabel, literalLabelsToInterpretedName, literalLabelsToLiteralName, literalNameToInterpretedName, literalNameToLiteralLabels, makeConcreteRegistryId, makeENSv1DomainId, makeENSv1RegistryId, makeENSv1VirtualRegistryId, makeENSv2DomainId, makeENSv2RegistryId, makePermissionsId, makePermissionsResourceId, makePermissionsUserId, makeRegistrationId, makeRenewalId, makeResolverId, makeResolverRecordsId, makeStorageId, makeSubdomainNode, makeUnindexedDomainId, namehashInterpretedName, normalizeLabel, normalizeName, parseEncodedLabelHash, parseLabelHash, parseLabelHashOrEncodedLabelHash, parseReverseName, reinterpretLabel, reinterpretName, reverseName, stringifyAccountId, stringifyAssetId, toNormalizedAddress };
package/dist/index.js CHANGED
@@ -278,6 +278,29 @@ function decodeDNSEncodedName(packet) {
278
278
  return segments;
279
279
  }
280
280
 
281
+ // src/lib/ens-metadata-service.ts
282
+ var METADATA_NETWORKS = {
283
+ mainnet: "mainnet",
284
+ sepolia: "sepolia"
285
+ };
286
+ var URI_SCHEME_PATTERN = /^[a-zA-Z][a-zA-Z0-9+.-]*:/;
287
+ function namespaceIdToMetadataNetwork(namespaceId) {
288
+ switch (namespaceId) {
289
+ case "mainnet":
290
+ return METADATA_NETWORKS.mainnet;
291
+ case "sepolia":
292
+ return METADATA_NETWORKS.sepolia;
293
+ default:
294
+ return null;
295
+ }
296
+ }
297
+ function getEnsMetadataServiceImageUrl(name, namespaceId, record) {
298
+ if (name.startsWith("//") || URI_SCHEME_PATTERN.test(name)) return null;
299
+ const network = namespaceIdToMetadataNetwork(namespaceId);
300
+ if (!network) return null;
301
+ return new URL(name, `https://metadata.ens.domains/${network}/${record}/`);
302
+ }
303
+
281
304
  // src/lib/ids.ts
282
305
  import { hexToBigInt } from "viem";
283
306
 
@@ -293,6 +316,7 @@ var makeConcreteRegistryId = (accountId) => _stringifyAccountId(accountId);
293
316
  var makeResolverId = (contract) => _stringifyAccountId(contract);
294
317
  var makeENSv1DomainId = (accountId, node) => [_stringifyAccountId(accountId), node].join("-");
295
318
  var makeENSv2DomainId = (registry, storageId) => [_stringifyAccountId(registry), storageId.toString()].join("-");
319
+ var makeUnindexedDomainId = (registryId, node) => ["unindexed", registryId, node].join("-");
296
320
  var makeStorageId = (tokenIdOrLabelHash) => {
297
321
  const tokenId = typeof tokenIdOrLabelHash === "bigint" ? tokenIdOrLabelHash : hexToBigInt(tokenIdOrLabelHash);
298
322
  return zeroLower32Bits(tokenId);
@@ -415,6 +439,21 @@ function reinterpretName(name) {
415
439
  return interpretedLabelsToInterpretedName(labels.map(reinterpretLabel));
416
440
  }
417
441
 
442
+ // src/lib/resolvable-name.ts
443
+ import { stringToBytes as stringToBytes2 } from "viem";
444
+ var MAX_RESOLVABLE_LABEL_BYTE_LENGTH = 256;
445
+ function isResolvableName(name) {
446
+ for (const label of interpretedNameToInterpretedLabels(name)) {
447
+ if (isEncodedLabelHash(label)) return false;
448
+ if (stringToBytes2(label).length >= MAX_RESOLVABLE_LABEL_BYTE_LENGTH) return false;
449
+ }
450
+ return true;
451
+ }
452
+ function asResolvableName(name) {
453
+ if (isResolvableName(name)) return name;
454
+ throw new Error(`Not a valid ResolvableName: '${name}'`);
455
+ }
456
+
418
457
  // src/lib/reverse-name.ts
419
458
  var ADDR_LABEL = asLiteralLabel("addr");
420
459
  var DEFAULT_LABEL = asLiteralLabel("default");
@@ -457,6 +496,7 @@ export {
457
496
  asLiteralLabel,
458
497
  asLiteralName,
459
498
  asNormalizedAddress,
499
+ asResolvableName,
460
500
  beautifyInterpretedLabel,
461
501
  beautifyInterpretedName,
462
502
  beautifyName,
@@ -470,6 +510,7 @@ export {
470
510
  encodeLabelHash,
471
511
  ensureInterpretedLabel,
472
512
  evmChainIdToCoinType,
513
+ getEnsMetadataServiceImageUrl,
473
514
  getNameHierarchy,
474
515
  getParentInterpretedName,
475
516
  interpretTokenIdAsLabelHash,
@@ -485,6 +526,7 @@ export {
485
526
  isNormalizedAddress,
486
527
  isNormalizedLabel,
487
528
  isNormalizedName,
529
+ isResolvableName,
488
530
  labelhashInterpretedLabel,
489
531
  labelhashLiteralLabel,
490
532
  literalLabelToInterpretedLabel,
@@ -507,6 +549,7 @@ export {
507
549
  makeResolverRecordsId,
508
550
  makeStorageId,
509
551
  makeSubdomainNode,
552
+ makeUnindexedDomainId,
510
553
  namehashInterpretedName,
511
554
  normalizeLabel,
512
555
  normalizeName,