@ensnode/ensnode-sdk 1.1.0 → 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.js CHANGED
@@ -1,11 +1,10 @@
1
- // src/api/deserialize.ts
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/api/zod-schemas.ts
5
- import { namehash as namehash2 } from "viem";
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/indexing-status/zod-schemas.ts
7
+ // src/ensindexer/config/zod-schemas.ts
9
8
  import z2 from "zod/v4";
10
9
 
11
10
  // src/ens/is-normalized.ts
@@ -884,6 +883,272 @@ function isWebSocketProtocol(url) {
884
883
  return ["ws:", "wss:"].includes(url.protocol);
885
884
  }
886
885
 
886
+ // src/ensindexer/config/is-subgraph-compatible.ts
887
+ import { ENSNamespaceIds as ENSNamespaceIds2 } from "@ensnode/datasources";
888
+
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 || {});
900
+
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
+
887
1152
  // src/ensindexer/indexing-status/types.ts
888
1153
  var ChainIndexingConfigTypeIds = {
889
1154
  /**
@@ -1338,52 +1603,52 @@ function invariant_realtimeIndexingStatusProjectionWorstCaseDistanceIsCorrect(ct
1338
1603
  }
1339
1604
 
1340
1605
  // src/ensindexer/indexing-status/zod-schemas.ts
1341
- var makeChainIndexingConfigSchema = (valueLabel = "Value") => z2.discriminatedUnion("configType", [
1342
- z2.strictObject({
1343
- configType: z2.literal(ChainIndexingConfigTypeIds.Indefinite),
1606
+ var makeChainIndexingConfigSchema = (valueLabel = "Value") => z4.discriminatedUnion("configType", [
1607
+ z4.strictObject({
1608
+ configType: z4.literal(ChainIndexingConfigTypeIds.Indefinite),
1344
1609
  startBlock: makeBlockRefSchema(valueLabel)
1345
1610
  }),
1346
- z2.strictObject({
1347
- configType: z2.literal(ChainIndexingConfigTypeIds.Definite),
1611
+ z4.strictObject({
1612
+ configType: z4.literal(ChainIndexingConfigTypeIds.Definite),
1348
1613
  startBlock: makeBlockRefSchema(valueLabel),
1349
1614
  endBlock: makeBlockRefSchema(valueLabel)
1350
1615
  })
1351
1616
  ]);
1352
- var makeChainIndexingStatusSnapshotQueuedSchema = (valueLabel = "Value") => z2.strictObject({
1353
- chainStatus: z2.literal(ChainIndexingStatusIds.Queued),
1617
+ var makeChainIndexingStatusSnapshotQueuedSchema = (valueLabel = "Value") => z4.strictObject({
1618
+ chainStatus: z4.literal(ChainIndexingStatusIds.Queued),
1354
1619
  config: makeChainIndexingConfigSchema(valueLabel)
1355
1620
  }).check(invariant_chainSnapshotQueuedBlocks);
1356
- var makeChainIndexingStatusSnapshotBackfillSchema = (valueLabel = "Value") => z2.strictObject({
1357
- chainStatus: z2.literal(ChainIndexingStatusIds.Backfill),
1621
+ var makeChainIndexingStatusSnapshotBackfillSchema = (valueLabel = "Value") => z4.strictObject({
1622
+ chainStatus: z4.literal(ChainIndexingStatusIds.Backfill),
1358
1623
  config: makeChainIndexingConfigSchema(valueLabel),
1359
1624
  latestIndexedBlock: makeBlockRefSchema(valueLabel),
1360
1625
  backfillEndBlock: makeBlockRefSchema(valueLabel)
1361
1626
  }).check(invariant_chainSnapshotBackfillBlocks);
1362
- var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") => z2.strictObject({
1363
- chainStatus: z2.literal(ChainIndexingStatusIds.Completed),
1364
- config: z2.strictObject({
1365
- configType: z2.literal(ChainIndexingConfigTypeIds.Definite),
1627
+ var makeChainIndexingStatusSnapshotCompletedSchema = (valueLabel = "Value") => z4.strictObject({
1628
+ chainStatus: z4.literal(ChainIndexingStatusIds.Completed),
1629
+ config: z4.strictObject({
1630
+ configType: z4.literal(ChainIndexingConfigTypeIds.Definite),
1366
1631
  startBlock: makeBlockRefSchema(valueLabel),
1367
1632
  endBlock: makeBlockRefSchema(valueLabel)
1368
1633
  }),
1369
1634
  latestIndexedBlock: makeBlockRefSchema(valueLabel)
1370
1635
  }).check(invariant_chainSnapshotCompletedBlocks);
1371
- var makeChainIndexingStatusSnapshotFollowingSchema = (valueLabel = "Value") => z2.strictObject({
1372
- chainStatus: z2.literal(ChainIndexingStatusIds.Following),
1373
- config: z2.strictObject({
1374
- configType: z2.literal(ChainIndexingConfigTypeIds.Indefinite),
1636
+ var makeChainIndexingStatusSnapshotFollowingSchema = (valueLabel = "Value") => z4.strictObject({
1637
+ chainStatus: z4.literal(ChainIndexingStatusIds.Following),
1638
+ config: z4.strictObject({
1639
+ configType: z4.literal(ChainIndexingConfigTypeIds.Indefinite),
1375
1640
  startBlock: makeBlockRefSchema(valueLabel)
1376
1641
  }),
1377
1642
  latestIndexedBlock: makeBlockRefSchema(valueLabel),
1378
1643
  latestKnownBlock: makeBlockRefSchema(valueLabel)
1379
1644
  }).check(invariant_chainSnapshotFollowingBlocks);
1380
- var makeChainIndexingStatusSnapshotSchema = (valueLabel = "Value") => z2.discriminatedUnion("chainStatus", [
1645
+ var makeChainIndexingStatusSnapshotSchema = (valueLabel = "Value") => z4.discriminatedUnion("chainStatus", [
1381
1646
  makeChainIndexingStatusSnapshotQueuedSchema(valueLabel),
1382
1647
  makeChainIndexingStatusSnapshotBackfillSchema(valueLabel),
1383
1648
  makeChainIndexingStatusSnapshotCompletedSchema(valueLabel),
1384
1649
  makeChainIndexingStatusSnapshotFollowingSchema(valueLabel)
1385
1650
  ]);
1386
- var makeChainIndexingStatusesSchema = (valueLabel = "Value") => z2.record(makeChainIdStringSchema(), makeChainIndexingStatusSnapshotSchema(valueLabel), {
1651
+ var makeChainIndexingStatusesSchema = (valueLabel = "Value") => z4.record(makeChainIdStringSchema(), makeChainIndexingStatusSnapshotSchema(valueLabel), {
1387
1652
  error: "Chains indexing statuses must be an object mapping valid chain IDs to their indexing status snapshots."
1388
1653
  }).transform((serializedChainsIndexingStatus) => {
1389
1654
  const chainsIndexingStatus = /* @__PURE__ */ new Map();
@@ -1392,29 +1657,29 @@ var makeChainIndexingStatusesSchema = (valueLabel = "Value") => z2.record(makeCh
1392
1657
  }
1393
1658
  return chainsIndexingStatus;
1394
1659
  });
1395
- var makeOmnichainIndexingStatusSnapshotUnstartedSchema = (valueLabel) => z2.strictObject({
1396
- omnichainStatus: z2.literal(OmnichainIndexingStatusIds.Unstarted),
1660
+ var makeOmnichainIndexingStatusSnapshotUnstartedSchema = (valueLabel) => z4.strictObject({
1661
+ omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Unstarted),
1397
1662
  chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainSnapshotUnstartedHasValidChains).transform((chains) => chains),
1398
1663
  omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
1399
1664
  });
1400
- var makeOmnichainIndexingStatusSnapshotBackfillSchema = (valueLabel) => z2.strictObject({
1401
- omnichainStatus: z2.literal(OmnichainIndexingStatusIds.Backfill),
1665
+ var makeOmnichainIndexingStatusSnapshotBackfillSchema = (valueLabel) => z4.strictObject({
1666
+ omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Backfill),
1402
1667
  chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainStatusSnapshotBackfillHasValidChains).transform(
1403
1668
  (chains) => chains
1404
1669
  ),
1405
1670
  omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
1406
1671
  });
