@ensnode/ensnode-sdk 0.33.0 → 0.35.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/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { Hex, Address } from 'viem';
1
+ import { Hex, Address, ByteArray } from 'viem';
2
+ import * as _ensdomains_address_encoder from '@ensdomains/address-encoder';
2
3
  import { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
3
4
  export { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
4
5
  import { ENSNamespaceId } from '@ensnode/datasources';
5
6
  export { ENSNamespaceId, ENSNamespaceIds } from '@ensnode/datasources';
7
+ import z from 'zod/v4';
6
8
 
7
9
  /**
8
10
  * A hash value that uniquely identifies a single ENS name.
@@ -43,6 +45,9 @@ type Label = string;
43
45
  type EncodedLabelHash = `[${string}]`;
44
46
 
45
47
  declare const ROOT_NODE: Node;
48
+ declare const ETH_NODE: `0x${string}`;
49
+ declare const BASENAMES_NODE: `0x${string}`;
50
+ declare const LINEANAMES_NODE: `0x${string}`;
46
51
  /**
47
52
  * A set of nodes whose children are used for reverse resolution.
48
53
  *
@@ -77,7 +82,7 @@ declare const maybeHealLabelByReverseAddress: ({ maybeReverseAddress, labelHash,
77
82
  * into Node or LabelHash, which is a common behavior in the ENS ecosystem.
78
83
  * (see NameWrapper, ETHRegistrarController)
79
84
  */
80
- declare const uint256ToHex32: (num: bigint) => `0x${string}`;
85
+ declare const uint256ToHex32: (num: bigint) => Hex;
81
86
  /**
82
87
  * Check if any characters in `label` are "unindexable".
83
88
  *
@@ -158,6 +163,15 @@ declare const uniq: <T>(arr: T[]) => T[];
158
163
  * Guaranteed to be a positive integer.
159
164
  **/
160
165
  type ChainId = number;
166
+ /**
167
+ * Represents an account (contract or EOA) at `address` on chain `chainId`.
168
+ *
169
+ * @see https://chainagnostic.org/CAIPs/caip-10
170
+ */
171
+ interface AccountId {
172
+ chainId: ChainId;
173
+ address: Address;
174
+ }
161
175
  /**
162
176
  * Block Number
163
177
  *
@@ -284,7 +298,51 @@ declare function deserializeBlockrange(maybeBlockrange: Partial<Blockrange>, val
284
298
  declare function deserializeBlockRef(maybeBlockRef: Partial<BlockRef>, valueLabel?: string): BlockRef;
285
299
  declare function deserializeDuration(maybeDuration: string, valueLabel?: string): Duration;
286
300
 
287
- declare function isNormalized(name: Name): boolean;
301
+ /**
302
+ * Determines whether the Name is normalized.
303
+ *
304
+ * @param name - The Name to check for normalization
305
+ * @returns True if the name is normalized according to ENS normalization rules, false otherwise
306
+ */
307
+ declare function isNormalizedName(name: Name): boolean;
308
+ /**
309
+ * Determines whether the Label is normalized.
310
+ *
311
+ * @param label - The Label to check for normalization
312
+ * @returns True if the label is normalized according to ENS normalization rules, false otherwise
313
+ */
314
+ declare function isNormalizedLabel(label: Label): boolean;
315
+
316
+ /**
317
+ * Determines where the provided AccountId values represent the same address on the same chain.
318
+ */
319
+ declare const accountIdEqual: (a: AccountId, b: AccountId) => boolean;
320
+
321
+ /**
322
+ * Transforms a Literal Label into an Interpreted Label.
323
+ *
324
+ * @see https://ensnode.io/docs/reference/terminology#literal-label
325
+ * @see https://ensnode.io/docs/reference/terminology#interpreted-label
326
+ *
327
+ * @param label - The Literal Label string to interpret
328
+ * @returns The provided label if it is normalized, else the EncodedLabelHash of the label
329
+ */
330
+ declare function interpretLiteralLabel(label: Label): Label | EncodedLabelHash;
331
+ /**
332
+ * Transforms a Literal Name into an Interpreted Name.
333
+ *
334
+ * @see https://ensnode.io/docs/reference/terminology#literal-name
335
+ * @see https://ensnode.io/docs/reference/terminology#interpreted-name
336
+ *
337
+ * If the name provided to this function contains empty-string labels (i.e 'this..name'),
338
+ * then the empty string labels will be Interpreted. Empty-string is not a normalizable name, so the
339
+ * label will be replaced with its Encoded LabelHash representation (i.e. )
340
+ *
341
+ * @param name - The Literal Name string to interpret
342
+ * @returns The provided name if it is normalized, else converts each label in name that is not a
343
+ * normalized label into an Interpreted Label
344
+ */
345
+ declare function interpretLiteralName(name: Name): Name;
288
346
 
289
347
  /**
290
348
  * The ETH coinType.
@@ -376,6 +434,67 @@ declare function parseReverseName(name: Name): {
376
434
  coinType: CoinType;
377
435
  } | null;
378
436
 
437
+ /**
438
+ * Formats a LabelHash as an Encoded LabelHash.
439
+ *
440
+ * @see https://ensnode.io/docs/reference/terminology#encoded-labelhash
441
+ *
442
+ * @param labelHash - A 32-byte hash string starting with '0x'
443
+ * @returns The encoded label hash in format `[hash_without_0x_prefix]`
444
+ */
445
+ declare const encodeLabelHash: (labelHash: LabelHash) => EncodedLabelHash;
446
+
447
+ /**
448
+ * A label set ID identifies a set of labels that can be used for deterministic healing.
449
+ * A label set allows clients to deterministically heal their state against a server,
450
+ * ensuring that both are operating on the same version of data.
451
+ *
452
+ * It is guaranteed to be 1 to 50 characters long and contain only lowercase letters (a-z)
453
+ * and hyphens (-).
454
+ */
455
+ type LabelSetId = string;
456
+ /**
457
+ * A label set version identifies a specific version of a label set. It allows clients to
458
+ * request data from a specific snapshot in time, ensuring deterministic results.
459
+ *
460
+ * It is guaranteed to be a non-negative integer.
461
+ */
462
+ type LabelSetVersion = number;
463
+ /**
464
+ * The label set preferences of an ENSRainbow client.
465
+ */
466
+ interface EnsRainbowClientLabelSet {
467
+ /**
468
+ * Optional label set ID that the ENSRainbow server is expected to use. If provided, heal
469
+ * operations will validate the ENSRainbow server is using this labelSetId.
470
+ * Required if `labelSetVersion` is defined.
471
+ */
472
+ labelSetId?: LabelSetId;
473
+ /**
474
+ * Optional highest label set version of label set id to query. Enables deterministic heal
475
+ * results across time even if the ENSRainbow server ingests label sets with greater versions
476
+ * than this value. If provided, only labels from label sets with versions less than or equal to this
477
+ * value will be returned. If not provided, the server will use the latest available version.
478
+ * When `labelSetVersion` is defined, `labelSetId` must also be defined.
479
+ */
480
+ labelSetVersion?: LabelSetVersion;
481
+ }
482
+ /**
483
+ * The state of label sets managed by an ENSRainbow server.
484
+ */
485
+ interface EnsRainbowServerLabelSet {
486
+ /**
487
+ * The LabelSetId managed by the ENSRainbow server.
488
+ */
489
+ labelSetId: LabelSetId;
490
+ /**
491
+ * The highest label set version available on the ENSRainbow server for the current
492
+ * label set ID. This represents the most recent version of the label set that the
493
+ * server has ingested and can provide label healing results for.
494
+ */
495
+ highestLabelSetVersion: LabelSetVersion;
496
+ }
497
+
379
498
  /**
380
499
  * A PluginName is a unique id for a 'plugin': we use the notion of
381
500
  * 'plugins' to describe bundles of indexing logic.
@@ -386,7 +505,8 @@ declare enum PluginName {
386
505
  Lineanames = "lineanames",
387
506
  ThreeDNS = "threedns",
388
507
  ReverseResolvers = "reverse-resolvers",
389
- Referrals = "referrals"
508
+ Referrals = "referrals",
509
+ TokenScope = "tokenscope"
390
510
  }
391
511
  /**
392
512
  * Information about ENSIndexer's dependencies.
@@ -432,6 +552,10 @@ interface ENSIndexerPublicConfig {
432
552
  * state about the ENSNode instance.
433
553
  */
434
554
  ensNodePublicUrl: URL;
555
+ /**
556
+ * The "fully pinned" label set reference that ENSIndexer will request ENSRainbow use for deterministic label healing across time. This label set reference is "fully pinned" as it requires both the labelSetId and labelSetVersion fields to be defined.
557
+ */
558
+ labelSet: Required<EnsRainbowClientLabelSet>;
435
559
  /**
436
560
  * A Postgres database schema name. This instance of ENSIndexer will write
437
561
  * indexed data to the tables in this schema.
@@ -472,12 +596,33 @@ interface ENSIndexerPublicConfig {
472
596
  * provide safe use of indexed resolver record values (in appropriate
473
597
  * contexts).
474
598
  *
475
- * Note that enabling {@link indexAdditionalResolverRecords} results in
476
- * indexed data becoming a _superset_ of the Subgraph. For exact data-level
477
- * backwards compatibility with the ENS Subgraph,
599
+ * Note that enabling {@link indexAdditionalResolverRecords} results in indexed data becoming a
600
+ * _superset_ of the Subgraph. For exact data-level backwards compatibility with the ENS Subgraph,
478
601
  * {@link indexAdditionalResolverRecords} should be `false`.
479
602
  */
480
603
  indexAdditionalResolverRecords: boolean;
604
+ /**
605
+ * Controls ENSIndexer's handling of Literal Labels and Literal Names
606
+ * This configuration only applies to the Subgraph datamodel and Subgraph Compatible GraphQL API responses.
607
+ *
608
+ * When set to true, all Literal Labels and Literal Names encountered by ENSIndexer will be Interpreted.
609
+ * - https://ensnode.io/docs/reference/terminology#interpreted-label
610
+ * - https://ensnode.io/docs/reference/terminology#interpreted-name
611
+ *
612
+ * That is,
613
+ * 1) all Labels stored and returned by ENSIndexer will either be normalized or represented as an Encoded
614
+ * LabelHash, and
615
+ * 2) all Names stored and returned by ENSIndexer will either be normalized or consist of Labels that
616
+ * may be represented as an Encoded LabelHash of the Literal Label value found onchain.
617
+ *
618
+ * When set to false, ENSIndexer will store and return Literal Labels and Literal Names without further
619
+ * interpretation.
620
+ * - https://ensnode.io/docs/reference/terminology#literal-label
621
+ * - https://ensnode.io/docs/reference/terminology#literal-name
622
+ *
623
+ * NOTE: {@link replaceUnnormalized} must be `false` for subgraph compatible indexing behavior.
624
+ */
625
+ replaceUnnormalized: boolean;
481
626
  /**
482
627
  * Indexed Chain IDs
483
628
  *
@@ -527,12 +672,11 @@ interface SerializedENSIndexerPublicConfig extends Omit<ENSIndexerPublicConfig,
527
672
  declare function deserializeENSIndexerPublicConfig(maybeConfig: SerializedENSIndexerPublicConfig, valueLabel?: string): ENSIndexerPublicConfig;
528
673
 
529
674
  /**
530
- * Subgraph compatibility
675
+ * Determines if the provided `config` produces an index equivalent to the ENS Subgraph.
531
676
  *
532
- * Tells if indexer config guarantees data to be indexed while
533
- * maintaining full subgraph-compatibility.
677
+ * @see https://ensnode.io/docs/reference/subgraph-compatibility/
534
678
  */
535
- declare function isSubgraphCompatible(config: Pick<ENSIndexerPublicConfig, "plugins" | "healReverseAddresses" | "indexAdditionalResolverRecords">): boolean;
679
+ declare function isSubgraphCompatible(config: Pick<ENSIndexerPublicConfig, "plugins" | "healReverseAddresses" | "indexAdditionalResolverRecords" | "replaceUnnormalized" | "labelSet">): boolean;
536
680
 
537
681
  /**
538
682
  * Serializes a {@link ChainConfig} object.
@@ -543,6 +687,160 @@ declare function serializeIndexedChainIds(indexedChainIds: Set<ChainId>): Serial
543
687
  */
544
688
  declare function serializeENSIndexerPublicConfig(config: ENSIndexerPublicConfig): SerializedENSIndexerPublicConfig;
545
689
 
690
+ /**
691
+ * All zod schemas we define must remain internal implementation details.
692
+ * We want the freedom to move away from zod in the future without impacting
693
+ * any users of the ensnode-sdk package.
694
+ *
695
+ * The only way to share Zod schemas is to re-export them from
696
+ * `./src/internal.ts` file.
697
+ */
698
+
699
+ /**
700
+ * Zod `.check()` function input.
701
+ */
702
+ type ZodCheckFnInput<T> = z.core.ParsePayload<T>;
703
+
704
+ /**
705
+ * All zod schemas we define must remain internal implementation details.
706
+ * We want the freedom to move away from zod in the future without impacting
707
+ * any users of the ensnode-sdk package.
708
+ *
709
+ * The only way to share Zod schemas is to re-export them from
710
+ * `./src/internal.ts` file.
711
+ */
712
+
713
+ /**
714
+ * Makes a schema for parsing {@link IndexedChainIds}.
715
+ */
716
+ declare const makeIndexedChainIdsSchema: (valueLabel?: string) => z.ZodPipe<z.ZodArray<z.ZodInt>, z.ZodTransform<Set<number>, number[]>>;
717
+ /**
718
+ * Makes a schema for parsing a list of {@link PluginName} items.
719
+ *
720
+ * The list is guaranteed to include at least one item exists, and no duplicates.
721
+ */
722
+ declare const makePluginsListSchema: (valueLabel?: string) => z.ZodArray<z.ZodEnum<typeof PluginName>>;
723
+ /**
724
+ * Makes a schema for parsing a name for a database schema.
725
+ *
726
+ * The name is guaranteed to be a non-empty string.
727
+ */
728
+ declare const makeDatabaseSchemaNameSchema: (valueLabel?: string) => z.ZodString;
729
+ /**
730
+ * Makes a schema for parsing a label set ID.
731
+ *
732
+ * The label set ID is guaranteed to be a string between 1-50 characters
733
+ * containing only lowercase letters (a-z) and hyphens (-).
734
+ *
735
+ * @param valueLabel - The label to use in error messages (e.g., "Label set ID", "LABEL_SET_ID")
736
+ */
737
+ declare const makeLabelSetIdSchema: (valueLabel: string) => z.ZodString;
738
+ /**
739
+ * Makes a schema for parsing a label set version.
740
+ *
741
+ * The label set version is guaranteed to be a non-negative integer.
742
+ *
743
+ * @param valueLabel - The label to use in error messages (e.g., "Label set version", "LABEL_SET_VERSION")
744
+
745
+ */
746
+ declare const makeLabelSetVersionSchema: (valueLabel: string) => z.ZodPipe<z.coerce.ZodCoercedNumber<unknown>, z.ZodInt>;
747
+ /**
748
+ * Makes a schema for parsing a label set where both label set ID and label set version are required.
749
+ *
750
+ * @param valueLabel - The label to use in error messages (e.g., "Label set", "LABEL_SET")
751
+ */
752
+ declare const makeFullyPinnedLabelSetSchema: (valueLabel?: string) => z.ZodObject<{
753
+ labelSetId: z.ZodString;
754
+ labelSetVersion: z.ZodPipe<z.coerce.ZodCoercedNumber<unknown>, z.ZodInt>;
755
+ }, z.core.$strip>;
756
+ declare const makeDependencyInfoSchema: (valueLabel?: string) => z.ZodObject<{
757
+ nodejs: z.ZodString;
758
+ ponder: z.ZodString;
759
+ ensRainbow: z.ZodString;
760
+ ensRainbowSchema: z.ZodInt;
761
+ }, z.core.$strict>;
762
+ declare function invariant_reverseResolversPluginNeedsResolverRecords(ctx: ZodCheckFnInput<Pick<ENSIndexerPublicConfig, "plugins" | "indexAdditionalResolverRecords">>): void;
763
+ declare function invariant_isSubgraphCompatibleRequirements(ctx: ZodCheckFnInput<Pick<ENSIndexerPublicConfig, "plugins" | "isSubgraphCompatible" | "healReverseAddresses" | "indexAdditionalResolverRecords" | "replaceUnnormalized" | "labelSet">>): void;
764
+ /**
765
+ * ENSIndexer Public Config Schema
766
+ *
767
+ * Makes a Zod schema definition for validating all important settings used
768
+ * during runtime of the ENSIndexer instance.
769
+ */
770
+ declare const makeENSIndexerPublicConfigSchema: (valueLabel?: string) => z.ZodObject<{
771
+ ensAdminUrl: z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>;
772
+ ensNodePublicUrl: z.ZodPipe<z.ZodURL, z.ZodTransform<URL, string>>;
773
+ labelSet: z.ZodObject<{
774
+ labelSetId: z.ZodString;
775
+ labelSetVersion: z.ZodPipe<z.coerce.ZodCoercedNumber<unknown>, z.ZodInt>;
776
+ }, z.core.$strip>;
777
+ healReverseAddresses: z.ZodBoolean;
778
+ indexAdditionalResolverRecords: z.ZodBoolean;
779
+ replaceUnnormalized: z.ZodBoolean;
780
+ indexedChainIds: z.ZodPipe<z.ZodArray<z.ZodInt>, z.ZodTransform<Set<number>, number[]>>;
781
+ isSubgraphCompatible: z.ZodBoolean;
782
+ namespace: z.ZodEnum<{
783
+ readonly Mainnet: "mainnet";
784
+ readonly Sepolia: "sepolia";
785
+ readonly Holesky: "holesky";
786
+ readonly EnsTestEnv: "ens-test-env";
787
+ }>;
788
+ plugins: z.ZodArray<z.ZodEnum<typeof PluginName>>;
789
+ databaseSchemaName: z.ZodString;
790
+ dependencyInfo: z.ZodObject<{
791
+ nodejs: z.ZodString;
792
+ ponder: z.ZodString;
793
+ ensRainbow: z.ZodString;
794
+ ensRainbowSchema: z.ZodInt;
795
+ }, z.core.$strict>;
796
+ }, z.core.$strip>;
797
+
798
+ /**
799
+ * Builds a valid LabelSetId from a string.
800
+ * @param maybeLabelSetId - The string to validate and convert to a LabelSetId.
801
+ * @returns A valid LabelSetId.
802
+ * @throws If the input string is not a valid LabelSetId.
803
+ */
804
+ declare function buildLabelSetId(maybeLabelSetId: string): LabelSetId;
805
+ /**
806
+ * Builds a valid LabelSetVersion from a number or string.
807
+ * @param maybeLabelSetVersion - The number or string to validate and convert to a LabelSetVersion.
808
+ * @returns A valid LabelSetVersion.
809
+ * @throws If the input is not a valid LabelSetVersion.
810
+ */
811
+ declare function buildLabelSetVersion(maybeLabelSetVersion: number | string): LabelSetVersion;
812
+ /**
813
+ * Builds an EnsRainbowClientLabelSet.
814
+ * @param labelSetId - The label set ID.
815
+ * @param labelSetVersion - The label set version.
816
+ * @returns A valid EnsRainbowClientLabelSet object.
817
+ * @throws If `labelSetVersion` is defined without `labelSetId`.
818
+ */
819
+ declare function buildEnsRainbowClientLabelSet(labelSetId?: LabelSetId, labelSetVersion?: LabelSetVersion): EnsRainbowClientLabelSet;
820
+ /**
821
+ * Validates that the server's label set is compatible with the client's requested label set.
822
+ * @param serverSet - The label set provided by the server.
823
+ * @param clientSet - The label set requested by the client.
824
+ * @throws If the server set is not compatible with the client set.
825
+ */
826
+ declare function validateSupportedLabelSetAndVersion(serverSet: EnsRainbowServerLabelSet, clientSet: EnsRainbowClientLabelSet): void;
827
+
828
+ /**
829
+ * Converts a Labelhash to bytes, with validation
830
+ * @param labelHash The Labelhash to convert
831
+ * @returns A ByteArray containing the bytes
832
+ * @throws Error if `labelHash` is not a valid 32-byte hex string
833
+ */
834
+ declare function labelHashToBytes(labelHash: LabelHash): ByteArray;
835
+
836
+ /**
837
+ * Parses a string into a non-negative integer.
838
+ * @param input The string to parse
839
+ * @returns The parsed non-negative integer
840
+ * @throws Error if the input is not a valid non-negative integer
841
+ */
842
+ declare function parseNonNegativeInteger(maybeNumber: string): number;
843
+
546
844
  declare const ChainIndexingStatusIds: {
547
845
  readonly Unstarted: "unstarted";
548
846
  readonly Backfill: "backfill";
@@ -658,7 +956,8 @@ interface ChainIndexingUnstartedStatus {
658
956
  *
659
957
  * Invariants:
660
958
  * - `config.startBlock` is always before or the same as `latestIndexedBlock`
661
- * - `latestIndexedBlock` is always before or the same as `backfillEndBlock`
959
+ * - `latestIndexedBlock` is always before or the same as `latestSyncedBlock`
960
+ * - `latestSyncedBlock` is always before or the same as `backfillEndBlock`
662
961
  * - `backfillEndBlock` is the same as `config.endBlock` if and only if
663
962
  * the config is definite.
664
963
  */
@@ -669,6 +968,11 @@ interface ChainIndexingBackfillStatus {
669
968
  * The block that was most recently indexed.
670
969
  */
671
970
  latestIndexedBlock: BlockRef;
971
+ /**
972
+ * The "highest" block that has been synced into RPC cache. Backfill indexing
973
+ * is accelerated by cached RPC calls through this block height.
974
+ */
975
+ latestSyncedBlock: BlockRef;
672
976
  /**
673
977
  * The block that is the target for finishing the backfill.
674
978
  */
@@ -935,6 +1239,16 @@ declare function getOverallIndexingStatus(chains: ChainIndexingStatus[]): Exclud
935
1239
  * @throws an error if none of the indexed chains was in the 'following' status.
936
1240
  */
937
1241
  declare function getOverallApproxRealtimeDistance(chains: ChainIndexingStatus[]): Duration;
1242
+ /**
1243
+ * Get lowest of the highest end block across all chains which status is
1244
+ * {@link ChainIndexingStatus}.
1245
+ */
1246
+ declare function getTimestampForLowestOmnichainStartBlock(chains: ChainIndexingStatus[]): UnixTimestamp;
1247
+ /**
1248
+ * Get timestamp of the highest known block across all chains which status is
1249
+ * {@link ChainIndexingStatusForBackfillOverallStatus}.
1250
+ */
1251
+ declare function getTimestampForHighestOmnichainKnownBlock(chains: ChainIndexingStatus[]): UnixTimestamp;
938
1252
  /**
939
1253
  * Get Omnichain Indexing Cursor across all chains which status is
940
1254
  * {@link ChainIndexingActiveStatus}.
@@ -991,6 +1305,11 @@ declare function checkChainIndexingStatusesForCompletedOverallStatus(chains: Cha
991
1305
  * - Any other chain can have any status.
992
1306
  */
993
1307
  declare function checkChainIndexingStatusesForFollowingOverallStatus(chains: ChainIndexingStatus[]): chains is ChainIndexingStatus[];
1308
+ /**
1309
+ * Sort a list of [{@link ChainId}, {@link ChainIndexingStatus}] tuples
1310
+ * by the omnichain start block timestamp in ascending order.
1311
+ */
1312
+ declare function sortAscChainStatusesByStartBlock<ChainStatusType extends ChainIndexingStatus>(chains: [ChainId, ChainStatusType][]): [ChainId, ChainStatusType][];
994
1313
 
995
1314
  /**
996
1315
  * Serialize chain indexing statuses.
@@ -1012,7 +1331,7 @@ declare enum TraceableENSProtocol {
1012
1331
  * Encodes the set of well-known steps in the ENS Forward Resolution protocol.
1013
1332
  */
1014
1333
  declare enum ForwardResolutionProtocolStep {
1015
- Operation = "operation",
1334
+ Operation = "forward-resolution",
1016
1335
  FindResolver = "find-resolver",
1017
1336
  ActiveResolverExists = "active-resolver-exists",
1018
1337
  AccelerateENSIP19ReverseResolver = "accelerate-ensip-19-reverse-resolver",
@@ -1025,43 +1344,46 @@ declare enum ForwardResolutionProtocolStep {
1025
1344
  * Encodes the set of well-known steps in the ENS Reverse Resolution protocol.
1026
1345
  */
1027
1346
  declare enum ReverseResolutionProtocolStep {
1028
- Operation = "operation",
1347
+ Operation = "reverse-resolution",
1029
1348
  ResolveReverseName = "resolve-reverse-name",
1030
1349
  NameRecordExists = "name-record-exists-check",
1031
1350
  ForwardResolveAddressRecord = "forward-resolve-address-record",
1032
1351
  VerifyResolvedAddressMatchesAddress = "verify-resolved-address-matches-address"
1033
1352
  }
1353
+ declare const PROTOCOL_ATTRIBUTE_PREFIX = "ens";
1034
1354
  declare const ATTR_PROTOCOL_NAME = "ens.protocol";
1035
1355
  declare const ATTR_PROTOCOL_STEP = "ens.protocol.step";
1036
1356
  declare const ATTR_PROTOCOL_STEP_RESULT = "ens.protocol.step.result";
1037
- /**
1038
- * Re-implements hrTimeToMicroseconds to avoid a dependency on @opentelemetry/core.
1039
- *
1040
- * @see https://github.com/open-telemetry/opentelemetry-js/blob/41ba7f57cbf5ae22290168188b467e0c60cd4765/packages/opentelemetry-core/src/common/time.ts#L135
1041
- */
1042
- declare function hrTimeToMicroseconds(time: [number, number]): number;
1043
- /**
1044
- * Encodes a ReadableSpan as a consumer-friendly and externally-visible JSON-representable object.
1045
- *
1046
- * NOTE: to avoid a dependency on @opentelemetry/sdk-trace-base and an obscure typing issue related
1047
- * to the patched version necessary for it to run in ENSIndexer, we type the span as `any`, but note
1048
- * that it is ReadableSpan.
1049
- */
1050
- declare const readableSpanToProtocolSpan: (span: any) => {
1051
- id: any;
1052
- traceId: any;
1053
- parentSpanContext: any;
1054
- name: any;
1357
+ interface SpanAttributes {
1358
+ [key: string]: unknown;
1359
+ }
1360
+ interface SpanEvent {
1361
+ name: string;
1362
+ attributes: SpanAttributes;
1363
+ time: number;
1364
+ }
1365
+ interface ProtocolSpan {
1366
+ scope: string;
1367
+ id: string;
1368
+ traceId: string;
1369
+ parentSpanContext: {
1370
+ traceId: string;
1371
+ spanId: string;
1372
+ } | undefined;
1373
+ name: string;
1055
1374
  timestamp: number;
1056
1375
  duration: number;
1057
- attributes: {
1058
- [k: string]: unknown;
1376
+ attributes: SpanAttributes;
1377
+ status: {
1378
+ code: number;
1379
+ message?: string;
1059
1380
  };
1060
- status: any;
1061
- events: any;
1381
+ events: SpanEvent[];
1382
+ }
1383
+ type ProtocolSpanTreeNode = ProtocolSpan & {
1384
+ children: ProtocolSpanTreeNode[];
1062
1385
  };
1063
- type ProtocolSpan = ReturnType<typeof readableSpanToProtocolSpan>;
1064
- type ProtocolTrace = ProtocolSpan[];
1386
+ type ProtocolTrace = ProtocolSpanTreeNode[];
1065
1387
 
1066
1388
  /**
1067
1389
  * Encodes a selection of Resolver records in the context of a specific Name.
@@ -1083,10 +1405,6 @@ interface ResolverRecordsSelection {
1083
1405
  */
1084
1406
  texts?: string[];
1085
1407
  }
1086
- declare const DEFAULT_RECORDS_SELECTION: {
1087
- readonly addresses: [CoinType];
1088
- readonly texts: ["url", "avatar", "header", "description", "email", "com.twitter", "com.farcaster", "com.github"];
1089
- };
1090
1408
  declare const isSelectionEmpty: (selection: ResolverRecordsSelection) => boolean;
1091
1409
 
1092
1410
  /**
@@ -1174,6 +1492,25 @@ interface MultichainPrimaryNameResolutionArgs {
1174
1492
  */
1175
1493
  type MultichainPrimaryNameResolutionResult = Record<ChainId, Name | null>;
1176
1494
 
1495
+ declare const DefaultRecordsSelection: {
1496
+ readonly mainnet: {
1497
+ readonly addresses: [_ensdomains_address_encoder.CoinType, ..._ensdomains_address_encoder.CoinType[]];
1498
+ readonly texts: ["url", "avatar", "header", "description", "email", "com.twitter", "com.farcaster", "com.github"];
1499
+ };
1500
+ readonly sepolia: {
1501
+ readonly addresses: [_ensdomains_address_encoder.CoinType, ..._ensdomains_address_encoder.CoinType[]];
1502
+ readonly texts: ["url", "avatar", "header", "description", "email", "com.twitter", "com.farcaster", "com.github"];
1503
+ };
1504
+ readonly holesky: {
1505
+ readonly addresses: [_ensdomains_address_encoder.CoinType, ..._ensdomains_address_encoder.CoinType[]];
1506
+ readonly texts: ["url", "avatar", "header", "description", "email", "com.twitter", "com.farcaster", "com.github"];
1507
+ };
1508
+ readonly "ens-test-env": {
1509
+ readonly addresses: [_ensdomains_address_encoder.CoinType, ..._ensdomains_address_encoder.CoinType[]];
1510
+ readonly texts: ["url", "avatar", "header", "description", "email", "com.twitter", "com.farcaster", "com.github"];
1511
+ };
1512
+ };
1513
+
1177
1514
  /**
1178
1515
  * API Error Response Type
1179
1516
  */
@@ -1190,6 +1527,9 @@ interface TraceableResponse {
1190
1527
  interface AcceleratableRequest {
1191
1528
  accelerate?: boolean;
1192
1529
  }
1530
+ interface AcceleratableResponse {
1531
+ accelerationAttempted: boolean;
1532
+ }
1193
1533
  /**
1194
1534
  * Resolve Records Request Type
1195
1535
  */
@@ -1198,7 +1538,7 @@ interface ResolveRecordsRequest<SELECTION extends ResolverRecordsSelection> exte
1198
1538
  /**
1199
1539
  * Resolve Records Response Type
1200
1540
  */
1201
- interface ResolveRecordsResponse<SELECTION extends ResolverRecordsSelection> extends TraceableResponse {
1541
+ interface ResolveRecordsResponse<SELECTION extends ResolverRecordsSelection> extends AcceleratableResponse, TraceableResponse {
1202
1542
  records: ResolverRecordsResponse<SELECTION>;
1203
1543
  }
1204
1544
  /**
@@ -1209,14 +1549,49 @@ interface ResolvePrimaryNameRequest extends ReverseResolutionArgs, Acceleratable
1209
1549
  /**
1210
1550
  * Resolve Primary Name Response Type
1211
1551
  */
1212
- interface ResolvePrimaryNameResponse extends TraceableResponse {
1552
+ interface ResolvePrimaryNameResponse extends AcceleratableResponse, TraceableResponse {
1213
1553
  name: ReverseResolutionResult;
1214
1554
  }
1215
1555
  interface ResolvePrimaryNamesRequest extends MultichainPrimaryNameResolutionArgs, AcceleratableRequest, TraceableRequest {
1216
1556
  }
1217
- interface ResolvePrimaryNamesResponse extends TraceableResponse {
1557
+ interface ResolvePrimaryNamesResponse extends AcceleratableResponse, TraceableResponse {
1218
1558
  names: MultichainPrimaryNameResolutionResult;
1219
1559
  }
1560
+ /**
1561
+ * ENSIndexer Public Config Response
1562
+ */
1563
+ type ConfigResponse = ENSIndexerPublicConfig;
1564
+ /**
1565
+ * ENSIndexer Overall Indexing Status Request
1566
+ */
1567
+ interface IndexingStatusRequest {
1568
+ /**
1569
+ * Max Realtime Distance (optional)
1570
+ *
1571
+ * A duration value in seconds, representing the max allowed distance
1572
+ * between the latest indexed block of each chain and the “tip” of
1573
+ * all indexed chains. Setting this parameter influences the HTTP response
1574
+ * code as follows:
1575
+ * - Success (200 OK): The latest indexed block of each chain
1576
+ * is within the requested distance from realtime.
1577
+ * - Service Unavailable (503): The latest indexed block of each chain
1578
+ * is NOT within the requested distance from realtime.
1579
+ */
1580
+ maxRealtimeDistance?: Duration;
1581
+ }
1582
+ /**
1583
+ * ENSIndexer Overall Indexing Status Response
1584
+ */
1585
+ type IndexingStatusResponse = ENSIndexerOverallIndexingStatus;
1586
+ /**
1587
+ * ENSIndexer Overall Indexing Status Response Codes
1588
+ *
1589
+ * Define a custom response code for known responses.
1590
+ */
1591
+ declare const IndexingStatusResponseCodes: {
1592
+ readonly IndexerError: 512;
1593
+ readonly RequestedDistanceNotAchievedError: 513;
1594
+ };
1220
1595
 
1221
1596
  /**
1222
1597
  * Default ENSNode API endpoint URL
@@ -1265,6 +1640,9 @@ declare class ENSNodeClient {
1265
1640
  /**
1266
1641
  * Resolves records for an ENS name (Forward Resolution).
1267
1642
  *
1643
+ * The returned `name` field, if set, is guaranteed to be a [Normalized Name](https://ensnode.io/docs/reference/terminology#normalized-name).
1644
+ * If the name record returned by the resolver is not normalized, `null` is returned as if no name record was set.
1645
+ *
1268
1646
  * @param name The ENS Name whose records to resolve
1269
1647
  * @param selection selection of Resolver records
1270
1648
  * @param options additional options
@@ -1300,6 +1678,9 @@ declare class ENSNodeClient {
1300
1678
  * the Default Name will be returned. You _may_ query the Default EVM Chain Id (`0`) in order to
1301
1679
  * determine the `address`'s Default Name directly.
1302
1680
  *
1681
+ * The returned Primary Name, if set, is guaranteed to be a [Normalized Name](https://ensnode.io/docs/reference/terminology#normalized-name).
1682
+ * If the primary name set for the address is not normalized, `null` is returned as if no primary name was set.
1683
+ *
1303
1684
  * @param address The Address whose Primary Name to resolve
1304
1685
  * @param chainId The chain id within which to query the address' ENSIP-19 Multichain Primary Name
1305
1686
  * @param options additional options
@@ -1332,6 +1713,9 @@ declare class ENSNodeClient {
1332
1713
  * Primary Name. To avoid misuse, you _may not_ query the Default EVM Chain Id (`0`) directly, and
1333
1714
  * should rely on the aforementioned per-chain defaulting behavior.
1334
1715
  *
1716
+ * Each returned Primary Name, if set, is guaranteed to be a [Normalized Name](https://ensnode.io/docs/reference/terminology#normalized-name).
1717
+ * If the primary name set for the address on any chain is not normalized, `null` is returned for that chain as if no primary name was set.
1718
+ *
1335
1719
  * @param address The Address whose Primary Names to resolve
1336
1720
  * @param options additional options
1337
1721
  * @param options.chainIds The set of chain ids within which to query the address' ENSIP-19
@@ -1367,6 +1751,47 @@ declare class ENSNodeClient {
1367
1751
  * ```
1368
1752
  */
1369
1753
  resolvePrimaryNames(address: ResolvePrimaryNamesRequest["address"], options?: Omit<ResolvePrimaryNamesRequest, "address">): Promise<ResolvePrimaryNamesResponse>;
1754
+ /**
1755
+ * Fetch ENSNode Config
1756
+ *
1757
+ * Fetch the ENSNode's configuration.
1758
+ *
1759
+ * @returns {ConfigResponse}
1760
+ *
1761
+ * @throws if the ENSNode request fails
1762
+ * @throws if the ENSNode API returns an error response
1763
+ * @throws if the ENSNode response breaks required invariants
1764
+ */
1765
+ config(): Promise<ConfigResponse>;
1766
+ /**
1767
+ * Fetch ENSNode Indexing Status
1768
+ *
1769
+ * Fetch the ENSNode's multichain indexing status.
1770
+ *
1771
+ * @param options additional options
1772
+ * @param options.maxRealtimeDistance the max allowed distance between the
1773
+ * latest indexed block of each chain and the "tip" of all indexed chains.
1774
+ * Setting this parameter influences the HTTP response code as follows:
1775
+ * - Success (200 OK): The latest indexed block of each chain is within the
1776
+ * requested distance from realtime.
1777
+ * - Service Unavailable (503): The latest indexed block of each chain is NOT
1778
+ * within the requested distance from realtime.
1779
+ *
1780
+ * @returns {IndexingStatusResponse}
1781
+ *
1782
+ * @throws if the ENSNode request fails
1783
+ * @throws if the ENSNode API returns an error response
1784
+ * @throws if the ENSNode response breaks required invariants
1785
+ */
1786
+ indexingStatus(options?: IndexingStatusRequest): Promise<IndexingStatusResponse>;
1787
+ }
1788
+
1789
+ declare function deserializeErrorResponse(maybeErrorResponse: unknown): ErrorResponse;
1790
+
1791
+ declare class ClientError extends Error {
1792
+ details?: unknown;
1793
+ constructor(message: string, details?: unknown);
1794
+ static fromErrorResponse({ message, details }: ErrorResponse): ClientError;
1370
1795
  }
1371
1796
 
1372
- export { ATTR_PROTOCOL_NAME, ATTR_PROTOCOL_STEP, ATTR_PROTOCOL_STEP_RESULT, type AcceleratableRequest, type BlockNumber, type BlockRef, type Blockrange, type Cache, type ChainId, type ChainIdString, type ChainIndexingActiveStatus, type ChainIndexingBackfillStatus, type ChainIndexingCompletedStatus, type ChainIndexingConfig, type ChainIndexingDefiniteConfig, type ChainIndexingFollowingStatus, type ChainIndexingIndefiniteConfig, type ChainIndexingStandbyStatus, type ChainIndexingStatus, type ChainIndexingStatusForBackfillOverallStatus, type ChainIndexingStatusId, ChainIndexingStatusIds, type ChainIndexingStrategyId, ChainIndexingStrategyIds, type ChainIndexingUnstartedStatus, type ClientOptions, DEFAULT_ENSNODE_API_URL, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, DEFAULT_RECORDS_SELECTION, type Datetime, type DatetimeISO8601, type DeepPartial, type DependencyInfo, type Duration, type ENSIndexerOverallIndexingBackfillStatus, type ENSIndexerOverallIndexingCompletedStatus, type ENSIndexerOverallIndexingErrorStatus, type ENSIndexerOverallIndexingFollowingStatus, type ENSIndexerOverallIndexingStatus, type ENSIndexerOverallIndexingUnstartedStatus, type ENSIndexerPublicConfig, ENSNodeClient, ETH_COIN_TYPE, type EncodedLabelHash, type ErrorResponse, type ForwardResolutionArgs, ForwardResolutionProtocolStep, type ForwardResolutionResult, type Label, type LabelHash, LruCache, type MultichainPrimaryNameResolutionArgs, type MultichainPrimaryNameResolutionResult, type Name, type Node, type OverallIndexingStatusId, OverallIndexingStatusIds, PluginName, type ProtocolSpan, type ProtocolTrace, REVERSE_ROOT_NODES, ROOT_NODE, type ResolvePrimaryNameRequest, type ResolvePrimaryNameResponse, type ResolvePrimaryNamesRequest, type ResolvePrimaryNamesResponse, type ResolveRecordsRequest, type ResolveRecordsResponse, type ResolverRecordsResponse, type ResolverRecordsResponseBase, type ResolverRecordsSelection, type ReverseResolutionArgs, ReverseResolutionProtocolStep, type ReverseResolutionResult, type RpcUrl, type SerializedENSIndexerOverallIndexingBackfillStatus, type SerializedENSIndexerOverallIndexingCompletedStatus, type SerializedENSIndexerOverallIndexingErrorStatus, type SerializedENSIndexerOverallIndexingFollowingStatus, type SerializedENSIndexerOverallIndexingStatus, type SerializedENSIndexerOverallIndexingUnstartedStatus, type SerializedENSIndexerPublicConfig, type SerializedIndexedChainIds, TraceableENSProtocol, type UnixTimestamp, type UrlString, addrReverseLabel, bigintToCoinType, checkChainIndexingStatusesForBackfillOverallStatus, checkChainIndexingStatusesForCompletedOverallStatus, checkChainIndexingStatusesForFollowingOverallStatus, checkChainIndexingStatusesForUnstartedOverallStatus, coinTypeReverseLabel, coinTypeToEvmChainId, createIndexingConfig, deserializeBlockNumber, deserializeBlockRef, deserializeBlockrange, deserializeChainId, deserializeDatetime, deserializeDuration, deserializeENSIndexerIndexingStatus, deserializeENSIndexerPublicConfig, deserializeUrl, evmChainIdToCoinType, getActiveChains, getNameHierarchy, getOmnichainIndexingCursor, getOverallApproxRealtimeDistance, getOverallIndexingStatus, getStandbyChains, hrTimeToMicroseconds, isLabelIndexable, isNormalized, isSelectionEmpty, isSubgraphCompatible, makeSubdomainNode, maybeHealLabelByReverseAddress, parseReverseName, readableSpanToProtocolSpan, reverseName, serializeChainId, serializeChainIndexingStatuses, serializeDatetime, serializeENSIndexerIndexingStatus, serializeENSIndexerPublicConfig, serializeIndexedChainIds, serializeUrl, uint256ToHex32, uniq };
1797
+ export { ATTR_PROTOCOL_NAME, ATTR_PROTOCOL_STEP, ATTR_PROTOCOL_STEP_RESULT, type AcceleratableRequest, type AcceleratableResponse, type AccountId, BASENAMES_NODE, type BlockNumber, type BlockRef, type Blockrange, type Cache, type ChainId, type ChainIdString, type ChainIndexingActiveStatus, type ChainIndexingBackfillStatus, type ChainIndexingCompletedStatus, type ChainIndexingConfig, type ChainIndexingDefiniteConfig, type ChainIndexingFollowingStatus, type ChainIndexingIndefiniteConfig, type ChainIndexingStandbyStatus, type ChainIndexingStatus, type ChainIndexingStatusForBackfillOverallStatus, type ChainIndexingStatusId, ChainIndexingStatusIds, type ChainIndexingStrategyId, ChainIndexingStrategyIds, type ChainIndexingUnstartedStatus, ClientError, type ClientOptions, type ConfigResponse, DEFAULT_ENSNODE_API_URL, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, type Datetime, type DatetimeISO8601, type DeepPartial, DefaultRecordsSelection, type DependencyInfo, type Duration, type ENSIndexerOverallIndexingBackfillStatus, type ENSIndexerOverallIndexingCompletedStatus, type ENSIndexerOverallIndexingErrorStatus, type ENSIndexerOverallIndexingFollowingStatus, type ENSIndexerOverallIndexingStatus, type ENSIndexerOverallIndexingUnstartedStatus, type ENSIndexerPublicConfig, ENSNodeClient, ETH_COIN_TYPE, ETH_NODE, type EncodedLabelHash, type EnsRainbowClientLabelSet, type EnsRainbowServerLabelSet, type ErrorResponse, type ForwardResolutionArgs, ForwardResolutionProtocolStep, type ForwardResolutionResult, type IndexingStatusRequest, type IndexingStatusResponse, IndexingStatusResponseCodes, LINEANAMES_NODE, type Label, type LabelHash, type LabelSetId, type LabelSetVersion, LruCache, type MultichainPrimaryNameResolutionArgs, type MultichainPrimaryNameResolutionResult, type Name, type Node, type OverallIndexingStatusId, OverallIndexingStatusIds, PROTOCOL_ATTRIBUTE_PREFIX, PluginName, type ProtocolSpan, type ProtocolSpanTreeNode, type ProtocolTrace, REVERSE_ROOT_NODES, ROOT_NODE, type ResolvePrimaryNameRequest, type ResolvePrimaryNameResponse, type ResolvePrimaryNamesRequest, type ResolvePrimaryNamesResponse, type ResolveRecordsRequest, type ResolveRecordsResponse, type ResolverRecordsResponse, type ResolverRecordsResponseBase, type ResolverRecordsSelection, type ReverseResolutionArgs, ReverseResolutionProtocolStep, type ReverseResolutionResult, type RpcUrl, type SerializedENSIndexerOverallIndexingBackfillStatus, type SerializedENSIndexerOverallIndexingCompletedStatus, type SerializedENSIndexerOverallIndexingErrorStatus, type SerializedENSIndexerOverallIndexingFollowingStatus, type SerializedENSIndexerOverallIndexingStatus, type SerializedENSIndexerOverallIndexingUnstartedStatus, type SerializedENSIndexerPublicConfig, type SerializedIndexedChainIds, TraceableENSProtocol, type TraceableRequest, type TraceableResponse, type UnixTimestamp, type UrlString, accountIdEqual, addrReverseLabel, bigintToCoinType, buildEnsRainbowClientLabelSet, buildLabelSetId, buildLabelSetVersion, checkChainIndexingStatusesForBackfillOverallStatus, checkChainIndexingStatusesForCompletedOverallStatus, checkChainIndexingStatusesForFollowingOverallStatus, checkChainIndexingStatusesForUnstartedOverallStatus, coinTypeReverseLabel, coinTypeToEvmChainId, createIndexingConfig, deserializeBlockNumber, deserializeBlockRef, deserializeBlockrange, deserializeChainId, deserializeDatetime, deserializeDuration, deserializeENSIndexerIndexingStatus, deserializeENSIndexerPublicConfig, deserializeErrorResponse, deserializeUrl, encodeLabelHash, evmChainIdToCoinType, getActiveChains, getNameHierarchy, getOmnichainIndexingCursor, getOverallApproxRealtimeDistance, getOverallIndexingStatus, getStandbyChains, getTimestampForHighestOmnichainKnownBlock, getTimestampForLowestOmnichainStartBlock, interpretLiteralLabel, interpretLiteralName, invariant_isSubgraphCompatibleRequirements, invariant_reverseResolversPluginNeedsResolverRecords, isLabelIndexable, isNormalizedLabel, isNormalizedName, isSelectionEmpty, isSubgraphCompatible, labelHashToBytes, makeDatabaseSchemaNameSchema, makeDependencyInfoSchema, makeENSIndexerPublicConfigSchema, makeFullyPinnedLabelSetSchema, makeIndexedChainIdsSchema, makeLabelSetIdSchema, makeLabelSetVersionSchema, makePluginsListSchema, makeSubdomainNode, maybeHealLabelByReverseAddress, parseNonNegativeInteger, parseReverseName, reverseName, serializeChainId, serializeChainIndexingStatuses, serializeDatetime, serializeENSIndexerIndexingStatus, serializeENSIndexerPublicConfig, serializeIndexedChainIds, serializeUrl, sortAscChainStatusesByStartBlock, uint256ToHex32, uniq, validateSupportedLabelSetAndVersion };