@ensnode/ensnode-sdk 1.0.3 → 1.2.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.cjs +1538 -879
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1065 -587
- package/dist/index.d.ts +1065 -587
- package/dist/index.js +1560 -901
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import { prettifyError as prettifyError2 } from "zod/v4";
|
|
1
|
+
// src/ensapi/config/deserialize.ts
|
|
2
|
+
import { prettifyError as prettifyError2, ZodError } from "zod/v4";
|
|
3
3
|
|
|
4
|
-
// src/
|
|
5
|
-
import {
|
|
6
|
-
import z7 from "zod/v4";
|
|
4
|
+
// src/ensapi/config/zod-schemas.ts
|
|
5
|
+
import { z as z3 } from "zod/v4";
|
|
7
6
|
|
|
8
|
-
// src/ensindexer/
|
|
7
|
+
// src/ensindexer/config/zod-schemas.ts
|
|
9
8
|
import z2 from "zod/v4";
|
|
10
9
|
|
|
11
10
|
// src/ens/is-normalized.ts
|
|
@@ -38,8 +37,58 @@ function asLowerCaseAddress(address) {
|
|
|
38
37
|
return address.toLowerCase();
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
// src/shared/cache.ts
|
|
42
|
-
|
|
40
|
+
// src/shared/cache/lru-cache.ts
|
|
41
|
+
var LruCache = class {
|
|
42
|
+
_cache = /* @__PURE__ */ new Map();
|
|
43
|
+
_capacity;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new LRU cache with the given capacity.
|
|
46
|
+
*
|
|
47
|
+
* @param capacity The maximum number of items in the cache. If set to 0, the cache is effectively disabled.
|
|
48
|
+
* @throws Error if capacity is not a non-negative integer.
|
|
49
|
+
*/
|
|
50
|
+
constructor(capacity) {
|
|
51
|
+
if (!Number.isInteger(capacity)) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`LruCache requires capacity to be an integer but a capacity of ${capacity} was requested.`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
if (capacity < 0) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`LruCache requires a non-negative capacity but a capacity of ${capacity} was requested.`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
this._capacity = capacity;
|
|
62
|
+
}
|
|
63
|
+
set(key, value) {
|
|
64
|
+
this._cache.set(key, value);
|
|
65
|
+
if (this._cache.size > this._capacity) {
|
|
66
|
+
const oldestKey = this._cache.keys().next().value;
|
|
67
|
+
this._cache.delete(oldestKey);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get(key) {
|
|
71
|
+
const value = this._cache.get(key);
|
|
72
|
+
if (value) {
|
|
73
|
+
this._cache.delete(key);
|
|
74
|
+
this._cache.set(key, value);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
clear() {
|
|
79
|
+
this._cache.clear();
|
|
80
|
+
}
|
|
81
|
+
get size() {
|
|
82
|
+
return this._cache.size;
|
|
83
|
+
}
|
|
84
|
+
get capacity() {
|
|
85
|
+
return this._capacity;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/shared/cache/swr-cache.ts
|
|
90
|
+
import { secondsToMilliseconds } from "date-fns";
|
|
91
|
+
import { getUnixTime } from "date-fns/getUnixTime";
|
|
43
92
|
|
|
44
93
|
// src/shared/deserialize.ts
|
|
45
94
|
import { prettifyError } from "zod/v4";
|
|
@@ -291,6 +340,13 @@ function reinterpretName(name) {
|
|
|
291
340
|
}
|
|
292
341
|
|
|
293
342
|
// src/shared/zod-schemas.ts
|
|
343
|
+
var makeFiniteNonNegativeNumberSchema = (valueLabel = "Value") => z.number({
|
|
344
|
+
// NOTE: Zod's implementation of `number` automatically rejects NaN and Infinity values.
|
|
345
|
+
// and therefore the finite check is implicit.
|
|
346
|
+
error: `${valueLabel} must be a finite number.`
|
|
347
|
+
}).nonnegative({
|
|
348
|
+
error: `${valueLabel} must be a non-negative number (>=0).`
|
|
349
|
+
});
|
|
294
350
|
var makeIntegerSchema = (valueLabel = "Value") => z.int({
|
|
295
351
|
error: `${valueLabel} must be an integer.`
|
|
296
352
|
});
|
|
@@ -365,13 +421,13 @@ var makePriceCurrencySchema = (currency, valueLabel = "Price Currency") => z.str
|
|
|
365
421
|
});
|
|
366
422
|
var makePriceEthSchema = (valueLabel = "Price ETH") => makePriceCurrencySchema(CurrencyIds.ETH, valueLabel).transform((v) => v);
|
|
367
423
|
var makeAccountIdSchema = (valueLabel = "AccountId") => z.strictObject({
|
|
368
|
-
chainId:
|
|
424
|
+
chainId: makeChainIdSchema(`${valueLabel} chain ID`),
|
|
369
425
|
address: makeLowercaseAddressSchema(`${valueLabel} address`)
|
|
370
426
|
});
|
|
371
427
|
var makeSerializedAccountIdSchema = (valueLabel = "Account ID") => z.coerce.string().transform((v) => {
|
|
372
428
|
const result = new CaipAccountId(v);
|
|
373
429
|
return {
|
|
374
|
-
chainId: result.chainId.reference,
|
|
430
|
+
chainId: Number(result.chainId.reference),
|
|
375
431
|
address: result.address
|
|
376
432
|
};
|
|
377
433
|
}).pipe(makeAccountIdSchema(valueLabel));
|
|
@@ -509,54 +565,185 @@ function addDuration(timestamp, duration) {
|
|
|
509
565
|
return deserializeUnixTimestamp(timestamp + duration, "UnixTimestamp");
|
|
510
566
|
}
|
|
511
567
|
|
|
512
|
-
// src/shared/cache.ts
|
|
513
|
-
var
|
|
514
|
-
|
|
515
|
-
_capacity;
|
|
568
|
+
// src/shared/cache/background-revalidation-scheduler.ts
|
|
569
|
+
var BackgroundRevalidationScheduler = class {
|
|
570
|
+
activeSchedules = /* @__PURE__ */ new Map();
|
|
516
571
|
/**
|
|
517
|
-
*
|
|
572
|
+
* Schedule a revalidation function to run on a recurring interval.
|
|
518
573
|
*
|
|
519
|
-
* @param
|
|
520
|
-
* @
|
|
574
|
+
* @param config Configuration object for the schedule
|
|
575
|
+
* @returns The revalidate function that can be passed to `cancel()` to stop the schedule
|
|
521
576
|
*/
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
);
|
|
577
|
+
schedule(config) {
|
|
578
|
+
const { revalidate, interval, initialDelay = 0, onError } = config;
|
|
579
|
+
if (this.activeSchedules.has(revalidate)) {
|
|
580
|
+
return revalidate;
|
|
527
581
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
582
|
+
const metadata = {
|
|
583
|
+
config,
|
|
584
|
+
timeoutId: null,
|
|
585
|
+
inProgress: false
|
|
586
|
+
};
|
|
587
|
+
this.activeSchedules.set(revalidate, metadata);
|
|
588
|
+
const executeRevalidation = async () => {
|
|
589
|
+
if (metadata.inProgress) return;
|
|
590
|
+
metadata.inProgress = true;
|
|
591
|
+
try {
|
|
592
|
+
await revalidate();
|
|
593
|
+
} catch (error) {
|
|
594
|
+
onError?.(error);
|
|
595
|
+
} finally {
|
|
596
|
+
metadata.inProgress = false;
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
const scheduleNext = () => {
|
|
600
|
+
if (!this.activeSchedules.has(revalidate)) return;
|
|
601
|
+
metadata.timeoutId = setTimeout(() => {
|
|
602
|
+
if (this.activeSchedules.has(revalidate)) {
|
|
603
|
+
executeRevalidation().then(() => scheduleNext());
|
|
604
|
+
}
|
|
605
|
+
}, interval);
|
|
606
|
+
};
|
|
607
|
+
if (initialDelay > 0) {
|
|
608
|
+
metadata.timeoutId = setTimeout(() => {
|
|
609
|
+
if (this.activeSchedules.has(revalidate)) {
|
|
610
|
+
executeRevalidation().then(() => scheduleNext());
|
|
611
|
+
}
|
|
612
|
+
}, initialDelay);
|
|
613
|
+
} else {
|
|
614
|
+
scheduleNext();
|
|
532
615
|
}
|
|
533
|
-
|
|
616
|
+
return revalidate;
|
|
534
617
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
618
|
+
/**
|
|
619
|
+
* Cancel a scheduled revalidation by its revalidate function.
|
|
620
|
+
*
|
|
621
|
+
* @param revalidate The revalidation function returned from `schedule()`
|
|
622
|
+
*/
|
|
623
|
+
cancel(revalidate) {
|
|
624
|
+
const metadata = this.activeSchedules.get(revalidate);
|
|
625
|
+
if (!metadata) return;
|
|
626
|
+
if (metadata.timeoutId !== null) {
|
|
627
|
+
clearTimeout(metadata.timeoutId);
|
|
540
628
|
}
|
|
629
|
+
this.activeSchedules.delete(revalidate);
|
|
541
630
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
631
|
+
/**
|
|
632
|
+
* Cancel all active schedules.
|
|
633
|
+
*/
|
|
634
|
+
cancelAll() {
|
|
635
|
+
for (const [, metadata] of this.activeSchedules) {
|
|
636
|
+
if (metadata.timeoutId !== null) {
|
|
637
|
+
clearTimeout(metadata.timeoutId);
|
|
638
|
+
}
|
|
547
639
|
}
|
|
548
|
-
|
|
640
|
+
this.activeSchedules.clear();
|
|
549
641
|
}
|
|
550
|
-
|
|
551
|
-
|
|
642
|
+
/**
|
|
643
|
+
* Get the count of active schedules.
|
|
644
|
+
* Useful for debugging and monitoring.
|
|
645
|
+
*
|
|
646
|
+
* @returns The number of currently active schedules
|
|
647
|
+
*/
|
|
648
|
+
getActiveScheduleCount() {
|
|
649
|
+
return this.activeSchedules.size;
|
|
552
650
|
}
|
|
553
|
-
|
|
554
|
-
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// src/shared/cache/swr-cache.ts
|
|
654
|
+
var bgRevalidationScheduler = new BackgroundRevalidationScheduler();
|
|
655
|
+
var SWRCache = class _SWRCache {
|
|
656
|
+
options;
|
|
657
|
+
cache;
|
|
658
|
+
/**
|
|
659
|
+
* Optional promise of the current in-progress attempt to revalidate the `cache`.
|
|
660
|
+
*
|
|
661
|
+
* If null, no revalidation attempt is currently in progress.
|
|
662
|
+
* If not null, identifies the revalidation attempt that is currently in progress.
|
|
663
|
+
*
|
|
664
|
+
* Used to enforce no concurrent revalidation attempts.
|
|
665
|
+
*/
|
|
666
|
+
inProgressRevalidate;
|
|
667
|
+
/**
|
|
668
|
+
* The callback function being managed by `BackgroundRevalidationScheduler`.
|
|
669
|
+
*
|
|
670
|
+
* If null, no background revalidation is scheduled.
|
|
671
|
+
* If not null, identifies the background revalidation that is currently scheduled.
|
|
672
|
+
*
|
|
673
|
+
* Used to enforce no concurrent background revalidation attempts.
|
|
674
|
+
*/
|
|
675
|
+
scheduledBackgroundRevalidate;
|
|
676
|
+
constructor(options) {
|
|
677
|
+
this.cache = null;
|
|
678
|
+
this.inProgressRevalidate = null;
|
|
679
|
+
this.scheduledBackgroundRevalidate = null;
|
|
680
|
+
this.options = options;
|
|
555
681
|
}
|
|
556
|
-
|
|
557
|
-
|
|
682
|
+
/**
|
|
683
|
+
* Asynchronously create a new `SWRCache` instance.
|
|
684
|
+
*
|
|
685
|
+
* @param options - The {@link SWRCacheOptions} for the SWR cache.
|
|
686
|
+
* @returns a new `SWRCache` instance.
|
|
687
|
+
*/
|
|
688
|
+
static async create(options) {
|
|
689
|
+
const cache = new _SWRCache(options);
|
|
690
|
+
if (cache.options.proactivelyInitialize) {
|
|
691
|
+
cache.readCache();
|
|
692
|
+
}
|
|
693
|
+
return cache;
|
|
558
694
|
}
|
|
695
|
+
revalidate = async () => {
|
|
696
|
+
if (this.inProgressRevalidate) {
|
|
697
|
+
return this.inProgressRevalidate;
|
|
698
|
+
}
|
|
699
|
+
return this.options.fn().then((value) => {
|
|
700
|
+
this.cache = {
|
|
701
|
+
value,
|
|
702
|
+
updatedAt: getUnixTime(/* @__PURE__ */ new Date())
|
|
703
|
+
};
|
|
704
|
+
return this.cache;
|
|
705
|
+
}).catch(() => {
|
|
706
|
+
return null;
|
|
707
|
+
}).finally(() => {
|
|
708
|
+
this.inProgressRevalidate = null;
|
|
709
|
+
if (this.options.revalidationInterval === void 0) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (this.scheduledBackgroundRevalidate) {
|
|
713
|
+
bgRevalidationScheduler.cancel(this.scheduledBackgroundRevalidate);
|
|
714
|
+
}
|
|
715
|
+
const backgroundRevalidate = async () => {
|
|
716
|
+
this.revalidate();
|
|
717
|
+
};
|
|
718
|
+
this.scheduledBackgroundRevalidate = bgRevalidationScheduler.schedule({
|
|
719
|
+
revalidate: backgroundRevalidate,
|
|
720
|
+
interval: secondsToMilliseconds(this.options.revalidationInterval)
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* Read the most recently cached `CachedValue` from the `SWRCache`.
|
|
726
|
+
*
|
|
727
|
+
* @returns a `CachedValue` holding a `value` of `ValueType` that was most recently successfully returned by `fn`
|
|
728
|
+
* or `null` if `fn` has never successfully returned and has always thrown an error,
|
|
729
|
+
*/
|
|
730
|
+
readCache = async () => {
|
|
731
|
+
if (!this.cache) {
|
|
732
|
+
this.inProgressRevalidate = this.revalidate();
|
|
733
|
+
return this.inProgressRevalidate;
|
|
734
|
+
}
|
|
735
|
+
if (durationBetween(this.cache.updatedAt, getUnixTime(/* @__PURE__ */ new Date())) <= this.options.ttl) {
|
|
736
|
+
return this.cache;
|
|
737
|
+
}
|
|
738
|
+
if (!this.inProgressRevalidate) {
|
|
739
|
+
this.inProgressRevalidate = this.revalidate();
|
|
740
|
+
}
|
|
741
|
+
return this.cache;
|
|
742
|
+
};
|
|
559
743
|
};
|
|
744
|
+
|
|
745
|
+
// src/shared/cache/ttl-cache.ts
|
|
746
|
+
import { getUnixTime as getUnixTime2 } from "date-fns/getUnixTime";
|
|
560
747
|
var TtlCache = class {
|
|
561
748
|
_cache = /* @__PURE__ */ new Map();
|
|
562
749
|
_ttl;
|
|
@@ -569,7 +756,7 @@ var TtlCache = class {
|
|
|
569
756
|
this._ttl = ttl;
|
|
570
757
|
}
|
|
571
758
|
_cleanup() {
|
|
572
|
-
const now =
|
|
759
|
+
const now = getUnixTime2(/* @__PURE__ */ new Date());
|
|
573
760
|
for (const [key, entry] of this._cache.entries()) {
|
|
574
761
|
if (entry.expiresAt <= now) {
|
|
575
762
|
this._cache.delete(key);
|
|
@@ -578,7 +765,7 @@ var TtlCache = class {
|
|
|
578
765
|
}
|
|
579
766
|
set(key, value) {
|
|
580
767
|
this._cleanup();
|
|
581
|
-
const expiresAt = addDuration(
|
|
768
|
+
const expiresAt = addDuration(getUnixTime2(/* @__PURE__ */ new Date()), this._ttl);
|
|
582
769
|
this._cache.set(key, { value, expiresAt });
|
|
583
770
|
}
|
|
584
771
|
get(key) {
|
|
@@ -587,7 +774,7 @@ var TtlCache = class {
|
|
|
587
774
|
if (!entry) {
|
|
588
775
|
return void 0;
|
|
589
776
|
}
|
|
590
|
-
if (entry.expiresAt <=
|
|
777
|
+
if (entry.expiresAt <= getUnixTime2(/* @__PURE__ */ new Date())) {
|
|
591
778
|
this._cache.delete(key);
|
|
592
779
|
return void 0;
|
|
593
780
|
}
|
|
@@ -609,7 +796,7 @@ var TtlCache = class {
|
|
|
609
796
|
if (!entry) {
|
|
610
797
|
return false;
|
|
611
798
|
}
|
|
612
|
-
if (entry.expiresAt <=
|
|
799
|
+
if (entry.expiresAt <= getUnixTime2(/* @__PURE__ */ new Date())) {
|
|
613
800
|
this._cache.delete(key);
|
|
614
801
|
return false;
|
|
615
802
|
}
|
|
@@ -619,39 +806,6 @@ var TtlCache = class {
|
|
|
619
806
|
return this._cache.delete(key);
|
|
620
807
|
}
|
|
621
808
|
};
|
|
622
|
-
function staleWhileRevalidate(options) {
|
|
623
|
-
const { fn, ttl } = options;
|
|
624
|
-
let cache = null;
|
|
625
|
-
let cacheInitializer = null;
|
|
626
|
-
return async () => {
|
|
627
|
-
if (!cache) {
|
|
628
|
-
if (cacheInitializer) {
|
|
629
|
-
return cacheInitializer;
|
|
630
|
-
}
|
|
631
|
-
cacheInitializer = fn().then((value) => {
|
|
632
|
-
cache = { value, updatedAt: getUnixTime(/* @__PURE__ */ new Date()) };
|
|
633
|
-
cacheInitializer = null;
|
|
634
|
-
return value;
|
|
635
|
-
}).catch(() => {
|
|
636
|
-
cacheInitializer = null;
|
|
637
|
-
return null;
|
|
638
|
-
});
|
|
639
|
-
return cacheInitializer;
|
|
640
|
-
}
|
|
641
|
-
const isStale = durationBetween(cache.updatedAt, getUnixTime(/* @__PURE__ */ new Date())) > ttl;
|
|
642
|
-
if (!isStale) return cache.value;
|
|
643
|
-
if (cache.inProgressRevalidation) return cache.value;
|
|
644
|
-
const revalidationPromise = fn().then((value) => {
|
|
645
|
-
cache = { value, updatedAt: getUnixTime(/* @__PURE__ */ new Date()) };
|
|
646
|
-
}).catch(() => {
|
|
647
|
-
if (cache) {
|
|
648
|
-
cache.inProgressRevalidation = void 0;
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
cache.inProgressRevalidation = revalidationPromise;
|
|
652
|
-
return cache.value;
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
809
|
|
|
656
810
|
// src/shared/collections.ts
|
|
657
811
|
var uniq = (arr) => [...new Set(arr)];
|
|
@@ -729,106 +883,372 @@ function isWebSocketProtocol(url) {
|
|
|
729
883
|
return ["ws:", "wss:"].includes(url.protocol);
|
|
730
884
|
}
|
|
731
885
|
|
|
732
|
-
// src/ensindexer/
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* Represents that indexing of the chain should be performed for an indefinite range.
|
|
736
|
-
*/
|
|
737
|
-
Indefinite: "indefinite",
|
|
738
|
-
/**
|
|
739
|
-
* Represents that indexing of the chain should be performed for a definite range.
|
|
740
|
-
*/
|
|
741
|
-
Definite: "definite"
|
|
742
|
-
};
|
|
743
|
-
var ChainIndexingStatusIds = {
|
|
744
|
-
/**
|
|
745
|
-
* Represents that indexing of the chain is not ready to begin yet because:
|
|
746
|
-
* - ENSIndexer is in its initialization phase and the data to build a
|
|
747
|
-
* "true" {@link ChainIndexingSnapshot} for the chain is still being loaded; or
|
|
748
|
-
* - ENSIndexer is using an omnichain indexing strategy and the
|
|
749
|
-
* `omnichainIndexingCursor` is <= `config.startBlock.timestamp` for the chain's
|
|
750
|
-
* {@link ChainIndexingSnapshot}.
|
|
751
|
-
*/
|
|
752
|
-
Queued: "chain-queued",
|
|
753
|
-
/**
|
|
754
|
-
* Represents that indexing of the chain is in progress and under a special
|
|
755
|
-
* "backfill" phase that optimizes for accelerated indexing until reaching the
|
|
756
|
-
* "fixed target" `backfillEndBlock`.
|
|
757
|
-
*/
|
|
758
|
-
Backfill: "chain-backfill",
|
|
759
|
-
/**
|
|
760
|
-
* Represents that the "backfill" phase of indexing the chain is completed
|
|
761
|
-
* and that the chain is configured to be indexed for an indefinite range.
|
|
762
|
-
* Therefore, indexing of the chain remains indefinitely in progress where
|
|
763
|
-
* ENSIndexer will continuously work to discover and index new blocks as they
|
|
764
|
-
* are added to the chain across time.
|
|
765
|
-
*/
|
|
766
|
-
Following: "chain-following",
|
|
767
|
-
/**
|
|
768
|
-
* Represents that indexing of the chain is completed as the chain is configured
|
|
769
|
-
* to be indexed for a definite range and the indexing of all blocks through
|
|
770
|
-
* that definite range is completed.
|
|
771
|
-
*/
|
|
772
|
-
Completed: "chain-completed"
|
|
773
|
-
};
|
|
774
|
-
var OmnichainIndexingStatusIds = {
|
|
775
|
-
/**
|
|
776
|
-
* Represents that omnichain indexing is not ready to begin yet because
|
|
777
|
-
* ENSIndexer is in its initialization phase and the data to build a "true"
|
|
778
|
-
* {@link OmnichainIndexingStatusSnapshot} is still being loaded.
|
|
779
|
-
*/
|
|
780
|
-
Unstarted: "omnichain-unstarted",
|
|
781
|
-
/**
|
|
782
|
-
* Represents that omnichain indexing is in an overall "backfill" status because
|
|
783
|
-
* - At least one indexed chain has a `chainStatus` of
|
|
784
|
-
* {@link ChainIndexingStatusIds.Backfill}; and
|
|
785
|
-
* - No indexed chain has a `chainStatus` of {@link ChainIndexingStatusIds.Following}.
|
|
786
|
-
*/
|
|
787
|
-
Backfill: "omnichain-backfill",
|
|
788
|
-
/**
|
|
789
|
-
* Represents that omnichain indexing is in an overall "following" status because
|
|
790
|
-
* at least one indexed chain has a `chainStatus` of
|
|
791
|
-
* {@link ChainIndexingStatusIds.Following}.
|
|
792
|
-
*/
|
|
793
|
-
Following: "omnichain-following",
|
|
794
|
-
/**
|
|
795
|
-
* Represents that omnichain indexing has completed because all indexed chains have
|
|
796
|
-
* a `chainStatus` of {@link ChainIndexingStatusIds.Completed}.
|
|
797
|
-
*/
|
|
798
|
-
Completed: "omnichain-completed"
|
|
799
|
-
};
|
|
800
|
-
var CrossChainIndexingStrategyIds = {
|
|
801
|
-
/**
|
|
802
|
-
* Represents that the indexing of events across all indexed chains will
|
|
803
|
-
* proceed in a deterministic "omnichain" ordering by block timestamp, chain ID,
|
|
804
|
-
* and block number.
|
|
805
|
-
*
|
|
806
|
-
* This strategy is "deterministic" in that the order of processing cross-chain indexed
|
|
807
|
-
* events and each resulting indexed data state transition recorded in ENSDb is always
|
|
808
|
-
* the same for each ENSIndexer instance operating with an equivalent
|
|
809
|
-
* `ENSIndexerConfig` and ENSIndexer version. However it also has the drawbacks of:
|
|
810
|
-
* - increased indexing latency that must wait for the slowest indexed chain to
|
|
811
|
-
* add new blocks or to discover new blocks through the configured RPCs.
|
|
812
|
-
* - if any indexed chain gets "stuck" due to chain or RPC failures, all indexed chains
|
|
813
|
-
* will be affected.
|
|
814
|
-
*/
|
|
815
|
-
Omnichain: "omnichain"
|
|
816
|
-
};
|
|
886
|
+
// src/ensindexer/config/is-subgraph-compatible.ts
|
|
887
|
+
import { ENSNamespaceIds as ENSNamespaceIds2 } from "@ensnode/datasources";
|
|
817
888
|
|
|
818
|
-
// src/
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
889
|
+
// src/ensindexer/config/types.ts
|
|
890
|
+
var PluginName = /* @__PURE__ */ ((PluginName2) => {
|
|
891
|
+
PluginName2["Subgraph"] = "subgraph";
|
|
892
|
+
PluginName2["Basenames"] = "basenames";
|
|
893
|
+
PluginName2["Lineanames"] = "lineanames";
|
|
894
|
+
PluginName2["ThreeDNS"] = "threedns";
|
|
895
|
+
PluginName2["ProtocolAcceleration"] = "protocol-acceleration";
|
|
896
|
+
PluginName2["Registrars"] = "registrars";
|
|
897
|
+
PluginName2["TokenScope"] = "tokenscope";
|
|
898
|
+
return PluginName2;
|
|
899
|
+
})(PluginName || {});
|
|
828
900
|
|
|
829
|
-
// src/ensindexer/
|
|
830
|
-
function
|
|
831
|
-
|
|
901
|
+
// src/ensindexer/config/is-subgraph-compatible.ts
|
|
902
|
+
function isSubgraphCompatible(config) {
|
|
903
|
+
const onlySubgraphPluginActivated = config.plugins.length === 1 && config.plugins[0] === "subgraph" /* Subgraph */;
|
|
904
|
+
const isSubgraphLabelSet = config.labelSet.labelSetId === "subgraph" && config.labelSet.labelSetVersion === 0;
|
|
905
|
+
const isEnsTestEnvLabelSet = config.labelSet.labelSetId === "ens-test-env" && config.labelSet.labelSetVersion === 0;
|
|
906
|
+
const labelSetIsSubgraphCompatible = isSubgraphLabelSet || config.namespace === ENSNamespaceIds2.EnsTestEnv && isEnsTestEnvLabelSet;
|
|
907
|
+
return onlySubgraphPluginActivated && labelSetIsSubgraphCompatible;
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// src/ensindexer/config/validations.ts
|
|
911
|
+
function invariant_ensDbVersionIsSameAsEnsIndexerVersion(ctx) {
|
|
912
|
+
const versionInfo = ctx.value;
|
|
913
|
+
if (versionInfo.ensDb !== versionInfo.ensIndexer) {
|
|
914
|
+
ctx.issues.push({
|
|
915
|
+
code: "custom",
|
|
916
|
+
input: versionInfo,
|
|
917
|
+
message: "`ensDb` version must be same as `ensIndexer` version"
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// src/ensindexer/config/zod-schemas.ts
|
|
923
|
+
var makeIndexedChainIdsSchema = (valueLabel = "Indexed Chain IDs") => z2.array(makeChainIdSchema(valueLabel), {
|
|
924
|
+
error: `${valueLabel} must be an array.`
|
|
925
|
+
}).min(1, { error: `${valueLabel} list must include at least one element.` }).transform((v) => new Set(v));
|
|
926
|
+
var makePluginsListSchema = (valueLabel = "Plugins") => z2.array(z2.string(), {
|
|
927
|
+
error: `${valueLabel} must be a list of strings.`
|
|
928
|
+
}).min(1, {
|
|
929
|
+
error: `${valueLabel} must be a list of strings with at least one string value`
|
|
930
|
+
}).refine((arr) => arr.length === uniq(arr).length, {
|
|
931
|
+
error: `${valueLabel} cannot contain duplicate values.`
|
|
932
|
+
});
|
|
933
|
+
var makeDatabaseSchemaNameSchema = (valueLabel = "Database schema name") => z2.string({ error: `${valueLabel} must be a string` }).trim().nonempty({
|
|
934
|
+
error: `${valueLabel} is required and must be a non-empty string.`
|
|
935
|
+
});
|
|
936
|
+
var makeLabelSetIdSchema = (valueLabel) => {
|
|
937
|
+
return z2.string({ error: `${valueLabel} must be a string` }).min(1, { error: `${valueLabel} must be 1-50 characters long` }).max(50, { error: `${valueLabel} must be 1-50 characters long` }).regex(/^[a-z-]+$/, {
|
|
938
|
+
error: `${valueLabel} can only contain lowercase letters (a-z) and hyphens (-)`
|
|
939
|
+
});
|
|
940
|
+
};
|
|
941
|
+
var makeLabelSetVersionSchema = (valueLabel) => {
|
|
942
|
+
return z2.coerce.number({ error: `${valueLabel} must be an integer.` }).pipe(makeNonNegativeIntegerSchema(valueLabel));
|
|
943
|
+
};
|
|
944
|
+
var makeFullyPinnedLabelSetSchema = (valueLabel = "Label set") => {
|
|
945
|
+
let valueLabelLabelSetId = valueLabel;
|
|
946
|
+
let valueLabelLabelSetVersion = valueLabel;
|
|
947
|
+
if (valueLabel === "LABEL_SET") {
|
|
948
|
+
valueLabelLabelSetId = "LABEL_SET_ID";
|
|
949
|
+
valueLabelLabelSetVersion = "LABEL_SET_VERSION";
|
|
950
|
+
} else {
|
|
951
|
+
valueLabelLabelSetId = `${valueLabel}.labelSetId`;
|
|
952
|
+
valueLabelLabelSetVersion = `${valueLabel}.labelSetVersion`;
|
|
953
|
+
}
|
|
954
|
+
return z2.object({
|
|
955
|
+
labelSetId: makeLabelSetIdSchema(valueLabelLabelSetId),
|
|
956
|
+
labelSetVersion: makeLabelSetVersionSchema(valueLabelLabelSetVersion)
|
|
957
|
+
});
|
|
958
|
+
};
|
|
959
|
+
var makeNonEmptyStringSchema = (valueLabel = "Value") => z2.string().nonempty({ error: `${valueLabel} must be a non-empty string.` });
|
|
960
|
+
var makeENSIndexerVersionInfoSchema = (valueLabel = "Value") => z2.strictObject(
|
|
961
|
+
{
|
|
962
|
+
nodejs: makeNonEmptyStringSchema(),
|
|
963
|
+
ponder: makeNonEmptyStringSchema(),
|
|
964
|
+
ensDb: makeNonEmptyStringSchema(),
|
|
965
|
+
ensIndexer: makeNonEmptyStringSchema(),
|
|
966
|
+
ensNormalize: makeNonEmptyStringSchema(),
|
|
967
|
+
ensRainbow: makeNonEmptyStringSchema(),
|
|
968
|
+
ensRainbowSchema: makePositiveIntegerSchema()
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
error: `${valueLabel} must be a valid ENSIndexerVersionInfo object.`
|
|
972
|
+
}
|
|
973
|
+
).check(invariant_ensDbVersionIsSameAsEnsIndexerVersion);
|
|
974
|
+
function invariant_isSubgraphCompatibleRequirements(ctx) {
|
|
975
|
+
const { value: config } = ctx;
|
|
976
|
+
if (config.isSubgraphCompatible && !isSubgraphCompatible(config)) {
|
|
977
|
+
ctx.issues.push({
|
|
978
|
+
code: "custom",
|
|
979
|
+
input: config,
|
|
980
|
+
message: `'isSubgraphCompatible' requires only the '${"subgraph" /* Subgraph */}' plugin to be active and labelSet must be {labelSetId: "subgraph", labelSetVersion: 0}`
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
var makeENSIndexerPublicConfigSchema = (valueLabel = "ENSIndexerPublicConfig") => z2.object({
|
|
985
|
+
labelSet: makeFullyPinnedLabelSetSchema(`${valueLabel}.labelSet`),
|
|
986
|
+
indexedChainIds: makeIndexedChainIdsSchema(`${valueLabel}.indexedChainIds`),
|
|
987
|
+
isSubgraphCompatible: z2.boolean({ error: `${valueLabel}.isSubgraphCompatible` }),
|
|
988
|
+
namespace: makeENSNamespaceIdSchema(`${valueLabel}.namespace`),
|
|
989
|
+
plugins: makePluginsListSchema(`${valueLabel}.plugins`),
|
|
990
|
+
databaseSchemaName: makeDatabaseSchemaNameSchema(`${valueLabel}.databaseSchemaName`),
|
|
991
|
+
versionInfo: makeENSIndexerVersionInfoSchema(`${valueLabel}.versionInfo`)
|
|
992
|
+
}).check(invariant_isSubgraphCompatibleRequirements);
|
|
993
|
+
|
|
994
|
+
// src/ensapi/config/zod-schemas.ts
|
|
995
|
+
var TheGraphCannotFallbackReasonSchema = z3.enum({
|
|
996
|
+
NotSubgraphCompatible: "not-subgraph-compatible",
|
|
997
|
+
NoApiKey: "no-api-key",
|
|
998
|
+
NoSubgraphUrl: "no-subgraph-url"
|
|
999
|
+
});
|
|
1000
|
+
var TheGraphFallbackSchema = z3.strictObject({
|
|
1001
|
+
canFallback: z3.boolean(),
|
|
1002
|
+
reason: TheGraphCannotFallbackReasonSchema.nullable()
|
|
1003
|
+
});
|
|
1004
|
+
function makeENSApiPublicConfigSchema(valueLabel) {
|
|
1005
|
+
const label = valueLabel ?? "ENSApiPublicConfig";
|
|
1006
|
+
return z3.strictObject({
|
|
1007
|
+
version: z3.string().min(1, `${label}.version must be a non-empty string`),
|
|
1008
|
+
theGraphFallback: TheGraphFallbackSchema,
|
|
1009
|
+
ensIndexerPublicConfig: makeENSIndexerPublicConfigSchema(`${label}.ensIndexerPublicConfig`)
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// src/ensapi/config/deserialize.ts
|
|
1014
|
+
function deserializeENSApiPublicConfig(maybeConfig, valueLabel) {
|
|
1015
|
+
const schema = makeENSApiPublicConfigSchema(valueLabel);
|
|
1016
|
+
try {
|
|
1017
|
+
return schema.parse(maybeConfig);
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
if (error instanceof ZodError) {
|
|
1020
|
+
throw new Error(`Cannot deserialize ENSApiPublicConfig:
|
|
1021
|
+
${prettifyError2(error)}
|
|
1022
|
+
`);
|
|
1023
|
+
}
|
|
1024
|
+
throw error;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
// src/ensindexer/config/deserialize.ts
|
|
1029
|
+
import { prettifyError as prettifyError3 } from "zod/v4";
|
|
1030
|
+
function deserializeENSIndexerPublicConfig(maybeConfig, valueLabel) {
|
|
1031
|
+
const schema = makeENSIndexerPublicConfigSchema(valueLabel);
|
|
1032
|
+
const parsed = schema.safeParse(maybeConfig);
|
|
1033
|
+
if (parsed.error) {
|
|
1034
|
+
throw new Error(`Cannot deserialize ENSIndexerPublicConfig:
|
|
1035
|
+
${prettifyError3(parsed.error)}
|
|
1036
|
+
`);
|
|
1037
|
+
}
|
|
1038
|
+
return parsed.data;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
// src/ensindexer/config/label-utils.ts
|
|
1042
|
+
import { hexToBytes as hexToBytes2 } from "viem";
|
|
1043
|
+
function labelHashToBytes(labelHash) {
|
|
1044
|
+
try {
|
|
1045
|
+
if (labelHash.length !== 66) {
|
|
1046
|
+
throw new Error(`Invalid labelHash length ${labelHash.length} characters (expected 66)`);
|
|
1047
|
+
}
|
|
1048
|
+
if (labelHash !== labelHash.toLowerCase()) {
|
|
1049
|
+
throw new Error("Labelhash must be in lowercase");
|
|
1050
|
+
}
|
|
1051
|
+
if (!labelHash.startsWith("0x")) {
|
|
1052
|
+
throw new Error("Labelhash must be 0x-prefixed");
|
|
1053
|
+
}
|
|
1054
|
+
const bytes = hexToBytes2(labelHash);
|
|
1055
|
+
if (bytes.length !== 32) {
|
|
1056
|
+
throw new Error(`Invalid labelHash length ${bytes.length} bytes (expected 32)`);
|
|
1057
|
+
}
|
|
1058
|
+
return bytes;
|
|
1059
|
+
} catch (e) {
|
|
1060
|
+
if (e instanceof Error) {
|
|
1061
|
+
throw e;
|
|
1062
|
+
}
|
|
1063
|
+
throw new Error("Invalid hex format");
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
// src/ensindexer/config/labelset-utils.ts
|
|
1068
|
+
function buildLabelSetId(maybeLabelSetId) {
|
|
1069
|
+
return makeLabelSetIdSchema("LabelSetId").parse(maybeLabelSetId);
|
|
1070
|
+
}
|
|
1071
|
+
function buildLabelSetVersion(maybeLabelSetVersion) {
|
|
1072
|
+
return makeLabelSetVersionSchema("LabelSetVersion").parse(maybeLabelSetVersion);
|
|
1073
|
+
}
|
|
1074
|
+
function buildEnsRainbowClientLabelSet(labelSetId, labelSetVersion) {
|
|
1075
|
+
if (labelSetVersion !== void 0 && labelSetId === void 0) {
|
|
1076
|
+
throw new Error("When a labelSetVersion is defined, labelSetId must also be defined.");
|
|
1077
|
+
}
|
|
1078
|
+
return { labelSetId, labelSetVersion };
|
|
1079
|
+
}
|
|
1080
|
+
function validateSupportedLabelSetAndVersion(serverSet, clientSet) {
|
|
1081
|
+
if (clientSet.labelSetId === void 0) {
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
if (serverSet.labelSetId !== clientSet.labelSetId) {
|
|
1085
|
+
throw new Error(
|
|
1086
|
+
`Server label set ID "${serverSet.labelSetId}" does not match client's requested label set ID "${clientSet.labelSetId}".`
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
if (clientSet.labelSetVersion !== void 0 && serverSet.highestLabelSetVersion < clientSet.labelSetVersion) {
|
|
1090
|
+
throw new Error(
|
|
1091
|
+
`Server highest label set version ${serverSet.highestLabelSetVersion} is less than client's requested version ${clientSet.labelSetVersion} for label set ID "${clientSet.labelSetId}".`
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
// src/ensindexer/config/parsing.ts
|
|
1097
|
+
function parseNonNegativeInteger(maybeNumber) {
|
|
1098
|
+
const trimmed = maybeNumber.trim();
|
|
1099
|
+
if (!trimmed) {
|
|
1100
|
+
throw new Error("Input cannot be empty");
|
|
1101
|
+
}
|
|
1102
|
+
if (trimmed === "-0") {
|
|
1103
|
+
throw new Error("Negative zero is not a valid non-negative integer");
|
|
1104
|
+
}
|
|
1105
|
+
const num = Number(maybeNumber);
|
|
1106
|
+
if (Number.isNaN(num)) {
|
|
1107
|
+
throw new Error(`"${maybeNumber}" is not a valid number`);
|
|
1108
|
+
}
|
|
1109
|
+
if (!Number.isFinite(num)) {
|
|
1110
|
+
throw new Error(`"${maybeNumber}" is not a finite number`);
|
|
1111
|
+
}
|
|
1112
|
+
if (!Number.isInteger(num)) {
|
|
1113
|
+
throw new Error(`"${maybeNumber}" is not an integer`);
|
|
1114
|
+
}
|
|
1115
|
+
if (num < 0) {
|
|
1116
|
+
throw new Error(`"${maybeNumber}" is not a non-negative integer`);
|
|
1117
|
+
}
|
|
1118
|
+
return num;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// src/ensindexer/config/serialize.ts
|
|
1122
|
+
function serializeIndexedChainIds(indexedChainIds) {
|
|
1123
|
+
return Array.from(indexedChainIds);
|
|
1124
|
+
}
|
|
1125
|
+
function serializeENSIndexerPublicConfig(config) {
|
|
1126
|
+
const {
|
|
1127
|
+
labelSet,
|
|
1128
|
+
indexedChainIds,
|
|
1129
|
+
databaseSchemaName,
|
|
1130
|
+
isSubgraphCompatible: isSubgraphCompatible2,
|
|
1131
|
+
namespace,
|
|
1132
|
+
plugins,
|
|
1133
|
+
versionInfo
|
|
1134
|
+
} = config;
|
|
1135
|
+
return {
|
|
1136
|
+
labelSet,
|
|
1137
|
+
indexedChainIds: serializeIndexedChainIds(indexedChainIds),
|
|
1138
|
+
databaseSchemaName,
|
|
1139
|
+
isSubgraphCompatible: isSubgraphCompatible2,
|
|
1140
|
+
namespace,
|
|
1141
|
+
plugins,
|
|
1142
|
+
versionInfo
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// src/ensindexer/indexing-status/deserialize.ts
|
|
1147
|
+
import { prettifyError as prettifyError4 } from "zod/v4";
|
|
1148
|
+
|
|
1149
|
+
// src/ensindexer/indexing-status/zod-schemas.ts
|
|
1150
|
+
import z4 from "zod/v4";
|
|
1151
|
+
|
|
1152
|
+
// src/ensindexer/indexing-status/types.ts
|
|
1153
|
+
var ChainIndexingConfigTypeIds = {
|
|
1154
|
+
/**
|
|
1155
|
+
* Represents that indexing of the chain should be performed for an indefinite range.
|
|
1156
|
+
*/
|
|
1157
|
+
Indefinite: "indefinite",
|
|
1158
|
+
/**
|
|
1159
|
+
* Represents that indexing of the chain should be performed for a definite range.
|
|
1160
|
+
*/
|
|
1161
|
+
Definite: "definite"
|
|
1162
|
+
};
|
|
1163
|
+
var ChainIndexingStatusIds = {
|
|
1164
|
+
/**
|
|
1165
|
+
* Represents that indexing of the chain is not ready to begin yet because:
|
|
1166
|
+
* - ENSIndexer is in its initialization phase and the data to build a
|
|
1167
|
+
* "true" {@link ChainIndexingSnapshot} for the chain is still being loaded; or
|
|
1168
|
+
* - ENSIndexer is using an omnichain indexing strategy and the
|
|
1169
|
+
* `omnichainIndexingCursor` is <= `config.startBlock.timestamp` for the chain's
|
|
1170
|
+
* {@link ChainIndexingSnapshot}.
|
|
1171
|
+
*/
|
|
1172
|
+
Queued: "chain-queued",
|
|
1173
|
+
/**
|
|
1174
|
+
* Represents that indexing of the chain is in progress and under a special
|
|
1175
|
+
* "backfill" phase that optimizes for accelerated indexing until reaching the
|
|
1176
|
+
* "fixed target" `backfillEndBlock`.
|
|
1177
|
+
*/
|
|
1178
|
+
Backfill: "chain-backfill",
|
|
1179
|
+
/**
|
|
1180
|
+
* Represents that the "backfill" phase of indexing the chain is completed
|
|
1181
|
+
* and that the chain is configured to be indexed for an indefinite range.
|
|
1182
|
+
* Therefore, indexing of the chain remains indefinitely in progress where
|
|
1183
|
+
* ENSIndexer will continuously work to discover and index new blocks as they
|
|
1184
|
+
* are added to the chain across time.
|
|
1185
|
+
*/
|
|
1186
|
+
Following: "chain-following",
|
|
1187
|
+
/**
|
|
1188
|
+
* Represents that indexing of the chain is completed as the chain is configured
|
|
1189
|
+
* to be indexed for a definite range and the indexing of all blocks through
|
|
1190
|
+
* that definite range is completed.
|
|
1191
|
+
*/
|
|
1192
|
+
Completed: "chain-completed"
|
|
1193
|
+
};
|
|
1194
|
+
var OmnichainIndexingStatusIds = {
|
|
1195
|
+
/**
|
|
1196
|
+
* Represents that omnichain indexing is not ready to begin yet because
|
|
1197
|
+
* ENSIndexer is in its initialization phase and the data to build a "true"
|
|
1198
|
+
* {@link OmnichainIndexingStatusSnapshot} is still being loaded.
|
|
1199
|
+
*/
|
|
1200
|
+
Unstarted: "omnichain-unstarted",
|
|
1201
|
+
/**
|
|
1202
|
+
* Represents that omnichain indexing is in an overall "backfill" status because
|
|
1203
|
+
* - At least one indexed chain has a `chainStatus` of
|
|
1204
|
+
* {@link ChainIndexingStatusIds.Backfill}; and
|
|
1205
|
+
* - No indexed chain has a `chainStatus` of {@link ChainIndexingStatusIds.Following}.
|
|
1206
|
+
*/
|
|
1207
|
+
Backfill: "omnichain-backfill",
|
|
1208
|
+
/**
|
|
1209
|
+
* Represents that omnichain indexing is in an overall "following" status because
|
|
1210
|
+
* at least one indexed chain has a `chainStatus` of
|
|
1211
|
+
* {@link ChainIndexingStatusIds.Following}.
|
|
1212
|
+
*/
|
|
1213
|
+
Following: "omnichain-following",
|
|
1214
|
+
/**
|
|
1215
|
+
* Represents that omnichain indexing has completed because all indexed chains have
|
|
1216
|
+
* a `chainStatus` of {@link ChainIndexingStatusIds.Completed}.
|
|
1217
|
+
*/
|
|
1218
|
+
Completed: "omnichain-completed"
|
|
1219
|
+
};
|
|
1220
|
+
var CrossChainIndexingStrategyIds = {
|
|
1221
|
+
/**
|
|
1222
|
+
* Represents that the indexing of events across all indexed chains will
|
|
1223
|
+
* proceed in a deterministic "omnichain" ordering by block timestamp, chain ID,
|
|
1224
|
+
* and block number.
|
|
1225
|
+
*
|
|
1226
|
+
* This strategy is "deterministic" in that the order of processing cross-chain indexed
|
|
1227
|
+
* events and each resulting indexed data state transition recorded in ENSDb is always
|
|
1228
|
+
* the same for each ENSIndexer instance operating with an equivalent
|
|
1229
|
+
* `ENSIndexerConfig` and ENSIndexer version. However it also has the drawbacks of:
|
|
1230
|
+
* - increased indexing latency that must wait for the slowest indexed chain to
|
|
1231
|
+
* add new blocks or to discover new blocks through the configured RPCs.
|
|
1232
|
+
* - if any indexed chain gets "stuck" due to chain or RPC failures, all indexed chains
|
|
1233
|
+
* will be affected.
|
|
1234
|
+
*/
|
|
1235
|
+
Omnichain: "omnichain"
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
// src/shared/block-ref.ts
|
|
1239
|
+
function isBefore(blockA, blockB) {
|
|
1240
|
+
return blockA.number < blockB.number && blockA.timestamp < blockB.timestamp;
|
|
1241
|
+
}
|
|
1242
|
+
function isEqualTo(blockA, blockB) {
|
|
1243
|
+
return blockA.number === blockB.number && blockA.timestamp === blockB.timestamp;
|
|
1244
|
+
}
|
|
1245
|
+
function isBeforeOrEqualTo(blockA, blockB) {
|
|
1246
|
+
return isBefore(blockA, blockB) || isEqualTo(blockA, blockB);
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
// src/ensindexer/indexing-status/helpers.ts
|
|
1250
|
+
function getOmnichainIndexingStatus(chains) {
|
|
1251
|
+
if (checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotFollowing(chains)) {
|
|
832
1252
|
return OmnichainIndexingStatusIds.Following;
|
|
833
1253
|
}
|
|
834
1254
|
if (checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill(chains)) {
|
|
@@ -927,6 +1347,16 @@ function sortChainStatusesByStartBlockAsc(chains) {
|
|
|
927
1347
|
);
|
|
928
1348
|
return chains;
|
|
929
1349
|
}
|
|
1350
|
+
function getLatestIndexedBlockRef(indexingStatus, chainId) {
|
|
1351
|
+
const chainIndexingStatus = indexingStatus.omnichainSnapshot.chains.get(chainId);
|
|
1352
|
+
if (chainIndexingStatus === void 0) {
|
|
1353
|
+
return null;
|
|
1354
|
+
}
|
|
1355
|
+
if (chainIndexingStatus.chainStatus === ChainIndexingStatusIds.Queued) {
|
|
1356
|
+
return null;
|
|
1357
|
+
}
|
|
1358
|
+
return chainIndexingStatus.latestIndexedBlock;
|
|
1359
|
+
}
|
|
930
1360
|
|
|
931
1361
|
// src/ensindexer/indexing-status/validations.ts
|
|
932
1362
|
function invariant_chainSnapshotQueuedBlocks(ctx) {
|
|
@@ -1173,52 +1603,52 @@ function invariant_realtimeIndexingStatusProjectionWorstCaseDistanceIsCorrect(ct
|
|
|
1173
1603
|
}
|
|
1174
1604
|
|
|
1175
1605
|
// src/ensindexer/indexing-status/zod-schemas.ts
|
|
1176
|
-
var makeChainIndexingConfigSchema = (valueLabel = "Value") =>
|
|
1177
|
-
|
|
1178
|
-
configType:
|
|
1606
|
+
var makeChainIndexingConfigSchema = (valueLabel = "Value") => z4.discriminatedUnion("configType", [
|
|
1607
|
+
z4.strictObject({
|
|
1608
|
+
configType: z4.literal(ChainIndexingConfigTypeIds.Indefinite),
|
|
1179
1609
|
startBlock: makeBlockRefSchema(valueLabel)
|
|
1180
1610
|
}),
|
|
1181
|
-
|
|
1182
|
-
configType:
|
|
1611
|
+
z4.strictObject({
|
|
1612
|
+
configType: z4.literal(ChainIndexingConfigTypeIds.Definite),
|
|
1183
1613
|
startBlock: makeBlockRefSchema(valueLabel),
|
|
1184
1614
|
endBlock: makeBlockRefSchema(valueLabel)
|
|
1185
1615
|
})
|
|
1186
1616
|
]);
|
|
1187
|
-
var makeChainIndexingStatusSnapshotQueuedSchema = (valueLabel = "Value") =>
|
|
1188
|
-
chainStatus:
|
|
1617
|
+
var makeChainIndexingStatusSnapshotQueuedSchema = (valueLabel = "Value") => z4.strictObject({
|
|
1618
|
+
chainStatus: z4.literal(ChainIndexingStatusIds.Queued),
|
|
1189
1619
|
config: makeChainIndexingConfigSchema(valueLabel)
|
|
1190
1620
|
}).check(invariant_chainSnapshotQueuedBlocks);
|
|
1191
|
-
var makeChainIndexingStatusSnapshotBackfillSchema = (valueLabel = "Value") =>
|
|
1192
|
-
chainStatus:
|
|
1621
|
+
var makeChainIndexingStatusSnapshotBackfillSchema = (valueLabel = "Value") => z4.strictObject({
|
|
1622
|
+
chainStatus: z4.literal(ChainIndexingStatusIds.Backfill),
|
|
1193
1623
|
config: makeChainIndexingConfigSchema(valueLabel),
|
|
1194
1624
|
latestIndexedBlock: makeBlockRefSchema(valueLabel),
|
|
1195
1625
|
backfillEndBlock: makeBlockRefSchema(valueLabel)
|
|
1196
1626
|
}).check(invariant_chainSnapshotBackfillBlocks);
|
|
1197
|
-
var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") =>
|
|
1198
|
-
chainStatus:
|
|
1199
|
-
config:
|
|
1200
|
-
configType:
|
|
1627
|
+
var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") => z4.strictObject({
|
|
1628
|
+
chainStatus: z4.literal(ChainIndexingStatusIds.Completed),
|
|
1629
|
+
config: z4.strictObject({
|
|
1630
|
+
configType: z4.literal(ChainIndexingConfigTypeIds.Definite),
|
|
1201
1631
|
startBlock: makeBlockRefSchema(valueLabel),
|
|
1202
1632
|
endBlock: makeBlockRefSchema(valueLabel)
|
|
1203
1633
|
}),
|
|
1204
1634
|
latestIndexedBlock: makeBlockRefSchema(valueLabel)
|
|
1205
1635
|
}).check(invariant_chainSnapshotCompletedBlocks);
|
|
1206
|
-
var makeChainIndexingStatusSnapshotFollowingSchema = (valueLabel = "Value") =>
|
|
1207
|
-
chainStatus:
|
|
1208
|
-
config:
|
|
1209
|
-
configType:
|
|
1636
|
+
var makeChainIndexingStatusSnapshotFollowingSchema = (valueLabel = "Value") => z4.strictObject({
|
|
1637
|
+
chainStatus: z4.literal(ChainIndexingStatusIds.Following),
|
|
1638
|
+
config: z4.strictObject({
|
|
1639
|
+
configType: z4.literal(ChainIndexingConfigTypeIds.Indefinite),
|
|
1210
1640
|
startBlock: makeBlockRefSchema(valueLabel)
|
|
1211
1641
|
}),
|
|
1212
1642
|
latestIndexedBlock: makeBlockRefSchema(valueLabel),
|
|
1213
1643
|
latestKnownBlock: makeBlockRefSchema(valueLabel)
|
|
1214
1644
|
}).check(invariant_chainSnapshotFollowingBlocks);
|
|
1215
|
-
var makeChainIndexingStatusSnapshotSchema = (valueLabel = "Value") =>
|
|
1645
|
+
var makeChainIndexingStatusSnapshotSchema = (valueLabel = "Value") => z4.discriminatedUnion("chainStatus", [
|
|
1216
1646
|
makeChainIndexingStatusSnapshotQueuedSchema(valueLabel),
|
|
1217
1647
|
makeChainIndexingStatusSnapshotBackfillSchema(valueLabel),
|
|
1218
1648
|
makeChainIndexingStatusSnapshotCompletedSchema(valueLabel),
|
|
1219
1649
|
makeChainIndexingStatusSnapshotFollowingSchema(valueLabel)
|
|
1220
1650
|
]);
|
|
1221
|
-
var makeChainIndexingStatusesSchema = (valueLabel = "Value") =>
|
|
1651
|
+
var makeChainIndexingStatusesSchema = (valueLabel = "Value") => z4.record(makeChainIdStringSchema(), makeChainIndexingStatusSnapshotSchema(valueLabel), {
|
|
1222
1652
|
error: "Chains indexing statuses must be an object mapping valid chain IDs to their indexing status snapshots."
|
|
1223
1653
|
}).transform((serializedChainsIndexingStatus) => {
|
|
1224
1654
|
const chainsIndexingStatus = /* @__PURE__ */ new Map();
|
|
@@ -1227,29 +1657,29 @@ var makeChainIndexingStatusesSchema = (valueLabel = "Value") => z2.record(makeCh
|
|
|
1227
1657
|
}
|
|
1228
1658
|
return chainsIndexingStatus;
|
|
1229
1659
|
});
|
|
1230
|
-
var makeOmnichainIndexingStatusSnapshotUnstartedSchema = (valueLabel) =>
|
|
1231
|
-
omnichainStatus:
|
|
1660
|
+
var makeOmnichainIndexingStatusSnapshotUnstartedSchema = (valueLabel) => z4.strictObject({
|
|
1661
|
+
omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Unstarted),
|
|
1232
1662
|
chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainSnapshotUnstartedHasValidChains).transform((chains) => chains),
|
|
1233
1663
|
omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
|
|
1234
1664
|
});
|
|
1235
|
-
var makeOmnichainIndexingStatusSnapshotBackfillSchema = (valueLabel) =>
|
|
1236
|
-
omnichainStatus:
|
|
1665
|
+
var makeOmnichainIndexingStatusSnapshotBackfillSchema = (valueLabel) => z4.strictObject({
|
|
1666
|
+
omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Backfill),
|
|
1237
1667
|
chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainStatusSnapshotBackfillHasValidChains).transform(
|
|
1238
1668
|
(chains) => chains
|
|
1239
1669
|
),
|
|
1240
1670
|
omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
|
|
1241
1671
|
});
|
|
1242
|
-
var makeOmnichainIndexingStatusSnapshotCompletedSchema = (valueLabel) =>
|
|
1243
|
-
omnichainStatus:
|
|
1672
|
+
var makeOmnichainIndexingStatusSnapshotCompletedSchema = (valueLabel) => z4.strictObject({
|
|
1673
|
+
omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Completed),
|
|
1244
1674
|
chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainStatusSnapshotCompletedHasValidChains).transform((chains) => chains),
|
|
1245
1675
|
omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
|
|
1246
1676
|
});
|
|
1247
|
-
var makeOmnichainIndexingStatusSnapshotFollowingSchema = (valueLabel) =>
|
|
1248
|
-
omnichainStatus:
|
|
1677
|
+
var makeOmnichainIndexingStatusSnapshotFollowingSchema = (valueLabel) => z4.strictObject({
|
|
1678
|
+
omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Following),
|
|
1249
1679
|
chains: makeChainIndexingStatusesSchema(valueLabel),
|
|
1250
1680
|
omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
|
|
1251
1681
|
});
|
|
1252
|
-
var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexing Snapshot") =>
|
|
1682
|
+
var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexing Snapshot") => z4.discriminatedUnion("omnichainStatus", [
|
|
1253
1683
|
makeOmnichainIndexingStatusSnapshotUnstartedSchema(valueLabel),
|
|
1254
1684
|
makeOmnichainIndexingStatusSnapshotBackfillSchema(valueLabel),
|
|
1255
1685
|
makeOmnichainIndexingStatusSnapshotCompletedSchema(valueLabel),
|
|
@@ -1257,236 +1687,237 @@ var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexin
|
|
|
1257
1687
|
]).check(invariant_omnichainSnapshotStatusIsConsistentWithChainSnapshot).check(invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueuedChains).check(
|
|
1258
1688
|
invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlockAcrossBackfillChains
|
|
1259
1689
|
).check(invariant_omnichainIndexingCursorIsEqualToHighestLatestIndexedBlockAcrossIndexedChain);
|
|
1260
|
-
var makeCrossChainIndexingStatusSnapshotOmnichainSchema = (valueLabel = "Cross-chain Indexing Status Snapshot Omnichain") =>
|
|
1261
|
-
strategy:
|
|
1690
|
+
var makeCrossChainIndexingStatusSnapshotOmnichainSchema = (valueLabel = "Cross-chain Indexing Status Snapshot Omnichain") => z4.strictObject({
|
|
1691
|
+
strategy: z4.literal(CrossChainIndexingStrategyIds.Omnichain),
|
|
1262
1692
|
slowestChainIndexingCursor: makeUnixTimestampSchema(valueLabel),
|
|
1263
1693
|
snapshotTime: makeUnixTimestampSchema(valueLabel),
|
|
1264
1694
|
omnichainSnapshot: makeOmnichainIndexingStatusSnapshotSchema(valueLabel)
|
|
1265
1695
|
}).check(invariant_slowestChainEqualsToOmnichainSnapshotTime).check(invariant_snapshotTimeIsTheHighestKnownBlockTimestamp);
|
|
1266
|
-
var makeCrossChainIndexingStatusSnapshotSchema = (valueLabel = "Cross-chain Indexing Status Snapshot") =>
|
|
1696
|
+
var makeCrossChainIndexingStatusSnapshotSchema = (valueLabel = "Cross-chain Indexing Status Snapshot") => z4.discriminatedUnion("strategy", [
|
|
1267
1697
|
makeCrossChainIndexingStatusSnapshotOmnichainSchema(valueLabel)
|
|
1268
1698
|
]);
|
|
1269
|
-
var makeRealtimeIndexingStatusProjectionSchema = (valueLabel = "Realtime Indexing Status Projection") =>
|
|
1699
|
+
var makeRealtimeIndexingStatusProjectionSchema = (valueLabel = "Realtime Indexing Status Projection") => z4.strictObject({
|
|
1270
1700
|
projectedAt: makeUnixTimestampSchema(valueLabel),
|
|
1271
1701
|
worstCaseDistance: makeDurationSchema(valueLabel),
|
|
1272
1702
|
snapshot: makeCrossChainIndexingStatusSnapshotSchema(valueLabel)
|
|
1273
1703
|
}).check(invariant_realtimeIndexingStatusProjectionProjectedAtIsAfterOrEqualToSnapshotTime).check(invariant_realtimeIndexingStatusProjectionWorstCaseDistanceIsCorrect);
|
|
1274
1704
|
|
|
1275
|
-
// src/ensindexer/
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
PluginName2["ProtocolAcceleration"] = "protocol-acceleration";
|
|
1288
|
-
PluginName2["Registrars"] = "registrars";
|
|
1289
|
-
PluginName2["TokenScope"] = "tokenscope";
|
|
1290
|
-
return PluginName2;
|
|
1291
|
-
})(PluginName || {});
|
|
1292
|
-
|
|
1293
|
-
// src/ensindexer/config/is-subgraph-compatible.ts
|
|
1294
|
-
function isSubgraphCompatible(config) {
|
|
1295
|
-
const onlySubgraphPluginActivated = config.plugins.length === 1 && config.plugins[0] === "subgraph" /* Subgraph */;
|
|
1296
|
-
const isSubgraphLabelSet = config.labelSet.labelSetId === "subgraph" && config.labelSet.labelSetVersion === 0;
|
|
1297
|
-
const isEnsTestEnvLabelSet = config.labelSet.labelSetId === "ens-test-env" && config.labelSet.labelSetVersion === 0;
|
|
1298
|
-
const labelSetIsSubgraphCompatible = isSubgraphLabelSet || config.namespace === ENSNamespaceIds2.EnsTestEnv && isEnsTestEnvLabelSet;
|
|
1299
|
-
return onlySubgraphPluginActivated && labelSetIsSubgraphCompatible;
|
|
1705
|
+
// src/ensindexer/indexing-status/deserialize.ts
|
|
1706
|
+
function deserializeChainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
|
|
1707
|
+
const schema = makeChainIndexingStatusSnapshotSchema(valueLabel);
|
|
1708
|
+
const parsed = schema.safeParse(maybeSnapshot);
|
|
1709
|
+
if (parsed.error) {
|
|
1710
|
+
throw new Error(
|
|
1711
|
+
`Cannot deserialize into ChainIndexingStatusSnapshot:
|
|
1712
|
+
${prettifyError4(parsed.error)}
|
|
1713
|
+
`
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
return parsed.data;
|
|
1300
1717
|
}
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
});
|
|
1718
|
+
function deserializeOmnichainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
|
|
1719
|
+
const schema = makeOmnichainIndexingStatusSnapshotSchema(valueLabel);
|
|
1720
|
+
const parsed = schema.safeParse(maybeSnapshot);
|
|
1721
|
+
if (parsed.error) {
|
|
1722
|
+
throw new Error(
|
|
1723
|
+
`Cannot deserialize into OmnichainIndexingStatusSnapshot:
|
|
1724
|
+
${prettifyError4(parsed.error)}
|
|
1725
|
+
`
|
|
1726
|
+
);
|
|
1311
1727
|
}
|
|
1728
|
+
return parsed.data;
|
|
1312
1729
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
error
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
}).refine((arr) => arr.length === uniq(arr).length, {
|
|
1323
|
-
error: `${valueLabel} cannot contain duplicate values.`
|
|
1324
|
-
});
|
|
1325
|
-
var makeDatabaseSchemaNameSchema = (valueLabel = "Database schema name") => z3.string({ error: `${valueLabel} must be a string` }).trim().nonempty({
|
|
1326
|
-
error: `${valueLabel} is required and must be a non-empty string.`
|
|
1327
|
-
});
|
|
1328
|
-
var makeLabelSetIdSchema = (valueLabel) => {
|
|
1329
|
-
return z3.string({ error: `${valueLabel} must be a string` }).min(1, { error: `${valueLabel} must be 1-50 characters long` }).max(50, { error: `${valueLabel} must be 1-50 characters long` }).regex(/^[a-z-]+$/, {
|
|
1330
|
-
error: `${valueLabel} can only contain lowercase letters (a-z) and hyphens (-)`
|
|
1331
|
-
});
|
|
1332
|
-
};
|
|
1333
|
-
var makeLabelSetVersionSchema = (valueLabel) => {
|
|
1334
|
-
return z3.coerce.number({ error: `${valueLabel} must be an integer.` }).pipe(makeNonNegativeIntegerSchema(valueLabel));
|
|
1335
|
-
};
|
|
1336
|
-
var makeFullyPinnedLabelSetSchema = (valueLabel = "Label set") => {
|
|
1337
|
-
let valueLabelLabelSetId = valueLabel;
|
|
1338
|
-
let valueLabelLabelSetVersion = valueLabel;
|
|
1339
|
-
if (valueLabel === "LABEL_SET") {
|
|
1340
|
-
valueLabelLabelSetId = "LABEL_SET_ID";
|
|
1341
|
-
valueLabelLabelSetVersion = "LABEL_SET_VERSION";
|
|
1342
|
-
} else {
|
|
1343
|
-
valueLabelLabelSetId = `${valueLabel}.labelSetId`;
|
|
1344
|
-
valueLabelLabelSetVersion = `${valueLabel}.labelSetVersion`;
|
|
1730
|
+
function deserializeCrossChainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
|
|
1731
|
+
const schema = makeCrossChainIndexingStatusSnapshotSchema(valueLabel);
|
|
1732
|
+
const parsed = schema.safeParse(maybeSnapshot);
|
|
1733
|
+
if (parsed.error) {
|
|
1734
|
+
throw new Error(
|
|
1735
|
+
`Cannot deserialize into CrossChainIndexingStatusSnapshot:
|
|
1736
|
+
${prettifyError4(parsed.error)}
|
|
1737
|
+
`
|
|
1738
|
+
);
|
|
1345
1739
|
}
|
|
1346
|
-
return
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
ensIndexer: makeNonEmptyStringSchema(),
|
|
1358
|
-
ensNormalize: makeNonEmptyStringSchema(),
|
|
1359
|
-
ensRainbow: makeNonEmptyStringSchema(),
|
|
1360
|
-
ensRainbowSchema: makePositiveIntegerSchema()
|
|
1361
|
-
},
|
|
1362
|
-
{
|
|
1363
|
-
error: `${valueLabel} must be a valid ENSIndexerVersionInfo object.`
|
|
1740
|
+
return parsed.data;
|
|
1741
|
+
}
|
|
1742
|
+
function deserializeRealtimeIndexingStatusProjection(maybeProjection, valueLabel) {
|
|
1743
|
+
const schema = makeRealtimeIndexingStatusProjectionSchema(valueLabel);
|
|
1744
|
+
const parsed = schema.safeParse(maybeProjection);
|
|
1745
|
+
if (parsed.error) {
|
|
1746
|
+
throw new Error(
|
|
1747
|
+
`Cannot deserialize into RealtimeIndexingStatusProjection:
|
|
1748
|
+
${prettifyError4(parsed.error)}
|
|
1749
|
+
`
|
|
1750
|
+
);
|
|
1364
1751
|
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1752
|
+
return parsed.data;
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// src/ensindexer/indexing-status/projection.ts
|
|
1756
|
+
function createRealtimeIndexingStatusProjection(snapshot, now) {
|
|
1757
|
+
const projectedAt = Math.max(now, snapshot.snapshotTime);
|
|
1758
|
+
return {
|
|
1759
|
+
projectedAt,
|
|
1760
|
+
worstCaseDistance: projectedAt - snapshot.slowestChainIndexingCursor,
|
|
1761
|
+
snapshot
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
// src/ensindexer/indexing-status/serialize.ts
|
|
1766
|
+
function serializeCrossChainIndexingStatusSnapshotOmnichain({
|
|
1767
|
+
strategy,
|
|
1768
|
+
slowestChainIndexingCursor,
|
|
1769
|
+
snapshotTime,
|
|
1770
|
+
omnichainSnapshot
|
|
1771
|
+
}) {
|
|
1772
|
+
return {
|
|
1773
|
+
strategy,
|
|
1774
|
+
slowestChainIndexingCursor,
|
|
1775
|
+
snapshotTime,
|
|
1776
|
+
omnichainSnapshot: serializeOmnichainIndexingStatusSnapshot(omnichainSnapshot)
|
|
1777
|
+
};
|
|
1778
|
+
}
|
|
1779
|
+
function serializeRealtimeIndexingStatusProjection(indexingProjection) {
|
|
1780
|
+
return {
|
|
1781
|
+
projectedAt: indexingProjection.projectedAt,
|
|
1782
|
+
worstCaseDistance: indexingProjection.worstCaseDistance,
|
|
1783
|
+
snapshot: serializeCrossChainIndexingStatusSnapshotOmnichain(indexingProjection.snapshot)
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
function serializeChainIndexingSnapshots(chains) {
|
|
1787
|
+
const serializedSnapshots = {};
|
|
1788
|
+
for (const [chainId, snapshot] of chains.entries()) {
|
|
1789
|
+
serializedSnapshots[serializeChainId(chainId)] = snapshot;
|
|
1790
|
+
}
|
|
1791
|
+
return serializedSnapshots;
|
|
1792
|
+
}
|
|
1793
|
+
function serializeOmnichainIndexingStatusSnapshot(indexingStatus) {
|
|
1794
|
+
switch (indexingStatus.omnichainStatus) {
|
|
1795
|
+
case OmnichainIndexingStatusIds.Unstarted:
|
|
1796
|
+
return {
|
|
1797
|
+
omnichainStatus: OmnichainIndexingStatusIds.Unstarted,
|
|
1798
|
+
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
1799
|
+
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
1800
|
+
};
|
|
1801
|
+
case OmnichainIndexingStatusIds.Backfill:
|
|
1802
|
+
return {
|
|
1803
|
+
omnichainStatus: OmnichainIndexingStatusIds.Backfill,
|
|
1804
|
+
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
1805
|
+
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
1806
|
+
};
|
|
1807
|
+
case OmnichainIndexingStatusIds.Completed: {
|
|
1808
|
+
return {
|
|
1809
|
+
omnichainStatus: OmnichainIndexingStatusIds.Completed,
|
|
1810
|
+
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
1811
|
+
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
case OmnichainIndexingStatusIds.Following:
|
|
1815
|
+
return {
|
|
1816
|
+
omnichainStatus: OmnichainIndexingStatusIds.Following,
|
|
1817
|
+
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
1818
|
+
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
1819
|
+
};
|
|
1374
1820
|
}
|
|
1375
1821
|
}
|
|
1376
|
-
var makeENSIndexerPublicConfigSchema = (valueLabel = "ENSIndexerPublicConfig") => z3.object({
|
|
1377
|
-
labelSet: makeFullyPinnedLabelSetSchema(`${valueLabel}.labelSet`),
|
|
1378
|
-
indexedChainIds: makeIndexedChainIdsSchema(`${valueLabel}.indexedChainIds`),
|
|
1379
|
-
isSubgraphCompatible: z3.boolean({ error: `${valueLabel}.isSubgraphCompatible` }),
|
|
1380
|
-
namespace: makeENSNamespaceIdSchema(`${valueLabel}.namespace`),
|
|
1381
|
-
plugins: makePluginsListSchema(`${valueLabel}.plugins`),
|
|
1382
|
-
databaseSchemaName: makeDatabaseSchemaNameSchema(`${valueLabel}.databaseSchemaName`),
|
|
1383
|
-
versionInfo: makeENSIndexerVersionInfoSchema(`${valueLabel}.versionInfo`)
|
|
1384
|
-
}).check(invariant_isSubgraphCompatibleRequirements);
|
|
1385
1822
|
|
|
1386
|
-
// src/
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
mainnet,
|
|
1396
|
-
optimism,
|
|
1397
|
-
optimismSepolia,
|
|
1398
|
-
scroll,
|
|
1399
|
-
scrollSepolia,
|
|
1400
|
-
sepolia
|
|
1401
|
-
} from "viem/chains";
|
|
1823
|
+
// src/ensapi/config/serialize.ts
|
|
1824
|
+
function serializeENSApiPublicConfig(config) {
|
|
1825
|
+
const { version, theGraphFallback, ensIndexerPublicConfig } = config;
|
|
1826
|
+
return {
|
|
1827
|
+
version,
|
|
1828
|
+
theGraphFallback,
|
|
1829
|
+
ensIndexerPublicConfig: serializeENSIndexerPublicConfig(ensIndexerPublicConfig)
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1402
1832
|
|
|
1403
|
-
// src/
|
|
1404
|
-
|
|
1833
|
+
// src/api/config/deserialize.ts
|
|
1834
|
+
function deserializeConfigResponse(serializedResponse) {
|
|
1835
|
+
return deserializeENSApiPublicConfig(serializedResponse);
|
|
1836
|
+
}
|
|
1405
1837
|
|
|
1406
|
-
// src/
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
const endpoints = ctx.value;
|
|
1410
|
-
const httpEndpoints = endpoints.filter(isHttpProtocol);
|
|
1411
|
-
if (httpEndpoints.length < 1) {
|
|
1412
|
-
ctx.issues.push({
|
|
1413
|
-
code: "custom",
|
|
1414
|
-
input: endpoints,
|
|
1415
|
-
message: `RPC endpoint configuration for a chain must include at least one http/https protocol URL.`
|
|
1416
|
-
});
|
|
1417
|
-
}
|
|
1838
|
+
// src/api/config/serialize.ts
|
|
1839
|
+
function serializeConfigResponse(response) {
|
|
1840
|
+
return serializeENSApiPublicConfig(response);
|
|
1418
1841
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1842
|
+
|
|
1843
|
+
// src/api/indexing-status/deserialize.ts
|
|
1844
|
+
import { prettifyError as prettifyError5 } from "zod/v4";
|
|
1845
|
+
|
|
1846
|
+
// src/api/indexing-status/zod-schemas.ts
|
|
1847
|
+
import z11 from "zod/v4";
|
|
1848
|
+
|
|
1849
|
+
// src/api/registrar-actions/zod-schemas.ts
|
|
1850
|
+
import { namehash as namehash2 } from "viem/ens";
|
|
1851
|
+
import z6 from "zod/v4";
|
|
1852
|
+
|
|
1853
|
+
// src/api/shared/errors/zod-schemas.ts
|
|
1854
|
+
import z5 from "zod/v4";
|
|
1855
|
+
var ErrorResponseSchema = z5.object({
|
|
1856
|
+
message: z5.string(),
|
|
1857
|
+
details: z5.optional(z5.unknown())
|
|
1858
|
+
});
|
|
1859
|
+
|
|
1860
|
+
// src/api/registrar-actions/response.ts
|
|
1861
|
+
var RegistrarActionsResponseCodes = {
|
|
1862
|
+
/**
|
|
1863
|
+
* Represents that Registrar Actions are available.
|
|
1864
|
+
*/
|
|
1865
|
+
Ok: "ok",
|
|
1866
|
+
/**
|
|
1867
|
+
* Represents that Registrar Actions are unavailable.
|
|
1868
|
+
*/
|
|
1869
|
+
Error: "error"
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
// src/api/registrar-actions/zod-schemas.ts
|
|
1873
|
+
function invariant_registrationLifecycleNodeMatchesName(ctx) {
|
|
1874
|
+
const { name, action } = ctx.value;
|
|
1875
|
+
const expectedNode = action.registrationLifecycle.node;
|
|
1876
|
+
const actualNode = namehash2(name);
|
|
1877
|
+
if (actualNode !== expectedNode) {
|
|
1423
1878
|
ctx.issues.push({
|
|
1424
1879
|
code: "custom",
|
|
1425
|
-
input:
|
|
1426
|
-
message: `
|
|
1880
|
+
input: ctx.value,
|
|
1881
|
+
message: `The 'action.registrationLifecycle.node' must match namehash of 'name'`
|
|
1427
1882
|
});
|
|
1428
1883
|
}
|
|
1429
1884
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
var
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
error: "DATABASE_SCHEMA is required and cannot be an empty string."
|
|
1438
|
-
});
|
|
1439
|
-
var RpcConfigSchema = z4.string().transform((val) => val.split(",")).pipe(z4.array(makeUrlSchema("RPC URL"))).check(invariant_rpcEndpointConfigIncludesAtLeastOneHTTPProtocolURL).check(invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL);
|
|
1440
|
-
var RpcConfigsSchema = z4.record(makeChainIdStringSchema("RPC URL"), RpcConfigSchema, {
|
|
1441
|
-
error: "Chains configuration must be an object mapping valid chain IDs to their configs."
|
|
1442
|
-
}).transform((records) => {
|
|
1443
|
-
const rpcConfigs = /* @__PURE__ */ new Map();
|
|
1444
|
-
for (const [chainIdString, rpcConfig] of Object.entries(records)) {
|
|
1445
|
-
const httpRPCs = rpcConfig.filter(isHttpProtocol);
|
|
1446
|
-
const websocketRPC = rpcConfig.find(isWebSocketProtocol);
|
|
1447
|
-
rpcConfigs.set(deserializeChainId(chainIdString), {
|
|
1448
|
-
httpRPCs,
|
|
1449
|
-
websocketRPC
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
return rpcConfigs;
|
|
1885
|
+
var makeNamedRegistrarActionSchema = (valueLabel = "Named Registrar Action") => z6.object({
|
|
1886
|
+
action: makeRegistrarActionSchema(valueLabel),
|
|
1887
|
+
name: makeReinterpretedNameSchema(valueLabel)
|
|
1888
|
+
}).check(invariant_registrationLifecycleNodeMatchesName);
|
|
1889
|
+
var makeRegistrarActionsResponseOkSchema = (valueLabel = "Registrar Actions Response OK") => z6.strictObject({
|
|
1890
|
+
responseCode: z6.literal(RegistrarActionsResponseCodes.Ok),
|
|
1891
|
+
registrarActions: z6.array(makeNamedRegistrarActionSchema(valueLabel))
|
|
1453
1892
|
});
|
|
1454
|
-
var
|
|
1455
|
-
|
|
1456
|
-
error:
|
|
1893
|
+
var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z6.strictObject({
|
|
1894
|
+
responseCode: z6.literal(RegistrarActionsResponseCodes.Error),
|
|
1895
|
+
error: ErrorResponseSchema
|
|
1457
1896
|
});
|
|
1458
|
-
var
|
|
1459
|
-
|
|
1897
|
+
var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z6.discriminatedUnion("responseCode", [
|
|
1898
|
+
makeRegistrarActionsResponseOkSchema(valueLabel),
|
|
1899
|
+
makeRegistrarActionsResponseErrorSchema(valueLabel)
|
|
1900
|
+
]);
|
|
1460
1901
|
|
|
1461
|
-
// src/shared/
|
|
1462
|
-
import
|
|
1463
|
-
DatasourceNames,
|
|
1464
|
-
maybeGetDatasource
|
|
1465
|
-
} from "@ensnode/datasources";
|
|
1466
|
-
var DATASOURCE_NAMES_WITH_RESOLVERS = [
|
|
1467
|
-
DatasourceNames.ENSRoot,
|
|
1468
|
-
DatasourceNames.Basenames,
|
|
1469
|
-
DatasourceNames.Lineanames,
|
|
1470
|
-
DatasourceNames.ThreeDNSOptimism,
|
|
1471
|
-
DatasourceNames.ThreeDNSBase
|
|
1472
|
-
];
|
|
1902
|
+
// src/api/shared/pagination/zod-schemas.ts
|
|
1903
|
+
import z7 from "zod/v4";
|
|
1473
1904
|
|
|
1474
|
-
// src/shared/
|
|
1475
|
-
|
|
1476
|
-
var
|
|
1905
|
+
// src/api/shared/pagination/request.ts
|
|
1906
|
+
var RECORDS_PER_PAGE_DEFAULT = 10;
|
|
1907
|
+
var RECORDS_PER_PAGE_MAX = 100;
|
|
1477
1908
|
|
|
1478
|
-
// src/
|
|
1479
|
-
import { isAddress as isAddress3
|
|
1909
|
+
// ../ens-referrals/src/address.ts
|
|
1910
|
+
import { isAddress as isAddress3 } from "viem";
|
|
1480
1911
|
|
|
1481
|
-
// ../ens-referrals/src/
|
|
1482
|
-
import { getAddress, pad, size as size2, slice, zeroAddress
|
|
1912
|
+
// ../ens-referrals/src/encoding.ts
|
|
1913
|
+
import { getAddress, pad, size as size2, slice, zeroAddress } from "viem";
|
|
1483
1914
|
var ENCODED_REFERRER_BYTE_OFFSET = 12;
|
|
1484
1915
|
var ENCODED_REFERRER_BYTE_LENGTH = 32;
|
|
1485
|
-
var
|
|
1916
|
+
var EXPECTED_ENCODED_REFERRER_PADDING = pad("0x", {
|
|
1486
1917
|
size: ENCODED_REFERRER_BYTE_OFFSET,
|
|
1487
1918
|
dir: "left"
|
|
1488
1919
|
});
|
|
1489
|
-
var
|
|
1920
|
+
var ZERO_ENCODED_REFERRER = pad("0x", {
|
|
1490
1921
|
size: ENCODED_REFERRER_BYTE_LENGTH,
|
|
1491
1922
|
dir: "left"
|
|
1492
1923
|
});
|
|
@@ -1497,8 +1928,8 @@ function decodeEncodedReferrer(encodedReferrer) {
|
|
|
1497
1928
|
);
|
|
1498
1929
|
}
|
|
1499
1930
|
const padding = slice(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1500
|
-
if (padding !==
|
|
1501
|
-
return
|
|
1931
|
+
if (padding !== EXPECTED_ENCODED_REFERRER_PADDING) {
|
|
1932
|
+
return zeroAddress;
|
|
1502
1933
|
}
|
|
1503
1934
|
const decodedReferrer = slice(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
|
|
1504
1935
|
try {
|
|
@@ -1508,8 +1939,26 @@ function decodeEncodedReferrer(encodedReferrer) {
|
|
|
1508
1939
|
}
|
|
1509
1940
|
}
|
|
1510
1941
|
|
|
1942
|
+
// ../ens-referrals/src/leaderboard-page.ts
|
|
1943
|
+
var REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
|
|
1944
|
+
|
|
1945
|
+
// ../ens-referrals/src/link.ts
|
|
1946
|
+
import { getAddress as getAddress2 } from "viem";
|
|
1947
|
+
|
|
1948
|
+
// ../ens-referrals/src/referrer-detail.ts
|
|
1949
|
+
var ReferrerDetailTypeIds = {
|
|
1950
|
+
/**
|
|
1951
|
+
* Represents a referrer who is ranked on the leaderboard.
|
|
1952
|
+
*/
|
|
1953
|
+
Ranked: "ranked",
|
|
1954
|
+
/**
|
|
1955
|
+
* Represents a referrer who is not ranked on the leaderboard.
|
|
1956
|
+
*/
|
|
1957
|
+
Unranked: "unranked"
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1511
1960
|
// src/registrars/zod-schemas.ts
|
|
1512
|
-
import
|
|
1961
|
+
import z8 from "zod/v4";
|
|
1513
1962
|
|
|
1514
1963
|
// src/registrars/subregistry.ts
|
|
1515
1964
|
function serializeSubregistry(subregistry) {
|
|
@@ -1567,11 +2016,11 @@ function serializeRegistrarAction(registrarAction) {
|
|
|
1567
2016
|
}
|
|
1568
2017
|
|
|
1569
2018
|
// src/registrars/zod-schemas.ts
|
|
1570
|
-
var makeSubregistrySchema = (valueLabel = "Subregistry") =>
|
|
2019
|
+
var makeSubregistrySchema = (valueLabel = "Subregistry") => z8.object({
|
|
1571
2020
|
subregistryId: makeSerializedAccountIdSchema(`${valueLabel} Subregistry ID`),
|
|
1572
2021
|
node: makeNodeSchema(`${valueLabel} Node`)
|
|
1573
2022
|
});
|
|
1574
|
-
var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") =>
|
|
2023
|
+
var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") => z8.object({
|
|
1575
2024
|
subregistry: makeSubregistrySchema(`${valueLabel} Subregistry`),
|
|
1576
2025
|
node: makeNodeSchema(`${valueLabel} Node`),
|
|
1577
2026
|
expiresAt: makeUnixTimestampSchema(`${valueLabel} Expires at`)
|
|
@@ -1587,18 +2036,18 @@ function invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium(ctx) {
|
|
|
1587
2036
|
});
|
|
1588
2037
|
}
|
|
1589
2038
|
}
|
|
1590
|
-
var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") =>
|
|
2039
|
+
var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") => z8.union([
|
|
1591
2040
|
// pricing available
|
|
1592
|
-
|
|
2041
|
+
z8.object({
|
|
1593
2042
|
baseCost: makePriceEthSchema(`${valueLabel} Base Cost`),
|
|
1594
2043
|
premium: makePriceEthSchema(`${valueLabel} Premium`),
|
|
1595
2044
|
total: makePriceEthSchema(`${valueLabel} Total`)
|
|
1596
2045
|
}).check(invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium).transform((v) => v),
|
|
1597
2046
|
// pricing unknown
|
|
1598
|
-
|
|
1599
|
-
baseCost:
|
|
1600
|
-
premium:
|
|
1601
|
-
total:
|
|
2047
|
+
z8.object({
|
|
2048
|
+
baseCost: z8.null(),
|
|
2049
|
+
premium: z8.null(),
|
|
2050
|
+
total: z8.null()
|
|
1602
2051
|
}).transform((v) => v)
|
|
1603
2052
|
]);
|
|
1604
2053
|
function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
|
|
@@ -1621,9 +2070,9 @@ function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
|
|
|
1621
2070
|
});
|
|
1622
2071
|
}
|
|
1623
2072
|
}
|
|
1624
|
-
var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") =>
|
|
2073
|
+
var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") => z8.union([
|
|
1625
2074
|
// referral available
|
|
1626
|
-
|
|
2075
|
+
z8.object({
|
|
1627
2076
|
encodedReferrer: makeHexStringSchema(
|
|
1628
2077
|
{ bytesCount: ENCODED_REFERRER_BYTE_LENGTH },
|
|
1629
2078
|
`${valueLabel} Encoded Referrer`
|
|
@@ -1631,9 +2080,9 @@ var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral
|
|
|
1631
2080
|
decodedReferrer: makeLowercaseAddressSchema(`${valueLabel} Decoded Referrer`)
|
|
1632
2081
|
}).check(invariant_registrarActionDecodedReferrerBasedOnRawReferrer),
|
|
1633
2082
|
// referral not applicable
|
|
1634
|
-
|
|
1635
|
-
encodedReferrer:
|
|
1636
|
-
decodedReferrer:
|
|
2083
|
+
z8.object({
|
|
2084
|
+
encodedReferrer: z8.null(),
|
|
2085
|
+
decodedReferrer: z8.null()
|
|
1637
2086
|
})
|
|
1638
2087
|
]);
|
|
1639
2088
|
function invariant_eventIdsInitialElementIsTheActionId(ctx) {
|
|
@@ -1646,9 +2095,9 @@ function invariant_eventIdsInitialElementIsTheActionId(ctx) {
|
|
|
1646
2095
|
});
|
|
1647
2096
|
}
|
|
1648
2097
|
}
|
|
1649
|
-
var EventIdSchema =
|
|
1650
|
-
var EventIdsSchema =
|
|
1651
|
-
var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") =>
|
|
2098
|
+
var EventIdSchema = z8.string().nonempty();
|
|
2099
|
+
var EventIdsSchema = z8.array(EventIdSchema).min(1).transform((v) => v);
|
|
2100
|
+
var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z8.object({
|
|
1652
2101
|
id: EventIdSchema,
|
|
1653
2102
|
incrementalDuration: makeDurationSchema(`${valueLabel} Incremental Duration`),
|
|
1654
2103
|
registrant: makeLowercaseAddressSchema(`${valueLabel} Registrant`),
|
|
@@ -1662,380 +2111,205 @@ var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z6
|
|
|
1662
2111
|
eventIds: EventIdsSchema
|
|
1663
2112
|
}).check(invariant_eventIdsInitialElementIsTheActionId);
|
|
1664
2113
|
var makeRegistrarActionRegistrationSchema = (valueLabel = "Registration ") => makeBaseRegistrarActionSchema(valueLabel).extend({
|
|
1665
|
-
type:
|
|
2114
|
+
type: z8.literal(RegistrarActionTypes.Registration)
|
|
1666
2115
|
});
|
|
1667
2116
|
var makeRegistrarActionRenewalSchema = (valueLabel = "Renewal") => makeBaseRegistrarActionSchema(valueLabel).extend({
|
|
1668
|
-
type:
|
|
2117
|
+
type: z8.literal(RegistrarActionTypes.Renewal)
|
|
1669
2118
|
});
|
|
1670
|
-
var makeRegistrarActionSchema = (valueLabel = "Registrar Action") =>
|
|
2119
|
+
var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => z8.discriminatedUnion("type", [
|
|
1671
2120
|
makeRegistrarActionRegistrationSchema(`${valueLabel} Registration`),
|
|
1672
2121
|
makeRegistrarActionRenewalSchema(`${valueLabel} Renewal`)
|
|
1673
2122
|
]);
|
|
1674
2123
|
|
|
1675
|
-
// src/
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
LatestRegistrarActions: "orderBy[timestamp]=desc"
|
|
1692
|
-
};
|
|
1693
|
-
var RegistrarActionsResponseCodes = {
|
|
1694
|
-
/**
|
|
1695
|
-
* Represents that Registrar Actions are available.
|
|
1696
|
-
*/
|
|
1697
|
-
Ok: "ok",
|
|
1698
|
-
/**
|
|
1699
|
-
* Represents that Registrar Actions are unavailable.
|
|
1700
|
-
*/
|
|
1701
|
-
Error: "error"
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
// src/api/zod-schemas.ts
|
|
1705
|
-
var ErrorResponseSchema = z7.object({
|
|
1706
|
-
message: z7.string(),
|
|
1707
|
-
details: z7.optional(z7.unknown())
|
|
1708
|
-
});
|
|
1709
|
-
var makeIndexingStatusResponseOkSchema = (valueLabel = "Indexing Status Response OK") => z7.strictObject({
|
|
1710
|
-
responseCode: z7.literal(IndexingStatusResponseCodes.Ok),
|
|
1711
|
-
realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel)
|
|
1712
|
-
});
|
|
1713
|
-
var makeIndexingStatusResponseErrorSchema = (_valueLabel = "Indexing Status Response Error") => z7.strictObject({
|
|
1714
|
-
responseCode: z7.literal(IndexingStatusResponseCodes.Error)
|
|
1715
|
-
});
|
|
1716
|
-
var makeIndexingStatusResponseSchema = (valueLabel = "Indexing Status Response") => z7.discriminatedUnion("responseCode", [
|
|
1717
|
-
makeIndexingStatusResponseOkSchema(valueLabel),
|
|
1718
|
-
makeIndexingStatusResponseErrorSchema(valueLabel)
|
|
1719
|
-
]);
|
|
1720
|
-
function invariant_registrationLifecycleNodeMatchesName(ctx) {
|
|
1721
|
-
const { name, action } = ctx.value;
|
|
1722
|
-
const expectedNode = action.registrationLifecycle.node;
|
|
1723
|
-
const actualNode = namehash2(name);
|
|
1724
|
-
if (actualNode !== expectedNode) {
|
|
1725
|
-
ctx.issues.push({
|
|
1726
|
-
code: "custom",
|
|
1727
|
-
input: ctx.value,
|
|
1728
|
-
message: `The 'action.registrationLifecycle.node' must match namehash of 'name'`
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
var makeNamedRegistrarActionSchema = (valueLabel = "Named Registrar Action") => z7.object({
|
|
1733
|
-
action: makeRegistrarActionSchema(valueLabel),
|
|
1734
|
-
name: makeReinterpretedNameSchema(valueLabel)
|
|
1735
|
-
}).check(invariant_registrationLifecycleNodeMatchesName);
|
|
1736
|
-
var makeRegistrarActionsResponseOkSchema = (valueLabel = "Registrar Actions Response OK") => z7.strictObject({
|
|
1737
|
-
responseCode: z7.literal(RegistrarActionsResponseCodes.Ok),
|
|
1738
|
-
registrarActions: z7.array(makeNamedRegistrarActionSchema(valueLabel))
|
|
1739
|
-
});
|
|
1740
|
-
var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z7.strictObject({
|
|
1741
|
-
responseCode: z7.literal(RegistrarActionsResponseCodes.Error),
|
|
1742
|
-
error: ErrorResponseSchema
|
|
1743
|
-
});
|
|
1744
|
-
var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z7.discriminatedUnion("responseCode", [
|
|
1745
|
-
makeRegistrarActionsResponseOkSchema(valueLabel),
|
|
1746
|
-
makeRegistrarActionsResponseErrorSchema(valueLabel)
|
|
1747
|
-
]);
|
|
1748
|
-
|
|
1749
|
-
// src/api/deserialize.ts
|
|
1750
|
-
function deserializeErrorResponse(maybeErrorResponse) {
|
|
1751
|
-
const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse);
|
|
1752
|
-
if (parsed.error) {
|
|
1753
|
-
throw new Error(`Cannot deserialize ErrorResponse:
|
|
1754
|
-
${prettifyError2(parsed.error)}
|
|
1755
|
-
`);
|
|
1756
|
-
}
|
|
1757
|
-
return parsed.data;
|
|
1758
|
-
}
|
|
1759
|
-
function deserializeIndexingStatusResponse(maybeResponse) {
|
|
1760
|
-
const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse);
|
|
1761
|
-
if (parsed.error) {
|
|
1762
|
-
throw new Error(`Cannot deserialize IndexingStatusResponse:
|
|
1763
|
-
${prettifyError2(parsed.error)}
|
|
1764
|
-
`);
|
|
1765
|
-
}
|
|
1766
|
-
return parsed.data;
|
|
1767
|
-
}
|
|
1768
|
-
function deserializeRegistrarActionsResponse(maybeResponse) {
|
|
1769
|
-
const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse);
|
|
1770
|
-
if (parsed.error) {
|
|
1771
|
-
throw new Error(
|
|
1772
|
-
`Cannot deserialize RegistrarActionsResponse:
|
|
1773
|
-
${prettifyError2(parsed.error)}
|
|
1774
|
-
`
|
|
1775
|
-
);
|
|
1776
|
-
}
|
|
1777
|
-
return parsed.data;
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
// src/api/registrar-actions/filters.ts
|
|
1781
|
-
function byParentNode(parentNode) {
|
|
1782
|
-
if (typeof parentNode === "undefined") {
|
|
1783
|
-
return void 0;
|
|
1784
|
-
}
|
|
1785
|
-
return {
|
|
1786
|
-
filterType: RegistrarActionsFilterTypes.BySubregistryNode,
|
|
1787
|
-
value: parentNode
|
|
1788
|
-
};
|
|
1789
|
-
}
|
|
1790
|
-
function withReferral(withReferral2) {
|
|
1791
|
-
if (!withReferral2) {
|
|
1792
|
-
return void 0;
|
|
1793
|
-
}
|
|
1794
|
-
return {
|
|
1795
|
-
filterType: RegistrarActionsFilterTypes.WithEncodedReferral
|
|
1796
|
-
};
|
|
1797
|
-
}
|
|
1798
|
-
var registrarActionsFilter = {
|
|
1799
|
-
byParentNode,
|
|
1800
|
-
withReferral
|
|
1801
|
-
};
|
|
1802
|
-
|
|
1803
|
-
// src/ensindexer/config/deserialize.ts
|
|
1804
|
-
import { prettifyError as prettifyError3 } from "zod/v4";
|
|
1805
|
-
function deserializeENSIndexerPublicConfig(maybeConfig, valueLabel) {
|
|
1806
|
-
const schema = makeENSIndexerPublicConfigSchema(valueLabel);
|
|
1807
|
-
const parsed = schema.safeParse(maybeConfig);
|
|
1808
|
-
if (parsed.error) {
|
|
1809
|
-
throw new Error(`Cannot deserialize ENSIndexerPublicConfig:
|
|
1810
|
-
${prettifyError3(parsed.error)}
|
|
1811
|
-
`);
|
|
1812
|
-
}
|
|
1813
|
-
return parsed.data;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
// src/ensindexer/config/label-utils.ts
|
|
1817
|
-
import { hexToBytes as hexToBytes2 } from "viem";
|
|
1818
|
-
function labelHashToBytes(labelHash) {
|
|
1819
|
-
try {
|
|
1820
|
-
if (labelHash.length !== 66) {
|
|
1821
|
-
throw new Error(`Invalid labelHash length ${labelHash.length} characters (expected 66)`);
|
|
1822
|
-
}
|
|
1823
|
-
if (labelHash !== labelHash.toLowerCase()) {
|
|
1824
|
-
throw new Error("Labelhash must be in lowercase");
|
|
1825
|
-
}
|
|
1826
|
-
if (!labelHash.startsWith("0x")) {
|
|
1827
|
-
throw new Error("Labelhash must be 0x-prefixed");
|
|
1828
|
-
}
|
|
1829
|
-
const bytes = hexToBytes2(labelHash);
|
|
1830
|
-
if (bytes.length !== 32) {
|
|
1831
|
-
throw new Error(`Invalid labelHash length ${bytes.length} bytes (expected 32)`);
|
|
1832
|
-
}
|
|
1833
|
-
return bytes;
|
|
1834
|
-
} catch (e) {
|
|
1835
|
-
if (e instanceof Error) {
|
|
1836
|
-
throw e;
|
|
1837
|
-
}
|
|
1838
|
-
throw new Error("Invalid hex format");
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
2124
|
+
// src/shared/config/build-rpc-urls.ts
|
|
2125
|
+
import {
|
|
2126
|
+
arbitrum,
|
|
2127
|
+
arbitrumSepolia,
|
|
2128
|
+
base,
|
|
2129
|
+
baseSepolia,
|
|
2130
|
+
holesky,
|
|
2131
|
+
linea,
|
|
2132
|
+
lineaSepolia,
|
|
2133
|
+
mainnet,
|
|
2134
|
+
optimism,
|
|
2135
|
+
optimismSepolia,
|
|
2136
|
+
scroll,
|
|
2137
|
+
scrollSepolia,
|
|
2138
|
+
sepolia
|
|
2139
|
+
} from "viem/chains";
|
|
1841
2140
|
|
|
1842
|
-
// src/
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
if (
|
|
1851
|
-
|
|
2141
|
+
// src/shared/config/rpc-configs-from-env.ts
|
|
2142
|
+
import { getENSNamespace } from "@ensnode/datasources";
|
|
2143
|
+
|
|
2144
|
+
// src/shared/config/validatons.ts
|
|
2145
|
+
import { getENSRootChainId as getENSRootChainId2 } from "@ensnode/datasources";
|
|
2146
|
+
function invariant_rpcEndpointConfigIncludesAtLeastOneHTTPProtocolURL(ctx) {
|
|
2147
|
+
const endpoints = ctx.value;
|
|
2148
|
+
const httpEndpoints = endpoints.filter(isHttpProtocol);
|
|
2149
|
+
if (httpEndpoints.length < 1) {
|
|
2150
|
+
ctx.issues.push({
|
|
2151
|
+
code: "custom",
|
|
2152
|
+
input: endpoints,
|
|
2153
|
+
message: `RPC endpoint configuration for a chain must include at least one http/https protocol URL.`
|
|
2154
|
+
});
|
|
1852
2155
|
}
|
|
1853
|
-
return { labelSetId, labelSetVersion };
|
|
1854
2156
|
}
|
|
1855
|
-
function
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
if (clientSet.labelSetVersion !== void 0 && serverSet.highestLabelSetVersion < clientSet.labelSetVersion) {
|
|
1865
|
-
throw new Error(
|
|
1866
|
-
`Server highest label set version ${serverSet.highestLabelSetVersion} is less than client's requested version ${clientSet.labelSetVersion} for label set ID "${clientSet.labelSetId}".`
|
|
1867
|
-
);
|
|
2157
|
+
function invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL(ctx) {
|
|
2158
|
+
const endpoints = ctx.value;
|
|
2159
|
+
const wsEndpoints = endpoints.filter(isWebSocketProtocol);
|
|
2160
|
+
if (wsEndpoints.length > 1) {
|
|
2161
|
+
ctx.issues.push({
|
|
2162
|
+
code: "custom",
|
|
2163
|
+
input: endpoints,
|
|
2164
|
+
message: `RPC endpoint configuration for a chain must include at most one websocket (ws/wss) protocol URL.`
|
|
2165
|
+
});
|
|
1868
2166
|
}
|
|
1869
2167
|
}
|
|
1870
2168
|
|
|
1871
|
-
// src/
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
throw new Error(`"${maybeNumber}" is not a non-negative integer`);
|
|
2169
|
+
// src/shared/config/zod-schemas.ts
|
|
2170
|
+
import { z as z9 } from "zod/v4";
|
|
2171
|
+
import { ENSNamespaceIds as ENSNamespaceIds3 } from "@ensnode/datasources";
|
|
2172
|
+
var DatabaseSchemaNameSchema = z9.string({
|
|
2173
|
+
error: "DATABASE_SCHEMA is required."
|
|
2174
|
+
}).trim().min(1, {
|
|
2175
|
+
error: "DATABASE_SCHEMA is required and cannot be an empty string."
|
|
2176
|
+
});
|
|
2177
|
+
var RpcConfigSchema = z9.string().transform((val) => val.split(",")).pipe(z9.array(makeUrlSchema("RPC URL"))).check(invariant_rpcEndpointConfigIncludesAtLeastOneHTTPProtocolURL).check(invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL);
|
|
2178
|
+
var RpcConfigsSchema = z9.record(makeChainIdStringSchema("RPC URL"), RpcConfigSchema, {
|
|
2179
|
+
error: "Chains configuration must be an object mapping valid chain IDs to their configs."
|
|
2180
|
+
}).transform((records) => {
|
|
2181
|
+
const rpcConfigs = /* @__PURE__ */ new Map();
|
|
2182
|
+
for (const [chainIdString, rpcConfig] of Object.entries(records)) {
|
|
2183
|
+
const httpRPCs = rpcConfig.filter(isHttpProtocol);
|
|
2184
|
+
const websocketRPC = rpcConfig.find(isWebSocketProtocol);
|
|
2185
|
+
rpcConfigs.set(deserializeChainId(chainIdString), {
|
|
2186
|
+
httpRPCs,
|
|
2187
|
+
websocketRPC
|
|
2188
|
+
});
|
|
1892
2189
|
}
|
|
1893
|
-
return
|
|
1894
|
-
}
|
|
2190
|
+
return rpcConfigs;
|
|
2191
|
+
});
|
|
2192
|
+
var EnsIndexerUrlSchema = makeUrlSchema("ENSINDEXER_URL");
|
|
2193
|
+
var ENSNamespaceSchema = z9.enum(ENSNamespaceIds3, {
|
|
2194
|
+
error: ({ input }) => `Invalid NAMESPACE. Got '${input}', but supported ENS namespaces are: ${Object.keys(ENSNamespaceIds3).join(", ")}`
|
|
2195
|
+
});
|
|
2196
|
+
var PortSchema = z9.coerce.number({ error: "PORT must be a number." }).min(1, { error: "PORT must be greater than 1." }).max(65535, { error: "PORT must be less than 65535" }).optional();
|
|
2197
|
+
var TheGraphApiKeySchema = z9.string().optional();
|
|
1895
2198
|
|
|
1896
|
-
// src/
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
versionInfo
|
|
1909
|
-
} = config;
|
|
1910
|
-
return {
|
|
1911
|
-
labelSet,
|
|
1912
|
-
indexedChainIds: serializeIndexedChainIds(indexedChainIds),
|
|
1913
|
-
databaseSchemaName,
|
|
1914
|
-
isSubgraphCompatible: isSubgraphCompatible2,
|
|
1915
|
-
namespace,
|
|
1916
|
-
plugins,
|
|
1917
|
-
versionInfo
|
|
1918
|
-
};
|
|
1919
|
-
}
|
|
2199
|
+
// src/shared/datasources-with-resolvers.ts
|
|
2200
|
+
import {
|
|
2201
|
+
DatasourceNames,
|
|
2202
|
+
maybeGetDatasource
|
|
2203
|
+
} from "@ensnode/datasources";
|
|
2204
|
+
var DATASOURCE_NAMES_WITH_RESOLVERS = [
|
|
2205
|
+
DatasourceNames.ENSRoot,
|
|
2206
|
+
DatasourceNames.Basenames,
|
|
2207
|
+
DatasourceNames.Lineanames,
|
|
2208
|
+
DatasourceNames.ThreeDNSOptimism,
|
|
2209
|
+
DatasourceNames.ThreeDNSBase
|
|
2210
|
+
];
|
|
1920
2211
|
|
|
1921
|
-
// src/
|
|
1922
|
-
import {
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2212
|
+
// src/shared/log-level.ts
|
|
2213
|
+
import { z as z10 } from "zod/v4";
|
|
2214
|
+
var LogLevelSchema = z10.enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]);
|
|
2215
|
+
|
|
2216
|
+
// src/shared/protocol-acceleration/interpret-record-values.ts
|
|
2217
|
+
import { isAddress as isAddress4, isAddressEqual as isAddressEqual2, zeroAddress as zeroAddress2 } from "viem";
|
|
2218
|
+
|
|
2219
|
+
// src/api/indexing-status/response.ts
|
|
2220
|
+
var IndexingStatusResponseCodes = {
|
|
2221
|
+
/**
|
|
2222
|
+
* Represents that the indexing status is available.
|
|
2223
|
+
*/
|
|
2224
|
+
Ok: "ok",
|
|
2225
|
+
/**
|
|
2226
|
+
* Represents that the indexing status is unavailable.
|
|
2227
|
+
*/
|
|
2228
|
+
Error: "error"
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
// src/api/indexing-status/zod-schemas.ts
|
|
2232
|
+
var makeIndexingStatusResponseOkSchema = (valueLabel = "Indexing Status Response OK") => z11.strictObject({
|
|
2233
|
+
responseCode: z11.literal(IndexingStatusResponseCodes.Ok),
|
|
2234
|
+
realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel)
|
|
2235
|
+
});
|
|
2236
|
+
var makeIndexingStatusResponseErrorSchema = (_valueLabel = "Indexing Status Response Error") => z11.strictObject({
|
|
2237
|
+
responseCode: z11.literal(IndexingStatusResponseCodes.Error)
|
|
2238
|
+
});
|
|
2239
|
+
var makeIndexingStatusResponseSchema = (valueLabel = "Indexing Status Response") => z11.discriminatedUnion("responseCode", [
|
|
2240
|
+
makeIndexingStatusResponseOkSchema(valueLabel),
|
|
2241
|
+
makeIndexingStatusResponseErrorSchema(valueLabel)
|
|
2242
|
+
]);
|
|
2243
|
+
|
|
2244
|
+
// src/api/indexing-status/deserialize.ts
|
|
2245
|
+
function deserializeIndexingStatusResponse(maybeResponse) {
|
|
2246
|
+
const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse);
|
|
1938
2247
|
if (parsed.error) {
|
|
1939
|
-
throw new Error(
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
`
|
|
1943
|
-
);
|
|
2248
|
+
throw new Error(`Cannot deserialize IndexingStatusResponse:
|
|
2249
|
+
${prettifyError5(parsed.error)}
|
|
2250
|
+
`);
|
|
1944
2251
|
}
|
|
1945
2252
|
return parsed.data;
|
|
1946
2253
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
2254
|
+
|
|
2255
|
+
// src/api/indexing-status/serialize.ts
|
|
2256
|
+
function serializeIndexingStatusResponse(response) {
|
|
2257
|
+
switch (response.responseCode) {
|
|
2258
|
+
case IndexingStatusResponseCodes.Ok:
|
|
2259
|
+
return {
|
|
2260
|
+
responseCode: response.responseCode,
|
|
2261
|
+
realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection)
|
|
2262
|
+
};
|
|
2263
|
+
case IndexingStatusResponseCodes.Error:
|
|
2264
|
+
return response;
|
|
1956
2265
|
}
|
|
1957
|
-
return parsed.data;
|
|
1958
2266
|
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
2267
|
+
|
|
2268
|
+
// src/api/registrar-actions/deserialize.ts
|
|
2269
|
+
import { prettifyError as prettifyError6 } from "zod/v4";
|
|
2270
|
+
function deserializeRegistrarActionsResponse(maybeResponse) {
|
|
2271
|
+
const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse);
|
|
1962
2272
|
if (parsed.error) {
|
|
1963
2273
|
throw new Error(
|
|
1964
|
-
`Cannot deserialize
|
|
1965
|
-
${
|
|
2274
|
+
`Cannot deserialize RegistrarActionsResponse:
|
|
2275
|
+
${prettifyError6(parsed.error)}
|
|
1966
2276
|
`
|
|
1967
2277
|
);
|
|
1968
2278
|
}
|
|
1969
2279
|
return parsed.data;
|
|
1970
2280
|
}
|
|
1971
2281
|
|
|
1972
|
-
// src/
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
}
|
|
2282
|
+
// src/api/registrar-actions/request.ts
|
|
2283
|
+
var RegistrarActionsFilterTypes = {
|
|
2284
|
+
BySubregistryNode: "bySubregistryNode",
|
|
2285
|
+
WithEncodedReferral: "withEncodedReferral"
|
|
2286
|
+
};
|
|
2287
|
+
var RegistrarActionsOrders = {
|
|
2288
|
+
LatestRegistrarActions: "orderBy[timestamp]=desc"
|
|
2289
|
+
};
|
|
1981
2290
|
|
|
1982
|
-
// src/
|
|
1983
|
-
function
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
snapshotTime,
|
|
1987
|
-
omnichainSnapshot
|
|
1988
|
-
}) {
|
|
1989
|
-
return {
|
|
1990
|
-
strategy,
|
|
1991
|
-
slowestChainIndexingCursor,
|
|
1992
|
-
snapshotTime,
|
|
1993
|
-
omnichainSnapshot: serializeOmnichainIndexingStatusSnapshot(omnichainSnapshot)
|
|
1994
|
-
};
|
|
1995
|
-
}
|
|
1996
|
-
function serializeRealtimeIndexingStatusProjection(indexingProjection) {
|
|
1997
|
-
return {
|
|
1998
|
-
projectedAt: indexingProjection.projectedAt,
|
|
1999
|
-
worstCaseDistance: indexingProjection.worstCaseDistance,
|
|
2000
|
-
snapshot: serializeCrossChainIndexingStatusSnapshotOmnichain(indexingProjection.snapshot)
|
|
2001
|
-
};
|
|
2002
|
-
}
|
|
2003
|
-
function serializeChainIndexingSnapshots(chains) {
|
|
2004
|
-
const serializedSnapshots = {};
|
|
2005
|
-
for (const [chainId, snapshot] of chains.entries()) {
|
|
2006
|
-
serializedSnapshots[serializeChainId(chainId)] = snapshot;
|
|
2291
|
+
// src/api/registrar-actions/filters.ts
|
|
2292
|
+
function byParentNode(parentNode) {
|
|
2293
|
+
if (typeof parentNode === "undefined") {
|
|
2294
|
+
return void 0;
|
|
2007
2295
|
}
|
|
2008
|
-
return
|
|
2296
|
+
return {
|
|
2297
|
+
filterType: RegistrarActionsFilterTypes.BySubregistryNode,
|
|
2298
|
+
value: parentNode
|
|
2299
|
+
};
|
|
2009
2300
|
}
|
|
2010
|
-
function
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
return {
|
|
2014
|
-
omnichainStatus: OmnichainIndexingStatusIds.Unstarted,
|
|
2015
|
-
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
2016
|
-
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
2017
|
-
};
|
|
2018
|
-
case OmnichainIndexingStatusIds.Backfill:
|
|
2019
|
-
return {
|
|
2020
|
-
omnichainStatus: OmnichainIndexingStatusIds.Backfill,
|
|
2021
|
-
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
2022
|
-
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
2023
|
-
};
|
|
2024
|
-
case OmnichainIndexingStatusIds.Completed: {
|
|
2025
|
-
return {
|
|
2026
|
-
omnichainStatus: OmnichainIndexingStatusIds.Completed,
|
|
2027
|
-
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
2028
|
-
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
2029
|
-
};
|
|
2030
|
-
}
|
|
2031
|
-
case OmnichainIndexingStatusIds.Following:
|
|
2032
|
-
return {
|
|
2033
|
-
omnichainStatus: OmnichainIndexingStatusIds.Following,
|
|
2034
|
-
chains: serializeChainIndexingSnapshots(indexingStatus.chains),
|
|
2035
|
-
omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
|
|
2036
|
-
};
|
|
2301
|
+
function withReferral(withReferral2) {
|
|
2302
|
+
if (!withReferral2) {
|
|
2303
|
+
return void 0;
|
|
2037
2304
|
}
|
|
2305
|
+
return {
|
|
2306
|
+
filterType: RegistrarActionsFilterTypes.WithEncodedReferral
|
|
2307
|
+
};
|
|
2038
2308
|
}
|
|
2309
|
+
var registrarActionsFilter = {
|
|
2310
|
+
byParentNode,
|
|
2311
|
+
withReferral
|
|
2312
|
+
};
|
|
2039
2313
|
|
|
2040
2314
|
// src/api/registrar-actions/prerequisites.ts
|
|
2041
2315
|
var registrarActionsPrerequisites = Object.freeze({
|
|
@@ -2104,18 +2378,7 @@ function getEthnamesSubregistryId(namespace) {
|
|
|
2104
2378
|
};
|
|
2105
2379
|
}
|
|
2106
2380
|
|
|
2107
|
-
// src/api/serialize.ts
|
|
2108
|
-
function serializeIndexingStatusResponse(response) {
|
|
2109
|
-
switch (response.responseCode) {
|
|
2110
|
-
case IndexingStatusResponseCodes.Ok:
|
|
2111
|
-
return {
|
|
2112
|
-
responseCode: response.responseCode,
|
|
2113
|
-
realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection)
|
|
2114
|
-
};
|
|
2115
|
-
case IndexingStatusResponseCodes.Error:
|
|
2116
|
-
return response;
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2381
|
+
// src/api/registrar-actions/serialize.ts
|
|
2119
2382
|
function serializeNamedRegistrarAction({
|
|
2120
2383
|
action,
|
|
2121
2384
|
name
|
|
@@ -2137,6 +2400,18 @@ function serializeRegistrarActionsResponse(response) {
|
|
|
2137
2400
|
}
|
|
2138
2401
|
}
|
|
2139
2402
|
|
|
2403
|
+
// src/api/shared/errors/deserialize.ts
|
|
2404
|
+
import { prettifyError as prettifyError7 } from "zod/v4";
|
|
2405
|
+
function deserializeErrorResponse(maybeErrorResponse) {
|
|
2406
|
+
const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse);
|
|
2407
|
+
if (parsed.error) {
|
|
2408
|
+
throw new Error(`Cannot deserialize ErrorResponse:
|
|
2409
|
+
${prettifyError7(parsed.error)}
|
|
2410
|
+
`);
|
|
2411
|
+
}
|
|
2412
|
+
return parsed.data;
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2140
2415
|
// src/client-error.ts
|
|
2141
2416
|
var ClientError = class _ClientError extends Error {
|
|
2142
2417
|
details;
|
|
@@ -2151,160 +2426,195 @@ var ClientError = class _ClientError extends Error {
|
|
|
2151
2426
|
};
|
|
2152
2427
|
|
|
2153
2428
|
// src/ensanalytics/deserialize.ts
|
|
2154
|
-
import { prettifyError as
|
|
2429
|
+
import { prettifyError as prettifyError8 } from "zod/v4";
|
|
2155
2430
|
|
|
2156
2431
|
// src/ensanalytics/zod-schemas.ts
|
|
2157
|
-
import
|
|
2432
|
+
import z12 from "zod/v4";
|
|
2158
2433
|
|
|
2159
2434
|
// src/ensanalytics/types.ts
|
|
2160
|
-
var
|
|
2161
|
-
|
|
2162
|
-
|
|
2435
|
+
var ReferrerLeaderboardPageResponseCodes = {
|
|
2436
|
+
/**
|
|
2437
|
+
* Represents that the requested referrer leaderboard page is available.
|
|
2438
|
+
*/
|
|
2439
|
+
Ok: "ok",
|
|
2440
|
+
/**
|
|
2441
|
+
* Represents that the referrer leaderboard data is not available.
|
|
2442
|
+
*/
|
|
2443
|
+
Error: "error"
|
|
2444
|
+
};
|
|
2445
|
+
var ReferrerDetailResponseCodes = {
|
|
2163
2446
|
/**
|
|
2164
|
-
* Represents that the
|
|
2165
|
-
* @note The response may contain an empty array for the first page if there are no qualified referrers.
|
|
2166
|
-
* When the array is empty, total will be 0, page will be 1, and both hasNext and hasPrev will be false.
|
|
2447
|
+
* Represents that the referrer detail data is available.
|
|
2167
2448
|
*/
|
|
2168
2449
|
Ok: "ok",
|
|
2169
2450
|
/**
|
|
2170
|
-
* Represents that
|
|
2451
|
+
* Represents that an error occurred while fetching the data.
|
|
2171
2452
|
*/
|
|
2172
2453
|
Error: "error"
|
|
2173
2454
|
};
|
|
2174
2455
|
|
|
2175
2456
|
// src/ensanalytics/zod-schemas.ts
|
|
2176
|
-
var
|
|
2457
|
+
var makeReferralProgramRulesSchema = (valueLabel = "ReferralProgramRules") => z12.object({
|
|
2458
|
+
totalAwardPoolValue: makeFiniteNonNegativeNumberSchema(`${valueLabel}.totalAwardPoolValue`),
|
|
2459
|
+
maxQualifiedReferrers: makeNonNegativeIntegerSchema(`${valueLabel}.maxQualifiedReferrers`),
|
|
2460
|
+
startTime: makeUnixTimestampSchema(`${valueLabel}.startTime`),
|
|
2461
|
+
endTime: makeUnixTimestampSchema(`${valueLabel}.endTime`),
|
|
2462
|
+
subregistryId: makeAccountIdSchema(`${valueLabel}.subregistryId`)
|
|
2463
|
+
});
|
|
2464
|
+
var makeAwardedReferrerMetricsSchema = (valueLabel = "AwardedReferrerMetrics") => z12.object({
|
|
2177
2465
|
referrer: makeLowercaseAddressSchema(`${valueLabel}.referrer`),
|
|
2178
|
-
totalReferrals:
|
|
2179
|
-
totalIncrementalDuration: makeDurationSchema(`${valueLabel}.totalIncrementalDuration`)
|
|
2466
|
+
totalReferrals: makeNonNegativeIntegerSchema(`${valueLabel}.totalReferrals`),
|
|
2467
|
+
totalIncrementalDuration: makeDurationSchema(`${valueLabel}.totalIncrementalDuration`),
|
|
2468
|
+
score: makeFiniteNonNegativeNumberSchema(`${valueLabel}.score`),
|
|
2469
|
+
rank: makePositiveIntegerSchema(`${valueLabel}.rank`),
|
|
2470
|
+
isQualified: z12.boolean(),
|
|
2471
|
+
finalScoreBoost: makeFiniteNonNegativeNumberSchema(`${valueLabel}.finalScoreBoost`).max(
|
|
2472
|
+
1,
|
|
2473
|
+
`${valueLabel}.finalScoreBoost must be <= 1`
|
|
2474
|
+
),
|
|
2475
|
+
finalScore: makeFiniteNonNegativeNumberSchema(`${valueLabel}.finalScore`),
|
|
2476
|
+
awardPoolShare: makeFiniteNonNegativeNumberSchema(`${valueLabel}.awardPoolShare`).max(
|
|
2477
|
+
1,
|
|
2478
|
+
`${valueLabel}.awardPoolShare must be <= 1`
|
|
2479
|
+
),
|
|
2480
|
+
awardPoolApproxValue: makeFiniteNonNegativeNumberSchema(`${valueLabel}.awardPoolApproxValue`)
|
|
2180
2481
|
});
|
|
2181
|
-
var
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2482
|
+
var makeUnrankedReferrerMetricsSchema = (valueLabel = "UnrankedReferrerMetrics") => z12.object({
|
|
2483
|
+
referrer: makeLowercaseAddressSchema(`${valueLabel}.referrer`),
|
|
2484
|
+
totalReferrals: makeNonNegativeIntegerSchema(`${valueLabel}.totalReferrals`),
|
|
2485
|
+
totalIncrementalDuration: makeDurationSchema(`${valueLabel}.totalIncrementalDuration`),
|
|
2486
|
+
score: makeFiniteNonNegativeNumberSchema(`${valueLabel}.score`),
|
|
2487
|
+
rank: z12.null(),
|
|
2488
|
+
isQualified: z12.literal(false),
|
|
2489
|
+
finalScoreBoost: makeFiniteNonNegativeNumberSchema(`${valueLabel}.finalScoreBoost`).max(
|
|
2490
|
+
1,
|
|
2491
|
+
`${valueLabel}.finalScoreBoost must be <= 1`
|
|
2492
|
+
),
|
|
2493
|
+
finalScore: makeFiniteNonNegativeNumberSchema(`${valueLabel}.finalScore`),
|
|
2494
|
+
awardPoolShare: makeFiniteNonNegativeNumberSchema(`${valueLabel}.awardPoolShare`).max(
|
|
2495
|
+
1,
|
|
2496
|
+
`${valueLabel}.awardPoolShare must be <= 1`
|
|
2497
|
+
),
|
|
2498
|
+
awardPoolApproxValue: makeFiniteNonNegativeNumberSchema(`${valueLabel}.awardPoolApproxValue`)
|
|
2188
2499
|
});
|
|
2189
|
-
var
|
|
2190
|
-
|
|
2191
|
-
|
|
2500
|
+
var makeAggregatedReferrerMetricsSchema = (valueLabel = "AggregatedReferrerMetrics") => z12.object({
|
|
2501
|
+
grandTotalReferrals: makeNonNegativeIntegerSchema(`${valueLabel}.grandTotalReferrals`),
|
|
2502
|
+
grandTotalIncrementalDuration: makeDurationSchema(
|
|
2503
|
+
`${valueLabel}.grandTotalIncrementalDuration`
|
|
2504
|
+
),
|
|
2505
|
+
grandTotalQualifiedReferrersFinalScore: makeFiniteNonNegativeNumberSchema(
|
|
2506
|
+
`${valueLabel}.grandTotalQualifiedReferrersFinalScore`
|
|
2507
|
+
),
|
|
2508
|
+
minFinalScoreToQualify: makeFiniteNonNegativeNumberSchema(
|
|
2509
|
+
`${valueLabel}.minFinalScoreToQualify`
|
|
2510
|
+
)
|
|
2192
2511
|
});
|
|
2193
|
-
var
|
|
2194
|
-
|
|
2195
|
-
|
|
2512
|
+
var makeReferrerLeaderboardPageContextSchema = (valueLabel = "ReferrerLeaderboardPageContext") => z12.object({
|
|
2513
|
+
page: makePositiveIntegerSchema(`${valueLabel}.page`),
|
|
2514
|
+
itemsPerPage: makePositiveIntegerSchema(`${valueLabel}.itemsPerPage`).max(
|
|
2515
|
+
REFERRERS_PER_LEADERBOARD_PAGE_MAX,
|
|
2516
|
+
`${valueLabel}.itemsPerPage must not exceed ${REFERRERS_PER_LEADERBOARD_PAGE_MAX}`
|
|
2196
2517
|
),
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
hasNext:
|
|
2200
|
-
hasPrev:
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2518
|
+
totalRecords: makeNonNegativeIntegerSchema(`${valueLabel}.totalRecords`),
|
|
2519
|
+
totalPages: makePositiveIntegerSchema(`${valueLabel}.totalPages`),
|
|
2520
|
+
hasNext: z12.boolean(),
|
|
2521
|
+
hasPrev: z12.boolean(),
|
|
2522
|
+
startIndex: z12.optional(makeNonNegativeIntegerSchema(`${valueLabel}.startIndex`)),
|
|
2523
|
+
endIndex: z12.optional(makeNonNegativeIntegerSchema(`${valueLabel}.endIndex`))
|
|
2524
|
+
});
|
|
2525
|
+
var makeReferrerLeaderboardPageSchema = (valueLabel = "ReferrerLeaderboardPage") => z12.object({
|
|
2526
|
+
rules: makeReferralProgramRulesSchema(`${valueLabel}.rules`),
|
|
2527
|
+
referrers: z12.array(makeAwardedReferrerMetricsSchema(`${valueLabel}.referrers[item]`)),
|
|
2528
|
+
aggregatedMetrics: makeAggregatedReferrerMetricsSchema(`${valueLabel}.aggregatedMetrics`),
|
|
2529
|
+
paginationContext: makeReferrerLeaderboardPageContextSchema(`${valueLabel}.paginationContext`),
|
|
2530
|
+
accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
|
|
2531
|
+
});
|
|
2532
|
+
var makeReferrerLeaderboardPageResponseOkSchema = (valueLabel = "ReferrerLeaderboardPageResponseOk") => z12.object({
|
|
2533
|
+
responseCode: z12.literal(ReferrerLeaderboardPageResponseCodes.Ok),
|
|
2534
|
+
data: makeReferrerLeaderboardPageSchema(`${valueLabel}.data`)
|
|
2535
|
+
});
|
|
2536
|
+
var makeReferrerLeaderboardPageResponseErrorSchema = (_valueLabel = "ReferrerLeaderboardPageResponseError") => z12.object({
|
|
2537
|
+
responseCode: z12.literal(ReferrerLeaderboardPageResponseCodes.Error),
|
|
2538
|
+
error: z12.string(),
|
|
2539
|
+
errorMessage: z12.string()
|
|
2540
|
+
});
|
|
2541
|
+
var makeReferrerLeaderboardPageResponseSchema = (valueLabel = "ReferrerLeaderboardPageResponse") => z12.union([
|
|
2542
|
+
makeReferrerLeaderboardPageResponseOkSchema(valueLabel),
|
|
2543
|
+
makeReferrerLeaderboardPageResponseErrorSchema(valueLabel)
|
|
2544
|
+
]);
|
|
2545
|
+
var makeReferrerDetailRankedSchema = (valueLabel = "ReferrerDetailRanked") => z12.object({
|
|
2546
|
+
type: z12.literal(ReferrerDetailTypeIds.Ranked),
|
|
2547
|
+
rules: makeReferralProgramRulesSchema(`${valueLabel}.rules`),
|
|
2548
|
+
referrer: makeAwardedReferrerMetricsSchema(`${valueLabel}.referrer`),
|
|
2549
|
+
aggregatedMetrics: makeAggregatedReferrerMetricsSchema(`${valueLabel}.aggregatedMetrics`),
|
|
2550
|
+
accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
|
|
2551
|
+
});
|
|
2552
|
+
var makeReferrerDetailUnrankedSchema = (valueLabel = "ReferrerDetailUnranked") => z12.object({
|
|
2553
|
+
type: z12.literal(ReferrerDetailTypeIds.Unranked),
|
|
2554
|
+
rules: makeReferralProgramRulesSchema(`${valueLabel}.rules`),
|
|
2555
|
+
referrer: makeUnrankedReferrerMetricsSchema(`${valueLabel}.referrer`),
|
|
2556
|
+
aggregatedMetrics: makeAggregatedReferrerMetricsSchema(`${valueLabel}.aggregatedMetrics`),
|
|
2557
|
+
accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
|
|
2221
2558
|
});
|
|
2222
|
-
var
|
|
2223
|
-
responseCode:
|
|
2224
|
-
data:
|
|
2559
|
+
var makeReferrerDetailResponseOkSchema = (valueLabel = "ReferrerDetailResponse") => z12.object({
|
|
2560
|
+
responseCode: z12.literal(ReferrerDetailResponseCodes.Ok),
|
|
2561
|
+
data: z12.union([
|
|
2562
|
+
makeReferrerDetailRankedSchema(`${valueLabel}.data`),
|
|
2563
|
+
makeReferrerDetailUnrankedSchema(`${valueLabel}.data`)
|
|
2564
|
+
])
|
|
2225
2565
|
});
|
|
2226
|
-
var
|
|
2227
|
-
responseCode:
|
|
2228
|
-
error:
|
|
2229
|
-
errorMessage:
|
|
2566
|
+
var makeReferrerDetailResponseErrorSchema = (_valueLabel = "ReferrerDetailResponse") => z12.object({
|
|
2567
|
+
responseCode: z12.literal(ReferrerDetailResponseCodes.Error),
|
|
2568
|
+
error: z12.string(),
|
|
2569
|
+
errorMessage: z12.string()
|
|
2230
2570
|
});
|
|
2231
|
-
var
|
|
2232
|
-
|
|
2233
|
-
|
|
2571
|
+
var makeReferrerDetailResponseSchema = (valueLabel = "ReferrerDetailResponse") => z12.union([
|
|
2572
|
+
makeReferrerDetailResponseOkSchema(valueLabel),
|
|
2573
|
+
makeReferrerDetailResponseErrorSchema(valueLabel)
|
|
2234
2574
|
]);
|
|
2235
2575
|
|
|
2236
2576
|
// src/ensanalytics/deserialize.ts
|
|
2237
|
-
function
|
|
2238
|
-
const schema =
|
|
2577
|
+
function deserializeReferrerLeaderboardPageResponse(maybeResponse, valueLabel) {
|
|
2578
|
+
const schema = makeReferrerLeaderboardPageResponseSchema(valueLabel);
|
|
2239
2579
|
const parsed = schema.safeParse(maybeResponse);
|
|
2240
2580
|
if (parsed.error) {
|
|
2241
2581
|
throw new Error(
|
|
2242
|
-
`Cannot deserialize
|
|
2243
|
-
${
|
|
2582
|
+
`Cannot deserialize SerializedReferrerLeaderboardPageResponse:
|
|
2583
|
+
${prettifyError8(parsed.error)}
|
|
2244
2584
|
`
|
|
2245
2585
|
);
|
|
2246
2586
|
}
|
|
2247
2587
|
return parsed.data;
|
|
2248
2588
|
}
|
|
2589
|
+
function deserializeReferrerDetailResponse(maybeResponse, valueLabel) {
|
|
2590
|
+
const schema = makeReferrerDetailResponseSchema(valueLabel);
|
|
2591
|
+
const parsed = schema.safeParse(maybeResponse);
|
|
2592
|
+
if (parsed.error) {
|
|
2593
|
+
throw new Error(`Cannot deserialize ReferrerDetailResponse:
|
|
2594
|
+
${prettifyError8(parsed.error)}
|
|
2595
|
+
`);
|
|
2596
|
+
}
|
|
2597
|
+
return parsed.data;
|
|
2598
|
+
}
|
|
2249
2599
|
|
|
2250
2600
|
// src/ensanalytics/serialize.ts
|
|
2251
|
-
function
|
|
2601
|
+
function serializeReferrerLeaderboardPageResponse(response) {
|
|
2252
2602
|
switch (response.responseCode) {
|
|
2253
|
-
case
|
|
2603
|
+
case ReferrerLeaderboardPageResponseCodes.Ok:
|
|
2254
2604
|
return response;
|
|
2255
|
-
case
|
|
2605
|
+
case ReferrerLeaderboardPageResponseCodes.Error:
|
|
2256
2606
|
return response;
|
|
2257
2607
|
}
|
|
2258
2608
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
var TheGraphCannotFallbackReasonSchema = z9.enum({
|
|
2266
|
-
NotSubgraphCompatible: "not-subgraph-compatible",
|
|
2267
|
-
NoApiKey: "no-api-key",
|
|
2268
|
-
NoSubgraphUrl: "no-subgraph-url"
|
|
2269
|
-
});
|
|
2270
|
-
var TheGraphFallbackSchema = z9.strictObject({
|
|
2271
|
-
canFallback: z9.boolean(),
|
|
2272
|
-
reason: TheGraphCannotFallbackReasonSchema.nullable()
|
|
2273
|
-
});
|
|
2274
|
-
function makeENSApiPublicConfigSchema(valueLabel) {
|
|
2275
|
-
const label = valueLabel ?? "ENSApiPublicConfig";
|
|
2276
|
-
return z9.strictObject({
|
|
2277
|
-
version: z9.string().min(1, `${label}.version must be a non-empty string`),
|
|
2278
|
-
theGraphFallback: TheGraphFallbackSchema,
|
|
2279
|
-
ensIndexerPublicConfig: makeENSIndexerPublicConfigSchema(`${label}.ensIndexerPublicConfig`)
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
|
-
// src/ensapi/config/deserialize.ts
|
|
2284
|
-
function deserializeENSApiPublicConfig(maybeConfig, valueLabel) {
|
|
2285
|
-
const schema = makeENSApiPublicConfigSchema(valueLabel);
|
|
2286
|
-
try {
|
|
2287
|
-
return schema.parse(maybeConfig);
|
|
2288
|
-
} catch (error) {
|
|
2289
|
-
if (error instanceof ZodError) {
|
|
2290
|
-
throw new Error(`Cannot deserialize ENSApiPublicConfig:
|
|
2291
|
-
${prettifyError6(error)}
|
|
2292
|
-
`);
|
|
2293
|
-
}
|
|
2294
|
-
throw error;
|
|
2609
|
+
function serializeReferrerDetailResponse(response) {
|
|
2610
|
+
switch (response.responseCode) {
|
|
2611
|
+
case ReferrerDetailResponseCodes.Ok:
|
|
2612
|
+
return response;
|
|
2613
|
+
case ReferrerDetailResponseCodes.Error:
|
|
2614
|
+
return response;
|
|
2295
2615
|
}
|
|
2296
2616
|
}
|
|
2297
2617
|
|
|
2298
|
-
// src/ensapi/config/serialize.ts
|
|
2299
|
-
function serializeENSApiPublicConfig(config) {
|
|
2300
|
-
const { version, theGraphFallback, ensIndexerPublicConfig } = config;
|
|
2301
|
-
return {
|
|
2302
|
-
version,
|
|
2303
|
-
theGraphFallback,
|
|
2304
|
-
ensIndexerPublicConfig: serializeENSIndexerPublicConfig(ensIndexerPublicConfig)
|
|
2305
|
-
};
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
2618
|
// src/client.ts
|
|
2309
2619
|
var DEFAULT_ENSNODE_API_URL = "https://api.alpha.ensnode.io";
|
|
2310
2620
|
var ENSNodeClient = class _ENSNodeClient {
|
|
@@ -2508,7 +2818,7 @@ var ENSNodeClient = class _ENSNodeClient {
|
|
|
2508
2818
|
const errorResponse = deserializeErrorResponse(responseData);
|
|
2509
2819
|
throw new Error(`Fetching ENSNode Config Failed: ${errorResponse.message}`);
|
|
2510
2820
|
}
|
|
2511
|
-
return
|
|
2821
|
+
return deserializeConfigResponse(responseData);
|
|
2512
2822
|
}
|
|
2513
2823
|
/**
|
|
2514
2824
|
* Fetch ENSNode Indexing Status
|
|
@@ -2542,15 +2852,15 @@ var ENSNodeClient = class _ENSNodeClient {
|
|
|
2542
2852
|
return deserializeIndexingStatusResponse(responseData);
|
|
2543
2853
|
}
|
|
2544
2854
|
/**
|
|
2545
|
-
* Fetch
|
|
2855
|
+
* Fetch Referrer Leaderboard Page
|
|
2546
2856
|
*
|
|
2547
|
-
* Retrieves a paginated list of
|
|
2857
|
+
* Retrieves a paginated list of referrer leaderboard metrics with contribution percentages.
|
|
2548
2858
|
* Each referrer's contribution is calculated as a percentage of the grand totals across all referrers.
|
|
2549
2859
|
*
|
|
2550
2860
|
* @param request - Pagination parameters
|
|
2551
2861
|
* @param request.page - The page number to retrieve (1-indexed, default: 1)
|
|
2552
2862
|
* @param request.itemsPerPage - Number of items per page (default: 25, max: 100)
|
|
2553
|
-
* @returns {
|
|
2863
|
+
* @returns {ReferrerLeaderboardPageResponse}
|
|
2554
2864
|
*
|
|
2555
2865
|
* @throws if the ENSNode request fails
|
|
2556
2866
|
* @throws if the ENSNode API returns an error response
|
|
@@ -2559,21 +2869,42 @@ var ENSNodeClient = class _ENSNodeClient {
|
|
|
2559
2869
|
* @example
|
|
2560
2870
|
* ```typescript
|
|
2561
2871
|
* // Get first page with default page size (25 items)
|
|
2562
|
-
* const response = await client.
|
|
2563
|
-
* if (response.responseCode ===
|
|
2564
|
-
*
|
|
2565
|
-
*
|
|
2872
|
+
* const response = await client.getReferrerLeaderboardPage();
|
|
2873
|
+
* if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
|
|
2874
|
+
* const {
|
|
2875
|
+
* aggregatedMetrics,
|
|
2876
|
+
* referrers,
|
|
2877
|
+
* rules,
|
|
2878
|
+
* paginationContext,
|
|
2879
|
+
* updatedAt
|
|
2880
|
+
* } = response.data;
|
|
2881
|
+
* console.log(aggregatedMetrics);
|
|
2882
|
+
* console.log(referrers);
|
|
2883
|
+
* console.log(rules);
|
|
2884
|
+
* console.log(updatedAt);
|
|
2885
|
+
* console.log(`Page ${paginationContext.page} of ${paginationContext.totalPages}`);
|
|
2566
2886
|
* }
|
|
2567
2887
|
* ```
|
|
2568
2888
|
*
|
|
2569
2889
|
* @example
|
|
2570
2890
|
* ```typescript
|
|
2571
2891
|
* // Get second page with 50 items per page
|
|
2572
|
-
* const response = await client.
|
|
2892
|
+
* const response = await client.getReferrerLeaderboardPage({ page: 2, itemsPerPage: 50 });
|
|
2893
|
+
* ```
|
|
2894
|
+
*
|
|
2895
|
+
* @example
|
|
2896
|
+
* ```typescript
|
|
2897
|
+
* // Handle error response, ie. when Referrer Leaderboard is not currently available.
|
|
2898
|
+
* const response = await client.getReferrerLeaderboardPage();
|
|
2899
|
+
*
|
|
2900
|
+
* if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Error) {
|
|
2901
|
+
* console.error(response.error);
|
|
2902
|
+
* console.error(response.errorMessage);
|
|
2903
|
+
* }
|
|
2573
2904
|
* ```
|
|
2574
2905
|
*/
|
|
2575
|
-
async
|
|
2576
|
-
const url = new URL(`/ensanalytics/
|
|
2906
|
+
async getReferrerLeaderboardPage(request) {
|
|
2907
|
+
const url = new URL(`/ensanalytics/referrers`, this.options.url);
|
|
2577
2908
|
if (request?.page) url.searchParams.set("page", request.page.toString());
|
|
2578
2909
|
if (request?.itemsPerPage)
|
|
2579
2910
|
url.searchParams.set("itemsPerPage", request.itemsPerPage.toString());
|
|
@@ -2584,10 +2915,100 @@ var ENSNodeClient = class _ENSNodeClient {
|
|
|
2584
2915
|
} catch {
|
|
2585
2916
|
throw new Error("Malformed response data: invalid JSON");
|
|
2586
2917
|
}
|
|
2587
|
-
return
|
|
2918
|
+
return deserializeReferrerLeaderboardPageResponse(
|
|
2588
2919
|
responseData
|
|
2589
2920
|
);
|
|
2590
2921
|
}
|
|
2922
|
+
/**
|
|
2923
|
+
* Fetch Referrer Detail
|
|
2924
|
+
*
|
|
2925
|
+
* Retrieves detailed information about a specific referrer, whether they are on the
|
|
2926
|
+
* leaderboard or not.
|
|
2927
|
+
*
|
|
2928
|
+
* The response data is a discriminated union type with a `type` field:
|
|
2929
|
+
*
|
|
2930
|
+
* **For referrers on the leaderboard** (`ReferrerDetailRanked`):
|
|
2931
|
+
* - `type`: {@link ReferrerDetailTypeIds.Ranked}
|
|
2932
|
+
* - `referrer`: The `AwardedReferrerMetrics` from @namehash/ens-referrals
|
|
2933
|
+
* - `rules`: The referral program rules
|
|
2934
|
+
* - `aggregatedMetrics`: Aggregated metrics for all referrers on the leaderboard
|
|
2935
|
+
* - `accurateAsOf`: Unix timestamp indicating when the data was last updated
|
|
2936
|
+
*
|
|
2937
|
+
* **For referrers NOT on the leaderboard** (`ReferrerDetailUnranked`):
|
|
2938
|
+
* - `type`: {@link ReferrerDetailTypeIds.Unranked}
|
|
2939
|
+
* - `referrer`: The `UnrankedReferrerMetrics` from @namehash/ens-referrals
|
|
2940
|
+
* - `rules`: The referral program rules
|
|
2941
|
+
* - `aggregatedMetrics`: Aggregated metrics for all referrers on the leaderboard
|
|
2942
|
+
* - `accurateAsOf`: Unix timestamp indicating when the data was last updated
|
|
2943
|
+
*
|
|
2944
|
+
* @see {@link https://www.npmjs.com/package/@namehash/ens-referrals|@namehash/ens-referrals} for calculation details
|
|
2945
|
+
*
|
|
2946
|
+
* @param request The referrer address to query
|
|
2947
|
+
* @returns {ReferrerDetailResponse} Returns the referrer detail response
|
|
2948
|
+
*
|
|
2949
|
+
* @throws if the ENSNode request fails
|
|
2950
|
+
* @throws if the response data is malformed
|
|
2951
|
+
*
|
|
2952
|
+
* @example
|
|
2953
|
+
* ```typescript
|
|
2954
|
+
* // Get referrer detail for a specific address
|
|
2955
|
+
* const response = await client.getReferrerDetail({
|
|
2956
|
+
* referrer: "0x1234567890123456789012345678901234567890"
|
|
2957
|
+
* });
|
|
2958
|
+
* if (response.responseCode === ReferrerDetailResponseCodes.Ok) {
|
|
2959
|
+
* const { type, referrer, rules, aggregatedMetrics, accurateAsOf } = response.data;
|
|
2960
|
+
* console.log(type); // ReferrerDetailTypeIds.Ranked or ReferrerDetailTypeIds.Unranked
|
|
2961
|
+
* console.log(referrer);
|
|
2962
|
+
* console.log(accurateAsOf);
|
|
2963
|
+
* }
|
|
2964
|
+
* ```
|
|
2965
|
+
*
|
|
2966
|
+
* @example
|
|
2967
|
+
* ```typescript
|
|
2968
|
+
* // Use discriminated union to check if referrer is ranked
|
|
2969
|
+
* const response = await client.getReferrerDetail({
|
|
2970
|
+
* referrer: "0x1234567890123456789012345678901234567890"
|
|
2971
|
+
* });
|
|
2972
|
+
* if (response.responseCode === ReferrerDetailResponseCodes.Ok) {
|
|
2973
|
+
* if (response.data.type === ReferrerDetailTypeIds.Ranked) {
|
|
2974
|
+
* // TypeScript knows this is ReferrerDetailRanked
|
|
2975
|
+
* console.log(`Rank: ${response.data.referrer.rank}`);
|
|
2976
|
+
* console.log(`Qualified: ${response.data.referrer.isQualified}`);
|
|
2977
|
+
* console.log(`Award Pool Share: ${response.data.referrer.awardPoolShare * 100}%`);
|
|
2978
|
+
* } else {
|
|
2979
|
+
* // TypeScript knows this is ReferrerDetailUnranked
|
|
2980
|
+
* console.log("Referrer is not on the leaderboard (no referrals yet)");
|
|
2981
|
+
* }
|
|
2982
|
+
* }
|
|
2983
|
+
* ```
|
|
2984
|
+
*
|
|
2985
|
+
* @example
|
|
2986
|
+
* ```typescript
|
|
2987
|
+
* // Handle error response, ie. when Referrer Detail is not currently available.
|
|
2988
|
+
* const response = await client.getReferrerDetail({
|
|
2989
|
+
* referrer: "0x1234567890123456789012345678901234567890"
|
|
2990
|
+
* });
|
|
2991
|
+
*
|
|
2992
|
+
* if (response.responseCode === ReferrerDetailResponseCodes.Error) {
|
|
2993
|
+
* console.error(response.error);
|
|
2994
|
+
* console.error(response.errorMessage);
|
|
2995
|
+
* }
|
|
2996
|
+
* ```
|
|
2997
|
+
*/
|
|
2998
|
+
async getReferrerDetail(request) {
|
|
2999
|
+
const url = new URL(
|
|
3000
|
+
`/api/ensanalytics/referrers/${encodeURIComponent(request.referrer)}`,
|
|
3001
|
+
this.options.url
|
|
3002
|
+
);
|
|
3003
|
+
const response = await fetch(url);
|
|
3004
|
+
let responseData;
|
|
3005
|
+
try {
|
|
3006
|
+
responseData = await response.json();
|
|
3007
|
+
} catch {
|
|
3008
|
+
throw new Error("Malformed response data: invalid JSON");
|
|
3009
|
+
}
|
|
3010
|
+
return deserializeReferrerDetailResponse(responseData);
|
|
3011
|
+
}
|
|
2591
3012
|
/**
|
|
2592
3013
|
* Fetch ENSNode Registrar Actions
|
|
2593
3014
|
*
|
|
@@ -2751,6 +3172,231 @@ var translateDefaultableChainIdToChainId = (chainId, namespaceId) => {
|
|
|
2751
3172
|
// src/resolution/resolver-records-selection.ts
|
|
2752
3173
|
var isSelectionEmpty = (selection) => !selection.name && !selection.addresses?.length && !selection.texts?.length;
|
|
2753
3174
|
|
|
3175
|
+
// src/tokenscope/assets.ts
|
|
3176
|
+
import { AssetId as CaipAssetId } from "caip";
|
|
3177
|
+
import { isAddressEqual as isAddressEqual3, zeroAddress as zeroAddress3 } from "viem";
|
|
3178
|
+
var AssetNamespaces = {
|
|
3179
|
+
ERC721: "erc721",
|
|
3180
|
+
ERC1155: "erc1155"
|
|
3181
|
+
};
|
|
3182
|
+
function serializeAssetId(assetId) {
|
|
3183
|
+
const { assetNamespace, contract, tokenId } = assetId;
|
|
3184
|
+
return CaipAssetId.format({
|
|
3185
|
+
chainId: { namespace: "eip155", reference: contract.chainId.toString() },
|
|
3186
|
+
assetName: { namespace: assetNamespace, reference: contract.address },
|
|
3187
|
+
tokenId: uint256ToHex32(tokenId)
|
|
3188
|
+
}).toLowerCase();
|
|
3189
|
+
}
|
|
3190
|
+
var buildAssetId = (contract, tokenId, assetNamespace) => {
|
|
3191
|
+
return {
|
|
3192
|
+
assetNamespace,
|
|
3193
|
+
contract,
|
|
3194
|
+
tokenId
|
|
3195
|
+
};
|
|
3196
|
+
};
|
|
3197
|
+
var NFTMintStatuses = {
|
|
3198
|
+
Minted: "minted",
|
|
3199
|
+
Burned: "burned"
|
|
3200
|
+
};
|
|
3201
|
+
var formatNFTTransferEventMetadata = (metadata) => {
|
|
3202
|
+
const serializedAssetId = serializeAssetId(metadata.nft);
|
|
3203
|
+
return [
|
|
3204
|
+
`Event: ${metadata.eventHandlerName}`,
|
|
3205
|
+
`Chain ID: ${metadata.chainId}`,
|
|
3206
|
+
`Block Number: ${metadata.blockNumber}`,
|
|
3207
|
+
`Transaction Hash: ${metadata.transactionHash}`,
|
|
3208
|
+
`NFT: ${serializedAssetId}`
|
|
3209
|
+
].map((line) => ` - ${line}`).join("\n");
|
|
3210
|
+
};
|
|
3211
|
+
var NFTTransferTypes = {
|
|
3212
|
+
/**
|
|
3213
|
+
* Initial transfer from zeroAddress to a non-zeroAddress
|
|
3214
|
+
* Can happen at most once to a NFT AssetId
|
|
3215
|
+
*
|
|
3216
|
+
* Invariants:
|
|
3217
|
+
* - NFT is not indexed and therefore has no previous mint status or owner
|
|
3218
|
+
* - new NFT mint status is `minted`
|
|
3219
|
+
* - new NFT owner is a non-zeroAddress
|
|
3220
|
+
*/
|
|
3221
|
+
Mint: "mint",
|
|
3222
|
+
/**
|
|
3223
|
+
* Subsequent transfer from zeroAddress to a non-zeroAddress
|
|
3224
|
+
* Can happen any number of times to a NFT AssetId as it passes in a cycle from
|
|
3225
|
+
* mint -> burn -> remint -> burn -> remint -> ...
|
|
3226
|
+
*
|
|
3227
|
+
* Invariants:
|
|
3228
|
+
* - NFT is indexed
|
|
3229
|
+
* - previous NFT mint status was `burned`
|
|
3230
|
+
* - previous NFT owner is the zeroAddress
|
|
3231
|
+
* - new NFT mint status is `minted`
|
|
3232
|
+
* - new NFT owner is a non-zeroAddress
|
|
3233
|
+
*/
|
|
3234
|
+
Remint: "remint",
|
|
3235
|
+
/**
|
|
3236
|
+
* Special transfer type for improperly implemented NFT contracts that allow a NFT
|
|
3237
|
+
* that is currently minted to be reminted before an intermediate burn.
|
|
3238
|
+
*
|
|
3239
|
+
* Transfer from zeroAddress to non-zeroAddress for an indexed NFT where the
|
|
3240
|
+
* previously indexed nft had status `minted` with a non-zeroAddress owner.
|
|
3241
|
+
*
|
|
3242
|
+
* Invariants:
|
|
3243
|
+
* - NFT is indexed
|
|
3244
|
+
* - previous NFT mint status was `minted`
|
|
3245
|
+
* - previous NFT owner was a non-zeroAddress
|
|
3246
|
+
* - new NFT mint status is `minted`
|
|
3247
|
+
* - new NFT owner is a non-zeroAddress
|
|
3248
|
+
*/
|
|
3249
|
+
MintedRemint: "minted-remint",
|
|
3250
|
+
/**
|
|
3251
|
+
* Transfer from a non-zeroAddress to zeroAddress
|
|
3252
|
+
*
|
|
3253
|
+
* Invariants:
|
|
3254
|
+
* - NFT is indexed
|
|
3255
|
+
* - previous NFT mint status was `minted`
|
|
3256
|
+
* - previous NFT owner is a non-zeroAddress
|
|
3257
|
+
* - new NFT mint status is `burned`
|
|
3258
|
+
* - new NFT owner is the zeroAddress
|
|
3259
|
+
*/
|
|
3260
|
+
Burn: "burn",
|
|
3261
|
+
/**
|
|
3262
|
+
* Transfer from a non-zeroAddress to a distinct non-zeroAddress
|
|
3263
|
+
*
|
|
3264
|
+
* Invariants:
|
|
3265
|
+
* - NFT is indexed
|
|
3266
|
+
* - previous and new NFT mint status is `minted`
|
|
3267
|
+
* - previous and new NFT owner are distinct non-zeroAddress
|
|
3268
|
+
*/
|
|
3269
|
+
Transfer: "transfer",
|
|
3270
|
+
/**
|
|
3271
|
+
* Transfer from a non-zeroAddress to the same non-zeroAddress
|
|
3272
|
+
*
|
|
3273
|
+
* Invariants:
|
|
3274
|
+
* - NFT is indexed
|
|
3275
|
+
* - previous and new NFT mint status is `minted`
|
|
3276
|
+
* - previous and new NFT owner are equivalent non-zeroAddress
|
|
3277
|
+
*/
|
|
3278
|
+
SelfTransfer: "self-transfer",
|
|
3279
|
+
/**
|
|
3280
|
+
* Transfer from zeroAddress to zeroAddress for an indexed NFT
|
|
3281
|
+
*
|
|
3282
|
+
* Invariants:
|
|
3283
|
+
* - NFT is indexed
|
|
3284
|
+
* - previous and new NFT mint status is `burned`
|
|
3285
|
+
* - previous and new NFT owner are zeroAddress
|
|
3286
|
+
*/
|
|
3287
|
+
RemintBurn: "remint-burn",
|
|
3288
|
+
/**
|
|
3289
|
+
* Special transfer type for improperly implemented NFT contracts that allow a NFT
|
|
3290
|
+
* that is currently minted to be reminted again before an intermediate burn.
|
|
3291
|
+
*
|
|
3292
|
+
* Transfer from zeroAddress to zeroAddress for an indexed NFT where the
|
|
3293
|
+
* previously indexed nft had status `minted` with a non-zeroAddress owner.
|
|
3294
|
+
*
|
|
3295
|
+
* Invariants:
|
|
3296
|
+
* - NFT is indexed
|
|
3297
|
+
* - previous NFT mint status was `minted`
|
|
3298
|
+
* - previous NFT owner was a non-zeroAddress
|
|
3299
|
+
* - new NFT mint status is `burned`
|
|
3300
|
+
* - new NFT owner is the zeroAddress
|
|
3301
|
+
*/
|
|
3302
|
+
MintedRemintBurn: "minted-remint-burn",
|
|
3303
|
+
/**
|
|
3304
|
+
* Transfer from zeroAddress to zeroAddress for an unindexed NFT
|
|
3305
|
+
*
|
|
3306
|
+
* Invariants:
|
|
3307
|
+
* - NFT is not indexed and therefore has no previous mint status or owner
|
|
3308
|
+
* - NFT should remain unindexed and without any mint status or owner
|
|
3309
|
+
*/
|
|
3310
|
+
MintBurn: "mint-burn"
|
|
3311
|
+
};
|
|
3312
|
+
var getNFTTransferType = (from, to, allowMintedRemint, metadata, currentlyIndexedOwner) => {
|
|
3313
|
+
const isIndexed = currentlyIndexedOwner !== void 0;
|
|
3314
|
+
const isIndexedAsMinted = isIndexed && !isAddressEqual3(currentlyIndexedOwner, zeroAddress3);
|
|
3315
|
+
const isMint = isAddressEqual3(from, zeroAddress3);
|
|
3316
|
+
const isBurn = isAddressEqual3(to, zeroAddress3);
|
|
3317
|
+
const isSelfTransfer = isAddressEqual3(from, to);
|
|
3318
|
+
if (isIndexed && !isAddressEqual3(currentlyIndexedOwner, from)) {
|
|
3319
|
+
if (isMint && allowMintedRemint) {
|
|
3320
|
+
} else {
|
|
3321
|
+
throw new Error(
|
|
3322
|
+
`Error: Sending from ${from} conflicts with currently indexed owner ${currentlyIndexedOwner}.
|
|
3323
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3324
|
+
);
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
if (isSelfTransfer) {
|
|
3328
|
+
if (isMint) {
|
|
3329
|
+
if (!isIndexed) {
|
|
3330
|
+
return NFTTransferTypes.MintBurn;
|
|
3331
|
+
} else if (!isIndexedAsMinted) {
|
|
3332
|
+
return NFTTransferTypes.RemintBurn;
|
|
3333
|
+
} else if (allowMintedRemint) {
|
|
3334
|
+
return NFTTransferTypes.MintedRemintBurn;
|
|
3335
|
+
} else {
|
|
3336
|
+
throw new Error(
|
|
3337
|
+
`Error: Invalid state transition from minted -> remint-burn
|
|
3338
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3341
|
+
} else {
|
|
3342
|
+
if (!isIndexed) {
|
|
3343
|
+
throw new Error(
|
|
3344
|
+
`Error: Invalid state transition from unindexed -> self-transfer
|
|
3345
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3346
|
+
);
|
|
3347
|
+
} else if (!isIndexedAsMinted) {
|
|
3348
|
+
throw new Error(
|
|
3349
|
+
`Error: invalid state transition from burned -> self-transfer
|
|
3350
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3351
|
+
);
|
|
3352
|
+
} else {
|
|
3353
|
+
return NFTTransferTypes.SelfTransfer;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
} else if (isMint) {
|
|
3357
|
+
if (!isIndexed) {
|
|
3358
|
+
return NFTTransferTypes.Mint;
|
|
3359
|
+
} else if (!isIndexedAsMinted) {
|
|
3360
|
+
return NFTTransferTypes.Remint;
|
|
3361
|
+
} else if (allowMintedRemint) {
|
|
3362
|
+
return NFTTransferTypes.MintedRemint;
|
|
3363
|
+
} else {
|
|
3364
|
+
throw new Error(
|
|
3365
|
+
`Error: Invalid state transition from minted -> mint
|
|
3366
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3367
|
+
);
|
|
3368
|
+
}
|
|
3369
|
+
} else if (isBurn) {
|
|
3370
|
+
if (!isIndexed) {
|
|
3371
|
+
throw new Error(
|
|
3372
|
+
`Error: Invalid state transition from unindexed -> burn
|
|
3373
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3374
|
+
);
|
|
3375
|
+
} else if (!isIndexedAsMinted) {
|
|
3376
|
+
throw new Error(
|
|
3377
|
+
`Error: Invalid state transition from burned -> burn
|
|
3378
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3379
|
+
);
|
|
3380
|
+
} else {
|
|
3381
|
+
return NFTTransferTypes.Burn;
|
|
3382
|
+
}
|
|
3383
|
+
} else {
|
|
3384
|
+
if (!isIndexed) {
|
|
3385
|
+
throw new Error(
|
|
3386
|
+
`Error: Invalid state transition from unindexed -> transfer
|
|
3387
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3388
|
+
);
|
|
3389
|
+
} else if (!isIndexedAsMinted) {
|
|
3390
|
+
throw new Error(
|
|
3391
|
+
`Error: Invalid state transition from burned -> transfer
|
|
3392
|
+
${formatNFTTransferEventMetadata(metadata)}`
|
|
3393
|
+
);
|
|
3394
|
+
} else {
|
|
3395
|
+
return NFTTransferTypes.Transfer;
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
};
|
|
3399
|
+
|
|
2754
3400
|
// src/tracing/index.ts
|
|
2755
3401
|
var TraceableENSProtocol = /* @__PURE__ */ ((TraceableENSProtocol2) => {
|
|
2756
3402
|
TraceableENSProtocol2["ForwardResolution"] = "forward-resolution";
|
|
@@ -2785,6 +3431,7 @@ export {
|
|
|
2785
3431
|
ATTR_PROTOCOL_NAME,
|
|
2786
3432
|
ATTR_PROTOCOL_STEP,
|
|
2787
3433
|
ATTR_PROTOCOL_STEP_RESULT,
|
|
3434
|
+
AssetNamespaces,
|
|
2788
3435
|
BASENAMES_NODE,
|
|
2789
3436
|
ChainIndexingConfigTypeIds,
|
|
2790
3437
|
ChainIndexingStatusIds,
|
|
@@ -2798,26 +3445,31 @@ export {
|
|
|
2798
3445
|
ETH_COIN_TYPE,
|
|
2799
3446
|
ETH_NODE,
|
|
2800
3447
|
ForwardResolutionProtocolStep,
|
|
2801
|
-
ITEMS_PER_PAGE_DEFAULT,
|
|
2802
|
-
ITEMS_PER_PAGE_MAX,
|
|
2803
3448
|
IndexingStatusResponseCodes,
|
|
2804
3449
|
LINEANAMES_NODE,
|
|
2805
3450
|
LruCache,
|
|
3451
|
+
NFTMintStatuses,
|
|
3452
|
+
NFTTransferTypes,
|
|
2806
3453
|
OmnichainIndexingStatusIds,
|
|
2807
3454
|
PROTOCOL_ATTRIBUTE_PREFIX,
|
|
2808
|
-
PaginatedAggregatedReferrersResponseCodes,
|
|
2809
3455
|
PluginName,
|
|
3456
|
+
RECORDS_PER_PAGE_DEFAULT,
|
|
3457
|
+
RECORDS_PER_PAGE_MAX,
|
|
2810
3458
|
ROOT_NODE,
|
|
3459
|
+
ReferrerDetailResponseCodes,
|
|
3460
|
+
ReferrerLeaderboardPageResponseCodes,
|
|
2811
3461
|
RegistrarActionTypes,
|
|
2812
3462
|
RegistrarActionsFilterTypes,
|
|
2813
3463
|
RegistrarActionsOrders,
|
|
2814
3464
|
RegistrarActionsResponseCodes,
|
|
2815
3465
|
ResolutionStatusIds,
|
|
2816
3466
|
ReverseResolutionProtocolStep,
|
|
3467
|
+
SWRCache,
|
|
2817
3468
|
TheGraphCannotFallbackReasonSchema,
|
|
2818
3469
|
TheGraphFallbackSchema,
|
|
2819
3470
|
TraceableENSProtocol,
|
|
2820
3471
|
TtlCache,
|
|
3472
|
+
ZERO_ENCODED_REFERRER,
|
|
2821
3473
|
accountIdEqual,
|
|
2822
3474
|
addDuration,
|
|
2823
3475
|
addPrices,
|
|
@@ -2826,6 +3478,7 @@ export {
|
|
|
2826
3478
|
beautifyName,
|
|
2827
3479
|
bigIntToNumber,
|
|
2828
3480
|
bigintToCoinType,
|
|
3481
|
+
buildAssetId,
|
|
2829
3482
|
buildEnsRainbowClientLabelSet,
|
|
2830
3483
|
buildLabelSetId,
|
|
2831
3484
|
buildLabelSetVersion,
|
|
@@ -2847,6 +3500,7 @@ export {
|
|
|
2847
3500
|
deserializeBlockrange,
|
|
2848
3501
|
deserializeChainId,
|
|
2849
3502
|
deserializeChainIndexingStatusSnapshot,
|
|
3503
|
+
deserializeConfigResponse,
|
|
2850
3504
|
deserializeCrossChainIndexingStatusSnapshot,
|
|
2851
3505
|
deserializeDatetime,
|
|
2852
3506
|
deserializeDuration,
|
|
@@ -2855,17 +3509,21 @@ export {
|
|
|
2855
3509
|
deserializeErrorResponse,
|
|
2856
3510
|
deserializeIndexingStatusResponse,
|
|
2857
3511
|
deserializeOmnichainIndexingStatusSnapshot,
|
|
2858
|
-
deserializePaginatedAggregatedReferrersResponse,
|
|
2859
3512
|
deserializeRealtimeIndexingStatusProjection,
|
|
3513
|
+
deserializeReferrerDetailResponse,
|
|
3514
|
+
deserializeReferrerLeaderboardPageResponse,
|
|
2860
3515
|
deserializeRegistrarActionsResponse,
|
|
2861
3516
|
deserializeUnixTimestamp,
|
|
2862
3517
|
deserializeUrl,
|
|
2863
3518
|
durationBetween,
|
|
2864
3519
|
encodeLabelHash,
|
|
2865
3520
|
evmChainIdToCoinType,
|
|
3521
|
+
formatNFTTransferEventMetadata,
|
|
2866
3522
|
getCurrencyInfo,
|
|
2867
3523
|
getENSRootChainId,
|
|
2868
3524
|
getEthnamesSubregistryId,
|
|
3525
|
+
getLatestIndexedBlockRef,
|
|
3526
|
+
getNFTTransferType,
|
|
2869
3527
|
getNameHierarchy,
|
|
2870
3528
|
getOmnichainIndexingCursor,
|
|
2871
3529
|
getOmnichainIndexingStatus,
|
|
@@ -2903,8 +3561,10 @@ export {
|
|
|
2903
3561
|
registrarActionsPrerequisites,
|
|
2904
3562
|
reverseName,
|
|
2905
3563
|
serializeAccountId,
|
|
3564
|
+
serializeAssetId,
|
|
2906
3565
|
serializeChainId,
|
|
2907
3566
|
serializeChainIndexingSnapshots,
|
|
3567
|
+
serializeConfigResponse,
|
|
2908
3568
|
serializeCrossChainIndexingStatusSnapshotOmnichain,
|
|
2909
3569
|
serializeDatetime,
|
|
2910
3570
|
serializeENSApiPublicConfig,
|
|
@@ -2913,10 +3573,11 @@ export {
|
|
|
2913
3573
|
serializeIndexingStatusResponse,
|
|
2914
3574
|
serializeNamedRegistrarAction,
|
|
2915
3575
|
serializeOmnichainIndexingStatusSnapshot,
|
|
2916
|
-
serializePaginatedAggregatedReferrersResponse,
|
|
2917
3576
|
serializePrice,
|
|
2918
3577
|
serializePriceEth,
|
|
2919
3578
|
serializeRealtimeIndexingStatusProjection,
|
|
3579
|
+
serializeReferrerDetailResponse,
|
|
3580
|
+
serializeReferrerLeaderboardPageResponse,
|
|
2920
3581
|
serializeRegistrarAction,
|
|
2921
3582
|
serializeRegistrarActionPricing,
|
|
2922
3583
|
serializeRegistrarActionsResponse,
|
|
@@ -2924,12 +3585,10 @@ export {
|
|
|
2924
3585
|
serializeSubregistry,
|
|
2925
3586
|
serializeUrl,
|
|
2926
3587
|
sortChainStatusesByStartBlockAsc,
|
|
2927
|
-
staleWhileRevalidate,
|
|
2928
3588
|
stripNullBytes,
|
|
2929
3589
|
translateDefaultableChainIdToChainId,
|
|
2930
3590
|
uint256ToHex32,
|
|
2931
3591
|
uniq,
|
|
2932
|
-
validateSupportedLabelSetAndVersion
|
|
2933
|
-
zeroEncodedReferrer
|
|
3592
|
+
validateSupportedLabelSetAndVersion
|
|
2934
3593
|
};
|
|
2935
3594
|
//# sourceMappingURL=index.js.map
|