1407
- var makeOmnichainIndexingStatusSnapshotCompletedSchema = (valueLabel) => z2.strictObject({
1408
- omnichainStatus: z2.literal(OmnichainIndexingStatusIds.Completed),
1672
+ var makeOmnichainIndexingStatusSnapshotCompletedSchema = (valueLabel) => z4.strictObject({
1673
+ omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Completed),
1409
1674
  chains: makeChainIndexingStatusesSchema(valueLabel).check(invariant_omnichainStatusSnapshotCompletedHasValidChains).transform((chains) => chains),
1410
1675
  omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
1411
1676
  });
1412
- var makeOmnichainIndexingStatusSnapshotFollowingSchema = (valueLabel) => z2.strictObject({
1413
- omnichainStatus: z2.literal(OmnichainIndexingStatusIds.Following),
1677
+ var makeOmnichainIndexingStatusSnapshotFollowingSchema = (valueLabel) => z4.strictObject({
1678
+ omnichainStatus: z4.literal(OmnichainIndexingStatusIds.Following),
1414
1679
  chains: makeChainIndexingStatusesSchema(valueLabel),
1415
1680
  omnichainIndexingCursor: makeUnixTimestampSchema(valueLabel)
1416
1681
  });
1417
- var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexing Snapshot") => z2.discriminatedUnion("omnichainStatus", [
1682
+ var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexing Snapshot") => z4.discriminatedUnion("omnichainStatus", [
1418
1683
  makeOmnichainIndexingStatusSnapshotUnstartedSchema(valueLabel),
1419
1684
  makeOmnichainIndexingStatusSnapshotBackfillSchema(valueLabel),
1420
1685
  makeOmnichainIndexingStatusSnapshotCompletedSchema(valueLabel),
@@ -1422,232 +1687,230 @@ var makeOmnichainIndexingStatusSnapshotSchema = (valueLabel = "Omnichain Indexin
1422
1687
  ]).check(invariant_omnichainSnapshotStatusIsConsistentWithChainSnapshot).check(invariant_omnichainIndexingCursorLowerThanEarliestStartBlockAcrossQueuedChains).check(
1423
1688
  invariant_omnichainIndexingCursorLowerThanOrEqualToLatestBackfillEndBlockAcrossBackfillChains
1424
1689
  ).check(invariant_omnichainIndexingCursorIsEqualToHighestLatestIndexedBlockAcrossIndexedChain);
1425
- var makeCrossChainIndexingStatusSnapshotOmnichainSchema = (valueLabel = "Cross-chain Indexing Status Snapshot Omnichain") => z2.strictObject({
1426
- strategy: z2.literal(CrossChainIndexingStrategyIds.Omnichain),
1690
+ var makeCrossChainIndexingStatusSnapshotOmnichainSchema = (valueLabel = "Cross-chain Indexing Status Snapshot Omnichain") => z4.strictObject({
1691
+ strategy: z4.literal(CrossChainIndexingStrategyIds.Omnichain),
1427
1692
  slowestChainIndexingCursor: makeUnixTimestampSchema(valueLabel),
1428
1693
  snapshotTime: makeUnixTimestampSchema(valueLabel),
1429
1694
  omnichainSnapshot: makeOmnichainIndexingStatusSnapshotSchema(valueLabel)
1430
1695
  }).check(invariant_slowestChainEqualsToOmnichainSnapshotTime).check(invariant_snapshotTimeIsTheHighestKnownBlockTimestamp);
1431
- var makeCrossChainIndexingStatusSnapshotSchema = (valueLabel = "Cross-chain Indexing Status Snapshot") => z2.discriminatedUnion("strategy", [
1696
+ var makeCrossChainIndexingStatusSnapshotSchema = (valueLabel = "Cross-chain Indexing Status Snapshot") => z4.discriminatedUnion("strategy", [
1432
1697
  makeCrossChainIndexingStatusSnapshotOmnichainSchema(valueLabel)
1433
1698
  ]);
1434
- var makeRealtimeIndexingStatusProjectionSchema = (valueLabel = "Realtime Indexing Status Projection") => z2.strictObject({
1699
+ var makeRealtimeIndexingStatusProjectionSchema = (valueLabel = "Realtime Indexing Status Projection") => z4.strictObject({
1435
1700
  projectedAt: makeUnixTimestampSchema(valueLabel),
1436
1701
  worstCaseDistance: makeDurationSchema(valueLabel),
1437
1702
  snapshot: makeCrossChainIndexingStatusSnapshotSchema(valueLabel)
1438
1703
  }).check(invariant_realtimeIndexingStatusProjectionProjectedAtIsAfterOrEqualToSnapshotTime).check(invariant_realtimeIndexingStatusProjectionWorstCaseDistanceIsCorrect);
1439
1704
 
1440
- // src/ensindexer/config/zod-schemas.ts
1441
- import z3 from "zod/v4";
1442
-
1443
- // src/ensindexer/config/is-subgraph-compatible.ts
1444
- import { ENSNamespaceIds as ENSNamespaceIds2 } from "@ensnode/datasources";
1445
-
1446
- // src/ensindexer/config/types.ts
1447
- var PluginName = /* @__PURE__ */ ((PluginName2) => {
1448
- PluginName2["Subgraph"] = "subgraph";
1449
- PluginName2["Basenames"] = "basenames";
1450
- PluginName2["Lineanames"] = "lineanames";
1451
- PluginName2["ThreeDNS"] = "threedns";
1452
- PluginName2["ProtocolAcceleration"] = "protocol-acceleration";
1453
- PluginName2["Registrars"] = "registrars";
1454
- PluginName2["TokenScope"] = "tokenscope";
1455
- return PluginName2;
1456
- })(PluginName || {});
1457
-
1458
- // src/ensindexer/config/is-subgraph-compatible.ts
1459
- function isSubgraphCompatible(config) {
1460
- const onlySubgraphPluginActivated = config.plugins.length === 1 && config.plugins[0] === "subgraph" /* Subgraph */;
1461
- const isSubgraphLabelSet = config.labelSet.labelSetId === "subgraph" && config.labelSet.labelSetVersion === 0;
1462
- const isEnsTestEnvLabelSet = config.labelSet.labelSetId === "ens-test-env" && config.labelSet.labelSetVersion === 0;
1463
- const labelSetIsSubgraphCompatible = isSubgraphLabelSet || config.namespace === ENSNamespaceIds2.EnsTestEnv && isEnsTestEnvLabelSet;
1464
- return onlySubgraphPluginActivated && labelSetIsSubgraphCompatible;
1465
- }
1466
-
1467
- // src/ensindexer/config/validations.ts
1468
- function invariant_ensDbVersionIsSameAsEnsIndexerVersion(ctx) {
1469
- const versionInfo = ctx.value;
1470
- if (versionInfo.ensDb !== versionInfo.ensIndexer) {
1471
- ctx.issues.push({
1472
- code: "custom",
1473
- input: versionInfo,
1474
- message: "`ensDb` version must be same as `ensIndexer` version"
1475
- });
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
+ );
1476
1715
  }
1716
+ return parsed.data;
1477
1717
  }
1478
-
1479
- // src/ensindexer/config/zod-schemas.ts
1480
- var makeIndexedChainIdsSchema = (valueLabel = "Indexed Chain IDs") => z3.array(makeChainIdSchema(valueLabel), {
1481
- error: `${valueLabel} must be an array.`
1482
- }).min(1, { error: `${valueLabel} list must include at least one element.` }).transform((v) => new Set(v));
1483
- var makePluginsListSchema = (valueLabel = "Plugins") => z3.array(z3.string(), {
1484
- error: `${valueLabel} must be a list of strings.`
1485
- }).min(1, {
1486
- error: `${valueLabel} must be a list of strings with at least one string value`
1487
- }).refine((arr) => arr.length === uniq(arr).length, {
1488
- error: `${valueLabel} cannot contain duplicate values.`
1489
- });
1490
- var makeDatabaseSchemaNameSchema = (valueLabel = "Database schema name") => z3.string({ error: `${valueLabel} must be a string` }).trim().nonempty({
1491
- error: `${valueLabel} is required and must be a non-empty string.`
1492
- });
1493
- var makeLabelSetIdSchema = (valueLabel) => {
1494
- 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-]+$/, {
1495
- error: `${valueLabel} can only contain lowercase letters (a-z) and hyphens (-)`
1496
- });
1497
- };
1498
- var makeLabelSetVersionSchema = (valueLabel) => {
1499
- return z3.coerce.number({ error: `${valueLabel} must be an integer.` }).pipe(makeNonNegativeIntegerSchema(valueLabel));
1500
- };
1501
- var makeFullyPinnedLabelSetSchema = (valueLabel = "Label set") => {
1502
- let valueLabelLabelSetId = valueLabel;
1503
- let valueLabelLabelSetVersion = valueLabel;
1504
- if (valueLabel === "LABEL_SET") {
1505
- valueLabelLabelSetId = "LABEL_SET_ID";
1506
- valueLabelLabelSetVersion = "LABEL_SET_VERSION";
1507
- } else {
1508
- valueLabelLabelSetId = `${valueLabel}.labelSetId`;
1509
- valueLabelLabelSetVersion = `${valueLabel}.labelSetVersion`;
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
+ );
1510
1727
  }
1511
- return z3.object({
1512
- labelSetId: makeLabelSetIdSchema(valueLabelLabelSetId),
1513
- labelSetVersion: makeLabelSetVersionSchema(valueLabelLabelSetVersion)
1514
- });
1515
- };
1516
- var makeNonEmptyStringSchema = (valueLabel = "Value") => z3.string().nonempty({ error: `${valueLabel} must be a non-empty string.` });
1517
- var makeENSIndexerVersionInfoSchema = (valueLabel = "Value") => z3.strictObject(
1518
- {
1519
- nodejs: makeNonEmptyStringSchema(),
1520
- ponder: makeNonEmptyStringSchema(),
1521
- ensDb: makeNonEmptyStringSchema(),
1522
- ensIndexer: makeNonEmptyStringSchema(),
1523
- ensNormalize: makeNonEmptyStringSchema(),
1524
- ensRainbow: makeNonEmptyStringSchema(),
1525
- ensRainbowSchema: makePositiveIntegerSchema()
1526
- },
1527
- {
1528
- error: `${valueLabel} must be a valid ENSIndexerVersionInfo object.`
1728
+ return parsed.data;
1729
+ }
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
+ );
1529
1739
  }
1530
- ).check(invariant_ensDbVersionIsSameAsEnsIndexerVersion);
1531
- function invariant_isSubgraphCompatibleRequirements(ctx) {
1532
- const { value: config } = ctx;
1533
- if (config.isSubgraphCompatible && !isSubgraphCompatible(config)) {
1534
- ctx.issues.push({
1535
- code: "custom",
1536
- input: config,
1537
- message: `'isSubgraphCompatible' requires only the '${"subgraph" /* Subgraph */}' plugin to be active and labelSet must be {labelSetId: "subgraph", labelSetVersion: 0}`
1538
- });
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
+ );
1539
1751
  }
1752
+ return parsed.data;
1540
1753
  }
1541
- var makeENSIndexerPublicConfigSchema = (valueLabel = "ENSIndexerPublicConfig") => z3.object({
1542
- labelSet: makeFullyPinnedLabelSetSchema(`${valueLabel}.labelSet`),
1543
- indexedChainIds: makeIndexedChainIdsSchema(`${valueLabel}.indexedChainIds`),
1544
- isSubgraphCompatible: z3.boolean({ error: `${valueLabel}.isSubgraphCompatible` }),
1545
- namespace: makeENSNamespaceIdSchema(`${valueLabel}.namespace`),
1546
- plugins: makePluginsListSchema(`${valueLabel}.plugins`),
1547
- databaseSchemaName: makeDatabaseSchemaNameSchema(`${valueLabel}.databaseSchemaName`),
1548
- versionInfo: makeENSIndexerVersionInfoSchema(`${valueLabel}.versionInfo`)
1549
- }).check(invariant_isSubgraphCompatibleRequirements);
1550
-
1551
- // src/shared/config/build-rpc-urls.ts
1552
- import {
1553
- arbitrum,
1554
- arbitrumSepolia,
1555
- base,
1556
- baseSepolia,
1557
- holesky,
1558
- linea,
1559
- lineaSepolia,
1560
- mainnet,
1561
- optimism,
1562
- optimismSepolia,
1563
- scroll,
1564
- scrollSepolia,
1565
- sepolia
1566
- } from "viem/chains";
1567
1754
 
1568
- // src/shared/config/rpc-configs-from-env.ts
1569
- import { getENSNamespace } from "@ensnode/datasources";
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
+ }
1570
1764
 
