@ensnode/ensnode-sdk 1.0.2 → 1.1.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,8 @@
1
1
  import { Hex, Address, ByteArray, Hash } from 'viem';
2
2
  import { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
3
3
  export { CoinType, EvmCoinType } from '@ensdomains/address-encoder';
4
- import { EncodedReferrer } from '@namehash/ens-referrals';
5
- export { EncodedReferrer, decodeEncodedReferrer, zeroEncodedReferrer } from '@namehash/ens-referrals';
4
+ import { EncodedReferrer, ReferrerLeaderboardPaginationParams, ReferrerLeaderboardPage } from '@namehash/ens-referrals';
5
+ export { EncodedReferrer, ZERO_ENCODED_REFERRER, decodeEncodedReferrer } from '@namehash/ens-referrals';
6
6
  import z$1, { z } from 'zod/v4';
7
7
  import { ENSNamespaceId } from '@ensnode/datasources';
8
8
  export { ENSNamespaceId, ENSNamespaceIds, getENSRootChainId } from '@ensnode/datasources';
@@ -622,6 +622,7 @@ interface Cache<KeyType extends string, ValueType> {
622
622
  */
623
623
  get capacity(): number;
624
624
  }
625
+
625
626
  /**
626
627
  * Cache that maps from string -> ValueType with a LRU (least recently used) eviction policy.
627
628
  *
@@ -645,60 +646,74 @@ declare class LruCache<KeyType extends string, ValueType> implements Cache<KeyTy
645
646
  get size(): number;
646
647
  get capacity(): number;
647
648
  }
649
+
648
650
  /**
649
- * Cache that maps from string -> ValueType with TTL (time-to-live) expiration.
650
- *
651
- * Items are automatically removed when they expire.
651
+ * Data structure for a single cached value.
652
652
  */
653
- declare class TtlCache<KeyType extends string, ValueType> implements Cache<KeyType, ValueType> {
654
- private readonly _cache;
655
- private readonly _ttl;
653
+ interface CachedValue<ValueType> {
656
654
  /**
657
- * Create a new TTL cache with the given TTL.
658
- *
659
- * @param ttl Time-to-live duration in seconds. Items expire after this duration.
655
+ * The cached value of type ValueType.
660
656
  */
661
- constructor(ttl: Duration);
662
- private _cleanup;
663
- set(key: string, value: ValueType): void;
664
- get(key: string): ValueType | undefined;
665
- clear(): void;
666
- get size(): number;
667
- get capacity(): number;
668
- has(key: string): boolean;
669
- delete(key: string): boolean;
657
+ value: ValueType;
658
+ /**
659
+ * Unix timestamp indicating when the cached `value` was generated.
660
+ */
661
+ updatedAt: UnixTimestamp;
670
662
  }
671
- interface StaleWhileRevalidateOptions<ValueType> {
663
+ interface SWRCacheOptions<ValueType> {
672
664
  /**
673
- * The async function to wrap with SWR caching.
674
- * On success this function returns a value of type `ValueType` to store in the `SWRCache`.
675
- * On error, this function throws an error and no changes will be made to the `SWRCache`.
665
+ * The async function generating a value of `ValueType` to wrap with SWR caching.
666
+ *
667
+ * On success:
668
+ * - This function returns a value of type `ValueType` to store in the `SWRCache`.
669
+ *
670
+ * On error:
671
+ * - This function throws an error and no changes will be made to the `SWRCache`.
676
672
  */
677
673
  fn: () => Promise<ValueType>;
678
674
  /**
679
675
  * Time-to-live duration in seconds. After this duration, data in the `SWRCache` is
680
- * considered stale but is still retained in the cache until replaced with a new value.
676
+ * considered stale but is still retained in the cache until successfully replaced with a new value.
681
677
  */
682
678
  ttl: Duration;
679
+ /**
680
+ * Optional time-to-proactively-revalidate duration in seconds. After this duration, automated attempts
681
+ * to asynchronously revalidate the cached value will be made in the background.
682
+ *
683
+ * If defined:
684
+ * - Proactive asynchronous revalidation attempts will be automatically triggered in the background
685
+ * on this interval.
686
+ *
687
+ * If undefined:
688
+ * - Revalidation only occurs lazily when an explicit request for the cached value is
689
+ * made after the `ttl` duration of the latest successfully cached value expires.
690
+ */
691
+ revalidationInterval?: Duration;
692
+ /**
693
+ * Proactively initialize
694
+ *
695
+ * Optional. Defaults to `false`.
696
+ *
697
+ * If `true`:
698
+ * - The SWR cache will proactively work to initialize itself, even before any explicit request to
699
+ * access the cached value is made.
700
+ *
701
+ * If `false`:
702
+ * - The SWR cache will lazily wait to initialize itself only when one of the following occurs:
703
+ * - Background revalidation occurred (if requested); or
704
+ * - An explicit attempt to access the cached value is made.
705
+ */
706
+ proactivelyInitialize?: boolean;
683
707
  }
684
708
  /**
685
- * Stale-While-Revalidate (SWR) cache wrapper for async functions.
709
+ * Stale-While-Revalidate (SWR) cache for async functions.
686
710
  *
687
711
  * This caching strategy serves cached data immediately (even if stale) while
688
712
  * asynchronously revalidating the cache in the background. This provides:
689
713
  * - Sub-millisecond response times (after first fetch)
690
714
  * - Always available data (serves stale data during revalidation)
691
- * - Automatic background updates (currently only triggered lazily when new requests
692
- * are made for the cached data after it becomes stale)
693
- *
694
- * Error Handling:
695
- * - If a new invocation of the provided `fn` throws an error and a cached value exists
696
- * from a previous successfully invocation of the provided `fn`, the stale cached value is returned.
697
- * - If a new invocation of the provided `fn` throws an error and NO cached value exists,
698
- * from any prior invocations of the provided `fn`, such that the provided `fn` has never
699
- * successfully returned a value for the lifetime of the `SWRCache`, then `null` is returned.
700
- * - Therefore, errors occuring within the provided `fn` are handled internally within
701
- * `staleWhileRevalidate` and do not propagate to the caller.
715
+ * - Automatic background updates (triggered lazily when new requests
716
+ * are made for the cached data or when the `revalidationInterval` is reached)
702
717
  *
703
718
  * @example
704
719
  * ```typescript
@@ -707,27 +722,96 @@ interface StaleWhileRevalidateOptions<ValueType> {
707
722
  * return response.json();
708
723
  * };
709
724
  *
710
- * const cachedFetch = staleWhileRevalidate(fetchExpensiveData, 60); // 60 second TTL
725
+ * const cache = await SWRCache.create({
726
+ * fn: fetchExpensiveData,
727
+ * ttl: 60, // 1 minute TTL
728
+ * revalidationInterval: 5 * 60 // proactive revalidation after 5 minutes from latest cache update
729
+ * });
711
730
  *
712
- * // First call: fetches data (slow)
713
- * const data1 = await cachedFetch();
731
+ * // [T0: 0] First call: fetches data (slow)
732
+ * const firstRead = await cache.readCache();
714
733
  *
715
- * // Within TTL: returns cached data (fast)
716
- * const data2 = await cachedFetch();
734
+ * // [T1: T0 + 59s] Within TTL: returns data cache at T0 (fast)
735
+ * const secondRead = await cache.readCache();
717
736
  *
718
- * // After TTL: returns stale data immediately, revalidates asynchronously in the background
719
- * const data3 = await cachedFetch(); // Still fast!
720
- * ```
737
+ * // [T2: T0 + 1m30s] After TTL: returns stale data that was cached at T0 immediately
738
+ * // revalidates asynchronously in the background
739
+ * const thirdRead = await cache.readCache(); // Still fast!
721
740
  *
722
- * @param fn The async function to wrap with SWR caching
723
- * @param ttl Time-to-live duration in seconds. After this duration, data is considered stale
724
- * @returns a value of `ValueType` that was most recently successfully returned by `fn`
725
- * or `null` if `fn` has never successfully returned and has always thrown an error.
741
+ * // [T3: T2 + 90m] Background revalidation kicks in
742
+ *
743
+ * // [T4: T3 + 1m] Within TTL: returns data cache at T3 (fast)
744
+ * const fourthRead = await cache.readCache(); // Still fast!
745
+ *
746
+ * // Please note how using `SWRCache` enabled action at T3 to happen.
747
+ * // If no `revalidationInterval` value was set, the action at T3 would not happen.
748
+ * // Therefore, the `fourthRead` would return stale data cached at T2.
726
749
  *
727
750
  * @link https://web.dev/stale-while-revalidate/
728
751
  * @link https://datatracker.ietf.org/doc/html/rfc5861
729
752
  */
730
- declare function staleWhileRevalidate<ValueType>(options: StaleWhileRevalidateOptions<ValueType>): () => Promise<ValueType | null>;
753
+ declare class SWRCache<ValueType> {
754
+ readonly options: SWRCacheOptions<ValueType>;
755
+ private cache;
756
+ /**
757
+ * Optional promise of the current in-progress attempt to revalidate the `cache`.
758
+ *
759
+ * If null, no revalidation attempt is currently in progress.
760
+ * If not null, identifies the revalidation attempt that is currently in progress.
761
+ *
762
+ * Used to enforce no concurrent revalidation attempts.
763
+ */
764
+ private inProgressRevalidate;
765
+ /**
766
+ * The callback function being managed by `BackgroundRevalidationScheduler`.
767
+ *
768
+ * If null, no background revalidation is scheduled.
769
+ * If not null, identifies the background revalidation that is currently scheduled.
770
+ *
771
+ * Used to enforce no concurrent background revalidation attempts.
772
+ */
773
+ private scheduledBackgroundRevalidate;
774
+ private constructor();
775
+ /**
776
+ * Asynchronously create a new `SWRCache` instance.
777
+ *
778
+ * @param options - The {@link SWRCacheOptions} for the SWR cache.
779
+ * @returns a new `SWRCache` instance.
780
+ */
781
+ static create<ValueType>(options: SWRCacheOptions<ValueType>): Promise<SWRCache<ValueType>>;
782
+ private revalidate;
783
+ /**
784
+ * Read the most recently cached `CachedValue` from the `SWRCache`.
785
+ *
786
+ * @returns a `CachedValue` holding a `value` of `ValueType` that was most recently successfully returned by `fn`
787
+ * or `null` if `fn` has never successfully returned and has always thrown an error,
788
+ */
789
+ readCache: () => Promise<CachedValue<ValueType> | null>;
790
+ }
791
+
792
+ /**
793
+ * Cache that maps from string -> ValueType with TTL (time-to-live) expiration.
794
+ *
795
+ * Items are automatically removed when they expire.
796
+ */
797
+ declare class TtlCache<KeyType extends string, ValueType> implements Cache<KeyType, ValueType> {
798
+ private readonly _cache;
799
+ private readonly _ttl;
800
+ /**
801
+ * Create a new TTL cache with the given TTL.
802
+ *
803
+ * @param ttl Time-to-live duration in seconds. Items expire after this duration.
804
+ */
805
+ constructor(ttl: Duration);
806
+ private _cleanup;
807
+ set(key: string, value: ValueType): void;
808
+ get(key: string): ValueType | undefined;
809
+ clear(): void;
810
+ get size(): number;
811
+ get capacity(): number;
812
+ has(key: string): boolean;
813
+ delete(key: string): boolean;
814
+ }
731
815
 
732
816
  /**
733
817
  * Filter out duplicates.
@@ -1946,6 +2030,13 @@ declare function checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFoll
1946
2030
  * by the omnichain start block timestamp in ascending order.
1947
2031
  */
1948
2032
  declare function sortChainStatusesByStartBlockAsc<ChainStatusType extends ChainIndexingStatusSnapshot>(chains: [ChainId, ChainStatusType][]): [ChainId, ChainStatusType][];
2033
+ /**
2034
+ * Gets the latest indexed {@link BlockRef} for the given {@link ChainId}.
2035
+ *
2036
+ * @returns the latest indexed {@link BlockRef} for the given {@link ChainId}, or null if the chain
2037
+ * isn't being indexed at all or is queued and therefore hasn't started indexing yet.
2038
+ */
2039
+ declare function getLatestIndexedBlockRef(indexingStatus: CrossChainIndexingStatusSnapshot, chainId: ChainId): BlockRef | null;
1949
2040
 
1950
2041
  /**
1951
2042
  * Create realtime indexing status projection from
@@ -3102,181 +3193,86 @@ declare function serializeNamedRegistrarAction({ action, name, }: NamedRegistrar
3102
3193
  declare function serializeRegistrarActionsResponse(response: RegistrarActionsResponse): SerializedRegistrarActionsResponse;
3103
3194
 
3104
3195
  /**
3105
- * The default number of items per page for paginated aggregated referrer queries.
3106
- */
3107
- declare const ITEMS_PER_PAGE_DEFAULT = 25;
3108
- /**
3109
- * The maximum number of items per page for paginated aggregated referrer queries.
3110
- */
3111
- declare const ITEMS_PER_PAGE_MAX = 100;
3112
- /**
3113
- * Represents the aggregated metrics for a single referrer.
3114
- */
3115
- interface AggregatedReferrerMetrics {
3116
- /** The Ethereum address of the referrer */
3117
- referrer: Address;
3118
- /**
3119
- * The total number of qualified referrals made by this referrer
3120
- * @invariant Guaranteed to be a positive integer (> 0)
3121
- */
3122
- totalReferrals: number;
3123
- /**
3124
- * The total incremental duration (in seconds) of all referrals made by this referrer
3125
- * @invariant Guaranteed to be a non-negative integer (>= 0), measured in seconds
3126
- */
3127
- totalIncrementalDuration: Duration;
3128
- }
3129
- /**
3130
- * Represents the aggregated metrics for a single referrer with contribution percentages.
3131
- * Extends {@link AggregatedReferrerMetrics} with additional fields that show the referrer's
3132
- * contribution as a percentage of the grand totals.
3196
+ * Request parameters for a referrer leaderboard page query.
3133
3197
  */
3134
- interface AggregatedReferrerMetricsContribution extends AggregatedReferrerMetrics {
3135
- /**
3136
- * The referrer's contribution to the grand total referrals as a decimal between 0 and 1 (inclusive).
3137
- * Calculated as: totalReferrals / grandTotalReferrals
3138
- * @invariant 0 <= totalReferralsContribution <= 1
3139
- */
3140
- totalReferralsContribution: number;
3141
- /**
3142
- * The referrer's contribution to the grand total incremental duration as a decimal between 0 and 1 (inclusive).
3143
- * Calculated as: totalIncrementalDuration / grandTotalIncrementalDuration
3144
- * @invariant 0 <= totalIncrementalDurationContribution <= 1
3145
- */
3146
- totalIncrementalDurationContribution: number;
3198
+ interface ReferrerLeaderboardPaginationRequest extends ReferrerLeaderboardPaginationParams {
3147
3199
  }
3148
3200
  /**
3149
- * Base pagination parameters for paginated queries.
3201
+ * A status code for a referrer leaderboard page API response.
3150
3202
  */
3151
- interface PaginationParams {
3203
+ declare const ReferrerLeaderboardPageResponseCodes: {
3152
3204
  /**
3153
- * Requested page number (1-indexed)
3154
- * @invariant Must be a positive integer (>= 1)
3155
- * @default 1
3156
- */
3157
- page?: number;
3158
- /**
3159
- * Maximum number of items per page
3160
- * @invariant Must be a positive integer (>= 1) and less than or equal to {@link ITEMS_PER_PAGE_MAX}
3161
- * @default {@link ITEMS_PER_PAGE_DEFAULT}
3162
- */
3163
- itemsPerPage?: number;
3164
- }
3165
- /**
3166
- * Request parameters for paginated aggregated referrers query.
3167
- */
3168
- interface PaginatedAggregatedReferrersRequest extends PaginationParams {
3169
- }
3170
- /**
3171
- * Paginated aggregated referrers data with metadata.
3172
- */
3173
- interface PaginatedAggregatedReferrers {
3174
- /**
3175
- * Array of aggregated referrers for the current page with contribution percentages
3176
- * @invariant Array may be empty for the first page if there are no qualified referrers.
3177
- */
3178
- referrers: AggregatedReferrerMetricsContribution[];
3179
- /**
3180
- * Total number of aggregated referrers across all pages
3181
- * @invariant Guaranteed to be a non-negative integer (>= 0)
3182
- */
3183
- total: number;
3184
- /**
3185
- * Pagination parameters
3186
- * @invariant Stores the pagination parameters from the request
3187
- */
3188
- paginationParams: PaginationParams;
3189
- /**
3190
- * Indicates whether there is a next page available
3191
- * @invariant true if and only if (page * itemsPerPage < total)
3192
- */
3193
- hasNext: boolean;
3194
- /**
3195
- * Indicates whether there is a previous page available
3196
- * @invariant true if and only if (page > 1)
3197
- */
3198
- hasPrev: boolean;
3199
- /** Unix timestamp of when the leaderboard was last updated */
3200
- updatedAt: UnixTimestamp;
3201
- }
3202
- /**
3203
- * A status code for paginated aggregated referrers API responses.
3204
- */
3205
- declare const PaginatedAggregatedReferrersResponseCodes: {
3206
- /**
3207
- * Represents that the aggregated referrers data is available.
3208
- * @note The response may contain an empty array for the first page if there are no qualified referrers.
3209
- * When the array is empty, total will be 0, page will be 1, and both hasNext and hasPrev will be false.
3205
+ * Represents that the requested referrer leaderboard page is available.
3210
3206
  */
3211
3207
  readonly Ok: "ok";
3212
3208
  /**
3213
- * Represents that the aggregated referrers data is not available.
3209
+ * Represents that the referrer leaderboard data is not available.
3214
3210
  */
3215
3211
  readonly Error: "error";
3216
3212
  };
3217
3213
  /**
3218
- * The derived string union of possible {@link PaginatedAggregatedReferrersResponseCodes}.
3214
+ * The derived string union of possible {@link ReferrerLeaderboardPageResponseCodes}.
3219
3215
  */
3220
- type PaginatedAggregatedReferrersResponseCode = (typeof PaginatedAggregatedReferrersResponseCodes)[keyof typeof PaginatedAggregatedReferrersResponseCodes];
3216
+ type ReferrerLeaderboardPageResponseCode = (typeof ReferrerLeaderboardPageResponseCodes)[keyof typeof ReferrerLeaderboardPageResponseCodes];
3221
3217
  /**
3222
- * A paginated aggregated referrers response when the data is available.
3218
+ * A referrer leaderboard page response when the data is available.
3223
3219
  */
3224
- type PaginatedAggregatedReferrersResponseOk = {
3225
- responseCode: typeof PaginatedAggregatedReferrersResponseCodes.Ok;
3226
- data: PaginatedAggregatedReferrers;
3220
+ type ReferrerLeaderboardPageResponseOk = {
3221
+ responseCode: typeof ReferrerLeaderboardPageResponseCodes.Ok;
3222
+ data: ReferrerLeaderboardPage;
3227
3223
  };
3228
3224
  /**
3229
- * A paginated aggregated referrers response when the data is not available.
3225
+ * A referrer leaderboard page response when the data is not available.
3230
3226
  */
3231
- type PaginatedAggregatedReferrersResponseError = {
3232
- responseCode: typeof PaginatedAggregatedReferrersResponseCodes.Error;
3227
+ type ReferrerLeaderboardPageResponseError = {
3228
+ responseCode: typeof ReferrerLeaderboardPageResponseCodes.Error;
3233
3229
  error: string;
3234
3230
  errorMessage: string;
3235
3231
  };
3236
3232
  /**
3237
- * A paginated aggregated referrers API response.
3233
+ * A referrer leaderboard page API response.
3238
3234
  *
3239
3235
  * Use the `responseCode` field to determine the specific type interpretation
3240
3236
  * at runtime.
3241
3237
  */
3242
- type PaginatedAggregatedReferrersResponse = PaginatedAggregatedReferrersResponseOk | PaginatedAggregatedReferrersResponseError;
3238
+ type ReferrerLeaderboardPageResponse = ReferrerLeaderboardPageResponseOk | ReferrerLeaderboardPageResponseError;
3243
3239
 
3244
3240
  /**
3245
- * Serialized representation of {@link PaginatedAggregatedReferrersResponseError}.
3241
+ * Serialized representation of {@link ReferrerLeaderboardPageResponseError}.
3246
3242
  *
3247
3243
  * Note: All fields are already serializable, so this type is identical to the source type.
3248
3244
  */
3249
- type SerializedPaginatedAggregatedReferrersResponseError = PaginatedAggregatedReferrersResponseError;
3245
+ type SerializedReferrerLeaderboardPageResponseError = ReferrerLeaderboardPageResponseError;
3250
3246
  /**
3251
- * Serialized representation of {@link PaginatedAggregatedReferrersResponseOk}.
3247
+ * Serialized representation of {@link ReferrerLeaderboardPageResponseOk}.
3252
3248
  *
3253
3249
  * Note: All fields are already serializable, so this type is identical to the source type.
3254
3250
  */
3255
- type SerializedPaginatedAggregatedReferrersResponseOk = PaginatedAggregatedReferrersResponseOk;
3251
+ type SerializedReferrerLeaderboardPageResponseOk = ReferrerLeaderboardPageResponseOk;
3256
3252
  /**
3257
- * Serialized representation of {@link PaginatedAggregatedReferrersResponse}.
3253
+ * Serialized representation of {@link ReferrerLeaderboardPageResponse}.
3258
3254
  */
3259
- type SerializedPaginatedAggregatedReferrersResponse = SerializedPaginatedAggregatedReferrersResponseOk | SerializedPaginatedAggregatedReferrersResponseError;
3255
+ type SerializedReferrerLeaderboardPageResponse = SerializedReferrerLeaderboardPageResponseOk | SerializedReferrerLeaderboardPageResponseError;
3260
3256
 
3261
3257
  /**
3262
- * Deserialize a {@link PaginatedAggregatedReferrersResponse} object.
3258
+ * Deserialize a {@link ReferrerLeaderboardPageResponse} object.
3263
3259
  *
3264
3260
  * Note: While the serialized and deserialized types are identical (all fields
3265
3261
  * are primitives), this function performs critical validation using Zod schemas
3266
3262
  * to enforce invariants on the data. This ensures data integrity when receiving
3267
3263
  * responses from the API.
3268
3264
  */
3269
- declare function deserializePaginatedAggregatedReferrersResponse(maybeResponse: SerializedPaginatedAggregatedReferrersResponse, valueLabel?: string): PaginatedAggregatedReferrersResponse;
3265
+ declare function deserializeReferrerLeaderboardPageResponse(maybeResponse: SerializedReferrerLeaderboardPageResponse, valueLabel?: string): ReferrerLeaderboardPageResponse;
3270
3266
 
3271
3267
  /**
3272
- * Serialize a {@link PaginatedAggregatedReferrersResponse} object.
3268
+ * Serialize a {@link ReferrerLeaderboardPageResponse} object.
3273
3269
  *
3274
- * Note: Since all fields in PaginatedAggregatedReferrersResponse are already
3270
+ * Note: Since all fields in ReferrerLeaderboardPageResponse are already
3275
3271
  * serializable primitives, this function performs an identity transformation.
3276
3272
  * It exists to maintain consistency with the serialization pattern used
3277
3273
  * throughout the codebase.
3278
3274
  */
3279
- declare function serializePaginatedAggregatedReferrersResponse(response: PaginatedAggregatedReferrersResponse): SerializedPaginatedAggregatedReferrersResponse;
3275
+ declare function serializeReferrerLeaderboardPageResponse(response: ReferrerLeaderboardPageResponse): SerializedReferrerLeaderboardPageResponse;
3280
3276
 
3281
3277
  /**
3282
3278
  * Configuration options for ENSNode API client
@@ -3458,15 +3454,15 @@ declare class ENSNodeClient {
3458
3454
  */
3459
3455
  indexingStatus(): Promise<IndexingStatusResponse>;
3460
3456
  /**
3461
- * Fetch Paginated Aggregated Referrers
3457
+ * Fetch Referrer Leaderboard Page
3462
3458
  *
3463
- * Retrieves a paginated list of aggregated referrer metrics with contribution percentages.
3459
+ * Retrieves a paginated list of referrer leaderboard metrics with contribution percentages.
3464
3460
  * Each referrer's contribution is calculated as a percentage of the grand totals across all referrers.
3465
3461
  *
3466
3462
  * @param request - Pagination parameters
3467
3463
  * @param request.page - The page number to retrieve (1-indexed, default: 1)
3468
3464
  * @param request.itemsPerPage - Number of items per page (default: 25, max: 100)
3469
- * @returns {PaginatedAggregatedReferrersResponse}
3465
+ * @returns {ReferrerLeaderboardPageResponse}
3470
3466
  *
3471
3467
  * @throws if the ENSNode request fails
3472
3468
  * @throws if the ENSNode API returns an error response
@@ -3475,20 +3471,41 @@ declare class ENSNodeClient {
3475
3471
  * @example
3476
3472
  * ```typescript
3477
3473
  * // Get first page with default page size (25 items)
3478
- * const response = await client.getAggregatedReferrers();
3479
- * if (response.responseCode === 'ok') {
3480
- * console.log(response.data.referrers);
3481
- * console.log(`Page ${response.data.paginationParams.page} of ${Math.ceil(response.data.total / response.data.paginationParams.itemsPerPage)}`);
3474
+ * const response = await client.getReferrerLeaderboard();
3475
+ * if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
3476
+ * const {
3477
+ * aggregatedMetrics,
3478
+ * referrers,
3479
+ * rules,
3480
+ * paginationContext,
3481
+ * updatedAt
3482
+ * } = response.data;
3483
+ * console.log(aggregatedMetrics);
3484
+ * console.log(referrers);
3485
+ * console.log(rules);
3486
+ * console.log(updatedAt);
3487
+ * console.log(`Page ${paginationContext.page} of ${paginationContext.totalPages}`);
3482
3488
  * }
3483
3489
  * ```
3484
3490
  *
3485
3491
  * @example
3486
3492
  * ```typescript
3487
3493
  * // Get second page with 50 items per page
3488
- * const response = await client.getAggregatedReferrers({ page: 2, itemsPerPage: 50 });
3494
+ * const response = await client.getReferrerLeaderboard({ page: 2, itemsPerPage: 50 });
3495
+ * ```
3496
+ *
3497
+ * @example
3498
+ * ```typescript
3499
+ * // Handle error response, ie. when Referrer Leaderboard is not currently available.
3500
+ * const response = await client.getReferrerLeaderboard();
3501
+ *
3502
+ * if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Error) {
3503
+ * console.error(response.error);
3504
+ * console.error(response.errorMessage);
3505
+ * }
3489
3506
  * ```
3490
3507
  */
3491
- getAggregatedReferrers(request?: PaginatedAggregatedReferrersRequest): Promise<PaginatedAggregatedReferrersResponse>;
3508
+ getReferrerLeaderboard(request?: ReferrerLeaderboardPaginationRequest): Promise<ReferrerLeaderboardPageResponse>;
3492
3509
  /**
3493
3510
  * Fetch ENSNode Registrar Actions
3494
3511
  *
@@ -3553,4 +3570,4 @@ declare class ClientError extends Error {
3553
3570
  static fromErrorResponse({ message, details }: ErrorResponse): ClientError;
3554
3571
  }
3555
3572
 
3556
- export { ADDR_REVERSE_NODE, ATTR_PROTOCOL_NAME, ATTR_PROTOCOL_STEP, ATTR_PROTOCOL_STEP_RESULT, type AcceleratableRequest, type AcceleratableResponse, type AccountId, type AggregatedReferrerMetrics, type AggregatedReferrerMetricsContribution, BASENAMES_NODE, type BlockNumber, type BlockRef, type Blockrange, type Cache, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingConfigDefinite, type ChainIndexingConfigIndefinite, type ChainIndexingConfigTypeId, ChainIndexingConfigTypeIds, type ChainIndexingStatusId, ChainIndexingStatusIds, type ChainIndexingStatusSnapshot, type ChainIndexingStatusSnapshotBackfill, type ChainIndexingStatusSnapshotCompleted, type ChainIndexingStatusSnapshotFollowing, type ChainIndexingStatusSnapshotForOmnichainIndexingStatusSnapshotBackfill, type ChainIndexingStatusSnapshotQueued, ClientError, type ClientOptions, type ConfigResponse, type CrossChainIndexingStatusSnapshot, type CrossChainIndexingStatusSnapshotOmnichain, type CrossChainIndexingStrategyId, CrossChainIndexingStrategyIds, type CurrencyAmount, type CurrencyId, CurrencyIds, type CurrencyInfo, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, type DNSEncodedLiteralName, type DNSEncodedName, type DNSEncodedPartiallyInterpretedName, type Datetime, type DatetimeISO8601, type DeepPartial, type DefaultableChainId, type Duration, type ENSApiPublicConfig, type ENSIndexerPublicConfig, type ENSIndexerVersionInfo, ENSNodeClient, ETH_COIN_TYPE, ETH_NODE, type EncodedLabelHash, type EnsRainbowClientLabelSet, type EnsRainbowServerLabelSet, type ErrorResponse, type ForwardResolutionArgs, ForwardResolutionProtocolStep, type ForwardResolutionResult, ITEMS_PER_PAGE_DEFAULT, ITEMS_PER_PAGE_MAX, type Identity, type IndexingStatusRequest, type IndexingStatusResponse, type IndexingStatusResponseCode, IndexingStatusResponseCodes, type IndexingStatusResponseError, type IndexingStatusResponseOk, type InterpretedLabel, type InterpretedName, LINEANAMES_NODE, type Label, type LabelHash, type LabelSetId, type LabelSetVersion, type LiteralLabel, type LiteralName, LruCache, type MultichainPrimaryNameResolutionArgs, type MultichainPrimaryNameResolutionResult, type Name, type NamedIdentity, type NamedRegistrarAction, type Node, type NormalizedName, type OmnichainIndexingStatusId, OmnichainIndexingStatusIds, type OmnichainIndexingStatusSnapshot, type OmnichainIndexingStatusSnapshotBackfill, type OmnichainIndexingStatusSnapshotCompleted, type OmnichainIndexingStatusSnapshotFollowing, type OmnichainIndexingStatusSnapshotUnstarted, PROTOCOL_ATTRIBUTE_PREFIX, type PaginatedAggregatedReferrers, type PaginatedAggregatedReferrersRequest, type PaginatedAggregatedReferrersResponse, type PaginatedAggregatedReferrersResponseCode, PaginatedAggregatedReferrersResponseCodes, type PaginatedAggregatedReferrersResponseError, type PaginatedAggregatedReferrersResponseOk, type PaginationParams, PluginName, type Price, type PriceDai, type PriceEth, type PriceUsdc, type ProtocolSpan, type ProtocolSpanTreeNode, type ProtocolTrace, ROOT_NODE, type RealtimeIndexingStatusProjection, type RegistrarAction, type RegistrarActionEventId, type RegistrarActionPricing, type RegistrarActionPricingAvailable, type RegistrarActionPricingUnknown, type RegistrarActionReferral, type RegistrarActionReferralAvailable, type RegistrarActionReferralNotApplicable, type RegistrarActionType, RegistrarActionTypes, type RegistrarActionsFilter, type RegistrarActionsFilterBySubregistryNode, type RegistrarActionsFilterType, RegistrarActionsFilterTypes, type RegistrarActionsFilterWithEncodedReferral, type RegistrarActionsOrder, RegistrarActionsOrders, type RegistrarActionsRequest, type RegistrarActionsResponse, type RegistrarActionsResponseCode, RegistrarActionsResponseCodes, type RegistrarActionsResponseError, type RegistrarActionsResponseOk, type RegistrationLifecycle, type RegistrationLifecycleStage, type ResolutionStatusId, ResolutionStatusIds, type ResolvePrimaryNameRequest, type ResolvePrimaryNameResponse, type ResolvePrimaryNamesRequest, type ResolvePrimaryNamesResponse, type ResolveRecordsRequest, type ResolveRecordsResponse, type ResolvedIdentity, type ResolverRecordsResponse, type ResolverRecordsResponseBase, type ResolverRecordsSelection, type ReverseResolutionArgs, ReverseResolutionProtocolStep, type ReverseResolutionResult, type RpcUrl, type SerializedAccountId, type SerializedChainIndexingStatusSnapshot, type SerializedChainIndexingStatusSnapshotBackfill, type SerializedChainIndexingStatusSnapshotCompleted, type SerializedChainIndexingStatusSnapshotFollowing, type SerializedChainIndexingStatusSnapshotQueued, type SerializedCrossChainIndexingStatusSnapshot, type SerializedCrossChainIndexingStatusSnapshotOmnichain, type SerializedCurrencyAmount, type SerializedCurrentIndexingProjectionOmnichain, type SerializedENSApiPublicConfig, type SerializedENSIndexerPublicConfig, type SerializedENSIndexerVersionInfo, type SerializedIndexedChainIds, type SerializedIndexingStatusResponse, type SerializedIndexingStatusResponseError, type SerializedIndexingStatusResponseOk, type SerializedNamedRegistrarAction, type SerializedOmnichainIndexingStatusSnapshot, type SerializedOmnichainIndexingStatusSnapshotBackfill, type SerializedOmnichainIndexingStatusSnapshotCompleted, type SerializedOmnichainIndexingStatusSnapshotFollowing, type SerializedOmnichainIndexingStatusSnapshotUnstarted, type SerializedPaginatedAggregatedReferrersResponse, type SerializedPaginatedAggregatedReferrersResponseError, type SerializedPaginatedAggregatedReferrersResponseOk, type SerializedPrice, type SerializedPriceDai, type SerializedPriceEth, type SerializedPriceUsdc, type SerializedRealtimeIndexingStatusProjection, type SerializedRegistrarAction, type SerializedRegistrarActionPricing, type SerializedRegistrarActionPricingAvailable, type SerializedRegistrarActionPricingUnknown, type SerializedRegistrarActionsResponse, type SerializedRegistrarActionsResponseError, type SerializedRegistrarActionsResponseOk, type SerializedRegistrationLifecycle, type SerializedSubregistry, type SubgraphInterpretedLabel, type SubgraphInterpretedName, type Subregistry, type TheGraphCannotFallbackReason, TheGraphCannotFallbackReasonSchema, type TheGraphFallback, TheGraphFallbackSchema, TraceableENSProtocol, type TraceableRequest, type TraceableResponse, TtlCache, type UnixTimestamp, type UnknownIdentity, type UnnamedIdentity, type UnresolvedIdentity, type UrlString, accountIdEqual, addDuration, addPrices, addrReverseLabel, asLowerCaseAddress, beautifyName, bigIntToNumber, bigintToCoinType, buildEnsRainbowClientLabelSet, buildLabelSetId, buildLabelSetVersion, buildUnresolvedIdentity, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotUnstarted, coinTypeReverseLabel, coinTypeToEvmChainId, createIndexingConfig, createRealtimeIndexingStatusProjection, decodeDNSEncodedLiteralName, decodeDNSEncodedName, deserializeAccountId, deserializeBlockNumber, deserializeBlockRef, deserializeBlockrange, deserializeChainId, deserializeChainIndexingStatusSnapshot, deserializeCrossChainIndexingStatusSnapshot, deserializeDatetime, deserializeDuration, deserializeENSApiPublicConfig, deserializeENSIndexerPublicConfig, deserializeErrorResponse, deserializeIndexingStatusResponse, deserializeOmnichainIndexingStatusSnapshot, deserializePaginatedAggregatedReferrersResponse, deserializeRealtimeIndexingStatusProjection, deserializeRegistrarActionsResponse, deserializeUnixTimestamp, deserializeUrl, durationBetween, encodeLabelHash, evmChainIdToCoinType, getCurrencyInfo, getEthnamesSubregistryId, getNameHierarchy, getOmnichainIndexingCursor, getOmnichainIndexingStatus, getResolvePrimaryNameChainIdParam, getTimestampForHighestOmnichainKnownBlock, getTimestampForLowestOmnichainStartBlock, hasNullByte, interpretedLabelsToInterpretedName, isEncodedLabelHash, isHttpProtocol, isLabelHash, isNormalizedLabel, isNormalizedName, isPriceCurrencyEqual, isPriceEqual, isRegistrarActionPricingAvailable, isRegistrarActionReferralAvailable, isResolvedIdentity, isSelectionEmpty, isSubgraphCompatible, isWebSocketProtocol, labelHashToBytes, labelhashLiteralLabel, literalLabelToInterpretedLabel, literalLabelsToInterpretedName, literalLabelsToLiteralName, makeENSApiPublicConfigSchema, makeSubdomainNode, parseNonNegativeInteger, parseReverseName, priceDai, priceEth, priceUsdc, registrarActionsFilter, registrarActionsPrerequisites, reverseName, serializeAccountId, serializeChainId, serializeChainIndexingSnapshots, serializeCrossChainIndexingStatusSnapshotOmnichain, serializeDatetime, serializeENSApiPublicConfig, serializeENSIndexerPublicConfig, serializeIndexedChainIds, serializeIndexingStatusResponse, serializeNamedRegistrarAction, serializeOmnichainIndexingStatusSnapshot, serializePaginatedAggregatedReferrersResponse, serializePrice, serializePriceEth, serializeRealtimeIndexingStatusProjection, serializeRegistrarAction, serializeRegistrarActionPricing, serializeRegistrarActionsResponse, serializeRegistrationLifecycle, serializeSubregistry, serializeUrl, sortChainStatusesByStartBlockAsc, staleWhileRevalidate, stripNullBytes, translateDefaultableChainIdToChainId, uint256ToHex32, uniq, validateSupportedLabelSetAndVersion };
3573
+ export { ADDR_REVERSE_NODE, 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 CachedValue, type ChainId, type ChainIdString, type ChainIndexingConfig, type ChainIndexingConfigDefinite, type ChainIndexingConfigIndefinite, type ChainIndexingConfigTypeId, ChainIndexingConfigTypeIds, type ChainIndexingStatusId, ChainIndexingStatusIds, type ChainIndexingStatusSnapshot, type ChainIndexingStatusSnapshotBackfill, type ChainIndexingStatusSnapshotCompleted, type ChainIndexingStatusSnapshotFollowing, type ChainIndexingStatusSnapshotForOmnichainIndexingStatusSnapshotBackfill, type ChainIndexingStatusSnapshotQueued, ClientError, type ClientOptions, type ConfigResponse, type CrossChainIndexingStatusSnapshot, type CrossChainIndexingStatusSnapshotOmnichain, type CrossChainIndexingStrategyId, CrossChainIndexingStrategyIds, type CurrencyAmount, type CurrencyId, CurrencyIds, type CurrencyInfo, DEFAULT_EVM_CHAIN_ID, DEFAULT_EVM_COIN_TYPE, type DNSEncodedLiteralName, type DNSEncodedName, type DNSEncodedPartiallyInterpretedName, type Datetime, type DatetimeISO8601, type DeepPartial, type DefaultableChainId, type Duration, type ENSApiPublicConfig, type ENSIndexerPublicConfig, type ENSIndexerVersionInfo, ENSNodeClient, ETH_COIN_TYPE, ETH_NODE, type EncodedLabelHash, type EnsRainbowClientLabelSet, type EnsRainbowServerLabelSet, type ErrorResponse, type ForwardResolutionArgs, ForwardResolutionProtocolStep, type ForwardResolutionResult, type Identity, type IndexingStatusRequest, type IndexingStatusResponse, type IndexingStatusResponseCode, IndexingStatusResponseCodes, type IndexingStatusResponseError, type IndexingStatusResponseOk, type InterpretedLabel, type InterpretedName, LINEANAMES_NODE, type Label, type LabelHash, type LabelSetId, type LabelSetVersion, type LiteralLabel, type LiteralName, LruCache, type MultichainPrimaryNameResolutionArgs, type MultichainPrimaryNameResolutionResult, type Name, type NamedIdentity, type NamedRegistrarAction, type Node, type NormalizedName, type OmnichainIndexingStatusId, OmnichainIndexingStatusIds, type OmnichainIndexingStatusSnapshot, type OmnichainIndexingStatusSnapshotBackfill, type OmnichainIndexingStatusSnapshotCompleted, type OmnichainIndexingStatusSnapshotFollowing, type OmnichainIndexingStatusSnapshotUnstarted, PROTOCOL_ATTRIBUTE_PREFIX, PluginName, type Price, type PriceDai, type PriceEth, type PriceUsdc, type ProtocolSpan, type ProtocolSpanTreeNode, type ProtocolTrace, ROOT_NODE, type RealtimeIndexingStatusProjection, type ReferrerLeaderboardPageResponse, type ReferrerLeaderboardPageResponseCode, ReferrerLeaderboardPageResponseCodes, type ReferrerLeaderboardPageResponseError, type ReferrerLeaderboardPageResponseOk, type ReferrerLeaderboardPaginationRequest, type RegistrarAction, type RegistrarActionEventId, type RegistrarActionPricing, type RegistrarActionPricingAvailable, type RegistrarActionPricingUnknown, type RegistrarActionReferral, type RegistrarActionReferralAvailable, type RegistrarActionReferralNotApplicable, type RegistrarActionType, RegistrarActionTypes, type RegistrarActionsFilter, type RegistrarActionsFilterBySubregistryNode, type RegistrarActionsFilterType, RegistrarActionsFilterTypes, type RegistrarActionsFilterWithEncodedReferral, type RegistrarActionsOrder, RegistrarActionsOrders, type RegistrarActionsRequest, type RegistrarActionsResponse, type RegistrarActionsResponseCode, RegistrarActionsResponseCodes, type RegistrarActionsResponseError, type RegistrarActionsResponseOk, type RegistrationLifecycle, type RegistrationLifecycleStage, type ResolutionStatusId, ResolutionStatusIds, type ResolvePrimaryNameRequest, type ResolvePrimaryNameResponse, type ResolvePrimaryNamesRequest, type ResolvePrimaryNamesResponse, type ResolveRecordsRequest, type ResolveRecordsResponse, type ResolvedIdentity, type ResolverRecordsResponse, type ResolverRecordsResponseBase, type ResolverRecordsSelection, type ReverseResolutionArgs, ReverseResolutionProtocolStep, type ReverseResolutionResult, type RpcUrl, SWRCache, type SWRCacheOptions, type SerializedAccountId, type SerializedChainIndexingStatusSnapshot, type SerializedChainIndexingStatusSnapshotBackfill, type SerializedChainIndexingStatusSnapshotCompleted, type SerializedChainIndexingStatusSnapshotFollowing, type SerializedChainIndexingStatusSnapshotQueued, type SerializedCrossChainIndexingStatusSnapshot, type SerializedCrossChainIndexingStatusSnapshotOmnichain, type SerializedCurrencyAmount, type SerializedCurrentIndexingProjectionOmnichain, type SerializedENSApiPublicConfig, type SerializedENSIndexerPublicConfig, type SerializedENSIndexerVersionInfo, type SerializedIndexedChainIds, type SerializedIndexingStatusResponse, type SerializedIndexingStatusResponseError, type SerializedIndexingStatusResponseOk, type SerializedNamedRegistrarAction, type SerializedOmnichainIndexingStatusSnapshot, type SerializedOmnichainIndexingStatusSnapshotBackfill, type SerializedOmnichainIndexingStatusSnapshotCompleted, type SerializedOmnichainIndexingStatusSnapshotFollowing, type SerializedOmnichainIndexingStatusSnapshotUnstarted, type SerializedPrice, type SerializedPriceDai, type SerializedPriceEth, type SerializedPriceUsdc, type SerializedRealtimeIndexingStatusProjection, type SerializedReferrerLeaderboardPageResponse, type SerializedReferrerLeaderboardPageResponseError, type SerializedReferrerLeaderboardPageResponseOk, type SerializedRegistrarAction, type SerializedRegistrarActionPricing, type SerializedRegistrarActionPricingAvailable, type SerializedRegistrarActionPricingUnknown, type SerializedRegistrarActionsResponse, type SerializedRegistrarActionsResponseError, type SerializedRegistrarActionsResponseOk, type SerializedRegistrationLifecycle, type SerializedSubregistry, type SubgraphInterpretedLabel, type SubgraphInterpretedName, type Subregistry, type TheGraphCannotFallbackReason, TheGraphCannotFallbackReasonSchema, type TheGraphFallback, TheGraphFallbackSchema, TraceableENSProtocol, type TraceableRequest, type TraceableResponse, TtlCache, type UnixTimestamp, type UnknownIdentity, type UnnamedIdentity, type UnresolvedIdentity, type UrlString, accountIdEqual, addDuration, addPrices, addrReverseLabel, asLowerCaseAddress, beautifyName, bigIntToNumber, bigintToCoinType, buildEnsRainbowClientLabelSet, buildLabelSetId, buildLabelSetVersion, buildUnresolvedIdentity, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing, checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotUnstarted, coinTypeReverseLabel, coinTypeToEvmChainId, createIndexingConfig, createRealtimeIndexingStatusProjection, decodeDNSEncodedLiteralName, decodeDNSEncodedName, deserializeAccountId, deserializeBlockNumber, deserializeBlockRef, deserializeBlockrange, deserializeChainId, deserializeChainIndexingStatusSnapshot, deserializeCrossChainIndexingStatusSnapshot, deserializeDatetime, deserializeDuration, deserializeENSApiPublicConfig, deserializeENSIndexerPublicConfig, deserializeErrorResponse, deserializeIndexingStatusResponse, deserializeOmnichainIndexingStatusSnapshot, deserializeRealtimeIndexingStatusProjection, deserializeReferrerLeaderboardPageResponse, deserializeRegistrarActionsResponse, deserializeUnixTimestamp, deserializeUrl, durationBetween, encodeLabelHash, evmChainIdToCoinType, getCurrencyInfo, getEthnamesSubregistryId, getLatestIndexedBlockRef, getNameHierarchy, getOmnichainIndexingCursor, getOmnichainIndexingStatus, getResolvePrimaryNameChainIdParam, getTimestampForHighestOmnichainKnownBlock, getTimestampForLowestOmnichainStartBlock, hasNullByte, interpretedLabelsToInterpretedName, isEncodedLabelHash, isHttpProtocol, isLabelHash, isNormalizedLabel, isNormalizedName, isPriceCurrencyEqual, isPriceEqual, isRegistrarActionPricingAvailable, isRegistrarActionReferralAvailable, isResolvedIdentity, isSelectionEmpty, isSubgraphCompatible, isWebSocketProtocol, labelHashToBytes, labelhashLiteralLabel, literalLabelToInterpretedLabel, literalLabelsToInterpretedName, literalLabelsToLiteralName, makeENSApiPublicConfigSchema, makeSubdomainNode, parseNonNegativeInteger, parseReverseName, priceDai, priceEth, priceUsdc, registrarActionsFilter, registrarActionsPrerequisites, reverseName, serializeAccountId, serializeChainId, serializeChainIndexingSnapshots, serializeCrossChainIndexingStatusSnapshotOmnichain, serializeDatetime, serializeENSApiPublicConfig, serializeENSIndexerPublicConfig, serializeIndexedChainIds, serializeIndexingStatusResponse, serializeNamedRegistrarAction, serializeOmnichainIndexingStatusSnapshot, serializePrice, serializePriceEth, serializeRealtimeIndexingStatusProjection, serializeReferrerLeaderboardPageResponse, serializeRegistrarAction, serializeRegistrarActionPricing, serializeRegistrarActionsResponse, serializeRegistrationLifecycle, serializeSubregistry, serializeUrl, sortChainStatusesByStartBlockAsc, stripNullBytes, translateDefaultableChainIdToChainId, uint256ToHex32, uniq, validateSupportedLabelSetAndVersion };