@ensnode/ensnode-sdk 0.31.0 → 0.33.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,15 +1,9 @@
1
1
  import { Hex, Address } from 'viem';
2
+ import { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
3
+ export { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
4
+ import { ENSNamespaceId } from '@ensnode/datasources';
5
+ export { ENSNamespaceId, ENSNamespaceIds } from '@ensnode/datasources';
2
6
 
3
- /**
4
- * A PluginName is a unique id for a 'plugin': we use the notion of 'plugins' to describe bundles
5
- * of indexing logic.
6
- */
7
- declare enum PluginName {
8
- Subgraph = "subgraph",
9
- Basenames = "basenames",
10
- Lineanames = "lineanames",
11
- ThreeDNS = "threedns"
12
- }
13
7
  /**
14
8
  * A hash value that uniquely identifies a single ENS name.
15
9
  * Result of `namehash` function as specified in ENSIP-1.
@@ -21,6 +15,12 @@ declare enum PluginName {
21
15
  * @link https://docs.ens.domains/ensip/1#namehash-algorithm
22
16
  */
23
17
  type Node = Hex;
18
+ /**
19
+ * A Name represents a human-readable ENS name.
20
+ *
21
+ * ex: vitalik.eth
22
+ */
23
+ type Name = string;
24
24
  /**
25
25
  * A LabelHash is the result of the labelhash function (which is just keccak256) on a Label.
26
26
  *
@@ -41,12 +41,6 @@ type Label = string;
41
41
  * @example [abcd].example.eth
42
42
  */
43
43
  type EncodedLabelHash = `[${string}]`;
44
- /**
45
- * A Name represents a human-readable ENS name.
46
- *
47
- * ex: vitalik.eth
48
- */
49
- type Name = string;
50
44
 
51
45
  declare const ROOT_NODE: Node;
52
46
  /**
@@ -56,12 +50,46 @@ declare const ROOT_NODE: Node;
56
50
  * See apps/ensindexer/src/handlers/Registry.ts for context.
57
51
  */
58
52
  declare const REVERSE_ROOT_NODES: Set<Node>;
53
+
59
54
  /**
60
- * The ETH coinType.
55
+ * Implements one step of the namehash algorithm, combining `labelHash` with `node` to produce
56
+ * the `node` of a given subdomain. Note that the order of the arguments is 'reversed' (as compared to
57
+ * the actual concatenation) in order to improve readability (i.e. read as [labelHash].[node]).
58
+ */
59
+ declare const makeSubdomainNode: (labelHash: LabelHash, node: Node) => Node;
60
+ /**
61
+ * Attempt to heal the labelHash of an addr.reverse subname using an address that might be related to the subname.
61
62
  *
62
- * @see https://docs.ens.domains/ensip/9
63
+ * @throws if maybeReverseAddress is not a valid Address
64
+ * @throws if labelHash is not a valid Labelhash
65
+ *
66
+ * @returns the original label if healed, otherwise null
67
+ */
68
+ declare const maybeHealLabelByReverseAddress: ({ maybeReverseAddress, labelHash, }: {
69
+ /** The address that is possibly associated with the addr.reverse subname */
70
+ maybeReverseAddress: Address;
71
+ /** The labelhash of the addr.reverse subname */
72
+ labelHash: LabelHash;
73
+ }) => string | null;
74
+ /**
75
+ * Encodes a uint256 bigint as hex string sized to 32 bytes.
76
+ * Uses include, in the context of ENS, decoding the uint256-encoded tokenId of NFT-issuing contracts
77
+ * into Node or LabelHash, which is a common behavior in the ENS ecosystem.
78
+ * (see NameWrapper, ETHRegistrarController)
79
+ */
80
+ declare const uint256ToHex32: (num: bigint) => `0x${string}`;
81
+ /**
82
+ * Check if any characters in `label` are "unindexable".
83
+ *
84
+ * Related logic in ENS Subgraph:
85
+ * https://github.com/ensdomains/ens-subgraph/blob/c844791/src/utils.ts#L68
86
+ *
87
+ * @param label - The label to check. Note:
88
+ * A `null` value for `label` represents an unhealable labelhash.
89
+ *
90
+ * @returns `true` if the label is indexable, `false` otherwise.
63
91
  */
64
- declare const ETH_COIN_TYPE = 60n;
92
+ declare const isLabelIndexable: (label: Label | null) => label is Label;
65
93
 
66
94
  /**
67
95
  * Cache that maps from string -> ValueType.
@@ -119,43 +147,1226 @@ declare class LruCache<KeyType extends string, ValueType> implements Cache<KeyTy
119
147
  }
120
148
 
121
149
  /**
122
- * Implements one step of the namehash algorithm, combining `labelHash` with `node` to produce
123
- * the `node` of a given subdomain. Note that the order of the arguments is 'reversed' (as compared to
124
- * the actual concatenation) in order to improve readability (i.e. read as [labelHash].[node]).
150
+ * Filter out duplicates.
125
151
  */
126
- declare const makeSubdomainNode: (labelHash: LabelHash, node: Node) => Node;
152
+ declare const uniq: <T>(arr: T[]) => T[];
153
+
127
154
  /**
128
- * Attempt to heal the labelHash of an addr.reverse subname using an address that might be related to the subname.
155
+ * Chain ID
129
156
  *
130
- * @throws if maybeReverseAddress is not a valid Address
131
- * @throws if labelHash is not a valid Labelhash
157
+ * Represents a unique identifier for a chain.
158
+ * Guaranteed to be a positive integer.
159
+ **/
160
+ type ChainId = number;
161
+ /**
162
+ * Block Number
132
163
  *
133
- * @returns the original label if healed, otherwise null
164
+ * Guaranteed to be a non-negative integer.
134
165
  */
135
- declare const maybeHealLabelByReverseAddress: ({ maybeReverseAddress, labelHash, }: {
136
- /** The address that is possibly associated with the addr.reverse subname */
137
- maybeReverseAddress: Address;
138
- /** The labelhash of the addr.reverse subname */
139
- labelHash: LabelHash;
140
- }) => string | null;
166
+ type BlockNumber = number;
141
167
  /**
142
- * Encodes a uint256 bigint as hex string sized to 32 bytes.
143
- * Uses include, in the context of ENS, decoding the uint256-encoded tokenId of NFT-issuing contracts
144
- * into Node or LabelHash, which is a common behavior in the ENS ecosystem.
145
- * (see NameWrapper, ETHRegistrarController)
168
+ * Datetime value
146
169
  */
147
- declare const uint256ToHex32: (num: bigint) => `0x${string}`;
170
+ type Datetime = Date;
148
171
  /**
149
- * Check if any characters in `label` are "unindexable".
172
+ * Unix timestamp value
150
173
  *
151
- * Related logic in ENS Subgraph:
152
- * https://github.com/ensdomains/ens-subgraph/blob/c844791/src/utils.ts#L68
174
+ * Guaranteed to be an integer.
175
+ */
176
+ type UnixTimestamp = number;
177
+ /**
178
+ * Represents a URL that is used for RPC endpoints.
179
+ */
180
+ type RpcUrl = URL;
181
+ /**
182
+ * BlockRef
153
183
  *
154
- * @param label - The label to check. Note:
155
- * A `null` value for `label` represents an unhealable labelhash.
184
+ * Describes a block.
156
185
  *
157
- * @returns `true` if the label is indexable, `false` otherwise.
186
+ * We use parameter types to maintain fields layout and documentation across
187
+ * the domain model and its serialized counterpart.
158
188
  */
159
- declare const isLabelIndexable: (label: Label | null) => label is Label;
189
+ interface BlockRef {
190
+ /** Block number (height) */
191
+ number: BlockNumber;
192
+ /** Block timestamp */
193
+ timestamp: UnixTimestamp;
194
+ }
195
+ /**
196
+ * Block range
197
+ *
198
+ * Represents a range of blocks
199
+ */
200
+ interface Blockrange<BlockType = BlockNumber> {
201
+ /** Start block number */
202
+ startBlock?: BlockType;
203
+ /** End block number */
204
+ endBlock?: BlockType;
205
+ }
206
+ /**
207
+ * Duration
208
+ *
209
+ * Representing a duration in seconds.
210
+ *
211
+ * Guaranteed to be a non-negative integer.
212
+ */
213
+ type Duration = number;
214
+ /**
215
+ * A utility type that makes all properties of a type optional recursively,
216
+ * including nested objects and arrays.
217
+ *
218
+ * @example
219
+ * ```typescript
220
+ * type Config = {
221
+ * a: string;
222
+ * b: {
223
+ * x: number;
224
+ * y: { z: boolean };
225
+ * };
226
+ * c: { id: string }[];
227
+ * }
228
+ *
229
+ * type PartialConfig = DeepPartial<Config>;
230
+ * // Results in:
231
+ * // {
232
+ * // a?: string;
233
+ * // b?: {
234
+ * // x?: number;
235
+ * // y?: { z?: boolean };
236
+ * // };
237
+ * // c?: { id?: string }[];
238
+ * // }
239
+ *
240
+ * // Usage:
241
+ * const update: PartialConfig = { b: { y: { z: true } } };
242
+ * ```
243
+ */
244
+ type DeepPartial<T> = {
245
+ [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
246
+ };
247
+
248
+ /**
249
+ * A string representation of {@link ChainId}.
250
+ **/
251
+ type ChainIdString = string;
252
+ /**
253
+ * Datetime value following the ISO 8601 standard.
254
+ *
255
+ * @see https://www.iso.org/iso-8601-date-and-time-format.html
256
+ */
257
+ type DatetimeISO8601 = string;
258
+ /**
259
+ * A string representation of a {@link URL}.
260
+ */
261
+ type UrlString = string;
262
+
263
+ /**
264
+ * Serializes a {@link ChainId} value into its string representation.
265
+ */
266
+ declare function serializeChainId(chainId: ChainId): ChainIdString;
267
+ /**
268
+ * Serializes a {@link Datetime} value into its string representation.
269
+ */
270
+ declare function serializeDatetime(datetime: Datetime): DatetimeISO8601;
271
+ /**
272
+ * Serializes a {@link URL} value into its string representation.
273
+ */
274
+ declare function serializeUrl(url: URL): UrlString;
275
+
276
+ declare function deserializeChainId(maybeChainId: ChainIdString, valueLabel?: string): ChainId;
277
+ declare function deserializeDatetime(maybeDatetime: string, valueLabel?: string): Datetime;
278
+ declare function deserializeUrl(maybeUrl: UrlString, valueLabel?: string): URL;
279
+ declare function deserializeBlockNumber(maybeBlockNumber: number, valueLabel?: string): BlockNumber;
280
+ declare function deserializeBlockrange(maybeBlockrange: Partial<Blockrange>, valueLabel?: string): {
281
+ startBlock?: number | undefined;
282
+ endBlock?: number | undefined;
283
+ };
284
+ declare function deserializeBlockRef(maybeBlockRef: Partial<BlockRef>, valueLabel?: string): BlockRef;
285
+ declare function deserializeDuration(maybeDuration: string, valueLabel?: string): Duration;
286
+
287
+ declare function isNormalized(name: Name): boolean;
288
+
289
+ /**
290
+ * The ETH coinType.
291
+ *
292
+ * @see https://docs.ens.domains/ensip/9
293
+ */
294
+ declare const ETH_COIN_TYPE: CoinType;
295
+ /**
296
+ * The 'default' chainId corresponding to the below {@link DEFAULT_EVM_COIN_TYPE} in the context of
297
+ * ENSIP-19.
298
+ *
299
+ * @see https://docs.ens.domains/ensip/19
300
+ */
301
+ declare const DEFAULT_EVM_CHAIN_ID: ChainId;
302
+ /**
303
+ * ENSIP-19 EVM CoinType representing the 'default' coinType for EVM chains in ENS.
304
+ *
305
+ * @see https://docs.ens.domains/ensip/19/#reverse-resolution
306
+ */
307
+ declare const DEFAULT_EVM_COIN_TYPE: EvmCoinType;
308
+ /**
309
+ * Converts a CoinType to an EVM Chain Id.
310
+ *
311
+ * NOTE: for whatever reason @ensdomains/address-encoder#coinTypeToEvmChainId doesn't handle the
312
+ * mainnet case so we implement that here
313
+ *
314
+ * @see https://docs.ens.domains/ensip/11/
315
+ */
316
+ declare const coinTypeToEvmChainId: (coinType: CoinType) => ChainId;
317
+ /**
318
+ * Converts an EVM Chain Id to a CoinType.
319
+ *
320
+ * NOTE: for whatever reason @ensdomains/address-encoder#evmChainIdToCoinType doesn't handle the
321
+ * mainnet case so we implement that here
322
+ */
323
+ declare const evmChainIdToCoinType: (chainId: ChainId) => CoinType;
324
+ /**
325
+ * Converts a bigint value representing a CoinType into a valid CoinType.
326
+ *
327
+ * This is useful when onchain events emit coinTypes as bigint but we want to constrain them to
328
+ * the CoinType type.
329
+ *
330
+ * @throws if `value` is too large to fit in Number.MAX_SAFE_INTEGER
331
+ */
332
+ declare const bigintToCoinType: (value: bigint) => CoinType;
333
+
334
+ /**
335
+ * Constructs a name hierarchy from a given Name.
336
+ * i.e. sub.example.eth -> [sub.example.eth, example.eth, eth]
337
+ */
338
+ declare const getNameHierarchy: (name: Name) => Name[];
339
+
340
+ /**
341
+ * Gets the Label used for the reverse names of subnames as per ENSIP-11 & ENSIP-19.
342
+ *
343
+ * @see https://docs.ens.domains/ensip/19/#reverse-resolution
344
+ */
345
+ declare const addrReverseLabel: (address: Address) => Label;
346
+ /**
347
+ * Converts `coinType` to prefix-free hex string.
348
+ *
349
+ * @see https://docs.ens.domains/ensip/19
350
+ */
351
+ declare const coinTypeReverseLabel: (coinType: CoinType) => Label;
352
+ /**
353
+ * Gets the reverse name for an address according to ENSIP-11 & ENSIP-19.
354
+ *
355
+ * @see https://docs.ens.domains/ensip/11#specification
356
+ * @see https://docs.ens.domains/ensip/19#specification
357
+ *
358
+ * @param address - The address to get the reverse name for
359
+ * @param coinType - The coin type to use for the reverse name
360
+ * @returns The reverse name for the address
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * reverseName("0x1234", BigInt(ETH_COIN_TYPE)) // "1234.addr.reverse"
365
+ * reverseName("0x1234", BigInt(0x80000000)) // "1234.default.reverse"
366
+ * reverseName("0x1234", BigInt(0x5678)) // "1234.5678.reverse"
367
+ * ```
368
+ */
369
+ declare function reverseName(address: Address, coinType: CoinType): Name;
370
+
371
+ /**
372
+ * Parse the address and coinType out of an ENSIP-19 reverse name.
373
+ */
374
+ declare function parseReverseName(name: Name): {
375
+ address: Address;
376
+ coinType: CoinType;
377
+ } | null;
378
+
379
+ /**
380
+ * A PluginName is a unique id for a 'plugin': we use the notion of
381
+ * 'plugins' to describe bundles of indexing logic.
382
+ */
383
+ declare enum PluginName {
384
+ Subgraph = "subgraph",
385
+ Basenames = "basenames",
386
+ Lineanames = "lineanames",
387
+ ThreeDNS = "threedns",
388
+ ReverseResolvers = "reverse-resolvers",
389
+ Referrals = "referrals"
390
+ }
391
+ /**
392
+ * Information about ENSIndexer's dependencies.
393
+ */
394
+ interface DependencyInfo {
395
+ /** Node.js runtime version */
396
+ nodejs: string;
397
+ /** Ponder framework version */
398
+ ponder: string;
399
+ /** ENSRainbow service version */
400
+ ensRainbow: string;
401
+ /** ENSRainbow schema version */
402
+ ensRainbowSchema: number;
403
+ }
404
+ /**
405
+ * Complete public configuration object for ENSIndexer.
406
+ *
407
+ * We use parameter types to maintain fields layout and documentation across
408
+ * the domain model and its serialized counterpart.
409
+ */
410
+ interface ENSIndexerPublicConfig {
411
+ /**
412
+ * The ENS namespace that ENSNode operates in the context of.
413
+ *
414
+ * See {@link ENSNamespaceIds} for available namespace identifiers.
415
+ */
416
+ namespace: ENSNamespaceId;
417
+ /**
418
+ * An ENSAdmin URL
419
+ *
420
+ * The ENSNode root api route `/` redirects to {@link ensAdminUrl},
421
+ * configuring ENSAdmin with an entry for this instance of ENSNode,
422
+ * identified by {@link ensNodePublicUrl}.
423
+ *
424
+ * @see https://ensnode.io/ensadmin/overview/what-is-ensadmin
425
+ */
426
+ ensAdminUrl: URL;
427
+ /**
428
+ * The publicly accessible endpoint of the ENSNode API
429
+ * (ex: http://localhost:42069).
430
+ *
431
+ * ENSAdmin will use this url to connect to the ENSNode api for querying
432
+ * state about the ENSNode instance.
433
+ */
434
+ ensNodePublicUrl: URL;
435
+ /**
436
+ * A Postgres database schema name. This instance of ENSIndexer will write
437
+ * indexed data to the tables in this schema.
438
+ *
439
+ * Invariants:
440
+ * - Must be a non-empty string that is a valid Postgres database schema
441
+ * identifier.
442
+ */
443
+ databaseSchemaName: string;
444
+ /**
445
+ * A set of {@link PluginName}s indicating which plugins to activate.
446
+ *
447
+ * Invariants:
448
+ * - A set of valid {@link PluginName}s with at least one value
449
+ */
450
+ plugins: PluginName[];
451
+ /**
452
+ * Enable or disable healing of addr.reverse subnames.
453
+ * If this is set to true, ENSIndexer will attempt to heal subnames of
454
+ * addr.reverse.
455
+ */
456
+ healReverseAddresses: boolean;
457
+ /**
458
+ * Enable or disable the indexing of Resolver record values.
459
+ * If this is set to false, ENSIndexer will apply subgraph-backwards
460
+ * compatible logic that only tracks the keys of Resolver records.
461
+ * If this is set to true, ENSIndexer will track both the keys and the values
462
+ * of Resolver records.
463
+ *
464
+ * WARNING: Special care must be taken when interacting with indexed resolver
465
+ * record values. It is unsafe to naively assume that indexed resolver record
466
+ * values are equivalent to the resolver record values that would be returned
467
+ * through dynamic lookups via the ENS protocol. For example, if a resolver
468
+ * implements CCIP-Read, the resolver records may not be discoverable through
469
+ * onchain indexing. This feature is under R&D. At this time we do not
470
+ * recommend anyone directly use indexed resolver record values in their
471
+ * applications. Features are planned in the ENSNode roadmap that will
472
+ * provide safe use of indexed resolver record values (in appropriate
473
+ * contexts).
474
+ *
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,
478
+ * {@link indexAdditionalResolverRecords} should be `false`.
479
+ */
480
+ indexAdditionalResolverRecords: boolean;
481
+ /**
482
+ * Indexed Chain IDs
483
+ *
484
+ * Includes the {@link ChainId} for each chain being indexed.
485
+ */
486
+ indexedChainIds: Set<ChainId>;
487
+ /**
488
+ * A flag derived from the built config indicating whether ENSIndexer is operating in a
489
+ * subgraph-compatible way. This flag is true if:
490
+ * a) only the subgraph plugin is activated,
491
+ * b) healReverseAddresess is false, and
492
+ * c) indexRecordValues is false
493
+ *
494
+ * If {@link isSubgraphCompatible} is true, ENSIndexer will:
495
+ * 1) use subgraph-compatible IDs for entities and events
496
+ * 2) limit indexing behavior to subgraph indexing semantics
497
+ */
498
+ isSubgraphCompatible: boolean;
499
+ /**
500
+ * Information about the ENSIndexer instance dependencies.
501
+ */
502
+ dependencyInfo: DependencyInfo;
503
+ }
504
+
505
+ type SerializedIndexedChainIds = Array<ChainId>;
506
+ /**
507
+ * Serialized representation of {@link ENSIndexerPublicConfig}
508
+ */
509
+ interface SerializedENSIndexerPublicConfig extends Omit<ENSIndexerPublicConfig, "ensAdminUrl" | "ensNodePublicUrl" | "indexedChainIds"> {
510
+ /**
511
+ * String representation of {@link ENSIndexerPublicConfig.ensAdminUrl}.
512
+ */
513
+ ensAdminUrl: UrlString;
514
+ /**
515
+ * String representation of {@link ENSIndexerPublicConfig.ensNodePublicUrl}.
516
+ */
517
+ ensNodePublicUrl: UrlString;
518
+ /**
519
+ * Array representation of {@link ENSIndexerPublicConfig.indexedChainIds}.
520
+ */
521
+ indexedChainIds: ChainId[];
522
+ }
523
+
524
+ /**
525
+ * Serialize a {@link ENSIndexerPublicConfig} object.
526
+ */
527
+ declare function deserializeENSIndexerPublicConfig(maybeConfig: SerializedENSIndexerPublicConfig, valueLabel?: string): ENSIndexerPublicConfig;
528
+
529
+ /**
530
+ * Subgraph compatibility
531
+ *
532
+ * Tells if indexer config guarantees data to be indexed while
533
+ * maintaining full subgraph-compatibility.
534
+ */
535
+ declare function isSubgraphCompatible(config: Pick<ENSIndexerPublicConfig, "plugins" | "healReverseAddresses" | "indexAdditionalResolverRecords">): boolean;
536
+
537
+ /**
538
+ * Serializes a {@link ChainConfig} object.
539
+ */
540
+ declare function serializeIndexedChainIds(indexedChainIds: Set<ChainId>): SerializedIndexedChainIds;
541
+ /**
542
+ * Serialize a {@link ENSIndexerPublicConfig} object.
543
+ */
544
+ declare function serializeENSIndexerPublicConfig(config: ENSIndexerPublicConfig): SerializedENSIndexerPublicConfig;
545
+
546
+ declare const ChainIndexingStatusIds: {
547
+ readonly Unstarted: "unstarted";
548
+ readonly Backfill: "backfill";
549
+ readonly Following: "following";
550
+ readonly Completed: "completed";
551
+ };
552
+ /**
553
+ * ChainIndexingStatusId is the derived string union of possible Chain Indexing Status identifiers.
554
+ */
555
+ type ChainIndexingStatusId = (typeof ChainIndexingStatusIds)[keyof typeof ChainIndexingStatusIds];
556
+ declare const OverallIndexingStatusIds: {
557
+ readonly Unstarted: "unstarted";
558
+ readonly Backfill: "backfill";
559
+ readonly Following: "following";
560
+ readonly Completed: "completed";
561
+ readonly IndexerError: "indexer-error";
562
+ };
563
+ /**
564
+ * OverallIndexingStatusId is the derived string union of possible Overall Indexing Status identifiers.
565
+ */
566
+ type OverallIndexingStatusId = (typeof OverallIndexingStatusIds)[keyof typeof OverallIndexingStatusIds];
567
+ declare const ChainIndexingStrategyIds: {
568
+ readonly Indefinite: "indefinite";
569
+ readonly Definite: "definite";
570
+ };
571
+ /**
572
+ * ChainIndexingStrategyIds is the derived string union of possible Chain Indexing Strategy identifiers.
573
+ */
574
+ type ChainIndexingStrategyId = (typeof ChainIndexingStrategyIds)[keyof typeof ChainIndexingStrategyIds];
575
+ /**
576
+ * Chain Indexing Indefinite Config
577
+ *
578
+ * Configures a chain to be indexed for an indefinite range.
579
+ */
580
+ interface ChainIndexingIndefiniteConfig {
581
+ /**
582
+ * Chain indexing strategy.
583
+ */
584
+ strategy: typeof ChainIndexingStrategyIds.Indefinite;
585
+ /**
586
+ * The block where indexing of the chain starts.
587
+ *
588
+ * An indexed chain always has its `startBlock` defined.
589
+ */
590
+ startBlock: BlockRef;
591
+ /**
592
+ * Indefinite chain indexing configs always have a null `endBlock`.
593
+ */
594
+ endBlock?: null;
595
+ }
596
+ /**
597
+ * Chain Indexing Definite Config
598
+ *
599
+ * Configures a chain to be indexed for a definite range.
600
+ *
601
+ * Invariants:
602
+ * - `startBlock` is always before or the same as `endBlock`
603
+ */
604
+ interface ChainIndexingDefiniteConfig {
605
+ /**
606
+ * Chain indexing strategy.
607
+ */
608
+ strategy: typeof ChainIndexingStrategyIds.Definite;
609
+ /**
610
+ * The block where indexing of the chain starts.
611
+ *
612
+ * `startBlock` must always be defined.
613
+ */
614
+ startBlock: BlockRef;
615
+ /**
616
+ * The block where indexing of the chain ends.
617
+ *
618
+ * Definite chain indexing configs always have a defined `endBlock`.
619
+ */
620
+ endBlock: BlockRef;
621
+ }
622
+ /**
623
+ * Chain Indexing Config
624
+ *
625
+ * Configuration of an indexed chain.
626
+ */
627
+ type ChainIndexingConfig = ChainIndexingIndefiniteConfig | ChainIndexingDefiniteConfig;
628
+ /**
629
+ * Chain Indexing Status: Unstarted
630
+ *
631
+ * Notes:
632
+ * - The "unstarted" status applies when using omnichain ordering and
633
+ * the omnichainIndexingCursor from the overall indexing status <= config.startBlock.timestamp.
634
+ */
635
+ interface ChainIndexingUnstartedStatus {
636
+ status: typeof ChainIndexingStatusIds.Unstarted;
637
+ config: ChainIndexingConfig;
638
+ }
639
+ /**
640
+ * Chain Indexing Status: Backfill
641
+ *
642
+ * During a backfill, special performance optimizations are applied to
643
+ * index all blocks between config.startBlock and backfillEndBlock
644
+ * as fast as possible.
645
+ *
646
+ * Notes:
647
+ * - The backfillEndBlock is either config.endBlock (if present) or
648
+ * the latest block on the chain when the ENSIndexer process started up.
649
+ * Note how this means the backfillEndBlock is always a "fixed target".
650
+ * - When latestIndexedBlock reaches backfillEndBlock, the backfill is complete.
651
+ * The moment backfill is complete the status does not immediately transition.
652
+ * Instead, internal processing is completed for a period of time while
653
+ * the status remains "backfill". After this internal processing is completed
654
+ * the status will change to "following" or "completed" depending on
655
+ * the configured indexing strategy. If the strategy is indefinite,
656
+ * changes to "following", else if the strategy is definite, changes to
657
+ * "completed".
658
+ *
659
+ * Invariants:
660
+ * - `config.startBlock` is always before or the same as `latestIndexedBlock`
661
+ * - `latestIndexedBlock` is always before or the same as `backfillEndBlock`
662
+ * - `backfillEndBlock` is the same as `config.endBlock` if and only if
663
+ * the config is definite.
664
+ */
665
+ interface ChainIndexingBackfillStatus {
666
+ status: typeof ChainIndexingStatusIds.Backfill;
667
+ config: ChainIndexingConfig;
668
+ /**
669
+ * The block that was most recently indexed.
670
+ */
671
+ latestIndexedBlock: BlockRef;
672
+ /**
673
+ * The block that is the target for finishing the backfill.
674
+ */
675
+ backfillEndBlock: BlockRef;
676
+ }
677
+ /**
678
+ * Chain Indexing Status: Following
679
+ *
680
+ * Following occurs after the backfill of a chain is completed and represents
681
+ * the process of indefinitely following (and indexing!) new blocks as they are
682
+ * added to the indexed chain across time.
683
+ *
684
+ * Invariants:
685
+ * - `config.startBlock` is always before or the same as `latestIndexedBlock`
686
+ * - `latestIndexedBlock` is always before or the same as `latestKnownBlock`
687
+ */
688
+ interface ChainIndexingFollowingStatus {
689
+ status: typeof ChainIndexingStatusIds.Following;
690
+ config: ChainIndexingIndefiniteConfig;
691
+ /**
692
+ * The block that was most recently indexed.
693
+ */
694
+ latestIndexedBlock: BlockRef;
695
+ /**
696
+ * The "highest" block that has been fetched by RPC calls and stored in
697
+ * the RPC cache as part of the indexing process.
698
+ */
699
+ latestKnownBlock: BlockRef;
700
+ /**
701
+ * The number of seconds between `latestIndexedBlock.timestamp` and
702
+ * the current time in ENSIndexer. This represents the upper-bound worst case
703
+ * distance approximation between the latest block on the chain (independent
704
+ * of it becoming known to us) and the latest block that has completed
705
+ * indexing. The true distance to the latest block on the chain will be less
706
+ * if the latest block on the chain was not issued at the current second.
707
+ */
708
+ approxRealtimeDistance: Duration;
709
+ }
710
+ /**
711
+ * Chain Indexing Status: Completed
712
+ *
713
+ * Indexing of a chain is completed after the backfill when the chain is
714
+ * not configured to be indefinitely indexed.
715
+ *
716
+ * Invariants:
717
+ * - `config.startBlock` is always before or the same as `latestIndexedBlock`
718
+ * - `latestIndexedBlock` is always the same as `config.endBlock`.
719
+ */
720
+ interface ChainIndexingCompletedStatus {
721
+ status: typeof ChainIndexingStatusIds.Completed;
722
+ config: ChainIndexingDefiniteConfig;
723
+ /**
724
+ * The block that was most recently indexed.
725
+ */
726
+ latestIndexedBlock: BlockRef;
727
+ }
728
+ /**
729
+ * Chain Indexing Status
730
+ *
731
+ * Use the `status` field to determine the correct type interpretation at runtime.
732
+ */
733
+ type ChainIndexingStatus = ChainIndexingUnstartedStatus | ChainIndexingBackfillStatus | ChainIndexingFollowingStatus | ChainIndexingCompletedStatus;
734
+ /**
735
+ * Chain Indexing Status: Active
736
+ *
737
+ * Represents a chain where indexing is currently active.
738
+ * The `latestIndexedBlock` field will be available.
739
+ */
740
+ type ChainIndexingActiveStatus = ChainIndexingBackfillStatus | ChainIndexingFollowingStatus;
741
+ /**
742
+ * Chain Indexing Status: Standby
743
+ *
744
+ * Represents a chain where indexing is currently on standby (not happening).
745
+ * The `latestIndexedBlock` field will not be available.
746
+ */
747
+ type ChainIndexingStandbyStatus = ChainIndexingUnstartedStatus | ChainIndexingCompletedStatus;
748
+ /**
749
+ * ENSIndexer Overall Indexing Status: Unstarted
750
+ *
751
+ * Describes the current state of indexing operations across all indexed chains
752
+ * when the overall indexing status is {@link OverallIndexingStatusIds.Unstarted}.
753
+ */
754
+ interface ENSIndexerOverallIndexingUnstartedStatus {
755
+ /**
756
+ * Overall Indexing Status
757
+ */
758
+ overallStatus: typeof OverallIndexingStatusIds.Unstarted;
759
+ /**
760
+ * Indexing Status for each chain.
761
+ *
762
+ * Each chain is guaranteed to have the "unstarted" status.
763
+ * It's impossible for any chain to have status other than "unstarted".
764
+ */
765
+ chains: Map<ChainId, ChainIndexingUnstartedStatus>;
766
+ }
767
+ /**
768
+ * Chain Indexing Status allowed when overall status is 'backfill'.
769
+ */
770
+ type ChainIndexingStatusForBackfillOverallStatus = ChainIndexingUnstartedStatus | ChainIndexingBackfillStatus | ChainIndexingCompletedStatus;
771
+ /**
772
+ * ENSIndexer Overall Indexing Status: Backfill
773
+ *
774
+ * Describes the current state of indexing operations across all indexed chains
775
+ * when the overall indexing status is {@link OverallIndexingStatusIds.Backfill}.
776
+ */
777
+ interface ENSIndexerOverallIndexingBackfillStatus {
778
+ /**
779
+ * Overall Indexing Status
780
+ */
781
+ overallStatus: typeof OverallIndexingStatusIds.Backfill;
782
+ /**
783
+ * Omnichain Indexing Cursor
784
+ *
785
+ * Identifies the timestamp of the progress of omnichain indexing across
786
+ * all chains in {@link ChainIndexingBackfillStatus} status.
787
+ *
788
+ * Invariants:
789
+ * - the cursor value is guaranteed to be lower than or equal to
790
+ * the timestamp of the earliest `config.startBlock` across all chains
791
+ * in {@link ChainIndexingStandbyStatus} status.
792
+ */
793
+ omnichainIndexingCursor: UnixTimestamp;
794
+ /**
795
+ * Indexing Status for each chain.
796
+ *
797
+ * At least one chain is guaranteed to be in the "backfill" status.
798
+ * Each chain is guaranteed to have a status of either "unstarted",
799
+ * "backfill" or "completed". It's impossible for any chain to be
800
+ * in the "following" status.
801
+ */
802
+ chains: Map<ChainId, ChainIndexingStatusForBackfillOverallStatus>;
803
+ }
804
+ /**
805
+ * ENSIndexer Overall Indexing Status: Completed
806
+ *
807
+ * Describes the final state of indexing operations across all indexed chains
808
+ * when all indexed chains are configured for a definite indexing strategy and
809
+ * all indexing of that definite range is completed.
810
+ */
811
+ interface ENSIndexerOverallIndexingCompletedStatus {
812
+ /**
813
+ * Overall Indexing Status
814
+ */
815
+ overallStatus: typeof OverallIndexingStatusIds.Completed;
816
+ /**
817
+ * Indexing Status for each chain.
818
+ *
819
+ * Each chain is guaranteed to have the "completed" status.
820
+ * It's impossible for any chain to have status other than "completed".
821
+ */
822
+ chains: Map<ChainId, ChainIndexingCompletedStatus>;
823
+ }
824
+ /**
825
+ * ENSIndexer Overall Indexing Status: Following
826
+ *
827
+ * Describes the state when the overall indexing status is
828
+ * {@link OverallIndexingStatusIds.Following}.
829
+ */
830
+ interface ENSIndexerOverallIndexingFollowingStatus {
831
+ /**
832
+ * Overall Indexing Status
833
+ */
834
+ overallStatus: typeof OverallIndexingStatusIds.Following;
835
+ /**
836
+ * Omnichain Indexing Cursor
837
+ *
838
+ * Identifies the timestamp of the progress of omnichain indexing across
839
+ * all chains in {@link ChainIndexingActiveStatus} status.
840
+ *
841
+ * Invariants:
842
+ * - the cursor value is guaranteed to be lower than or equal to
843
+ * the timestamp of the earliest `config.startBlock` across all chains
844
+ * in {@link ChainIndexingStandbyStatus} status.
845
+ */
846
+ omnichainIndexingCursor: UnixTimestamp;
847
+ /**
848
+ * Indexing Status for each chain.
849
+ *
850
+ * At least one chain is guaranteed to be in the "following" status.
851
+ * Each chain is guaranteed to have a status of either "unstarted",
852
+ * "backfill", "following" or "completed".
853
+ */
854
+ chains: Map<ChainId, ChainIndexingStatus>;
855
+ /**
856
+ * The maximum
857
+ * {@link ChainIndexingFollowingStatus.approxRealtimeDistance} value
858
+ * across all chains with status: 'following'.
859
+ */
860
+ overallApproxRealtimeDistance: Duration;
861
+ }
862
+ /**
863
+ * ENSIndexer Overall Indexing Status: Error
864
+ *
865
+ * Describes the state when ENSIndexer failed to return the indexing status for
866
+ * all indexed chains.
867
+ *
868
+ * This state suggests an error with the "primary" ENSIndexer.
869
+ */
870
+ interface ENSIndexerOverallIndexingErrorStatus {
871
+ /**
872
+ * Overall Indexing Status
873
+ */
874
+ overallStatus: typeof OverallIndexingStatusIds.IndexerError;
875
+ }
876
+ /**
877
+ * ENSIndexer Overall Indexing Status
878
+ *
879
+ * Describes the overall state of indexing operations.
880
+ */
881
+ type ENSIndexerOverallIndexingStatus = ENSIndexerOverallIndexingUnstartedStatus | ENSIndexerOverallIndexingBackfillStatus | ENSIndexerOverallIndexingCompletedStatus | ENSIndexerOverallIndexingFollowingStatus | ENSIndexerOverallIndexingErrorStatus;
882
+
883
+ /**
884
+ * Serialized representation of {@link ENSIndexerOverallIndexingUnstartedStatus}
885
+ */
886
+ interface SerializedENSIndexerOverallIndexingUnstartedStatus extends Omit<ENSIndexerOverallIndexingUnstartedStatus, "chains"> {
887
+ chains: Record<ChainIdString, ChainIndexingUnstartedStatus>;
888
+ }
889
+ /**
890
+ * Serialized representation of {@link ENSIndexerOverallIndexingBackfillStatus}
891
+ */
892
+ interface SerializedENSIndexerOverallIndexingBackfillStatus extends Omit<ENSIndexerOverallIndexingBackfillStatus, "chains"> {
893
+ chains: Record<ChainIdString, ChainIndexingStatusForBackfillOverallStatus>;
894
+ }
895
+ /**
896
+ * Serialized representation of {@link ENSIndexerOverallIndexingCompletedStatus}
897
+ */
898
+ interface SerializedENSIndexerOverallIndexingCompletedStatus extends Omit<ENSIndexerOverallIndexingCompletedStatus, "chains"> {
899
+ chains: Record<ChainIdString, ChainIndexingCompletedStatus>;
900
+ }
901
+ /**
902
+ * Serialized representation of {@link ENSIndexerOverallIndexingFollowingStatus}
903
+ */
904
+ interface SerializedENSIndexerOverallIndexingFollowingStatus extends Omit<ENSIndexerOverallIndexingFollowingStatus, "chains"> {
905
+ chains: Record<ChainIdString, ChainIndexingStatus>;
906
+ }
907
+ /**
908
+ * Serialized representation of {@link ENSIndexerOverallIndexingErrorStatus}
909
+ */
910
+ interface SerializedENSIndexerOverallIndexingErrorStatus extends ENSIndexerOverallIndexingErrorStatus {
911
+ }
912
+ /**
913
+ * Serialized representation of {@link ENSIndexerOverallIndexingStatus}
914
+ */
915
+ type SerializedENSIndexerOverallIndexingStatus = SerializedENSIndexerOverallIndexingUnstartedStatus | SerializedENSIndexerOverallIndexingBackfillStatus | SerializedENSIndexerOverallIndexingCompletedStatus | SerializedENSIndexerOverallIndexingFollowingStatus | SerializedENSIndexerOverallIndexingErrorStatus;
916
+
917
+ /**
918
+ * Serialize a {@link ENSIndexerOverallIndexingStatus} object.
919
+ */
920
+ declare function deserializeENSIndexerIndexingStatus(maybeStatus: SerializedENSIndexerOverallIndexingStatus, valueLabel?: string): ENSIndexerOverallIndexingStatus;
921
+
922
+ /**
923
+ * Get {@link OverallIndexingStatusId} based on indexed chains' statuses.
924
+ *
925
+ * This function decides what is the current overall indexing status,
926
+ * based on provided chain indexing statuses. The fact that chain indexing
927
+ * statuses were provided to this function guarantees there was no indexer
928
+ * error, and that the overall indexing status is never
929
+ * an {@link OverallIndexingStatusIds.IndexerError}
930
+ */
931
+ declare function getOverallIndexingStatus(chains: ChainIndexingStatus[]): Exclude<OverallIndexingStatusId, typeof OverallIndexingStatusIds.IndexerError>;
932
+ /**
933
+ * Get overall approximate realtime distance across all indexed chains.
934
+ *
935
+ * @throws an error if none of the indexed chains was in the 'following' status.
936
+ */
937
+ declare function getOverallApproxRealtimeDistance(chains: ChainIndexingStatus[]): Duration;
938
+ /**
939
+ * Get Omnichain Indexing Cursor across all chains which status is
940
+ * {@link ChainIndexingActiveStatus}.
941
+ */
942
+ declare function getOmnichainIndexingCursor(chains: ChainIndexingActiveStatus[]): UnixTimestamp;
943
+ /**
944
+ * Get all chains which status is {@link ChainIndexingActiveStatus}.
945
+ */
946
+ declare function getActiveChains(chains: ChainIndexingStatus[]): ChainIndexingActiveStatus[];
947
+ /**
948
+ * Get all chains which status is {@link ChainIndexingStandbyStatus}.
949
+ */
950
+ declare function getStandbyChains(chains: ChainIndexingStatus[]): ChainIndexingStandbyStatus[];
951
+ /**
952
+ * Create {@link ChainIndexingConfig} for given block refs.
953
+ *
954
+ * @param startBlock required block ref
955
+ * @param endBlock optional block ref
956
+ */
957
+ declare function createIndexingConfig(startBlock: BlockRef, endBlock: BlockRef | null): ChainIndexingConfig;
958
+ /**
959
+ * Check if Chain Indexing Statuses fit the 'unstarted' overall status
960
+ * requirements:
961
+ * - All chains are guaranteed to have a status of "unstarted".
962
+ *
963
+ * Note: This function narrows the {@link ChainIndexingStatus} type to
964
+ * {@link ChainIndexingUnstartedStatus}.
965
+ */
966
+ declare function checkChainIndexingStatusesForUnstartedOverallStatus(chains: ChainIndexingStatus[]): chains is ChainIndexingUnstartedStatus[];
967
+ /**
968
+ * Check if Chain Indexing Statuses fit the 'backfill' overall status
969
+ * requirements:
970
+ * - At least one chain is guaranteed to be in the "backfill" status.
971
+ * - Each chain is guaranteed to have a status of either "unstarted",
972
+ * "backfill" or "completed".
973
+ *
974
+ * Note: This function narrows the {@linkChainIndexingStatus} type to
975
+ * {@link ChainIndexingStatusForBackfillOverallStatus}.
976
+ */
977
+ declare function checkChainIndexingStatusesForBackfillOverallStatus(chains: ChainIndexingStatus[]): chains is ChainIndexingStatusForBackfillOverallStatus[];
978
+ /**
979
+ * Checks if Chain Indexing Statuses fit the 'completed' overall status
980
+ * requirements:
981
+ * - All chains are guaranteed to have a status of "completed".
982
+ *
983
+ * Note: This function narrows the {@linkChainIndexingStatus} type to
984
+ * {@link ChainIndexingCompletedStatus}.
985
+ */
986
+ declare function checkChainIndexingStatusesForCompletedOverallStatus(chains: ChainIndexingStatus[]): chains is ChainIndexingCompletedStatus[];
987
+ /**
988
+ * Checks Chain Indexing Statuses fit the 'following' overall status
989
+ * requirements:
990
+ * - At least one chain is guaranteed to be in the "following" status.
991
+ * - Any other chain can have any status.
992
+ */
993
+ declare function checkChainIndexingStatusesForFollowingOverallStatus(chains: ChainIndexingStatus[]): chains is ChainIndexingStatus[];
994
+
995
+ /**
996
+ * Serialize chain indexing statuses.
997
+ */
998
+ declare function serializeChainIndexingStatuses<ChainIndexingStatusType extends ChainIndexingStatus>(chainIndexingStatuses: Map<ChainId, ChainIndexingStatusType>): Record<ChainIdString, ChainIndexingStatusType>;
999
+ /**
1000
+ * Serialize a {@link ENSIndexerIndexingStatus} object.
1001
+ */
1002
+ declare function serializeENSIndexerIndexingStatus(indexingStatus: ENSIndexerOverallIndexingStatus): SerializedENSIndexerOverallIndexingStatus;
1003
+
1004
+ /**
1005
+ * Identifiers for each traceable ENS protocol.
1006
+ */
1007
+ declare enum TraceableENSProtocol {
1008
+ ForwardResolution = "forward-resolution",
1009
+ ReverseResolution = "reverse-resolution"
1010
+ }
1011
+ /**
1012
+ * Encodes the set of well-known steps in the ENS Forward Resolution protocol.
1013
+ */
1014
+ declare enum ForwardResolutionProtocolStep {
1015
+ Operation = "operation",
1016
+ FindResolver = "find-resolver",
1017
+ ActiveResolverExists = "active-resolver-exists",
1018
+ AccelerateENSIP19ReverseResolver = "accelerate-ensip-19-reverse-resolver",
1019
+ AccelerateKnownOffchainLookupResolver = "accelerate-known-offchain-lookup-resolver",
1020
+ AccelerateKnownOnchainStaticResolver = "accelerate-known-onchain-static-resolver",
1021
+ RequireResolver = "require-resolver",
1022
+ ExecuteResolveCalls = "execute-resolve-calls"
1023
+ }
1024
+ /**
1025
+ * Encodes the set of well-known steps in the ENS Reverse Resolution protocol.
1026
+ */
1027
+ declare enum ReverseResolutionProtocolStep {
1028
+ Operation = "operation",
1029
+ ResolveReverseName = "resolve-reverse-name",
1030
+ NameRecordExists = "name-record-exists-check",
1031
+ ForwardResolveAddressRecord = "forward-resolve-address-record",
1032
+ VerifyResolvedAddressMatchesAddress = "verify-resolved-address-matches-address"
1033
+ }
1034
+ declare const ATTR_PROTOCOL_NAME = "ens.protocol";
1035
+ declare const ATTR_PROTOCOL_STEP = "ens.protocol.step";
1036
+ 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;
1055
+ timestamp: number;
1056
+ duration: number;
1057
+ attributes: {
1058
+ [k: string]: unknown;
1059
+ };
1060
+ status: any;
1061
+ events: any;
1062
+ };
1063
+ type ProtocolSpan = ReturnType<typeof readableSpanToProtocolSpan>;
1064
+ type ProtocolTrace = ProtocolSpan[];
1065
+
1066
+ /**
1067
+ * Encodes a selection of Resolver records in the context of a specific Name.
1068
+ */
1069
+ interface ResolverRecordsSelection {
1070
+ /**
1071
+ * Whether to fetch the name's `name` record. This value is primarily used in the context of
1072
+ * Reverse Resolution.
1073
+ *
1074
+ * @see https://docs.ens.domains/ensip/19/#reverse-resolution
1075
+ */
1076
+ name?: boolean;
1077
+ /**
1078
+ * Which coinTypes to fetch address records for.
1079
+ */
1080
+ addresses?: CoinType[];
1081
+ /**
1082
+ * Which keys to fetch text records for.
1083
+ */
1084
+ texts?: string[];
1085
+ }
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
+ declare const isSelectionEmpty: (selection: ResolverRecordsSelection) => boolean;
1091
+
1092
+ /**
1093
+ * An internal type representing a non-inferred ResolverRecordsResponse, used in situations where
1094
+ * access to the more specific inferred type (ResolverRecordsResponse<SELECTION>) is difficult or
1095
+ * unnecessary.
1096
+ */
1097
+ type ResolverRecordsResponseBase = {
1098
+ /**
1099
+ * The name record, relevant in the context of Reverse Resolution.
1100
+ * Null if no name record is set.
1101
+ */
1102
+ name: Name | null;
1103
+ /**
1104
+ * Address records, keyed by CoinType.
1105
+ * Value is null if no record for the specified CoinType is set.
1106
+ *
1107
+ * NOTE: ENS resolver address records can store arbitrary string values,
1108
+ * including non-EVM addresses — always validate the record value against
1109
+ * the format your application expects.
1110
+ */
1111
+ addresses: Record<CoinType, string | null>;
1112
+ /**
1113
+ * Text records, keyed by key.
1114
+ * Value is null if no record for the specified key is set.
1115
+ */
1116
+ texts: Record<string, string | null>;
1117
+ };
1118
+ /**
1119
+ * Represents the strongly-typed set of records based on the provided SELECTION
1120
+ *
1121
+ * @example
1122
+ * ```typescript
1123
+ * const selection = {
1124
+ * name: true,
1125
+ * addresses: [60],
1126
+ * texts: ["com.twitter", "avatar"],
1127
+ * } as const satisfies ResolverRecordsSelection;
1128
+ *
1129
+ * type Response = ResolverRecordsResponse<typeof selection>;
1130
+ *
1131
+ * // results in the following type
1132
+ * type Response = {
1133
+ * readonly name: Name | null;
1134
+ * readonly addresses: Record<"60", string | null>;
1135
+ * readonly texts: Record<"avatar" | "com.twitter", string | null>;
1136
+ * }
1137
+ * ```
1138
+ */
1139
+ type ResolverRecordsResponse<T extends ResolverRecordsSelection = ResolverRecordsSelection> = {
1140
+ [K in keyof T as T[K] extends true | any[] ? K : never]: K extends "addresses" ? Record<`${T["addresses"] extends readonly CoinType[] ? T["addresses"][number] : never}`, string | null> : K extends "texts" ? Record<T["texts"] extends readonly string[] ? T["texts"][number] : never, string | null> : ResolverRecordsResponseBase[K & keyof ResolverRecordsResponseBase];
1141
+ };
1142
+
1143
+ /**
1144
+ * Arguments required to perform Forward Resolution
1145
+ */
1146
+ interface ForwardResolutionArgs<SELECTION extends ResolverRecordsSelection> {
1147
+ name: Name;
1148
+ selection: SELECTION;
1149
+ }
1150
+ /**
1151
+ * The result of performing ForwardResolution
1152
+ */
1153
+ type ForwardResolutionResult<SELECTION extends ResolverRecordsSelection> = ResolverRecordsResponse<SELECTION>;
1154
+ /**
1155
+ * Arguments required to perform Reverse Resolution
1156
+ */
1157
+ interface ReverseResolutionArgs {
1158
+ address: Address;
1159
+ chainId: ChainId;
1160
+ }
1161
+ /**
1162
+ * The result of performing ReverseResolution
1163
+ */
1164
+ type ReverseResolutionResult = Name | null;
1165
+ /**
1166
+ * Arguments required to perform Multichain Primary Name Resolution
1167
+ */
1168
+ interface MultichainPrimaryNameResolutionArgs {
1169
+ address: Address;
1170
+ chainIds?: ChainId[];
1171
+ }
1172
+ /**
1173
+ * The result of performing MultichainPrimaryNameResolution
1174
+ */
1175
+ type MultichainPrimaryNameResolutionResult = Record<ChainId, Name | null>;
1176
+
1177
+ /**
1178
+ * API Error Response Type
1179
+ */
1180
+ interface ErrorResponse {
1181
+ message: string;
1182
+ details?: unknown;
1183
+ }
1184
+ interface TraceableRequest {
1185
+ trace?: boolean;
1186
+ }
1187
+ interface TraceableResponse {
1188
+ trace?: ProtocolTrace;
1189
+ }
1190
+ interface AcceleratableRequest {
1191
+ accelerate?: boolean;
1192
+ }
1193
+ /**
1194
+ * Resolve Records Request Type
1195
+ */
1196
+ interface ResolveRecordsRequest<SELECTION extends ResolverRecordsSelection> extends ForwardResolutionArgs<SELECTION>, AcceleratableRequest, TraceableRequest {
1197
+ }
1198
+ /**
1199
+ * Resolve Records Response Type
1200
+ */
1201
+ interface ResolveRecordsResponse<SELECTION extends ResolverRecordsSelection> extends TraceableResponse {
1202
+ records: ResolverRecordsResponse<SELECTION>;
1203
+ }
1204
+ /**
1205
+ * Resolve Primary Name Request Type
1206
+ */
1207
+ interface ResolvePrimaryNameRequest extends ReverseResolutionArgs, AcceleratableRequest, TraceableRequest {
1208
+ }
1209
+ /**
1210
+ * Resolve Primary Name Response Type
1211
+ */
1212
+ interface ResolvePrimaryNameResponse extends TraceableResponse {
1213
+ name: ReverseResolutionResult;
1214
+ }
1215
+ interface ResolvePrimaryNamesRequest extends MultichainPrimaryNameResolutionArgs, AcceleratableRequest, TraceableRequest {
1216
+ }
1217
+ interface ResolvePrimaryNamesResponse extends TraceableResponse {
1218
+ names: MultichainPrimaryNameResolutionResult;
1219
+ }
1220
+
1221
+ /**
1222
+ * Default ENSNode API endpoint URL
1223
+ */
1224
+ declare const DEFAULT_ENSNODE_API_URL: "https://api.alpha.ensnode.io";
1225
+ /**
1226
+ * Configuration options for ENSNode API client
1227
+ */
1228
+ interface ClientOptions {
1229
+ /** The ENSNode API URL */
1230
+ url: URL;
1231
+ }
1232
+ /**
1233
+ * ENSNode API Client
1234
+ *
1235
+ * Provides access to the following ENSNode APIs:
1236
+ * - Resolution API
1237
+ * - 🚧 Configuration API
1238
+ * - 🚧 Indexing Status API
1239
+ *
1240
+ * @example
1241
+ * ```typescript
1242
+ * // Create client with default options
1243
+ * const client = new ENSNodeClient();
1244
+ *
1245
+ * // Use resolution methods
1246
+ * const { records } = await client.resolveRecords("jesse.base.eth", {
1247
+ * addresses: [60],
1248
+ * texts: ["avatar"]
1249
+ * });
1250
+ * ```
1251
+ *
1252
+ * @example
1253
+ * ```typescript
1254
+ * // Custom configuration
1255
+ * const client = new ENSNodeClient({
1256
+ * url: new URL("https://my-ensnode-instance.com"),
1257
+ * });
1258
+ * ```
1259
+ */
1260
+ declare class ENSNodeClient {
1261
+ private readonly options;
1262
+ static defaultOptions(): ClientOptions;
1263
+ constructor(options?: Partial<ClientOptions>);
1264
+ getOptions(): Readonly<ClientOptions>;
1265
+ /**
1266
+ * Resolves records for an ENS name (Forward Resolution).
1267
+ *
1268
+ * @param name The ENS Name whose records to resolve
1269
+ * @param selection selection of Resolver records
1270
+ * @param options additional options
1271
+ * @param options.accelerate whether to attempt Protocol Acceleration (default false)
1272
+ * @param options.trace whether to include a trace in the response (default false)
1273
+ * @returns ResolveRecordsResponse<SELECTION>
1274
+ * @throws If the request fails or the ENSNode API returns an error response
1275
+ *
1276
+ * @example
1277
+ * ```typescript
1278
+ * const { records } = await client.resolveRecords("jesse.base.eth", {
1279
+ * addresses: [60],
1280
+ * texts: ["avatar", "com.twitter"]
1281
+ * });
1282
+ *
1283
+ * console.log(records);
1284
+ * // {
1285
+ * // addresses: {
1286
+ * // 60: "0xabcd..."
1287
+ * // },
1288
+ * // texts: {
1289
+ * // avatar: "https://example.com/image.jpg",
1290
+ * // "com.twitter": null, // if not set, for example
1291
+ * // }
1292
+ * // }
1293
+ * ```
1294
+ */
1295
+ resolveRecords<SELECTION extends ResolverRecordsSelection>(name: ResolveRecordsRequest<SELECTION>["name"], selection: ResolveRecordsRequest<SELECTION>["selection"], options?: Omit<ResolveRecordsRequest<SELECTION>, "name" | "selection">): Promise<ResolveRecordsResponse<SELECTION>>;
1296
+ /**
1297
+ * Resolves the primary name of a specified address (Reverse Resolution) on a specific chain.
1298
+ *
1299
+ * If the `address` specifies a valid [ENSIP-19 Default Name](https://docs.ens.domains/ensip/19/#default-primary-name),
1300
+ * the Default Name will be returned. You _may_ query the Default EVM Chain Id (`0`) in order to
1301
+ * determine the `address`'s Default Name directly.
1302
+ *
1303
+ * @param address The Address whose Primary Name to resolve
1304
+ * @param chainId The chain id within which to query the address' ENSIP-19 Multichain Primary Name
1305
+ * @param options additional options
1306
+ * @param options.accelerate whether to attempt Protocol Acceleration (default false)
1307
+ * @param options.trace whether to include a trace in the response (default false)
1308
+ * @returns ResolvePrimaryNameResponse
1309
+ * @throws If the request fails or the ENSNode API returns an error response
1310
+ *
1311
+ * @example
1312
+ * ```typescript
1313
+ * // Resolve the address' Primary Name on Ethereum Mainnet
1314
+ * const { name } = await client.resolvePrimaryName("0x179A862703a4adfb29896552DF9e307980D19285", 1);
1315
+ * // name === 'gregskril.eth'
1316
+ *
1317
+ * // Resolve the address' Primary Name on Base
1318
+ * const { name } = await client.resolvePrimaryName("0x179A862703a4adfb29896552DF9e307980D19285", 8453);
1319
+ * // name === 'greg.base.eth'
1320
+ *
1321
+ * // Resolve the address' Default Primary Name
1322
+ * const { name } = await client.resolvePrimaryName("0x179A862703a4adfb29896552DF9e307980D19285", 0);
1323
+ * // name === 'gregskril.eth'
1324
+ * ```
1325
+ */
1326
+ resolvePrimaryName(address: ResolvePrimaryNameRequest["address"], chainId: ResolvePrimaryNameRequest["chainId"], options?: Omit<ResolvePrimaryNameRequest, "address" | "chainId">): Promise<ResolvePrimaryNameResponse>;
1327
+ /**
1328
+ * Resolves the primary names of a specified address across multiple chains.
1329
+ *
1330
+ * If the `address` specifies a valid [ENSIP-19 Default Name](https://docs.ens.domains/ensip/19/#default-primary-name),
1331
+ * the Default Name will be returned for all chainIds for which there is not a chain-specific
1332
+ * Primary Name. To avoid misuse, you _may not_ query the Default EVM Chain Id (`0`) directly, and
1333
+ * should rely on the aforementioned per-chain defaulting behavior.
1334
+ *
1335
+ * @param address The Address whose Primary Names to resolve
1336
+ * @param options additional options
1337
+ * @param options.chainIds The set of chain ids within which to query the address' ENSIP-19
1338
+ * Multichain Primary Name (default: all ENSIP-19 supported chains)
1339
+ * @param options.accelerate whether to attempt Protocol Acceleration (default: true)
1340
+ * @param options.trace whether to include a trace in the response (default: false)
1341
+ * @returns ResolvePrimaryNamesResponse
1342
+ * @throws If the request fails or the ENSNode API returns an error response
1343
+ *
1344
+ * @example
1345
+ * ```typescript
1346
+ * // Resolve the address' Primary Names on all ENSIP-19 supported chain ids
1347
+ * const { names } = await client.resolvePrimaryNames("0x179A862703a4adfb29896552DF9e307980D19285");
1348
+ *
1349
+ * console.log(names);
1350
+ * // {
1351
+ * // "1": "gregskril.eth",
1352
+ * // "10": "gregskril.eth",
1353
+ * // "8453": "greg.base.eth", // base-specific Primary Name!
1354
+ * // "42161": "gregskril.eth",
1355
+ * // "59144": "gregskril.eth",
1356
+ * // "534352": "gregskril.eth"
1357
+ * // }
1358
+ *
1359
+ * // Resolve the address' Primary Names on specific chain Ids
1360
+ * const { names } = await client.resolvePrimaryNames("0xabcd...", [1, 8453]);
1361
+ *
1362
+ * console.log(names);
1363
+ * // {
1364
+ * // "1": "gregskril.eth",
1365
+ * // "8453": "greg.base.eth", // base-specific Primary Name!
1366
+ * // }
1367
+ * ```
1368
+ */
1369
+ resolvePrimaryNames(address: ResolvePrimaryNamesRequest["address"], options?: Omit<ResolvePrimaryNamesRequest, "address">): Promise<ResolvePrimaryNamesResponse>;
1370
+ }
160
1371
 
161
- export { type Cache, ETH_COIN_TYPE, type EncodedLabelHash, type Label, type LabelHash, LruCache, type Name, type Node, PluginName, REVERSE_ROOT_NODES, ROOT_NODE, isLabelIndexable, makeSubdomainNode, maybeHealLabelByReverseAddress, uint256ToHex32 };
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 };