1571
- // src/shared/config/validatons.ts
1572
- import { getENSRootChainId as getENSRootChainId2 } from "@ensnode/datasources";
1573
- function invariant_rpcEndpointConfigIncludesAtLeastOneHTTPProtocolURL(ctx) {
1574
- const endpoints = ctx.value;
1575
- const httpEndpoints = endpoints.filter(isHttpProtocol);
1576
- if (httpEndpoints.length < 1) {
1577
- ctx.issues.push({
1578
- code: "custom",
1579
- input: endpoints,
1580
- message: `RPC endpoint configuration for a chain must include at least one http/https protocol URL.`
1581
- });
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;
1582
1790
  }
1791
+ return serializedSnapshots;
1583
1792
  }
1584
- function invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL(ctx) {
1585
- const endpoints = ctx.value;
1586
- const wsEndpoints = endpoints.filter(isWebSocketProtocol);
1587
- if (wsEndpoints.length > 1) {
1588
- ctx.issues.push({
1589
- code: "custom",
1590
- input: endpoints,
1591
- message: `RPC endpoint configuration for a chain must include at most one websocket (ws/wss) protocol URL.`
1592
- });
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
+ };
1593
1820
  }
1594
1821
  }
1595
1822
 
1596
- // src/shared/config/zod-schemas.ts
1597
- import { z as z4 } from "zod/v4";
1598
- import { ENSNamespaceIds as ENSNamespaceIds3 } from "@ensnode/datasources";
1599
- var DatabaseSchemaNameSchema = z4.string({
1600
- error: "DATABASE_SCHEMA is required."
1601
- }).trim().min(1, {
1602
- error: "DATABASE_SCHEMA is required and cannot be an empty string."
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
+ }
1832
+
1833
+ // src/api/config/deserialize.ts
1834
+ function deserializeConfigResponse(serializedResponse) {
1835
+ return deserializeENSApiPublicConfig(serializedResponse);
1836
+ }
1837
+
1838
+ // src/api/config/serialize.ts
1839
+ function serializeConfigResponse(response) {
1840
+ return serializeENSApiPublicConfig(response);
1841
+ }
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())
1603
1858
  });
1604
- var RpcConfigSchema = z4.string().transform((val) => val.split(",")).pipe(z4.array(makeUrlSchema("RPC URL"))).check(invariant_rpcEndpointConfigIncludesAtLeastOneHTTPProtocolURL).check(invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL);
1605
- var RpcConfigsSchema = z4.record(makeChainIdStringSchema("RPC URL"), RpcConfigSchema, {
1606
- error: "Chains configuration must be an object mapping valid chain IDs to their configs."
1607
- }).transform((records) => {
1608
- const rpcConfigs = /* @__PURE__ */ new Map();
1609
- for (const [chainIdString, rpcConfig] of Object.entries(records)) {
1610
- const httpRPCs = rpcConfig.filter(isHttpProtocol);
1611
- const websocketRPC = rpcConfig.find(isWebSocketProtocol);
1612
- rpcConfigs.set(deserializeChainId(chainIdString), {
1613
- httpRPCs,
1614
- websocketRPC
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) {
1878
+ ctx.issues.push({
1879
+ code: "custom",
1880
+ input: ctx.value,
1881
+ message: `The 'action.registrationLifecycle.node' must match namehash of 'name'`
1615
1882
  });
1616
1883
  }
1617
- return rpcConfigs;
1884
+ }
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))
1618
1892
  });
1619
- var EnsIndexerUrlSchema = makeUrlSchema("ENSINDEXER_URL");
1620
- var ENSNamespaceSchema = z4.enum(ENSNamespaceIds3, {
1621
- error: ({ input }) => `Invalid NAMESPACE. Got '${input}', but supported ENS namespaces are: ${Object.keys(ENSNamespaceIds3).join(", ")}`
1893
+ var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z6.strictObject({
1894
+ responseCode: z6.literal(RegistrarActionsResponseCodes.Error),
1895
+ error: ErrorResponseSchema
1622
1896
  });
1623
- var PortSchema = z4.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();
1624
- var TheGraphApiKeySchema = z4.string().optional();
1625
-
1626
- // src/shared/datasources-with-resolvers.ts
1627
- import {
1628
- DatasourceNames,
1629
- maybeGetDatasource
1630
- } from "@ensnode/datasources";
1631
- var DATASOURCE_NAMES_WITH_RESOLVERS = [
1632
- DatasourceNames.ENSRoot,
1633
- DatasourceNames.Basenames,
1634
- DatasourceNames.Lineanames,
1635
- DatasourceNames.ThreeDNSOptimism,
1636
- DatasourceNames.ThreeDNSBase
1637
- ];
1897
+ var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z6.discriminatedUnion("responseCode", [
1898
+ makeRegistrarActionsResponseOkSchema(valueLabel),
1899
+ makeRegistrarActionsResponseErrorSchema(valueLabel)
1900
+ ]);
1638
1901
 
1639
- // src/shared/log-level.ts
1640
- import { z as z5 } from "zod/v4";
1641
- var LogLevelSchema = z5.enum(["fatal", "error", "warn", "info", "debug", "trace", "silent"]);
1902
+ // src/api/shared/pagination/zod-schemas.ts
1903
+ import z7 from "zod/v4";
1642
1904
 
1643
- // src/shared/protocol-acceleration/interpret-record-values.ts
1644
- import { isAddress as isAddress3, isAddressEqual as isAddressEqual2, zeroAddress } from "viem";
1905
+ // src/api/shared/pagination/request.ts
1906
+ var RECORDS_PER_PAGE_DEFAULT = 10;
1907
+ var RECORDS_PER_PAGE_MAX = 100;
1645
1908
 
1646
1909
  // ../ens-referrals/src/address.ts
1647
- import { isAddress as isAddress4 } from "viem";
1910
+ import { isAddress as isAddress3 } from "viem";
1648
1911
 
1649
1912
  // ../ens-referrals/src/encoding.ts
1650
- import { getAddress, pad, size as size2, slice, zeroAddress as zeroAddress2 } from "viem";
1913
+ import { getAddress, pad, size as size2, slice, zeroAddress } from "viem";
1651
1914
  var ENCODED_REFERRER_BYTE_OFFSET = 12;
1652
1915
  var ENCODED_REFERRER_BYTE_LENGTH = 32;
1653
1916
  var EXPECTED_ENCODED_REFERRER_PADDING = pad("0x", {
@@ -1666,7 +1929,7 @@ function decodeEncodedReferrer(encodedReferrer) {
1666
1929
  }
1667
1930
  const padding = slice(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
1668
1931
  if (padding !== EXPECTED_ENCODED_REFERRER_PADDING) {
1669
- return zeroAddress2;
1932
+ return zeroAddress;
1670
1933
  }
1671
1934
  const decodedReferrer = slice(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
1672
1935
  try {
@@ -1682,8 +1945,20 @@ var REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
1682
1945
  // ../ens-referrals/src/link.ts
1683
1946
  import { getAddress as getAddress2 } from "viem";
1684
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
+
1685
1960
  // src/registrars/zod-schemas.ts
1686
- import z6 from "zod/v4";
1961
+ import z8 from "zod/v4";
1687
1962
 
1688
1963
  // src/registrars/subregistry.ts
1689
1964
  function serializeSubregistry(subregistry) {
@@ -1741,11 +2016,11 @@ function serializeRegistrarAction(registrarAction) {
1741
2016
  }
1742
2017
 
1743
2018
  // src/registrars/zod-schemas.ts
1744
- var makeSubregistrySchema = (valueLabel = "Subregistry") => z6.object({
2019
+ var makeSubregistrySchema = (valueLabel = "Subregistry") => z8.object({
1745
2020
  subregistryId: makeSerializedAccountIdSchema(`${valueLabel} Subregistry ID`),
1746
2021
  node: makeNodeSchema(`${valueLabel} Node`)
1747
2022
  });
1748
- var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") => z6.object({
2023
+ var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") => z8.object({
1749
2024
  subregistry: makeSubregistrySchema(`${valueLabel} Subregistry`),
1750
2025
  node: makeNodeSchema(`${valueLabel} Node`),
1751
2026
  expiresAt: makeUnixTimestampSchema(`${valueLabel} Expires at`)
@@ -1761,18 +2036,18 @@ function invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium(ctx) {
1761
2036
  });
1762
2037
  }
1763
2038
  }
1764
- var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") => z6.union([
2039
+ var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") => z8.union([
1765
2040
  // pricing available
1766
- z6.object({
2041
+ z8.object({
1767
2042
  baseCost: makePriceEthSchema(`${valueLabel} Base Cost`),
1768
2043
  premium: makePriceEthSchema(`${valueLabel} Premium`),
1769
2044
  total: makePriceEthSchema(`${valueLabel} Total`)
1770
2045
  }).check(invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium).transform((v) => v),
1771
2046
  // pricing unknown
1772
- z6.object({
1773
- baseCost: z6.null(),
1774
- premium: z6.null(),
1775
- total: z6.null()
2047
+ z8.object({
2048
+ baseCost: z8.null(),
2049
+ premium: z8.null(),
2050
+ total: z8.null()
1776
2051
  }).transform((v) => v)
1777
2052
  ]);
1778
2053
  function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
@@ -1795,9 +2070,9 @@ function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
1795
2070
  });
1796
2071
  }
1797
2072
  }
1798
- var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") => z6.union([
2073
+ var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") => z8.union([
1799
2074
  // referral available
1800
- z6.object({
2075
+ z8.object({
1801
2076
  encodedReferrer: makeHexStringSchema(
1802
2077
  { bytesCount: ENCODED_REFERRER_BYTE_LENGTH },
1803
2078
  `${valueLabel} Encoded Referrer`
@@ -1805,9 +2080,9 @@ var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral
1805
2080
  decodedReferrer: makeLowercaseAddressSchema(`${valueLabel} Decoded Referrer`)
1806
2081
  }).check(invariant_registrarActionDecodedReferrerBasedOnRawReferrer),
1807
2082
  // referral not applicable
1808
- z6.object({
1809
- encodedReferrer: z6.null(),
1810
- decodedReferrer: z6.null()
2083
+ z8.object({
2084
+ encodedReferrer: z8.null(),
2085
+ decodedReferrer: z8.null()
1811
2086
  })
1812
2087
  ]);
1813
2088
  function invariant_eventIdsInitialElementIsTheActionId(ctx) {
@@ -1820,9 +2095,9 @@ function invariant_eventIdsInitialElementIsTheActionId(ctx) {
1820
2095
  });
1821
2096
  }
1822
2097
  }
1823
- var EventIdSchema = z6.string().nonempty();
1824
- var EventIdsSchema = z6.array(EventIdSchema).min(1).transform((v) => v);
1825
- var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z6.object({
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({
1826
2101
  id: EventIdSchema,
1827
2102
  incrementalDuration: makeDurationSchema(`${valueLabel} Incremental Duration`),
1828
2103
  registrant: makeLowercaseAddressSchema(`${valueLabel} Registrant`),
@@ -1836,380 +2111,205 @@ var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z6
1836
2111
  eventIds: EventIdsSchema
1837
2112
  }).check(invariant_eventIdsInitialElementIsTheActionId);
1838
2113
  var makeRegistrarActionRegistrationSchema = (valueLabel = "Registration ") => makeBaseRegistrarActionSchema(valueLabel).extend({
1839
- type: z6.literal(RegistrarActionTypes.Registration)
2114
+ type: z8.literal(RegistrarActionTypes.Registration)
1840
2115
  });
1841
2116
  var makeRegistrarActionRenewalSchema = (valueLabel = "Renewal") => makeBaseRegistrarActionSchema(valueLabel).extend({
1842
- type: z6.literal(RegistrarActionTypes.Renewal)
2117
+ type: z8.literal(RegistrarActionTypes.Renewal)
1843
2118
  });
1844
- var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => z6.discriminatedUnion("type", [
2119
+ var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => z8.discriminatedUnion("type", [
1845
2120
  makeRegistrarActionRegistrationSchema(`${valueLabel} Registration`),
1846
2121
  makeRegistrarActionRenewalSchema(`${valueLabel} Renewal`)
1847
2122
  ]);
1848
2123
 
1849
- // src/api/types.ts
1850
- var IndexingStatusResponseCodes = {
1851
- /**
1852
- * Represents that the indexing status is available.
1853
- */
1854
- Ok: "ok",
1855
- /**
1856
- * Represents that the indexing status is unavailable.
1857
- */
1858
- Error: "error"
1859
- };
1860
- var RegistrarActionsFilterTypes = {
1861
- BySubregistryNode: "bySubregistryNode",
1862
- WithEncodedReferral: "withEncodedReferral"
1863
- };
1864
- var RegistrarActionsOrders = {
1865
- LatestRegistrarActions: "orderBy[timestamp]=desc"
1866
- };
1867
- var RegistrarActionsResponseCodes = {
1868
- /**
1869
- * Represents that Registrar Actions are available.
1870
- */
1871
- Ok: "ok",
1872
- /**
1873
- * Represents that Registrar Actions are unavailable.
1874
- */
1875
- Error: "error"
1876
- };
1877
-
1878
- // src/api/zod-schemas.ts
1879
- var ErrorResponseSchema = z7.object({
1880
- message: z7.string(),
1881
- details: z7.optional(z7.unknown())
1882
- });
1883
- var makeIndexingStatusResponseOkSchema = (valueLabel = "Indexing Status Response OK") => z7.strictObject({
1884
- responseCode: z7.literal(IndexingStatusResponseCodes.Ok),
1885
- realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel)
1886
- });
1887
- var makeIndexingStatusResponseErrorSchema = (_valueLabel = "Indexing Status Response Error") => z7.strictObject({
1888
- responseCode: z7.literal(IndexingStatusResponseCodes.Error)
1889
- });
1890
- var makeIndexingStatusResponseSchema = (valueLabel = "Indexing Status Response") => z7.discriminatedUnion("responseCode", [
1891
- makeIndexingStatusResponseOkSchema(valueLabel),
1892
- makeIndexingStatusResponseErrorSchema(valueLabel)
1893
- ]);
1894
- function invariant_registrationLifecycleNodeMatchesName(ctx) {
1895
- const { name, action } = ctx.value;
1896
- const expectedNode = action.registrationLifecycle.node;
1897
- const actualNode = namehash2(name);
1898
- if (actualNode !== expectedNode) {
1899
- ctx.issues.push({
1900
- code: "custom",
1901
- input: ctx.value,
1902
- message: `The 'action.registrationLifecycle.node' must match namehash of 'name'`
1903
- });
1904
- }
1905
- }
1906
- var makeNamedRegistrarActionSchema = (valueLabel = "Named Registrar Action") => z7.object({
1907
- action: makeRegistrarActionSchema(valueLabel),
1908
- name: makeReinterpretedNameSchema(valueLabel)
1909
- }).check(invariant_registrationLifecycleNodeMatchesName);
1910
- var makeRegistrarActionsResponseOkSchema = (valueLabel = "Registrar Actions Response OK") => z7.strictObject({
1911
- responseCode: z7.literal(RegistrarActionsResponseCodes.Ok),
1912
- registrarActions: z7.array(makeNamedRegistrarActionSchema(valueLabel))
1913
- });
1914
- var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z7.strictObject({
1915
- responseCode: z7.literal(RegistrarActionsResponseCodes.Error),
1916
- error: ErrorResponseSchema
1917
- });
1918
- var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z7.discriminatedUnion("responseCode", [
1919
- makeRegistrarActionsResponseOkSchema(valueLabel),
1920
- makeRegistrarActionsResponseErrorSchema(valueLabel)
1921
- ]);
1922
-
1923
- // src/api/deserialize.ts
1924
- function deserializeErrorResponse(maybeErrorResponse) {
1925
- const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse);
1926
- if (parsed.error) {
1927
- throw new Error(`Cannot deserialize ErrorResponse:
1928
- ${prettifyError2(parsed.error)}
1929
- `);
1930
- }
1931
- return parsed.data;
1932
- }
1933
- function deserializeIndexingStatusResponse(maybeResponse) {
1934
- const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse);
1935
- if (parsed.error) {
1936
- throw new Error(`Cannot deserialize IndexingStatusResponse:
1937
- ${prettifyError2(parsed.error)}
1938
- `);
1939
- }
1940
- return parsed.data;
1941
- }
1942
- function deserializeRegistrarActionsResponse(maybeResponse) {
1943
- const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse);
1944
- if (parsed.error) {
1945
- throw new Error(
1946
- `Cannot deserialize RegistrarActionsResponse:
1947
- ${prettifyError2(parsed.error)}
1948
- `
1949
- );
1950
- }
1951
- return parsed.data;
1952
- }
1953
-
1954
- // src/api/registrar-actions/filters.ts
1955
- function byParentNode(parentNode) {
1956
- if (typeof parentNode === "undefined") {
1957
- return void 0;
1958
- }
1959
- return {
1960
- filterType: RegistrarActionsFilterTypes.BySubregistryNode,
1961
- value: parentNode
1962
- };
1963
- }
1964
- function withReferral(withReferral2) {
1965
- if (!withReferral2) {
1966
- return void 0;
1967
- }
1968
- return {
1969
- filterType: RegistrarActionsFilterTypes.WithEncodedReferral
1970
- };
1971
- }
1972
- var registrarActionsFilter = {
1973
- byParentNode,
1974
- withReferral
1975
- };
1976
-
1977
- // src/ensindexer/config/deserialize.ts
1978
- import { prettifyError as prettifyError3 } from "zod/v4";
1979
- function deserializeENSIndexerPublicConfig(maybeConfig, valueLabel) {
1980
- const schema = makeENSIndexerPublicConfigSchema(valueLabel);
1981
- const parsed = schema.safeParse(maybeConfig);
1982
- if (parsed.error) {
1983
- throw new Error(`Cannot deserialize ENSIndexerPublicConfig:
1984
- ${prettifyError3(parsed.error)}
1985
- `);
1986
- }
1987
- return parsed.data;
1988
- }
1989
-
1990
- // src/ensindexer/config/label-utils.ts
1991
- import { hexToBytes as hexToBytes2 } from "viem";
1992
- function labelHashToBytes(labelHash) {
1993
- try {
1994
- if (labelHash.length !== 66) {
1995
- throw new Error(`Invalid labelHash length ${labelHash.length} characters (expected 66)`);
1996
- }
1997
- if (labelHash !== labelHash.toLowerCase()) {
1998
- throw new Error("Labelhash must be in lowercase");
1999
- }
2000
- if (!labelHash.startsWith("0x")) {
2001
- throw new Error("Labelhash must be 0x-prefixed");
2002
- }
2003
- const bytes = hexToBytes2(labelHash);
2004
- if (bytes.length !== 32) {
2005
- throw new Error(`Invalid labelHash length ${bytes.length} bytes (expected 32)`);
2006
- }
2007
- return bytes;
2008
- } catch (e) {
2009
- if (e instanceof Error) {
2010
- throw e;
2011
- }
2012
- throw new Error("Invalid hex format");
2013
- }
2014
- }
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";
2015
2140
 
2016
- // src/ensindexer/config/labelset-utils.ts
2017
- function buildLabelSetId(maybeLabelSetId) {
2018
- return makeLabelSetIdSchema("LabelSetId").parse(maybeLabelSetId);
2019
- }
2020
- function buildLabelSetVersion(maybeLabelSetVersion) {
2021
- return makeLabelSetVersionSchema("LabelSetVersion").parse(maybeLabelSetVersion);
2022
- }
2023
- function buildEnsRainbowClientLabelSet(labelSetId, labelSetVersion) {
2024
- if (labelSetVersion !== void 0 && labelSetId === void 0) {
2025
- throw new Error("When a labelSetVersion is defined, labelSetId must also be defined.");
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
+ });
2026
2155
  }
2027
- return { labelSetId, labelSetVersion };
2028
2156
  }
2029
- function validateSupportedLabelSetAndVersion(serverSet, clientSet) {
2030
- if (clientSet.labelSetId === void 0) {
2031
- return;
2032
- }
2033
- if (serverSet.labelSetId !== clientSet.labelSetId) {
2034
- throw new Error(
2035
- `Server label set ID "${serverSet.labelSetId}" does not match client's requested label set ID "${clientSet.labelSetId}".`
2036
- );
2037
- }
2038
- if (clientSet.labelSetVersion !== void 0 && serverSet.highestLabelSetVersion < clientSet.labelSetVersion) {
2039
- throw new Error(
2040
- `Server highest label set version ${serverSet.highestLabelSetVersion} is less than client's requested version ${clientSet.labelSetVersion} for label set ID "${clientSet.labelSetId}".`
2041
- );
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
+ });
2042
2166
  }
2043
2167
  }
2044
2168
 
2045
- // src/ensindexer/config/parsing.ts
2046
- function parseNonNegativeInteger(maybeNumber) {
2047
- const trimmed = maybeNumber.trim();
2048
- if (!trimmed) {
2049
- throw new Error("Input cannot be empty");
2050
- }
2051
- if (trimmed === "-0") {
2052
- throw new Error("Negative zero is not a valid non-negative integer");
2053
- }
2054
- const num = Number(maybeNumber);
2055
- if (Number.isNaN(num)) {
2056
- throw new Error(`"${maybeNumber}" is not a valid number`);
2057
- }
2058
- if (!Number.isFinite(num)) {
2059
- throw new Error(`"${maybeNumber}" is not a finite number`);
2060
- }
2061
- if (!Number.isInteger(num)) {
2062
- throw new Error(`"${maybeNumber}" is not an integer`);
2063
- }
2064
- if (num < 0) {
2065
- 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
+ });
2066
2189
  }
2067
- return num;
2068
- }
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();
2069
2198
 
2070
- // src/ensindexer/config/serialize.ts
2071
- function serializeIndexedChainIds(indexedChainIds) {
2072
- return Array.from(indexedChainIds);
2073
- }
2074
- function serializeENSIndexerPublicConfig(config) {
2075
- const {
2076
- labelSet,
2077
- indexedChainIds,
2078
- databaseSchemaName,
2079
- isSubgraphCompatible: isSubgraphCompatible2,
2080
- namespace,
2081
- plugins,
2082
- versionInfo
2083
- } = config;
2084
- return {
2085
- labelSet,
2086
- indexedChainIds: serializeIndexedChainIds(indexedChainIds),
2087
- databaseSchemaName,
2088
- isSubgraphCompatible: isSubgraphCompatible2,
2089
- namespace,
2090
- plugins,
2091
- versionInfo
2092
- };
2093
- }
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
+ ];
2094
2211
 
2095
- // src/ensindexer/indexing-status/deserialize.ts
2096
- import { prettifyError as prettifyError4 } from "zod/v4";
2097
- function deserializeChainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
2098
- const schema = makeChainIndexingStatusSnapshotSchema(valueLabel);
2099
- const parsed = schema.safeParse(maybeSnapshot);
2100
- if (parsed.error) {
2101
- throw new Error(
2102
- `Cannot deserialize into ChainIndexingStatusSnapshot:
2103
- ${prettifyError4(parsed.error)}
2104
- `
2105
- );
2106
- }
2107
- return parsed.data;
2108
- }
2109
- function deserializeOmnichainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
2110
- const schema = makeOmnichainIndexingStatusSnapshotSchema(valueLabel);
2111
- const parsed = schema.safeParse(maybeSnapshot);
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);
2112
2247
  if (parsed.error) {
2113
- throw new Error(
2114
- `Cannot deserialize into OmnichainIndexingStatusSnapshot:
2115
- ${prettifyError4(parsed.error)}
2116
- `
2117
- );
2248
+ throw new Error(`Cannot deserialize IndexingStatusResponse:
2249
+ ${prettifyError5(parsed.error)}
2250
+ `);
2118
2251
  }
2119
2252
  return parsed.data;
2120
2253
  }
2121
- function deserializeCrossChainIndexingStatusSnapshot(maybeSnapshot, valueLabel) {
2122
- const schema = makeCrossChainIndexingStatusSnapshotSchema(valueLabel);
2123
- const parsed = schema.safeParse(maybeSnapshot);
2124
- if (parsed.error) {
2125
- throw new Error(
2126
- `Cannot deserialize into CrossChainIndexingStatusSnapshot:
2127
- ${prettifyError4(parsed.error)}
2128
- `
2129
- );
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;
2130
2265
  }
2131
- return parsed.data;
2132
2266
  }
2133
- function deserializeRealtimeIndexingStatusProjection(maybeProjection, valueLabel) {
2134
- const schema = makeRealtimeIndexingStatusProjectionSchema(valueLabel);
2135
- const parsed = schema.safeParse(maybeProjection);
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);
2136
2272
  if (parsed.error) {
2137
2273
  throw new Error(
2138
- `Cannot deserialize into RealtimeIndexingStatusProjection:
2139
- ${prettifyError4(parsed.error)}
2274
+ `Cannot deserialize RegistrarActionsResponse:
2275
+ ${prettifyError6(parsed.error)}
2140
2276
  `
2141
2277
  );
2142
2278
  }
2143
2279
  return parsed.data;
2144
2280
  }
2145
2281
 
2146
- // src/ensindexer/indexing-status/projection.ts
2147
- function createRealtimeIndexingStatusProjection(snapshot, now) {
2148
- const projectedAt = Math.max(now, snapshot.snapshotTime);
2149
- return {
2150
- projectedAt,
2151
- worstCaseDistance: projectedAt - snapshot.slowestChainIndexingCursor,
2152
- snapshot
2153
- };
2154
- }
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
+ };
2155
2290
 
2156
- // src/ensindexer/indexing-status/serialize.ts
2157
- function serializeCrossChainIndexingStatusSnapshotOmnichain({
2158
- strategy,
2159
- slowestChainIndexingCursor,
2160
- snapshotTime,
2161
- omnichainSnapshot
2162
- }) {
2163
- return {
2164
- strategy,
2165
- slowestChainIndexingCursor,
2166
- snapshotTime,
2167
- omnichainSnapshot: serializeOmnichainIndexingStatusSnapshot(omnichainSnapshot)
2168
- };
2169
- }
2170
- function serializeRealtimeIndexingStatusProjection(indexingProjection) {
2171
- return {
2172
- projectedAt: indexingProjection.projectedAt,
2173
- worstCaseDistance: indexingProjection.worstCaseDistance,
2174
- snapshot: serializeCrossChainIndexingStatusSnapshotOmnichain(indexingProjection.snapshot)
2175
- };
2176
- }
2177
- function serializeChainIndexingSnapshots(chains) {
2178
- const serializedSnapshots = {};
2179
- for (const [chainId, snapshot] of chains.entries()) {
2180
- serializedSnapshots[serializeChainId(chainId)] = snapshot;
2291
+ // src/api/registrar-actions/filters.ts
2292
+ function byParentNode(parentNode) {
2293
+ if (typeof parentNode === "undefined") {
2294
+ return void 0;
2181
2295
  }
2182
- return serializedSnapshots;
2296
+ return {
2297
+ filterType: RegistrarActionsFilterTypes.BySubregistryNode,
2298
+ value: parentNode
2299
+ };
2183
2300
  }
2184
- function serializeOmnichainIndexingStatusSnapshot(indexingStatus) {
2185
- switch (indexingStatus.omnichainStatus) {
2186
- case OmnichainIndexingStatusIds.Unstarted:
2187
- return {
2188
- omnichainStatus: OmnichainIndexingStatusIds.Unstarted,
2189
- chains: serializeChainIndexingSnapshots(indexingStatus.chains),
2190
- omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
2191
- };
2192
- case OmnichainIndexingStatusIds.Backfill:
2193
- return {
2194
- omnichainStatus: OmnichainIndexingStatusIds.Backfill,
2195
- chains: serializeChainIndexingSnapshots(indexingStatus.chains),
2196
- omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
2197
- };
2198
- case OmnichainIndexingStatusIds.Completed: {
2199
- return {
2200
- omnichainStatus: OmnichainIndexingStatusIds.Completed,
2201
- chains: serializeChainIndexingSnapshots(indexingStatus.chains),
2202
- omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
2203
- };
2204
- }
2205
- case OmnichainIndexingStatusIds.Following:
2206
- return {
2207
- omnichainStatus: OmnichainIndexingStatusIds.Following,
2208
- chains: serializeChainIndexingSnapshots(indexingStatus.chains),
2209
- omnichainIndexingCursor: indexingStatus.omnichainIndexingCursor
2210
- };
2301
+ function withReferral(withReferral2) {
2302
+ if (!withReferral2) {
2303
+ return void 0;
2211
2304
  }
2305
+ return {
2306
+ filterType: RegistrarActionsFilterTypes.WithEncodedReferral
2307
+ };
2212
2308
  }
2309
+ var registrarActionsFilter = {
2310
+ byParentNode,
2311
+ withReferral
2312
+ };
2213
2313
 
2214
2314
  // src/api/registrar-actions/prerequisites.ts
2215
2315
  var registrarActionsPrerequisites = Object.freeze({
@@ -2278,18 +2378,7 @@ function getEthnamesSubregistryId(namespace) {
2278
2378
  };
2279
2379
  }
2280
2380
 
2281
- // src/api/serialize.ts
2282
- function serializeIndexingStatusResponse(response) {
2283
- switch (response.responseCode) {
2284
- case IndexingStatusResponseCodes.Ok:
2285
- return {
2286
- responseCode: response.responseCode,
2287
- realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection)
2288
- };
2289
- case IndexingStatusResponseCodes.Error:
2290
- return response;
2291
- }
2292
- }
2381
+ // src/api/registrar-actions/serialize.ts
2293
2382
  function serializeNamedRegistrarAction({
2294
2383
  action,
2295
2384
  name
@@ -2311,6 +2400,18 @@ function serializeRegistrarActionsResponse(response) {
2311
2400
  }
2312
2401
  }
2313
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
+
2314
2415
  // src/client-error.ts
2315
2416
  var ClientError = class _ClientError extends Error {
2316
2417
  details;
@@ -2325,10 +2426,10 @@ var ClientError = class _ClientError extends Error {
2325
2426
  };
2326
2427
 
2327
2428
  // src/ensanalytics/deserialize.ts
2328
- import { prettifyError as prettifyError5 } from "zod/v4";
2429
+ import { prettifyError as prettifyError8 } from "zod/v4";
2329
2430
 
2330
2431
  // src/ensanalytics/zod-schemas.ts
2331
- import z8 from "zod/v4";
2432
+ import z12 from "zod/v4";
2332
2433
 
2333
2434
  // src/ensanalytics/types.ts
2334
2435
  var ReferrerLeaderboardPageResponseCodes = {
@@ -2341,22 +2442,50 @@ var ReferrerLeaderboardPageResponseCodes = {
2341
2442
  */
2342
2443
  Error: "error"
2343
2444
  };
2445
+ var ReferrerDetailResponseCodes = {
2446
+ /**
2447
+ * Represents that the referrer detail data is available.
2448
+ */
2449
+ Ok: "ok",
2450
+ /**
2451
+ * Represents that an error occurred while fetching the data.
2452
+ */
2453
+ Error: "error"
2454
+ };
2344
2455
 
2345
2456
  // src/ensanalytics/zod-schemas.ts
2346
- var makeReferralProgramRulesSchema = (valueLabel = "ReferralProgramRules") => z8.object({
2457
+ var makeReferralProgramRulesSchema = (valueLabel = "ReferralProgramRules") => z12.object({
2347
2458
  totalAwardPoolValue: makeFiniteNonNegativeNumberSchema(`${valueLabel}.totalAwardPoolValue`),
2348
2459
  maxQualifiedReferrers: makeNonNegativeIntegerSchema(`${valueLabel}.maxQualifiedReferrers`),
2349
2460
  startTime: makeUnixTimestampSchema(`${valueLabel}.startTime`),
2350
2461
  endTime: makeUnixTimestampSchema(`${valueLabel}.endTime`),
2351
2462
  subregistryId: makeAccountIdSchema(`${valueLabel}.subregistryId`)
2352
2463
  });
2353
- var makeAwardedReferrerMetricsSchema = (valueLabel = "AwardedReferrerMetrics") => z8.object({
2464
+ var makeAwardedReferrerMetricsSchema = (valueLabel = "AwardedReferrerMetrics") => z12.object({
2354
2465
  referrer: makeLowercaseAddressSchema(`${valueLabel}.referrer`),
2355
2466
  totalReferrals: makeNonNegativeIntegerSchema(`${valueLabel}.totalReferrals`),
2356
2467
  totalIncrementalDuration: makeDurationSchema(`${valueLabel}.totalIncrementalDuration`),
2357
2468
  score: makeFiniteNonNegativeNumberSchema(`${valueLabel}.score`),
2358
2469
  rank: makePositiveIntegerSchema(`${valueLabel}.rank`),
2359
- isQualified: z8.boolean(),
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`)
2481
+ });
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),
2360
2489
  finalScoreBoost: makeFiniteNonNegativeNumberSchema(`${valueLabel}.finalScoreBoost`).max(
2361
2490
  1,
2362
2491
  `${valueLabel}.finalScoreBoost must be <= 1`
@@ -2368,7 +2497,7 @@ var makeAwardedReferrerMetricsSchema = (valueLabel = "AwardedReferrerMetrics") =
2368
2497
  ),
2369
2498
  awardPoolApproxValue: makeFiniteNonNegativeNumberSchema(`${valueLabel}.awardPoolApproxValue`)
2370
2499
  });
2371
- var makeAggregatedReferrerMetricsSchema = (valueLabel = "AggregatedReferrerMetrics") => z8.object({
2500
+ var makeAggregatedReferrerMetricsSchema = (valueLabel = "AggregatedReferrerMetrics") => z12.object({
2372
2501
  grandTotalReferrals: makeNonNegativeIntegerSchema(`${valueLabel}.grandTotalReferrals`),
2373
2502
  grandTotalIncrementalDuration: makeDurationSchema(
2374
2503
  `${valueLabel}.grandTotalIncrementalDuration`
@@ -2380,7 +2509,7 @@ var makeAggregatedReferrerMetricsSchema = (valueLabel = "AggregatedReferrerMetri
2380
2509
  `${valueLabel}.minFinalScoreToQualify`
2381
2510
  )
2382
2511
  });
2383
- var makeReferrerLeaderboardPaginationContextSchema = (valueLabel = "ReferrerLeaderboardPaginationContext") => z8.object({
2512
+ var makeReferrerLeaderboardPageContextSchema = (valueLabel = "ReferrerLeaderboardPageContext") => z12.object({
2384
2513
  page: makePositiveIntegerSchema(`${valueLabel}.page`),
2385
2514
  itemsPerPage: makePositiveIntegerSchema(`${valueLabel}.itemsPerPage`).max(
2386
2515
  REFERRERS_PER_LEADERBOARD_PAGE_MAX,
@@ -2388,33 +2517,61 @@ var makeReferrerLeaderboardPaginationContextSchema = (valueLabel = "ReferrerLead
2388
2517
  ),
2389
2518
  totalRecords: makeNonNegativeIntegerSchema(`${valueLabel}.totalRecords`),
2390
2519
  totalPages: makePositiveIntegerSchema(`${valueLabel}.totalPages`),
2391
- hasNext: z8.boolean(),
2392
- hasPrev: z8.boolean(),
2393
- startIndex: z8.optional(makeNonNegativeIntegerSchema(`${valueLabel}.startIndex`)),
2394
- endIndex: z8.optional(makeNonNegativeIntegerSchema(`${valueLabel}.endIndex`))
2520
+ hasNext: z12.boolean(),
2521
+ hasPrev: z12.boolean(),
2522
+ startIndex: z12.optional(makeNonNegativeIntegerSchema(`${valueLabel}.startIndex`)),
2523
+ endIndex: z12.optional(makeNonNegativeIntegerSchema(`${valueLabel}.endIndex`))
2395
2524
  });
2396
- var makeReferrerLeaderboardPageSchema = (valueLabel = "ReferrerLeaderboardPage") => z8.object({
2525
+ var makeReferrerLeaderboardPageSchema = (valueLabel = "ReferrerLeaderboardPage") => z12.object({
2397
2526
  rules: makeReferralProgramRulesSchema(`${valueLabel}.rules`),
2398
- referrers: z8.array(makeAwardedReferrerMetricsSchema(`${valueLabel}.referrers[item]`)),
2527
+ referrers: z12.array(makeAwardedReferrerMetricsSchema(`${valueLabel}.referrers[item]`)),
2399
2528
  aggregatedMetrics: makeAggregatedReferrerMetricsSchema(`${valueLabel}.aggregatedMetrics`),
2400
- paginationContext: makeReferrerLeaderboardPaginationContextSchema(
2401
- `${valueLabel}.paginationContext`
2402
- ),
2529
+ paginationContext: makeReferrerLeaderboardPageContextSchema(`${valueLabel}.paginationContext`),
2403
2530
  accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
2404
2531
  });
2405
- var makeReferrerLeaderboardPageResponseOkSchema = (valueLabel = "ReferrerLeaderboardPageResponseOk") => z8.object({
2406
- responseCode: z8.literal(ReferrerLeaderboardPageResponseCodes.Ok),
2532
+ var makeReferrerLeaderboardPageResponseOkSchema = (valueLabel = "ReferrerLeaderboardPageResponseOk") => z12.object({
2533
+ responseCode: z12.literal(ReferrerLeaderboardPageResponseCodes.Ok),
2407
2534
  data: makeReferrerLeaderboardPageSchema(`${valueLabel}.data`)
2408
2535
  });
2409
- var makeReferrerLeaderboardPageResponseErrorSchema = (_valueLabel = "ReferrerLeaderboardPageResponseError") => z8.object({
2410
- responseCode: z8.literal(ReferrerLeaderboardPageResponseCodes.Error),
2411
- error: z8.string(),
2412
- errorMessage: z8.string()
2536
+ var makeReferrerLeaderboardPageResponseErrorSchema = (_valueLabel = "ReferrerLeaderboardPageResponseError") => z12.object({
2537
+ responseCode: z12.literal(ReferrerLeaderboardPageResponseCodes.Error),
2538
+ error: z12.string(),
2539
+ errorMessage: z12.string()
2413
2540
  });
2414
- var makeReferrerLeaderboardPageResponseSchema = (valueLabel = "ReferrerLeaderboardPageResponse") => z8.union([
2541
+ var makeReferrerLeaderboardPageResponseSchema = (valueLabel = "ReferrerLeaderboardPageResponse") => z12.union([
2415
2542
  makeReferrerLeaderboardPageResponseOkSchema(valueLabel),
2416
2543
  makeReferrerLeaderboardPageResponseErrorSchema(valueLabel)
2417
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`)
2558
+ });
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
+ ])
2565
+ });
2566
+ var makeReferrerDetailResponseErrorSchema = (_valueLabel = "ReferrerDetailResponse") => z12.object({
2567
+ responseCode: z12.literal(ReferrerDetailResponseCodes.Error),
2568
+ error: z12.string(),
2569
+ errorMessage: z12.string()
2570
+ });
2571
+ var makeReferrerDetailResponseSchema = (valueLabel = "ReferrerDetailResponse") => z12.union([
2572
+ makeReferrerDetailResponseOkSchema(valueLabel),
2573
+ makeReferrerDetailResponseErrorSchema(valueLabel)
2574
+ ]);
2418
2575
 
2419
2576
  // src/ensanalytics/deserialize.ts
2420
2577
  function deserializeReferrerLeaderboardPageResponse(maybeResponse, valueLabel) {
@@ -2423,12 +2580,22 @@ function deserializeReferrerLeaderboardPageResponse(maybeResponse, valueLabel) {
2423
2580
  if (parsed.error) {
2424
2581
  throw new Error(
2425
2582
  `Cannot deserialize SerializedReferrerLeaderboardPageResponse:
2426
- ${prettifyError5(parsed.error)}
2583
+ ${prettifyError8(parsed.error)}
2427
2584
  `
2428
2585
  );
2429
2586
  }
2430
2587
  return parsed.data;
2431
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
+ }
2432
2599
 
2433
2600
  // src/ensanalytics/serialize.ts
2434
2601
  function serializeReferrerLeaderboardPageResponse(response) {
@@ -2439,55 +2606,15 @@ function serializeReferrerLeaderboardPageResponse(response) {
2439
2606
  return response;
2440
2607
  }
2441
2608
  }
2442
-
2443
- // src/ensapi/config/deserialize.ts
2444
- import { prettifyError as prettifyError6, ZodError } from "zod/v4";
2445
-
2446
- // src/ensapi/config/zod-schemas.ts
2447
- import { z as z9 } from "zod/v4";
2448
- var TheGraphCannotFallbackReasonSchema = z9.enum({
2449
- NotSubgraphCompatible: "not-subgraph-compatible",
2450
- NoApiKey: "no-api-key",
2451
- NoSubgraphUrl: "no-subgraph-url"
2452
- });
2453
- var TheGraphFallbackSchema = z9.strictObject({
2454
- canFallback: z9.boolean(),
2455
- reason: TheGraphCannotFallbackReasonSchema.nullable()
2456
- });
2457
- function makeENSApiPublicConfigSchema(valueLabel) {
2458
- const label = valueLabel ?? "ENSApiPublicConfig";
2459
- return z9.strictObject({
2460
- version: z9.string().min(1, `${label}.version must be a non-empty string`),
2461
- theGraphFallback: TheGraphFallbackSchema,
2462
- ensIndexerPublicConfig: makeENSIndexerPublicConfigSchema(`${label}.ensIndexerPublicConfig`)
2463
- });
2464
- }
2465
-
2466
- // src/ensapi/config/deserialize.ts
2467
- function deserializeENSApiPublicConfig(maybeConfig, valueLabel) {
2468
- const schema = makeENSApiPublicConfigSchema(valueLabel);
2469
- try {
2470
- return schema.parse(maybeConfig);
2471
- } catch (error) {
2472
- if (error instanceof ZodError) {
2473
- throw new Error(`Cannot deserialize ENSApiPublicConfig:
2474
- ${prettifyError6(error)}
2475
- `);
2476
- }
2477
- throw error;
2609
+ function serializeReferrerDetailResponse(response) {
2610
+ switch (response.responseCode) {
2611
+ case ReferrerDetailResponseCodes.Ok:
2612
+ return response;
2613
+ case ReferrerDetailResponseCodes.Error:
2614
+ return response;
2478
2615
  }
2479
2616
  }
2480
2617
 
2481
- // src/ensapi/config/serialize.ts
2482
- function serializeENSApiPublicConfig(config) {
2483
- const { version, theGraphFallback, ensIndexerPublicConfig } = config;
2484
- return {
2485
- version,
2486
- theGraphFallback,
2487
- ensIndexerPublicConfig: serializeENSIndexerPublicConfig(ensIndexerPublicConfig)
2488
- };
2489
- }
2490
-
2491
2618
  // src/client.ts
2492
2619
  var DEFAULT_ENSNODE_API_URL = "https://api.alpha.ensnode.io";
2493
2620
  var ENSNodeClient = class _ENSNodeClient {
@@ -2691,7 +2818,7 @@ var ENSNodeClient = class _ENSNodeClient {
2691
2818
  const errorResponse = deserializeErrorResponse(responseData);
2692
2819
  throw new Error(`Fetching ENSNode Config Failed: ${errorResponse.message}`);
2693
2820
  }
2694
- return deserializeENSApiPublicConfig(responseData);
2821
+ return deserializeConfigResponse(responseData);
2695
2822
  }
2696
2823
  /**
2697
2824
  * Fetch ENSNode Indexing Status
@@ -2742,7 +2869,7 @@ var ENSNodeClient = class _ENSNodeClient {
2742
2869
  * @example
2743
2870
  * ```typescript
2744
2871
  * // Get first page with default page size (25 items)
2745
- * const response = await client.getReferrerLeaderboard();
2872
+ * const response = await client.getReferrerLeaderboardPage();
2746
2873
  * if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
2747
2874
  * const {
2748
2875
  * aggregatedMetrics,
@@ -2762,13 +2889,13 @@ var ENSNodeClient = class _ENSNodeClient {
2762
2889
  * @example
2763
2890
  * ```typescript
2764
2891
  * // Get second page with 50 items per page
2765
- * const response = await client.getReferrerLeaderboard({ page: 2, itemsPerPage: 50 });
2892
+ * const response = await client.getReferrerLeaderboardPage({ page: 2, itemsPerPage: 50 });
2766
2893
  * ```
2767
2894
  *
2768
2895
  * @example
2769
2896
  * ```typescript
2770
2897
  * // Handle error response, ie. when Referrer Leaderboard is not currently available.
2771
- * const response = await client.getReferrerLeaderboard();
2898
+ * const response = await client.getReferrerLeaderboardPage();
2772
2899
  *
2773
2900
  * if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Error) {
2774
2901
  * console.error(response.error);
@@ -2776,7 +2903,7 @@ var ENSNodeClient = class _ENSNodeClient {
2776
2903
  * }
2777
2904
  * ```
2778
2905
  */
2779
- async getReferrerLeaderboard(request) {
2906
+ async getReferrerLeaderboardPage(request) {
2780
2907
  const url = new URL(`/ensanalytics/referrers`, this.options.url);
2781
2908
  if (request?.page) url.searchParams.set("page", request.page.toString());
2782
2909
  if (request?.itemsPerPage)
@@ -2792,6 +2919,96 @@ var ENSNodeClient = class _ENSNodeClient {
2792
2919
  responseData
2793
2920
  );
2794
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
+ }
2795
3012
  /**
2796
3013
  * Fetch ENSNode Registrar Actions
2797
3014
  *
@@ -2955,6 +3172,231 @@ var translateDefaultableChainIdToChainId = (chainId, namespaceId) => {
2955
3172
  // src/resolution/resolver-records-selection.ts
2956
3173
  var isSelectionEmpty = (selection) => !selection.name && !selection.addresses?.length && !selection.texts?.length;
2957
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
+
2958
3400
  // src/tracing/index.ts
2959
3401
  var TraceableENSProtocol = /* @__PURE__ */ ((TraceableENSProtocol2) => {
2960
3402
  TraceableENSProtocol2["ForwardResolution"] = "forward-resolution";
@@ -2989,6 +3431,7 @@ export {
2989
3431
  ATTR_PROTOCOL_NAME,
2990
3432
  ATTR_PROTOCOL_STEP,
2991
3433
  ATTR_PROTOCOL_STEP_RESULT,
3434
+ AssetNamespaces,
2992
3435
  BASENAMES_NODE,
2993
3436
  ChainIndexingConfigTypeIds,
2994
3437
  ChainIndexingStatusIds,
@@ -3005,10 +3448,15 @@ export {
3005
3448
  IndexingStatusResponseCodes,
3006
3449
  LINEANAMES_NODE,
3007
3450
  LruCache,
3451
+ NFTMintStatuses,
3452
+ NFTTransferTypes,
3008
3453
  OmnichainIndexingStatusIds,
3009
3454
  PROTOCOL_ATTRIBUTE_PREFIX,
3010
3455
  PluginName,
3456
+ RECORDS_PER_PAGE_DEFAULT,
3457
+ RECORDS_PER_PAGE_MAX,
3011
3458
  ROOT_NODE,
3459
+ ReferrerDetailResponseCodes,
3012
3460
  ReferrerLeaderboardPageResponseCodes,
3013
3461
  RegistrarActionTypes,
3014
3462
  RegistrarActionsFilterTypes,
@@ -3030,6 +3478,7 @@ export {
3030
3478
  beautifyName,
3031
3479
  bigIntToNumber,
3032
3480
  bigintToCoinType,
3481
+ buildAssetId,
3033
3482
  buildEnsRainbowClientLabelSet,
3034
3483
  buildLabelSetId,
3035
3484
  buildLabelSetVersion,
@@ -3051,6 +3500,7 @@ export {
3051
3500
  deserializeBlockrange,
3052
3501
  deserializeChainId,
3053
3502
  deserializeChainIndexingStatusSnapshot,
3503
+ deserializeConfigResponse,
3054
3504
  deserializeCrossChainIndexingStatusSnapshot,
3055
3505
  deserializeDatetime,
3056
3506
  deserializeDuration,
@@ -3060,6 +3510,7 @@ export {
3060
3510
  deserializeIndexingStatusResponse,
3061
3511
  deserializeOmnichainIndexingStatusSnapshot,
3062
3512
  deserializeRealtimeIndexingStatusProjection,
3513
+ deserializeReferrerDetailResponse,
3063
3514
  deserializeReferrerLeaderboardPageResponse,
3064
3515
  deserializeRegistrarActionsResponse,
3065
3516
  deserializeUnixTimestamp,
@@ -3067,10 +3518,12 @@ export {
3067
3518
  durationBetween,
3068
3519
  encodeLabelHash,
3069
3520
  evmChainIdToCoinType,
3521
+ formatNFTTransferEventMetadata,
3070
3522
  getCurrencyInfo,
3071
3523
  getENSRootChainId,
3072
3524
  getEthnamesSubregistryId,
3073
3525
  getLatestIndexedBlockRef,
3526
+ getNFTTransferType,
3074
3527
  getNameHierarchy,
3075
3528
  getOmnichainIndexingCursor,
3076
3529
  getOmnichainIndexingStatus,
@@ -3108,8 +3561,10 @@ export {
3108
3561
  registrarActionsPrerequisites,
3109
3562
  reverseName,
3110
3563
  serializeAccountId,
3564
+ serializeAssetId,
3111
3565
  serializeChainId,
3112
3566
  serializeChainIndexingSnapshots,
3567
+ serializeConfigResponse,
3113
3568
  serializeCrossChainIndexingStatusSnapshotOmnichain,
3114
3569
  serializeDatetime,
3115
3570
  serializeENSApiPublicConfig,
@@ -3121,6 +3576,7 @@ export {
3121
3576
  serializePrice,
3122
3577
  serializePriceEth,
3123
3578
  serializeRealtimeIndexingStatusProjection,
3579
+ serializeReferrerDetailResponse,
3124
3580
  serializeReferrerLeaderboardPageResponse,
3125
3581
  serializeRegistrarAction,
3126
3582
  serializeRegistrarActionPricing,