@ensnode/ensnode-sdk 1.2.0 → 1.3.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
@@ -7,25 +7,6 @@ import { z as z3 } from "zod/v4";
7
7
  // src/ensindexer/config/zod-schemas.ts
8
8
  import z2 from "zod/v4";
9
9
 
10
- // src/ens/is-normalized.ts
11
- import { normalize } from "viem/ens";
12
- function isNormalizedName(name) {
13
- try {
14
- return name === normalize(name);
15
- } catch {
16
- return false;
17
- }
18
- }
19
- function isNormalizedLabel(label) {
20
- if (label === "") return false;
21
- if (label.includes(".")) return false;
22
- try {
23
- return label === normalize(label);
24
- } catch {
25
- return false;
26
- }
27
- }
28
-
29
10
  // src/shared/account-id.ts
30
11
  import { isAddressEqual } from "viem";
31
12
  var accountIdEqual = (a, b) => {
@@ -179,9 +160,39 @@ function isEncodedLabelHash(maybeEncodedLabelHash) {
179
160
  return expectedFormatting && includesLabelHash;
180
161
  }
181
162
 
163
+ // src/ens/is-normalized.ts
164
+ import { normalize } from "viem/ens";
165
+ function isNormalizedName(name) {
166
+ try {
167
+ return name === normalize(name);
168
+ } catch {
169
+ return false;
170
+ }
171
+ }
172
+ function isNormalizedLabel(label) {
173
+ if (label === "") return false;
174
+ if (label.includes(".")) return false;
175
+ try {
176
+ return label === normalize(label);
177
+ } catch {
178
+ return false;
179
+ }
180
+ }
181
+
182
182
  // src/ens/names.ts
183
183
  import { ens_beautify } from "@adraffy/ens-normalize";
184
+ var ENS_ROOT = "";
184
185
  var getNameHierarchy = (name) => name.split(".").map((_, i, labels) => labels.slice(i).join("."));
186
+ var getParentNameFQDN = (name) => {
187
+ if (name === ENS_ROOT) {
188
+ throw new Error("There is no parent name for ENS Root.");
189
+ }
190
+ const labels = name.split(".");
191
+ if (labels.length === 1) {
192
+ return ENS_ROOT;
193
+ }
194
+ return labels.slice(1).join(".");
195
+ };
185
196
  var beautifyName = (name) => {
186
197
  const beautifiedLabels = name.split(".").map((label) => {
187
198
  if (isNormalizedLabel(label)) {
@@ -424,7 +435,7 @@ var makeAccountIdSchema = (valueLabel = "AccountId") => z.strictObject({
424
435
  chainId: makeChainIdSchema(`${valueLabel} chain ID`),
425
436
  address: makeLowercaseAddressSchema(`${valueLabel} address`)
426
437
  });
427
- var makeSerializedAccountIdSchema = (valueLabel = "Account ID") => z.coerce.string().transform((v) => {
438
+ var makeAccountIdStringSchema = (valueLabel = "Account ID String") => z.coerce.string().transform((v) => {
428
439
  const result = new CaipAccountId(v);
429
440
  return {
430
441
  chainId: Number(result.chainId.reference),
@@ -436,7 +447,7 @@ var makeHexStringSchema = (options, valueLabel = "String representation of bytes
436
447
  ctx.issues.push({
437
448
  code: "custom",
438
449
  input: ctx.value,
439
- message: `${valueLabel} must start with '0x'.`
450
+ message: `${valueLabel} must be a hexadecimal value which starts with '0x'.`
440
451
  });
441
452
  }
442
453
  }).transform((v) => v).check(function invariant_encodesRequiredBytesCount(ctx) {
@@ -546,8 +557,8 @@ ${prettifyError(parsed.error)}
546
557
  }
547
558
  return parsed.data;
548
559
  }
549
- function deserializeAccountId(maybeAccountId, valueLabel) {
550
- const schema = makeSerializedAccountIdSchema(valueLabel);
560
+ function parseAccountId(maybeAccountId, valueLabel) {
561
+ const schema = makeAccountIdStringSchema(valueLabel);
551
562
  const parsed = schema.safeParse(maybeAccountId);
552
563
  if (parsed.error) {
553
564
  throw new RangeError(`Cannot deserialize AccountId:
@@ -810,6 +821,28 @@ var TtlCache = class {
810
821
  // src/shared/collections.ts
811
822
  var uniq = (arr) => [...new Set(arr)];
812
823
 
824
+ // src/shared/datasource-contract.ts
825
+ import { maybeGetDatasource } from "@ensnode/datasources";
826
+ var maybeGetDatasourceContract = (namespaceId, datasourceName, contractName) => {
827
+ const datasource = maybeGetDatasource(namespaceId, datasourceName);
828
+ if (!datasource) return void 0;
829
+ const address = datasource.contracts[contractName]?.address;
830
+ if (address === void 0 || Array.isArray(address)) return void 0;
831
+ return {
832
+ chainId: datasource.chain.id,
833
+ address
834
+ };
835
+ };
836
+ var getDatasourceContract = (namespaceId, datasourceName, contractName) => {
837
+ const contract = maybeGetDatasourceContract(namespaceId, datasourceName, contractName);
838
+ if (!contract) {
839
+ throw new Error(
840
+ `Expected contract not found for ${namespaceId} ${datasourceName} ${contractName}`
841
+ );
842
+ }
843
+ return contract;
844
+ };
845
+
813
846
  // src/shared/labelhash.ts
814
847
  import { keccak256 as keccak2562, stringToBytes } from "viem";
815
848
  var labelhashLiteralLabel = (label) => keccak2562(stringToBytes(label));
@@ -868,7 +901,7 @@ function serializePrice(price) {
868
901
  function serializePriceEth(price) {
869
902
  return serializePrice(price);
870
903
  }
871
- function serializeAccountId(accountId) {
904
+ function formatAccountId(accountId) {
872
905
  return CaipAccountId2.format({
873
906
  chainId: { namespace: "eip155", reference: accountId.chainId.toString() },
874
907
  address: accountId.address
@@ -1844,245 +1877,841 @@ function serializeConfigResponse(response) {
1844
1877
  import { prettifyError as prettifyError5 } from "zod/v4";
1845
1878
 
1846
1879
  // 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
1880
  import z5 from "zod/v4";
1855
- var ErrorResponseSchema = z5.object({
1856
- message: z5.string(),
1857
- details: z5.optional(z5.unknown())
1858
- });
1859
1881
 
1860
- // src/api/registrar-actions/response.ts
1861
- var RegistrarActionsResponseCodes = {
1882
+ // src/api/indexing-status/response.ts
1883
+ var IndexingStatusResponseCodes = {
1862
1884
  /**
1863
- * Represents that Registrar Actions are available.
1885
+ * Represents that the indexing status is available.
1864
1886
  */
1865
1887
  Ok: "ok",
1866
1888
  /**
1867
- * Represents that Registrar Actions are unavailable.
1889
+ * Represents that the indexing status is unavailable.
1868
1890
  */
1869
1891
  Error: "error"
1870
1892
  };
1871
1893
 
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'`
1882
- });
1883
- }
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))
1894
+ // src/api/indexing-status/zod-schemas.ts
1895
+ var makeIndexingStatusResponseOkSchema = (valueLabel = "Indexing Status Response OK") => z5.strictObject({
1896
+ responseCode: z5.literal(IndexingStatusResponseCodes.Ok),
1897
+ realtimeProjection: makeRealtimeIndexingStatusProjectionSchema(valueLabel)
1892
1898
  });
1893
- var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z6.strictObject({
1894
- responseCode: z6.literal(RegistrarActionsResponseCodes.Error),
1895
- error: ErrorResponseSchema
1899
+ var makeIndexingStatusResponseErrorSchema = (_valueLabel = "Indexing Status Response Error") => z5.strictObject({
1900
+ responseCode: z5.literal(IndexingStatusResponseCodes.Error)
1896
1901
  });
1897
- var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z6.discriminatedUnion("responseCode", [
1898
- makeRegistrarActionsResponseOkSchema(valueLabel),
1899
- makeRegistrarActionsResponseErrorSchema(valueLabel)
1902
+ var makeIndexingStatusResponseSchema = (valueLabel = "Indexing Status Response") => z5.discriminatedUnion("responseCode", [
1903
+ makeIndexingStatusResponseOkSchema(valueLabel),
1904
+ makeIndexingStatusResponseErrorSchema(valueLabel)
1900
1905
  ]);
1901
1906
 
1902
- // src/api/shared/pagination/zod-schemas.ts
1903
- import z7 from "zod/v4";
1904
-
1905
- // src/api/shared/pagination/request.ts
1906
- var RECORDS_PER_PAGE_DEFAULT = 10;
1907
- var RECORDS_PER_PAGE_MAX = 100;
1908
-
1909
- // ../ens-referrals/src/address.ts
1910
- import { isAddress as isAddress3 } from "viem";
1911
-
1912
- // ../ens-referrals/src/encoding.ts
1913
- import { getAddress, pad, size as size2, slice, zeroAddress } from "viem";
1914
- var ENCODED_REFERRER_BYTE_OFFSET = 12;
1915
- var ENCODED_REFERRER_BYTE_LENGTH = 32;
1916
- var EXPECTED_ENCODED_REFERRER_PADDING = pad("0x", {
1917
- size: ENCODED_REFERRER_BYTE_OFFSET,
1918
- dir: "left"
1919
- });
1920
- var ZERO_ENCODED_REFERRER = pad("0x", {
1921
- size: ENCODED_REFERRER_BYTE_LENGTH,
1922
- dir: "left"
1923
- });
1924
- function decodeEncodedReferrer(encodedReferrer) {
1925
- if (size2(encodedReferrer) !== ENCODED_REFERRER_BYTE_LENGTH) {
1926
- throw new Error(
1927
- `Encoded referrer value must be represented by ${ENCODED_REFERRER_BYTE_LENGTH} bytes.`
1928
- );
1929
- }
1930
- const padding = slice(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
1931
- if (padding !== EXPECTED_ENCODED_REFERRER_PADDING) {
1932
- return zeroAddress;
1907
+ // src/api/indexing-status/deserialize.ts
1908
+ function deserializeIndexingStatusResponse(maybeResponse) {
1909
+ const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse);
1910
+ if (parsed.error) {
1911
+ throw new Error(`Cannot deserialize IndexingStatusResponse:
1912
+ ${prettifyError5(parsed.error)}
1913
+ `);
1933
1914
  }
1934
- const decodedReferrer = slice(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
1935
- try {
1936
- return getAddress(decodedReferrer);
1937
- } catch {
1938
- throw new Error(`Decoded referrer value must be a valid EVM address.`);
1915
+ return parsed.data;
1916
+ }
1917
+
1918
+ // src/api/indexing-status/serialize.ts
1919
+ function serializeIndexingStatusResponse(response) {
1920
+ switch (response.responseCode) {
1921
+ case IndexingStatusResponseCodes.Ok:
1922
+ return {
1923
+ responseCode: response.responseCode,
1924
+ realtimeProjection: serializeRealtimeIndexingStatusProjection(response.realtimeProjection)
1925
+ };
1926
+ case IndexingStatusResponseCodes.Error:
1927
+ return response;
1939
1928
  }
1940
1929
  }
1941
1930
 
1942
- // ../ens-referrals/src/leaderboard-page.ts
1943
- var REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
1931
+ // src/api/name-tokens/deserialize.ts
1932
+ import { prettifyError as prettifyError7 } from "zod/v4";
1944
1933
 
1945
- // ../ens-referrals/src/link.ts
1946
- import { getAddress as getAddress2 } from "viem";
1934
+ // src/api/name-tokens/zod-schemas.ts
1935
+ import { namehash as namehash2 } from "viem";
1936
+ import z8 from "zod/v4";
1947
1937
 
1948
- // ../ens-referrals/src/referrer-detail.ts
1949
- var ReferrerDetailTypeIds = {
1938
+ // src/tokenscope/assets.ts
1939
+ import { AssetId as CaipAssetId2 } from "caip";
1940
+ import { isAddressEqual as isAddressEqual3, zeroAddress as zeroAddress3 } from "viem";
1941
+ import { prettifyError as prettifyError6 } from "zod/v4";
1942
+
1943
+ // src/tokenscope/zod-schemas.ts
1944
+ import { AssetId as CaipAssetId } from "caip";
1945
+ import { zeroAddress as zeroAddress2 } from "viem";
1946
+ import z6 from "zod/v4";
1947
+
1948
+ // src/tokenscope/name-token.ts
1949
+ import { isAddressEqual as isAddressEqual2, zeroAddress } from "viem";
1950
+ import { DatasourceNames } from "@ensnode/datasources";
1951
+ var NameTokenOwnershipTypes = {
1950
1952
  /**
1951
- * Represents a referrer who is ranked on the leaderboard.
1953
+ * Name Token is owned by NameWrapper account.
1952
1954
  */
1953
- Ranked: "ranked",
1955
+ NameWrapper: "namewrapper",
1954
1956
  /**
1955
- * Represents a referrer who is not ranked on the leaderboard.
1957
+ * Name Token is owned fully onchain.
1958
+ *
1959
+ * This ownership type can only apply to direct subnames of `.eth`
1956
1960
  */
1957
- Unranked: "unranked"
1961
+ FullyOnchain: "fully-onchain",
1962
+ /**
1963
+ * Name Token ownership has been transferred to the null address.
1964
+ */
1965
+ Burned: "burned",
1966
+ /**
1967
+ * Name Token ownership is unknown.
1968
+ */
1969
+ Unknown: "unknown"
1958
1970
  };
1959
-
1960
- // src/registrars/zod-schemas.ts
1961
- import z8 from "zod/v4";
1962
-
1963
- // src/registrars/subregistry.ts
1964
- function serializeSubregistry(subregistry) {
1965
- return {
1966
- subregistryId: serializeAccountId(subregistry.subregistryId),
1967
- node: subregistry.node
1968
- };
1969
- }
1970
-
1971
- // src/registrars/registration-lifecycle.ts
1972
- function serializeRegistrationLifecycle(registrationLifecycle) {
1971
+ function serializeNameToken(nameToken) {
1973
1972
  return {
1974
- subregistry: serializeSubregistry(registrationLifecycle.subregistry),
1975
- node: registrationLifecycle.node,
1976
- expiresAt: registrationLifecycle.expiresAt
1973
+ token: serializeAssetId(nameToken.token),
1974
+ ownership: nameToken.ownership,
1975
+ mintStatus: nameToken.mintStatus
1977
1976
  };
1978
1977
  }
1979
-
1980
- // src/registrars/registrar-action.ts
1981
- var RegistrarActionTypes = {
1982
- Registration: "registration",
1983
- Renewal: "renewal"
1984
- };
1985
- function isRegistrarActionPricingAvailable(registrarActionPricing) {
1986
- const { baseCost, premium, total } = registrarActionPricing;
1987
- return baseCost !== null && premium !== null && total !== null;
1988
- }
1989
- function isRegistrarActionReferralAvailable(registrarActionReferral) {
1990
- const { encodedReferrer, decodedReferrer } = registrarActionReferral;
1991
- return encodedReferrer !== null && decodedReferrer !== null;
1978
+ function getNameWrapperAccounts(namespaceId) {
1979
+ const ethnamesNameWrapperAccount = getDatasourceContract(
1980
+ namespaceId,
1981
+ DatasourceNames.ENSRoot,
1982
+ "NameWrapper"
1983
+ );
1984
+ const lineanamesNameWrapperAccount = maybeGetDatasourceContract(
1985
+ namespaceId,
1986
+ DatasourceNames.Lineanames,
1987
+ "NameWrapper"
1988
+ );
1989
+ const nameWrapperAccounts = [
1990
+ // NameWrapper for direct subnames of .eth is defined for all ENS namespaces
1991
+ ethnamesNameWrapperAccount
1992
+ ];
1993
+ if (lineanamesNameWrapperAccount) {
1994
+ nameWrapperAccounts.push(lineanamesNameWrapperAccount);
1995
+ }
1996
+ return nameWrapperAccounts;
1992
1997
  }
1993
- function serializeRegistrarActionPricing(pricing) {
1994
- if (isRegistrarActionPricingAvailable(pricing)) {
1998
+ function getNameTokenOwnership(namespaceId, name, owner) {
1999
+ const nameWrapperAccounts = getNameWrapperAccounts(namespaceId);
2000
+ const hasNameWrapperOwnership = nameWrapperAccounts.some(
2001
+ (nameWrapperAccount) => accountIdEqual(owner, nameWrapperAccount)
2002
+ );
2003
+ if (hasNameWrapperOwnership) {
1995
2004
  return {
1996
- baseCost: serializePriceEth(pricing.baseCost),
1997
- premium: serializePriceEth(pricing.premium),
1998
- total: serializePriceEth(pricing.total)
2005
+ ownershipType: NameTokenOwnershipTypes.NameWrapper,
2006
+ owner
2007
+ };
2008
+ }
2009
+ if (isAddressEqual2(owner.address, zeroAddress)) {
2010
+ return {
2011
+ ownershipType: NameTokenOwnershipTypes.Burned,
2012
+ owner
2013
+ };
2014
+ }
2015
+ const parentName = getParentNameFQDN(name);
2016
+ if (parentName === "eth") {
2017
+ return {
2018
+ ownershipType: NameTokenOwnershipTypes.FullyOnchain,
2019
+ owner
1999
2020
  };
2000
2021
  }
2001
- return pricing;
2002
- }
2003
- function serializeRegistrarAction(registrarAction) {
2004
2022
  return {
2005
- id: registrarAction.id,
2006
- type: registrarAction.type,
2007
- incrementalDuration: registrarAction.incrementalDuration,
2008
- registrant: registrarAction.registrant,
2009
- registrationLifecycle: serializeRegistrationLifecycle(registrarAction.registrationLifecycle),
2010
- pricing: serializeRegistrarActionPricing(registrarAction.pricing),
2011
- referral: registrarAction.referral,
2012
- block: registrarAction.block,
2013
- transactionHash: registrarAction.transactionHash,
2014
- eventIds: registrarAction.eventIds
2023
+ ownershipType: NameTokenOwnershipTypes.Unknown,
2024
+ owner
2015
2025
  };
2016
2026
  }
2017
2027
 
2018
- // src/registrars/zod-schemas.ts
2019
- var makeSubregistrySchema = (valueLabel = "Subregistry") => z8.object({
2020
- subregistryId: makeSerializedAccountIdSchema(`${valueLabel} Subregistry ID`),
2021
- node: makeNodeSchema(`${valueLabel} Node`)
2028
+ // src/tokenscope/zod-schemas.ts
2029
+ var makeAssetIdSchema = (valueLabel = "Asset ID Schema") => z6.object({
2030
+ assetNamespace: z6.enum(AssetNamespaces),
2031
+ contract: makeAccountIdSchema(valueLabel),
2032
+ tokenId: z6.preprocess((v) => typeof v === "string" ? BigInt(v) : v, z6.bigint().positive())
2022
2033
  });
2023
- var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") => z8.object({
2024
- subregistry: makeSubregistrySchema(`${valueLabel} Subregistry`),
2025
- node: makeNodeSchema(`${valueLabel} Node`),
2026
- expiresAt: makeUnixTimestampSchema(`${valueLabel} Expires at`)
2027
- });
2028
- function invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium(ctx) {
2029
- const { baseCost, premium, total } = ctx.value;
2030
- const actualTotal = addPrices(baseCost, premium);
2031
- if (!isPriceEqual(actualTotal, total)) {
2034
+ var makeAssetIdStringSchema = (valueLabel = "Asset ID String Schema") => z6.preprocess((v) => {
2035
+ if (typeof v === "string") {
2036
+ const result = new CaipAssetId(v);
2037
+ return {
2038
+ assetNamespace: result.assetName.namespace,
2039
+ contract: {
2040
+ chainId: Number(result.chainId.reference),
2041
+ address: result.assetName.reference
2042
+ },
2043
+ tokenId: result.tokenId
2044
+ };
2045
+ }
2046
+ return v;
2047
+ }, makeAssetIdSchema(valueLabel));
2048
+ function invariant_nameTokenOwnershipHasNonZeroAddressOwner(ctx) {
2049
+ const ownership = ctx.value;
2050
+ if (ctx.value.owner.address === zeroAddress2) {
2032
2051
  ctx.issues.push({
2033
2052
  code: "custom",
2034
2053
  input: ctx.value,
2035
- message: `'total' must be equal to the sum of 'baseCost' and 'premium'`
2054
+ message: `Name Token Ownership with '${ownership.ownershipType}' must have 'address' other than the zero address.`
2036
2055
  });
2037
2056
  }
2038
2057
  }
2039
- var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") => z8.union([
2040
- // pricing available
2041
- z8.object({
2042
- baseCost: makePriceEthSchema(`${valueLabel} Base Cost`),
2043
- premium: makePriceEthSchema(`${valueLabel} Premium`),
2044
- total: makePriceEthSchema(`${valueLabel} Total`)
2045
- }).check(invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium).transform((v) => v),
2046
- // pricing unknown
2047
- z8.object({
2048
- baseCost: z8.null(),
2049
- premium: z8.null(),
2050
- total: z8.null()
2051
- }).transform((v) => v)
2052
- ]);
2053
- function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
2054
- const { encodedReferrer, decodedReferrer } = ctx.value;
2055
- try {
2056
- const expectedDecodedReferrer = decodeEncodedReferrer(encodedReferrer).toLowerCase();
2057
- if (decodedReferrer !== expectedDecodedReferrer) {
2058
- ctx.issues.push({
2059
- code: "custom",
2060
- input: ctx.value,
2061
- message: `'decodedReferrer' must be based on 'encodedReferrer'`
2062
- });
2063
- }
2064
- } catch (error) {
2065
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
2058
+ var makeNameTokenOwnershipNameWrapperSchema = (valueLabel = "Name Token Ownership NameWrapper") => z6.object({
2059
+ ownershipType: z6.literal(NameTokenOwnershipTypes.NameWrapper),
2060
+ owner: makeAccountIdSchema(`${valueLabel}.owner`)
2061
+ }).check(invariant_nameTokenOwnershipHasNonZeroAddressOwner);
2062
+ var makeNameTokenOwnershipFullyOnchainSchema = (valueLabel = "Name Token Ownership Fully Onchain") => z6.object({
2063
+ ownershipType: z6.literal(NameTokenOwnershipTypes.FullyOnchain),
2064
+ owner: makeAccountIdSchema(`${valueLabel}.owner`)
2065
+ }).check(invariant_nameTokenOwnershipHasNonZeroAddressOwner);
2066
+ var makeNameTokenOwnershipBurnedSchema = (valueLabel = "Name Token Ownership Burned") => z6.object({
2067
+ ownershipType: z6.literal(NameTokenOwnershipTypes.Burned),
2068
+ owner: makeAccountIdSchema(`${valueLabel}.owner`)
2069
+ }).check(invariant_nameTokenOwnershipHasZeroAddressOwner);
2070
+ var makeNameTokenOwnershipUnknownSchema = (valueLabel = "Name Token Ownership Unknown") => z6.object({
2071
+ ownershipType: z6.literal(NameTokenOwnershipTypes.Unknown),
2072
+ owner: makeAccountIdSchema(`${valueLabel}.owner`)
2073
+ }).check(invariant_nameTokenOwnershipHasNonZeroAddressOwner);
2074
+ function invariant_nameTokenOwnershipHasZeroAddressOwner(ctx) {
2075
+ const ownership = ctx.value;
2076
+ if (ctx.value.owner.address !== zeroAddress2) {
2066
2077
  ctx.issues.push({
2067
2078
  code: "custom",
2068
2079
  input: ctx.value,
2069
- message: errorMessage
2080
+ message: `Name Token Ownership with '${ownership.ownershipType}' must have 'address' set to the zero address.`
2070
2081
  });
2071
2082
  }
2072
2083
  }
2073
- var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") => z8.union([
2074
- // referral available
2075
- z8.object({
2076
- encodedReferrer: makeHexStringSchema(
2077
- { bytesCount: ENCODED_REFERRER_BYTE_LENGTH },
2078
- `${valueLabel} Encoded Referrer`
2079
- ),
2080
- decodedReferrer: makeLowercaseAddressSchema(`${valueLabel} Decoded Referrer`)
2084
+ var makeNameTokenOwnershipSchema = (valueLabel = "Name Token Ownership") => z6.discriminatedUnion("ownershipType", [
2085
+ makeNameTokenOwnershipNameWrapperSchema(valueLabel),
2086
+ makeNameTokenOwnershipFullyOnchainSchema(valueLabel),
2087
+ makeNameTokenOwnershipBurnedSchema(valueLabel),
2088
+ makeNameTokenOwnershipUnknownSchema(valueLabel)
2089
+ ]);
2090
+ var makeNameTokenSchema = (valueLabel = "Name Token Schema") => z6.object({
2091
+ token: makeAssetIdSchema(`${valueLabel}.token`),
2092
+ ownership: makeNameTokenOwnershipSchema(`${valueLabel}.ownership`),
2093
+ mintStatus: z6.enum(NFTMintStatuses)
2094
+ });
2095
+
2096
+ // src/tokenscope/assets.ts
2097
+ var AssetNamespaces = {
2098
+ ERC721: "erc721",
2099
+ ERC1155: "erc1155"
2100
+ };
2101
+ function serializeAssetId(assetId) {
2102
+ return {
2103
+ assetNamespace: assetId.assetNamespace,
2104
+ contract: assetId.contract,
2105
+ tokenId: uint256ToHex32(assetId.tokenId)
2106
+ };
2107
+ }
2108
+ function deserializeAssetId(maybeAssetId, valueLabel) {
2109
+ const schema = makeAssetIdSchema(valueLabel);
2110
+ const parsed = schema.safeParse(maybeAssetId);
2111
+ if (parsed.error) {
2112
+ throw new RangeError(`Cannot deserialize AssetId:
2113
+ ${prettifyError6(parsed.error)}
2114
+ `);
2115
+ }
2116
+ return parsed.data;
2117
+ }
2118
+ function formatAssetId(assetId) {
2119
+ const { assetNamespace, contract, tokenId } = serializeAssetId(assetId);
2120
+ return CaipAssetId2.format({
2121
+ chainId: { namespace: "eip155", reference: contract.chainId.toString() },
2122
+ assetName: { namespace: assetNamespace, reference: contract.address },
2123
+ tokenId
2124
+ }).toLowerCase();
2125
+ }
2126
+ function parseAssetId(maybeAssetId, valueLabel) {
2127
+ const schema = makeAssetIdStringSchema(valueLabel);
2128
+ const parsed = schema.safeParse(maybeAssetId);
2129
+ if (parsed.error) {
2130
+ throw new RangeError(`Cannot parse AssetId:
2131
+ ${prettifyError6(parsed.error)}
2132
+ `);
2133
+ }
2134
+ return parsed.data;
2135
+ }
2136
+ var buildAssetId = (contract, tokenId, assetNamespace) => {
2137
+ return {
2138
+ assetNamespace,
2139
+ contract,
2140
+ tokenId
2141
+ };
2142
+ };
2143
+ function serializeDomainAssetId(domainAsset) {
2144
+ return {
2145
+ ...serializeAssetId(domainAsset),
2146
+ domainId: domainAsset.domainId
2147
+ };
2148
+ }
2149
+ var NFTMintStatuses = {
2150
+ Minted: "minted",
2151
+ Burned: "burned"
2152
+ };
2153
+ var formatNFTTransferEventMetadata = (metadata) => {
2154
+ const serializedAssetId = serializeAssetId(metadata.nft);
2155
+ return [
2156
+ `Event: ${metadata.eventHandlerName}`,
2157
+ `Chain ID: ${metadata.chainId}`,
2158
+ `Block Number: ${metadata.blockNumber}`,
2159
+ `Transaction Hash: ${metadata.transactionHash}`,
2160
+ `NFT: ${serializedAssetId}`
2161
+ ].map((line) => ` - ${line}`).join("\n");
2162
+ };
2163
+ var NFTTransferTypes = {
2164
+ /**
2165
+ * Initial transfer from zeroAddress to a non-zeroAddress
2166
+ * Can happen at most once to a NFT AssetId
2167
+ *
2168
+ * Invariants:
2169
+ * - NFT is not indexed and therefore has no previous mint status or owner
2170
+ * - new NFT mint status is `minted`
2171
+ * - new NFT owner is a non-zeroAddress
2172
+ */
2173
+ Mint: "mint",
2174
+ /**
2175
+ * Subsequent transfer from zeroAddress to a non-zeroAddress
2176
+ * Can happen any number of times to a NFT AssetId as it passes in a cycle from
2177
+ * mint -> burn -> remint -> burn -> remint -> ...
2178
+ *
2179
+ * Invariants:
2180
+ * - NFT is indexed
2181
+ * - previous NFT mint status was `burned`
2182
+ * - previous NFT owner is the zeroAddress
2183
+ * - new NFT mint status is `minted`
2184
+ * - new NFT owner is a non-zeroAddress
2185
+ */
2186
+ Remint: "remint",
2187
+ /**
2188
+ * Special transfer type for improperly implemented NFT contracts that allow a NFT
2189
+ * that is currently minted to be reminted before an intermediate burn.
2190
+ *
2191
+ * Transfer from zeroAddress to non-zeroAddress for an indexed NFT where the
2192
+ * previously indexed nft had status `minted` with a non-zeroAddress owner.
2193
+ *
2194
+ * Invariants:
2195
+ * - NFT is indexed
2196
+ * - previous NFT mint status was `minted`
2197
+ * - previous NFT owner was a non-zeroAddress
2198
+ * - new NFT mint status is `minted`
2199
+ * - new NFT owner is a non-zeroAddress
2200
+ */
2201
+ MintedRemint: "minted-remint",
2202
+ /**
2203
+ * Transfer from a non-zeroAddress to zeroAddress
2204
+ *
2205
+ * Invariants:
2206
+ * - NFT is indexed
2207
+ * - previous NFT mint status was `minted`
2208
+ * - previous NFT owner is a non-zeroAddress
2209
+ * - new NFT mint status is `burned`
2210
+ * - new NFT owner is the zeroAddress
2211
+ */
2212
+ Burn: "burn",
2213
+ /**
2214
+ * Transfer from a non-zeroAddress to a distinct non-zeroAddress
2215
+ *
2216
+ * Invariants:
2217
+ * - NFT is indexed
2218
+ * - previous and new NFT mint status is `minted`
2219
+ * - previous and new NFT owner are distinct non-zeroAddress
2220
+ */
2221
+ Transfer: "transfer",
2222
+ /**
2223
+ * Transfer from a non-zeroAddress to the same non-zeroAddress
2224
+ *
2225
+ * Invariants:
2226
+ * - NFT is indexed
2227
+ * - previous and new NFT mint status is `minted`
2228
+ * - previous and new NFT owner are equivalent non-zeroAddress
2229
+ */
2230
+ SelfTransfer: "self-transfer",
2231
+ /**
2232
+ * Transfer from zeroAddress to zeroAddress for an indexed NFT
2233
+ *
2234
+ * Invariants:
2235
+ * - NFT is indexed
2236
+ * - previous and new NFT mint status is `burned`
2237
+ * - previous and new NFT owner are zeroAddress
2238
+ */
2239
+ RemintBurn: "remint-burn",
2240
+ /**
2241
+ * Special transfer type for improperly implemented NFT contracts that allow a NFT
2242
+ * that is currently minted to be reminted again before an intermediate burn.
2243
+ *
2244
+ * Transfer from zeroAddress to zeroAddress for an indexed NFT where the
2245
+ * previously indexed nft had status `minted` with a non-zeroAddress owner.
2246
+ *
2247
+ * Invariants:
2248
+ * - NFT is indexed
2249
+ * - previous NFT mint status was `minted`
2250
+ * - previous NFT owner was a non-zeroAddress
2251
+ * - new NFT mint status is `burned`
2252
+ * - new NFT owner is the zeroAddress
2253
+ */
2254
+ MintedRemintBurn: "minted-remint-burn",
2255
+ /**
2256
+ * Transfer from zeroAddress to zeroAddress for an unindexed NFT
2257
+ *
2258
+ * Invariants:
2259
+ * - NFT is not indexed and therefore has no previous mint status or owner
2260
+ * - NFT should remain unindexed and without any mint status or owner
2261
+ */
2262
+ MintBurn: "mint-burn"
2263
+ };
2264
+ var getNFTTransferType = (from, to, allowMintedRemint, metadata, currentlyIndexedOwner) => {
2265
+ const isIndexed = currentlyIndexedOwner !== void 0;
2266
+ const isIndexedAsMinted = isIndexed && !isAddressEqual3(currentlyIndexedOwner, zeroAddress3);
2267
+ const isMint = isAddressEqual3(from, zeroAddress3);
2268
+ const isBurn = isAddressEqual3(to, zeroAddress3);
2269
+ const isSelfTransfer = isAddressEqual3(from, to);
2270
+ if (isIndexed && !isAddressEqual3(currentlyIndexedOwner, from)) {
2271
+ if (isMint && allowMintedRemint) {
2272
+ } else {
2273
+ throw new Error(
2274
+ `Error: Sending from ${from} conflicts with currently indexed owner ${currentlyIndexedOwner}.
2275
+ ${formatNFTTransferEventMetadata(metadata)}`
2276
+ );
2277
+ }
2278
+ }
2279
+ if (isSelfTransfer) {
2280
+ if (isMint) {
2281
+ if (!isIndexed) {
2282
+ return NFTTransferTypes.MintBurn;
2283
+ } else if (!isIndexedAsMinted) {
2284
+ return NFTTransferTypes.RemintBurn;
2285
+ } else if (allowMintedRemint) {
2286
+ return NFTTransferTypes.MintedRemintBurn;
2287
+ } else {
2288
+ throw new Error(
2289
+ `Error: Invalid state transition from minted -> remint-burn
2290
+ ${formatNFTTransferEventMetadata(metadata)}`
2291
+ );
2292
+ }
2293
+ } else {
2294
+ if (!isIndexed) {
2295
+ throw new Error(
2296
+ `Error: Invalid state transition from unindexed -> self-transfer
2297
+ ${formatNFTTransferEventMetadata(metadata)}`
2298
+ );
2299
+ } else if (!isIndexedAsMinted) {
2300
+ throw new Error(
2301
+ `Error: invalid state transition from burned -> self-transfer
2302
+ ${formatNFTTransferEventMetadata(metadata)}`
2303
+ );
2304
+ } else {
2305
+ return NFTTransferTypes.SelfTransfer;
2306
+ }
2307
+ }
2308
+ } else if (isMint) {
2309
+ if (!isIndexed) {
2310
+ return NFTTransferTypes.Mint;
2311
+ } else if (!isIndexedAsMinted) {
2312
+ return NFTTransferTypes.Remint;
2313
+ } else if (allowMintedRemint) {
2314
+ return NFTTransferTypes.MintedRemint;
2315
+ } else {
2316
+ throw new Error(
2317
+ `Error: Invalid state transition from minted -> mint
2318
+ ${formatNFTTransferEventMetadata(metadata)}`
2319
+ );
2320
+ }
2321
+ } else if (isBurn) {
2322
+ if (!isIndexed) {
2323
+ throw new Error(
2324
+ `Error: Invalid state transition from unindexed -> burn
2325
+ ${formatNFTTransferEventMetadata(metadata)}`
2326
+ );
2327
+ } else if (!isIndexedAsMinted) {
2328
+ throw new Error(
2329
+ `Error: Invalid state transition from burned -> burn
2330
+ ${formatNFTTransferEventMetadata(metadata)}`
2331
+ );
2332
+ } else {
2333
+ return NFTTransferTypes.Burn;
2334
+ }
2335
+ } else {
2336
+ if (!isIndexed) {
2337
+ throw new Error(
2338
+ `Error: Invalid state transition from unindexed -> transfer
2339
+ ${formatNFTTransferEventMetadata(metadata)}`
2340
+ );
2341
+ } else if (!isIndexedAsMinted) {
2342
+ throw new Error(
2343
+ `Error: Invalid state transition from burned -> transfer
2344
+ ${formatNFTTransferEventMetadata(metadata)}`
2345
+ );
2346
+ } else {
2347
+ return NFTTransferTypes.Transfer;
2348
+ }
2349
+ }
2350
+ };
2351
+
2352
+ // src/api/shared/errors/zod-schemas.ts
2353
+ import z7 from "zod/v4";
2354
+ var ErrorResponseSchema = z7.object({
2355
+ message: z7.string(),
2356
+ details: z7.optional(z7.unknown())
2357
+ });
2358
+
2359
+ // src/api/name-tokens/response.ts
2360
+ var NameTokensResponseCodes = {
2361
+ /**
2362
+ * Represents a response when Name Tokens API can respond with requested data.
2363
+ */
2364
+ Ok: "ok",
2365
+ /**
2366
+ * Represents a response when Name Tokens API could not respond with requested data.
2367
+ */
2368
+ Error: "error"
2369
+ };
2370
+ var NameTokensResponseErrorCodes = {
2371
+ /**
2372
+ * Name tokens not indexed
2373
+ *
2374
+ * Represents an error when tokens for the requested name are not indexed by
2375
+ * the ENSNode instance's configuration.
2376
+ */
2377
+ NameTokensNotIndexed: "name-tokens-not-indexed",
2378
+ /**
2379
+ * Unsupported ENSIndexer Config
2380
+ *
2381
+ * Represents a prerequisites error when connected ENSIndexer config lacks
2382
+ * params required to enable Name Tokens API.
2383
+ */
2384
+ EnsIndexerConfigUnsupported: "unsupported-ensindexer-config",
2385
+ /**
2386
+ * Unsupported Indexing Status
2387
+ *
2388
+ * Represents a prerequisites error when Indexing Status has not yet reached
2389
+ * status required to enable Name Tokens API.
2390
+ */
2391
+ IndexingStatusUnsupported: "unsupported-indexing-status"
2392
+ };
2393
+
2394
+ // src/api/name-tokens/zod-schemas.ts
2395
+ function invariant_nameIsAssociatedWithDomainId(ctx) {
2396
+ const { name, domainId } = ctx.value;
2397
+ if (namehash2(name) !== domainId) {
2398
+ ctx.issues.push({
2399
+ code: "custom",
2400
+ input: ctx.value,
2401
+ message: `'name' must be associated with 'domainId': ${domainId}`
2402
+ });
2403
+ }
2404
+ }
2405
+ function invariant_nameTokensOwnershipTypeNameWrapperRequiresOwnershipTypeFullyOnchainOrUnknown(ctx) {
2406
+ const { tokens } = ctx.value;
2407
+ const containsOwnershipNameWrapper = tokens.some(
2408
+ (t) => t.ownership.ownershipType === NameTokenOwnershipTypes.NameWrapper
2409
+ );
2410
+ const containsOwnershipFullyOnchainOrUnknown = tokens.some(
2411
+ (t) => t.ownership.ownershipType === NameTokenOwnershipTypes.FullyOnchain || t.ownership.ownershipType === NameTokenOwnershipTypes.Unknown
2412
+ );
2413
+ if (containsOwnershipNameWrapper && !containsOwnershipFullyOnchainOrUnknown) {
2414
+ ctx.issues.push({
2415
+ code: "custom",
2416
+ input: ctx.value,
2417
+ message: `'tokens' must contain name token with ownership type 'fully-onchain' or 'unknown' when name token with ownership type 'namewrapper' in listed`
2418
+ });
2419
+ }
2420
+ }
2421
+ function invariant_nameTokensContainAtMostOneWithOwnershipTypeEffective(ctx) {
2422
+ const { tokens } = ctx.value;
2423
+ const tokensCountWithOwnershipFullyOnchain = tokens.filter(
2424
+ (t) => t.ownership.ownershipType === NameTokenOwnershipTypes.FullyOnchain
2425
+ ).length;
2426
+ if (tokensCountWithOwnershipFullyOnchain > 1) {
2427
+ ctx.issues.push({
2428
+ code: "custom",
2429
+ input: ctx.value,
2430
+ message: `'tokens' must contain at most one name token with ownership type 'fully-onchain', current count: ${tokensCountWithOwnershipFullyOnchain}`
2431
+ });
2432
+ }
2433
+ }
2434
+ var makeRegisteredNameTokenSchema = (valueLabel = "Registered Name Token") => z8.object({
2435
+ domainId: makeNodeSchema(`${valueLabel}.domainId`),
2436
+ name: makeReinterpretedNameSchema(valueLabel),
2437
+ tokens: z8.array(makeNameTokenSchema(`${valueLabel}.tokens`)).nonempty(),
2438
+ expiresAt: makeUnixTimestampSchema(`${valueLabel}.expiresAt`),
2439
+ accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
2440
+ }).check(invariant_nameIsAssociatedWithDomainId).check(invariant_nameTokensContainAtMostOneWithOwnershipTypeEffective).check(invariant_nameTokensOwnershipTypeNameWrapperRequiresOwnershipTypeFullyOnchainOrUnknown);
2441
+ var makeNameTokensResponseOkSchema = (valueLabel = "Name Tokens Response OK") => z8.strictObject({
2442
+ responseCode: z8.literal(NameTokensResponseCodes.Ok),
2443
+ registeredNameTokens: makeRegisteredNameTokenSchema(`${valueLabel}.nameTokens`)
2444
+ });
2445
+ var makeNameTokensResponseErrorNameTokensNotIndexedSchema = (_valueLabel = "Name Tokens Response Error Name Not Indexed") => z8.strictObject({
2446
+ responseCode: z8.literal(NameTokensResponseCodes.Error),
2447
+ errorCode: z8.literal(NameTokensResponseErrorCodes.NameTokensNotIndexed),
2448
+ error: ErrorResponseSchema
2449
+ });
2450
+ var makeNameTokensResponseErrorEnsIndexerConfigUnsupported = (_valueLabel = "Name Tokens Response Error ENSIndexer Config Unsupported") => z8.strictObject({
2451
+ responseCode: z8.literal(NameTokensResponseCodes.Error),
2452
+ errorCode: z8.literal(NameTokensResponseErrorCodes.EnsIndexerConfigUnsupported),
2453
+ error: ErrorResponseSchema
2454
+ });
2455
+ var makeNameTokensResponseErrorNameIndexingStatusUnsupported = (_valueLabel = "Name Tokens Response Error Indexing Status Unsupported") => z8.strictObject({
2456
+ responseCode: z8.literal(NameTokensResponseCodes.Error),
2457
+ errorCode: z8.literal(NameTokensResponseErrorCodes.IndexingStatusUnsupported),
2458
+ error: ErrorResponseSchema
2459
+ });
2460
+ var makeNameTokensResponseErrorSchema = (valueLabel = "Name Tokens Response Error") => z8.discriminatedUnion("errorCode", [
2461
+ makeNameTokensResponseErrorNameTokensNotIndexedSchema(valueLabel),
2462
+ makeNameTokensResponseErrorEnsIndexerConfigUnsupported(valueLabel),
2463
+ makeNameTokensResponseErrorNameIndexingStatusUnsupported(valueLabel)
2464
+ ]);
2465
+ var makeNameTokensResponseSchema = (valueLabel = "Name Tokens Response") => z8.discriminatedUnion("responseCode", [
2466
+ makeNameTokensResponseOkSchema(valueLabel),
2467
+ makeNameTokensResponseErrorSchema(valueLabel)
2468
+ ]);
2469
+
2470
+ // src/api/name-tokens/deserialize.ts
2471
+ function deserializedNameTokensResponse(maybeResponse) {
2472
+ const parsed = makeNameTokensResponseSchema().safeParse(maybeResponse);
2473
+ if (parsed.error) {
2474
+ throw new Error(`Cannot deserialize NameTokensResponse:
2475
+ ${prettifyError7(parsed.error)}
2476
+ `);
2477
+ }
2478
+ return parsed.data;
2479
+ }
2480
+
2481
+ // src/api/name-tokens/prerequisites.ts
2482
+ var nameTokensPrerequisites = Object.freeze({
2483
+ /**
2484
+ * Required plugins to enable Name Tokens API routes.
2485
+ *
2486
+ * 1. `registrars` plugin is required so that data in the `registrationLifecycles`
2487
+ * table is populated.
2488
+ * 2. `tokenscope` plugin is required so that data in the `nameTokens`
2489
+ * table is populated.
2490
+ */
2491
+ requiredPlugins: ["registrars" /* Registrars */, "tokenscope" /* TokenScope */],
2492
+ /**
2493
+ * Check if provided ENSApiPublicConfig supports the Name Tokens API.
2494
+ */
2495
+ hasEnsIndexerConfigSupport(config) {
2496
+ return nameTokensPrerequisites.requiredPlugins.every(
2497
+ (plugin) => config.plugins.includes(plugin)
2498
+ );
2499
+ },
2500
+ /**
2501
+ * Required Indexing Status IDs
2502
+ *
2503
+ * Database indexes are created by the time the omnichain indexing status
2504
+ * is either `completed` or `following`.
2505
+ */
2506
+ supportedIndexingStatusIds: [
2507
+ OmnichainIndexingStatusIds.Completed,
2508
+ OmnichainIndexingStatusIds.Following
2509
+ ],
2510
+ /**
2511
+ * Check if provided indexing status supports the Name Tokens API.
2512
+ */
2513
+ hasIndexingStatusSupport(omnichainIndexingStatusId) {
2514
+ return nameTokensPrerequisites.supportedIndexingStatusIds.some(
2515
+ (supportedIndexingStatusId) => supportedIndexingStatusId === omnichainIndexingStatusId
2516
+ );
2517
+ }
2518
+ });
2519
+
2520
+ // src/api/name-tokens/serialize.ts
2521
+ function serializeRegisteredNameTokens({
2522
+ domainId,
2523
+ name,
2524
+ tokens,
2525
+ expiresAt,
2526
+ accurateAsOf
2527
+ }) {
2528
+ return {
2529
+ domainId,
2530
+ name,
2531
+ tokens: tokens.map(serializeNameToken),
2532
+ expiresAt,
2533
+ accurateAsOf
2534
+ };
2535
+ }
2536
+ function serializeNameTokensResponse(response) {
2537
+ switch (response.responseCode) {
2538
+ case NameTokensResponseCodes.Ok:
2539
+ return {
2540
+ responseCode: response.responseCode,
2541
+ registeredNameTokens: serializeRegisteredNameTokens(response.registeredNameTokens)
2542
+ };
2543
+ case NameTokensResponseCodes.Error:
2544
+ return response;
2545
+ }
2546
+ }
2547
+
2548
+ // src/api/registrar-actions/deserialize.ts
2549
+ import { prettifyError as prettifyError8 } from "zod/v4";
2550
+
2551
+ // src/api/registrar-actions/zod-schemas.ts
2552
+ import { namehash as namehash3 } from "viem/ens";
2553
+ import z11 from "zod/v4";
2554
+
2555
+ // ../ens-referrals/src/address.ts
2556
+ import { isAddress as isAddress3 } from "viem";
2557
+
2558
+ // ../ens-referrals/src/encoding.ts
2559
+ import { getAddress, pad, size as size2, slice, zeroAddress as zeroAddress4 } from "viem";
2560
+ var ENCODED_REFERRER_BYTE_OFFSET = 12;
2561
+ var ENCODED_REFERRER_BYTE_LENGTH = 32;
2562
+ var EXPECTED_ENCODED_REFERRER_PADDING = pad("0x", {
2563
+ size: ENCODED_REFERRER_BYTE_OFFSET,
2564
+ dir: "left"
2565
+ });
2566
+ var ZERO_ENCODED_REFERRER = pad("0x", {
2567
+ size: ENCODED_REFERRER_BYTE_LENGTH,
2568
+ dir: "left"
2569
+ });
2570
+ function decodeEncodedReferrer(encodedReferrer) {
2571
+ if (size2(encodedReferrer) !== ENCODED_REFERRER_BYTE_LENGTH) {
2572
+ throw new Error(
2573
+ `Encoded referrer value must be represented by ${ENCODED_REFERRER_BYTE_LENGTH} bytes.`
2574
+ );
2575
+ }
2576
+ const padding = slice(encodedReferrer, 0, ENCODED_REFERRER_BYTE_OFFSET);
2577
+ if (padding !== EXPECTED_ENCODED_REFERRER_PADDING) {
2578
+ return zeroAddress4;
2579
+ }
2580
+ const decodedReferrer = slice(encodedReferrer, ENCODED_REFERRER_BYTE_OFFSET);
2581
+ try {
2582
+ return getAddress(decodedReferrer);
2583
+ } catch {
2584
+ throw new Error(`Decoded referrer value must be a valid EVM address.`);
2585
+ }
2586
+ }
2587
+
2588
+ // ../ens-referrals/src/leaderboard-page.ts
2589
+ var REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
2590
+
2591
+ // ../ens-referrals/src/link.ts
2592
+ import { getAddress as getAddress2 } from "viem";
2593
+
2594
+ // ../ens-referrals/src/referrer-detail.ts
2595
+ var ReferrerDetailTypeIds = {
2596
+ /**
2597
+ * Represents a referrer who is ranked on the leaderboard.
2598
+ */
2599
+ Ranked: "ranked",
2600
+ /**
2601
+ * Represents a referrer who is not ranked on the leaderboard.
2602
+ */
2603
+ Unranked: "unranked"
2604
+ };
2605
+
2606
+ // src/registrars/zod-schemas.ts
2607
+ import z9 from "zod/v4";
2608
+
2609
+ // src/registrars/registrar-action.ts
2610
+ var RegistrarActionTypes = {
2611
+ Registration: "registration",
2612
+ Renewal: "renewal"
2613
+ };
2614
+ function isRegistrarActionPricingAvailable(registrarActionPricing) {
2615
+ const { baseCost, premium, total } = registrarActionPricing;
2616
+ return baseCost !== null && premium !== null && total !== null;
2617
+ }
2618
+ function isRegistrarActionReferralAvailable(registrarActionReferral) {
2619
+ const { encodedReferrer, decodedReferrer } = registrarActionReferral;
2620
+ return encodedReferrer !== null && decodedReferrer !== null;
2621
+ }
2622
+ function serializeRegistrarActionPricing(pricing) {
2623
+ if (isRegistrarActionPricingAvailable(pricing)) {
2624
+ return {
2625
+ baseCost: serializePriceEth(pricing.baseCost),
2626
+ premium: serializePriceEth(pricing.premium),
2627
+ total: serializePriceEth(pricing.total)
2628
+ };
2629
+ }
2630
+ return pricing;
2631
+ }
2632
+ function serializeRegistrarAction(registrarAction) {
2633
+ return {
2634
+ id: registrarAction.id,
2635
+ type: registrarAction.type,
2636
+ incrementalDuration: registrarAction.incrementalDuration,
2637
+ registrant: registrarAction.registrant,
2638
+ registrationLifecycle: registrarAction.registrationLifecycle,
2639
+ pricing: serializeRegistrarActionPricing(registrarAction.pricing),
2640
+ referral: registrarAction.referral,
2641
+ block: registrarAction.block,
2642
+ transactionHash: registrarAction.transactionHash,
2643
+ eventIds: registrarAction.eventIds
2644
+ };
2645
+ }
2646
+
2647
+ // src/registrars/zod-schemas.ts
2648
+ var makeSubregistrySchema = (valueLabel = "Subregistry") => z9.object({
2649
+ subregistryId: makeAccountIdSchema(`${valueLabel} Subregistry ID`),
2650
+ node: makeNodeSchema(`${valueLabel} Node`)
2651
+ });
2652
+ var makeRegistrationLifecycleSchema = (valueLabel = "Registration Lifecycle") => z9.object({
2653
+ subregistry: makeSubregistrySchema(`${valueLabel} Subregistry`),
2654
+ node: makeNodeSchema(`${valueLabel} Node`),
2655
+ expiresAt: makeUnixTimestampSchema(`${valueLabel} Expires at`)
2656
+ });
2657
+ function invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium(ctx) {
2658
+ const { baseCost, premium, total } = ctx.value;
2659
+ const actualTotal = addPrices(baseCost, premium);
2660
+ if (!isPriceEqual(actualTotal, total)) {
2661
+ ctx.issues.push({
2662
+ code: "custom",
2663
+ input: ctx.value,
2664
+ message: `'total' must be equal to the sum of 'baseCost' and 'premium'`
2665
+ });
2666
+ }
2667
+ }
2668
+ var makeRegistrarActionPricingSchema = (valueLabel = "Registrar Action Pricing") => z9.union([
2669
+ // pricing available
2670
+ z9.object({
2671
+ baseCost: makePriceEthSchema(`${valueLabel} Base Cost`),
2672
+ premium: makePriceEthSchema(`${valueLabel} Premium`),
2673
+ total: makePriceEthSchema(`${valueLabel} Total`)
2674
+ }).check(invariant_registrarActionPricingTotalIsSumOfBaseCostAndPremium).transform((v) => v),
2675
+ // pricing unknown
2676
+ z9.object({
2677
+ baseCost: z9.null(),
2678
+ premium: z9.null(),
2679
+ total: z9.null()
2680
+ }).transform((v) => v)
2681
+ ]);
2682
+ function invariant_registrarActionDecodedReferrerBasedOnRawReferrer(ctx) {
2683
+ const { encodedReferrer, decodedReferrer } = ctx.value;
2684
+ try {
2685
+ const expectedDecodedReferrer = decodeEncodedReferrer(encodedReferrer).toLowerCase();
2686
+ if (decodedReferrer !== expectedDecodedReferrer) {
2687
+ ctx.issues.push({
2688
+ code: "custom",
2689
+ input: ctx.value,
2690
+ message: `'decodedReferrer' must be based on 'encodedReferrer'`
2691
+ });
2692
+ }
2693
+ } catch (error) {
2694
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
2695
+ ctx.issues.push({
2696
+ code: "custom",
2697
+ input: ctx.value,
2698
+ message: errorMessage
2699
+ });
2700
+ }
2701
+ }
2702
+ var makeRegistrarActionReferralSchema = (valueLabel = "Registrar Action Referral") => z9.union([
2703
+ // referral available
2704
+ z9.object({
2705
+ encodedReferrer: makeHexStringSchema(
2706
+ { bytesCount: ENCODED_REFERRER_BYTE_LENGTH },
2707
+ `${valueLabel} Encoded Referrer`
2708
+ ),
2709
+ decodedReferrer: makeLowercaseAddressSchema(`${valueLabel} Decoded Referrer`)
2081
2710
  }).check(invariant_registrarActionDecodedReferrerBasedOnRawReferrer),
2082
2711
  // referral not applicable
2083
- z8.object({
2084
- encodedReferrer: z8.null(),
2085
- decodedReferrer: z8.null()
2712
+ z9.object({
2713
+ encodedReferrer: z9.null(),
2714
+ decodedReferrer: z9.null()
2086
2715
  })
2087
2716
  ]);
2088
2717
  function invariant_eventIdsInitialElementIsTheActionId(ctx) {
@@ -2095,9 +2724,9 @@ function invariant_eventIdsInitialElementIsTheActionId(ctx) {
2095
2724
  });
2096
2725
  }
2097
2726
  }
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({
2727
+ var EventIdSchema = z9.string().nonempty();
2728
+ var EventIdsSchema = z9.array(EventIdSchema).min(1).transform((v) => v);
2729
+ var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z9.object({
2101
2730
  id: EventIdSchema,
2102
2731
  incrementalDuration: makeDurationSchema(`${valueLabel} Incremental Duration`),
2103
2732
  registrant: makeLowercaseAddressSchema(`${valueLabel} Registrant`),
@@ -2111,168 +2740,135 @@ var makeBaseRegistrarActionSchema = (valueLabel = "Base Registrar Action") => z8
2111
2740
  eventIds: EventIdsSchema
2112
2741
  }).check(invariant_eventIdsInitialElementIsTheActionId);
2113
2742
  var makeRegistrarActionRegistrationSchema = (valueLabel = "Registration ") => makeBaseRegistrarActionSchema(valueLabel).extend({
2114
- type: z8.literal(RegistrarActionTypes.Registration)
2743
+ type: z9.literal(RegistrarActionTypes.Registration)
2115
2744
  });
2116
2745
  var makeRegistrarActionRenewalSchema = (valueLabel = "Renewal") => makeBaseRegistrarActionSchema(valueLabel).extend({
2117
- type: z8.literal(RegistrarActionTypes.Renewal)
2746
+ type: z9.literal(RegistrarActionTypes.Renewal)
2118
2747
  });
2119
- var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => z8.discriminatedUnion("type", [
2748
+ var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => z9.discriminatedUnion("type", [
2120
2749
  makeRegistrarActionRegistrationSchema(`${valueLabel} Registration`),
2121
2750
  makeRegistrarActionRenewalSchema(`${valueLabel} Renewal`)
2122
2751
  ]);
2123
2752
 
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";
2140
-
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) {
2753
+ // src/api/shared/pagination/zod-schemas.ts
2754
+ import z10 from "zod/v4";
2755
+
2756
+ // src/api/shared/pagination/request.ts
2757
+ var RECORDS_PER_PAGE_DEFAULT = 10;
2758
+ var RECORDS_PER_PAGE_MAX = 100;
2759
+
2760
+ // src/api/shared/pagination/zod-schemas.ts
2761
+ var makeRequestPageParamsSchema = (valueLabel = "RequestPageParams") => z10.object({
2762
+ page: makePositiveIntegerSchema(`${valueLabel}.page`),
2763
+ recordsPerPage: makePositiveIntegerSchema(`${valueLabel}.recordsPerPage`).max(
2764
+ RECORDS_PER_PAGE_MAX,
2765
+ `${valueLabel}.recordsPerPage must not exceed ${RECORDS_PER_PAGE_MAX}`
2766
+ )
2767
+ });
2768
+ var makeResponsePageContextSchemaWithNoRecords = (valueLabel = "ResponsePageContextWithNoRecords") => z10.object({
2769
+ totalRecords: z10.literal(0),
2770
+ totalPages: z10.literal(1),
2771
+ hasNext: z10.literal(false),
2772
+ hasPrev: z10.literal(false),
2773
+ startIndex: z10.undefined(),
2774
+ endIndex: z10.undefined()
2775
+ }).extend(makeRequestPageParamsSchema(valueLabel).shape);
2776
+ function invariant_responsePageWithRecordsIsCorrect(ctx) {
2777
+ const { hasNext, hasPrev, recordsPerPage, page, totalRecords, startIndex, endIndex } = ctx.value;
2778
+ const expectedHasNext = page * recordsPerPage < totalRecords;
2779
+ if (hasNext !== expectedHasNext) {
2150
2780
  ctx.issues.push({
2151
2781
  code: "custom",
2152
- input: endpoints,
2153
- message: `RPC endpoint configuration for a chain must include at least one http/https protocol URL.`
2782
+ input: ctx.value,
2783
+ message: `hasNext must be equal to '${expectedHasNext ? "true" : "false"}'`
2154
2784
  });
2155
2785
  }
2156
- }
2157
- function invariant_rpcEndpointConfigIncludesAtMostOneWebSocketsProtocolURL(ctx) {
2158
- const endpoints = ctx.value;
2159
- const wsEndpoints = endpoints.filter(isWebSocketProtocol);
2160
- if (wsEndpoints.length > 1) {
2786
+ const expectedHasPrev = page > 1;
2787
+ if (hasPrev !== expectedHasPrev) {
2161
2788
  ctx.issues.push({
2162
2789
  code: "custom",
2163
- input: endpoints,
2164
- message: `RPC endpoint configuration for a chain must include at most one websocket (ws/wss) protocol URL.`
2790
+ input: ctx.value,
2791
+ message: `hasPrev must be equal to '${expectedHasPrev ? "true" : "false"}'`
2165
2792
  });
2166
2793
  }
2167
- }
2168
-
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
2794
+ if (endIndex < startIndex) {
2795
+ ctx.issues.push({
2796
+ code: "custom",
2797
+ input: ctx.value,
2798
+ message: `endIndex must be greater than or equal to startIndex`
2188
2799
  });
2189
2800
  }
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();
2198
-
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
- ];
2211
-
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";
2801
+ if (endIndex >= totalRecords) {
2802
+ ctx.issues.push({
2803
+ code: "custom",
2804
+ input: ctx.value,
2805
+ message: `endIndex must be lower than totalRecords`
2806
+ });
2807
+ }
2808
+ }
2809
+ var makeResponsePageContextSchemaWithRecords = (valueLabel = "ResponsePageContextWithRecords") => z10.object({
2810
+ totalRecords: makePositiveIntegerSchema(`${valueLabel}.totalRecords`),
2811
+ totalPages: makePositiveIntegerSchema(`${valueLabel}.totalPages`),
2812
+ hasNext: z10.boolean(),
2813
+ hasPrev: z10.boolean(),
2814
+ startIndex: makeNonNegativeIntegerSchema(`${valueLabel}.startIndex`),
2815
+ endIndex: makeNonNegativeIntegerSchema(`${valueLabel}.endIndex`)
2816
+ }).extend(makeRequestPageParamsSchema(valueLabel).shape).check(invariant_responsePageWithRecordsIsCorrect);
2817
+ var makeResponsePageContextSchema = (valueLabel = "ResponsePageContext") => z10.union([
2818
+ makeResponsePageContextSchemaWithNoRecords(valueLabel),
2819
+ makeResponsePageContextSchemaWithRecords(valueLabel)
2820
+ ]);
2218
2821
 
2219
- // src/api/indexing-status/response.ts
2220
- var IndexingStatusResponseCodes = {
2822
+ // src/api/registrar-actions/response.ts
2823
+ var RegistrarActionsResponseCodes = {
2221
2824
  /**
2222
- * Represents that the indexing status is available.
2825
+ * Represents that Registrar Actions are available.
2223
2826
  */
2224
2827
  Ok: "ok",
2225
2828
  /**
2226
- * Represents that the indexing status is unavailable.
2829
+ * Represents that Registrar Actions are unavailable.
2227
2830
  */
2228
2831
  Error: "error"
2229
2832
  };
2230
2833
 
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)
2834
+ // src/api/registrar-actions/zod-schemas.ts
2835
+ function invariant_registrationLifecycleNodeMatchesName(ctx) {
2836
+ const { name, action } = ctx.value;
2837
+ const expectedNode = action.registrationLifecycle.node;
2838
+ const actualNode = namehash3(name);
2839
+ if (actualNode !== expectedNode) {
2840
+ ctx.issues.push({
2841
+ code: "custom",
2842
+ input: ctx.value,
2843
+ message: `The 'action.registrationLifecycle.node' must match namehash of 'name'`
2844
+ });
2845
+ }
2846
+ }
2847
+ var makeNamedRegistrarActionSchema = (valueLabel = "Named Registrar Action") => z11.object({
2848
+ action: makeRegistrarActionSchema(valueLabel),
2849
+ name: makeReinterpretedNameSchema(valueLabel)
2850
+ }).check(invariant_registrationLifecycleNodeMatchesName);
2851
+ var makeRegistrarActionsResponseOkSchema = (valueLabel = "Registrar Actions Response OK") => z11.strictObject({
2852
+ responseCode: z11.literal(RegistrarActionsResponseCodes.Ok),
2853
+ registrarActions: z11.array(makeNamedRegistrarActionSchema(valueLabel)),
2854
+ pageContext: makeResponsePageContextSchema(`${valueLabel}.pageContext`)
2235
2855
  });
2236
- var makeIndexingStatusResponseErrorSchema = (_valueLabel = "Indexing Status Response Error") => z11.strictObject({
2237
- responseCode: z11.literal(IndexingStatusResponseCodes.Error)
2856
+ var makeRegistrarActionsResponseErrorSchema = (_valueLabel = "Registrar Actions Response Error") => z11.strictObject({
2857
+ responseCode: z11.literal(RegistrarActionsResponseCodes.Error),
2858
+ error: ErrorResponseSchema
2238
2859
  });
2239
- var makeIndexingStatusResponseSchema = (valueLabel = "Indexing Status Response") => z11.discriminatedUnion("responseCode", [
2240
- makeIndexingStatusResponseOkSchema(valueLabel),
2241
- makeIndexingStatusResponseErrorSchema(valueLabel)
2860
+ var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Response") => z11.discriminatedUnion("responseCode", [
2861
+ makeRegistrarActionsResponseOkSchema(valueLabel),
2862
+ makeRegistrarActionsResponseErrorSchema(valueLabel)
2242
2863
  ]);
2243
2864
 
2244
- // src/api/indexing-status/deserialize.ts
2245
- function deserializeIndexingStatusResponse(maybeResponse) {
2246
- const parsed = makeIndexingStatusResponseSchema().safeParse(maybeResponse);
2247
- if (parsed.error) {
2248
- throw new Error(`Cannot deserialize IndexingStatusResponse:
2249
- ${prettifyError5(parsed.error)}
2250
- `);
2251
- }
2252
- return parsed.data;
2253
- }
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;
2265
- }
2266
- }
2267
-
2268
2865
  // src/api/registrar-actions/deserialize.ts
2269
- import { prettifyError as prettifyError6 } from "zod/v4";
2270
2866
  function deserializeRegistrarActionsResponse(maybeResponse) {
2271
2867
  const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse);
2272
2868
  if (parsed.error) {
2273
2869
  throw new Error(
2274
2870
  `Cannot deserialize RegistrarActionsResponse:
2275
- ${prettifyError6(parsed.error)}
2871
+ ${prettifyError8(parsed.error)}
2276
2872
  `
2277
2873
  );
2278
2874
  }
@@ -2282,7 +2878,8 @@ ${prettifyError6(parsed.error)}
2282
2878
  // src/api/registrar-actions/request.ts
2283
2879
  var RegistrarActionsFilterTypes = {
2284
2880
  BySubregistryNode: "bySubregistryNode",
2285
- WithEncodedReferral: "withEncodedReferral"
2881
+ WithEncodedReferral: "withEncodedReferral",
2882
+ ByDecodedReferrer: "byDecodedReferrer"
2286
2883
  };
2287
2884
  var RegistrarActionsOrders = {
2288
2885
  LatestRegistrarActions: "orderBy[timestamp]=desc"
@@ -2306,9 +2903,19 @@ function withReferral(withReferral2) {
2306
2903
  filterType: RegistrarActionsFilterTypes.WithEncodedReferral
2307
2904
  };
2308
2905
  }
2906
+ function byDecodedReferrer(decodedReferrer) {
2907
+ if (typeof decodedReferrer === "undefined") {
2908
+ return void 0;
2909
+ }
2910
+ return {
2911
+ filterType: RegistrarActionsFilterTypes.ByDecodedReferrer,
2912
+ value: decodedReferrer
2913
+ };
2914
+ }
2309
2915
  var registrarActionsFilter = {
2310
2916
  byParentNode,
2311
- withReferral
2917
+ withReferral,
2918
+ byDecodedReferrer
2312
2919
  };
2313
2920
 
2314
2921
  // src/api/registrar-actions/prerequisites.ts
@@ -2361,12 +2968,80 @@ var registrarActionsPrerequisites = Object.freeze({
2361
2968
  }
2362
2969
  });
2363
2970
 
2971
+ // src/registrars/basenames-subregistry.ts
2972
+ import {
2973
+ DatasourceNames as DatasourceNames2,
2974
+ ENSNamespaceIds as ENSNamespaceIds3,
2975
+ maybeGetDatasource as maybeGetDatasource2
2976
+ } from "@ensnode/datasources";
2977
+ function getBasenamesSubregistryId(namespace) {
2978
+ const datasource = maybeGetDatasource2(namespace, DatasourceNames2.Basenames);
2979
+ if (!datasource) {
2980
+ throw new Error(`Datasource not found for ${namespace} ${DatasourceNames2.Basenames}`);
2981
+ }
2982
+ const address = datasource.contracts.BaseRegistrar?.address;
2983
+ if (address === void 0 || Array.isArray(address)) {
2984
+ throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
2985
+ }
2986
+ return {
2987
+ chainId: datasource.chain.id,
2988
+ address
2989
+ };
2990
+ }
2991
+ function getBasenamesSubregistryManagedName(namespaceId) {
2992
+ switch (namespaceId) {
2993
+ case ENSNamespaceIds3.Mainnet:
2994
+ return "base.eth";
2995
+ case ENSNamespaceIds3.Sepolia:
2996
+ return "basetest.eth";
2997
+ case ENSNamespaceIds3.Holesky:
2998
+ case ENSNamespaceIds3.EnsTestEnv:
2999
+ throw new Error(
3000
+ `No registrar managed name is known for the 'basenames' subregistry within the "${namespaceId}" namespace.`
3001
+ );
3002
+ }
3003
+ }
3004
+
2364
3005
  // src/registrars/ethnames-subregistry.ts
2365
- import { DatasourceNames as DatasourceNames2, maybeGetDatasource as maybeGetDatasource2 } from "@ensnode/datasources";
3006
+ import {
3007
+ DatasourceNames as DatasourceNames3,
3008
+ ENSNamespaceIds as ENSNamespaceIds4,
3009
+ maybeGetDatasource as maybeGetDatasource3
3010
+ } from "@ensnode/datasources";
2366
3011
  function getEthnamesSubregistryId(namespace) {
2367
- const datasource = maybeGetDatasource2(namespace, DatasourceNames2.ENSRoot);
3012
+ const datasource = maybeGetDatasource3(namespace, DatasourceNames3.ENSRoot);
3013
+ if (!datasource) {
3014
+ throw new Error(`Datasource not found for ${namespace} ${DatasourceNames3.ENSRoot}`);
3015
+ }
3016
+ const address = datasource.contracts.BaseRegistrar?.address;
3017
+ if (address === void 0 || Array.isArray(address)) {
3018
+ throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3019
+ }
3020
+ return {
3021
+ chainId: datasource.chain.id,
3022
+ address
3023
+ };
3024
+ }
3025
+ function getEthnamesSubregistryManagedName(namespaceId) {
3026
+ switch (namespaceId) {
3027
+ case ENSNamespaceIds4.Mainnet:
3028
+ case ENSNamespaceIds4.Sepolia:
3029
+ case ENSNamespaceIds4.Holesky:
3030
+ case ENSNamespaceIds4.EnsTestEnv:
3031
+ return "eth";
3032
+ }
3033
+ }
3034
+
3035
+ // src/registrars/lineanames-subregistry.ts
3036
+ import {
3037
+ DatasourceNames as DatasourceNames4,
3038
+ ENSNamespaceIds as ENSNamespaceIds5,
3039
+ maybeGetDatasource as maybeGetDatasource4
3040
+ } from "@ensnode/datasources";
3041
+ function getLineanamesSubregistryId(namespace) {
3042
+ const datasource = maybeGetDatasource4(namespace, DatasourceNames4.Lineanames);
2368
3043
  if (!datasource) {
2369
- throw new Error(`Datasource not found for ${namespace} ${DatasourceNames2.ENSRoot}`);
3044
+ throw new Error(`Datasource not found for ${namespace} ${DatasourceNames4.Lineanames}`);
2370
3045
  }
2371
3046
  const address = datasource.contracts.BaseRegistrar?.address;
2372
3047
  if (address === void 0 || Array.isArray(address)) {
@@ -2377,6 +3052,19 @@ function getEthnamesSubregistryId(namespace) {
2377
3052
  address
2378
3053
  };
2379
3054
  }
3055
+ function getLineanamesSubregistryManagedName(namespaceId) {
3056
+ switch (namespaceId) {
3057
+ case ENSNamespaceIds5.Mainnet:
3058
+ return "linea.eth";
3059
+ case ENSNamespaceIds5.Sepolia:
3060
+ return "linea-sepolia.eth";
3061
+ case ENSNamespaceIds5.Holesky:
3062
+ case ENSNamespaceIds5.EnsTestEnv:
3063
+ throw new Error(
3064
+ `No registrar managed name is known for the 'Lineanames' subregistry within the "${namespaceId}" namespace.`
3065
+ );
3066
+ }
3067
+ }
2380
3068
 
2381
3069
  // src/api/registrar-actions/serialize.ts
2382
3070
  function serializeNamedRegistrarAction({
@@ -2393,7 +3081,8 @@ function serializeRegistrarActionsResponse(response) {
2393
3081
  case RegistrarActionsResponseCodes.Ok:
2394
3082
  return {
2395
3083
  responseCode: response.responseCode,
2396
- registrarActions: response.registrarActions.map(serializeNamedRegistrarAction)
3084
+ registrarActions: response.registrarActions.map(serializeNamedRegistrarAction),
3085
+ pageContext: response.pageContext
2397
3086
  };
2398
3087
  case RegistrarActionsResponseCodes.Error:
2399
3088
  return response;
@@ -2401,17 +3090,52 @@ function serializeRegistrarActionsResponse(response) {
2401
3090
  }
2402
3091
 
2403
3092
  // src/api/shared/errors/deserialize.ts
2404
- import { prettifyError as prettifyError7 } from "zod/v4";
3093
+ import { prettifyError as prettifyError9 } from "zod/v4";
2405
3094
  function deserializeErrorResponse(maybeErrorResponse) {
2406
3095
  const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse);
2407
3096
  if (parsed.error) {
2408
3097
  throw new Error(`Cannot deserialize ErrorResponse:
2409
- ${prettifyError7(parsed.error)}
3098
+ ${prettifyError9(parsed.error)}
2410
3099
  `);
2411
3100
  }
2412
3101
  return parsed.data;
2413
3102
  }
2414
3103
 
3104
+ // src/api/shared/pagination/build-page-context.ts
3105
+ function buildPageContext(page, recordsPerPage, totalRecords) {
3106
+ const totalPages = Math.max(1, Math.ceil(totalRecords / recordsPerPage));
3107
+ if (page > totalPages) {
3108
+ throw new Error(`Invalid page: page ${page} exceeds total pages ${totalPages}.`);
3109
+ }
3110
+ if (totalRecords === 0) {
3111
+ return {
3112
+ page,
3113
+ recordsPerPage,
3114
+ totalRecords: 0,
3115
+ totalPages: 1,
3116
+ hasNext: false,
3117
+ hasPrev: false,
3118
+ startIndex: void 0,
3119
+ endIndex: void 0
3120
+ };
3121
+ }
3122
+ const startIndex = (page - 1) * recordsPerPage;
3123
+ const maxTheoreticalIndexOnPage = startIndex + (recordsPerPage - 1);
3124
+ const endIndex = Math.min(maxTheoreticalIndexOnPage, totalRecords - 1);
3125
+ const hasNext = maxTheoreticalIndexOnPage < totalRecords - 1;
3126
+ const hasPrev = page > 1;
3127
+ return {
3128
+ page,
3129
+ recordsPerPage,
3130
+ totalRecords,
3131
+ totalPages,
3132
+ hasNext,
3133
+ hasPrev,
3134
+ startIndex,
3135
+ endIndex
3136
+ };
3137
+ }
3138
+
2415
3139
  // src/client-error.ts
2416
3140
  var ClientError = class _ClientError extends Error {
2417
3141
  details;
@@ -2426,7 +3150,7 @@ var ClientError = class _ClientError extends Error {
2426
3150
  };
2427
3151
 
2428
3152
  // src/ensanalytics/deserialize.ts
2429
- import { prettifyError as prettifyError8 } from "zod/v4";
3153
+ import { prettifyError as prettifyError10 } from "zod/v4";
2430
3154
 
2431
3155
  // src/ensanalytics/zod-schemas.ts
2432
3156
  import z12 from "zod/v4";
@@ -2511,9 +3235,9 @@ var makeAggregatedReferrerMetricsSchema = (valueLabel = "AggregatedReferrerMetri
2511
3235
  });
2512
3236
  var makeReferrerLeaderboardPageContextSchema = (valueLabel = "ReferrerLeaderboardPageContext") => z12.object({
2513
3237
  page: makePositiveIntegerSchema(`${valueLabel}.page`),
2514
- itemsPerPage: makePositiveIntegerSchema(`${valueLabel}.itemsPerPage`).max(
3238
+ recordsPerPage: makePositiveIntegerSchema(`${valueLabel}.recordsPerPage`).max(
2515
3239
  REFERRERS_PER_LEADERBOARD_PAGE_MAX,
2516
- `${valueLabel}.itemsPerPage must not exceed ${REFERRERS_PER_LEADERBOARD_PAGE_MAX}`
3240
+ `${valueLabel}.recordsPerPage must not exceed ${REFERRERS_PER_LEADERBOARD_PAGE_MAX}`
2517
3241
  ),
2518
3242
  totalRecords: makeNonNegativeIntegerSchema(`${valueLabel}.totalRecords`),
2519
3243
  totalPages: makePositiveIntegerSchema(`${valueLabel}.totalPages`),
@@ -2524,9 +3248,9 @@ var makeReferrerLeaderboardPageContextSchema = (valueLabel = "ReferrerLeaderboar
2524
3248
  });
2525
3249
  var makeReferrerLeaderboardPageSchema = (valueLabel = "ReferrerLeaderboardPage") => z12.object({
2526
3250
  rules: makeReferralProgramRulesSchema(`${valueLabel}.rules`),
2527
- referrers: z12.array(makeAwardedReferrerMetricsSchema(`${valueLabel}.referrers[item]`)),
3251
+ referrers: z12.array(makeAwardedReferrerMetricsSchema(`${valueLabel}.referrers[record]`)),
2528
3252
  aggregatedMetrics: makeAggregatedReferrerMetricsSchema(`${valueLabel}.aggregatedMetrics`),
2529
- paginationContext: makeReferrerLeaderboardPageContextSchema(`${valueLabel}.paginationContext`),
3253
+ pageContext: makeReferrerLeaderboardPageContextSchema(`${valueLabel}.pageContext`),
2530
3254
  accurateAsOf: makeUnixTimestampSchema(`${valueLabel}.accurateAsOf`)
2531
3255
  });
2532
3256
  var makeReferrerLeaderboardPageResponseOkSchema = (valueLabel = "ReferrerLeaderboardPageResponseOk") => z12.object({
@@ -2580,7 +3304,7 @@ function deserializeReferrerLeaderboardPageResponse(maybeResponse, valueLabel) {
2580
3304
  if (parsed.error) {
2581
3305
  throw new Error(
2582
3306
  `Cannot deserialize SerializedReferrerLeaderboardPageResponse:
2583
- ${prettifyError8(parsed.error)}
3307
+ ${prettifyError10(parsed.error)}
2584
3308
  `
2585
3309
  );
2586
3310
  }
@@ -2591,7 +3315,7 @@ function deserializeReferrerDetailResponse(maybeResponse, valueLabel) {
2591
3315
  const parsed = schema.safeParse(maybeResponse);
2592
3316
  if (parsed.error) {
2593
3317
  throw new Error(`Cannot deserialize ReferrerDetailResponse:
2594
- ${prettifyError8(parsed.error)}
3318
+ ${prettifyError10(parsed.error)}
2595
3319
  `);
2596
3320
  }
2597
3321
  return parsed.data;
@@ -2859,7 +3583,7 @@ var ENSNodeClient = class _ENSNodeClient {
2859
3583
  *
2860
3584
  * @param request - Pagination parameters
2861
3585
  * @param request.page - The page number to retrieve (1-indexed, default: 1)
2862
- * @param request.itemsPerPage - Number of items per page (default: 25, max: 100)
3586
+ * @param request.recordsPerPage - Number of records per page (default: 25, max: 100)
2863
3587
  * @returns {ReferrerLeaderboardPageResponse}
2864
3588
  *
2865
3589
  * @throws if the ENSNode request fails
@@ -2868,28 +3592,28 @@ var ENSNodeClient = class _ENSNodeClient {
2868
3592
  *
2869
3593
  * @example
2870
3594
  * ```typescript
2871
- * // Get first page with default page size (25 items)
3595
+ * // Get first page with default page size (25 records)
2872
3596
  * const response = await client.getReferrerLeaderboardPage();
2873
3597
  * if (response.responseCode === ReferrerLeaderboardPageResponseCodes.Ok) {
2874
3598
  * const {
2875
3599
  * aggregatedMetrics,
2876
3600
  * referrers,
2877
3601
  * rules,
2878
- * paginationContext,
3602
+ * pageContext,
2879
3603
  * updatedAt
2880
3604
  * } = response.data;
2881
3605
  * console.log(aggregatedMetrics);
2882
3606
  * console.log(referrers);
2883
3607
  * console.log(rules);
2884
3608
  * console.log(updatedAt);
2885
- * console.log(`Page ${paginationContext.page} of ${paginationContext.totalPages}`);
3609
+ * console.log(`Page ${pageContext.page} of ${pageContext.totalPages}`);
2886
3610
  * }
2887
3611
  * ```
2888
3612
  *
2889
3613
  * @example
2890
3614
  * ```typescript
2891
- * // Get second page with 50 items per page
2892
- * const response = await client.getReferrerLeaderboardPage({ page: 2, itemsPerPage: 50 });
3615
+ * // Get second page with 50 records per page
3616
+ * const response = await client.getReferrerLeaderboardPage({ page: 2, recordsPerPage: 50 });
2893
3617
  * ```
2894
3618
  *
2895
3619
  * @example
@@ -2906,8 +3630,8 @@ var ENSNodeClient = class _ENSNodeClient {
2906
3630
  async getReferrerLeaderboardPage(request) {
2907
3631
  const url = new URL(`/ensanalytics/referrers`, this.options.url);
2908
3632
  if (request?.page) url.searchParams.set("page", request.page.toString());
2909
- if (request?.itemsPerPage)
2910
- url.searchParams.set("itemsPerPage", request.itemsPerPage.toString());
3633
+ if (request?.recordsPerPage)
3634
+ url.searchParams.set("recordsPerPage", request.recordsPerPage.toString());
2911
3635
  const response = await fetch(url);
2912
3636
  let responseData;
2913
3637
  try {
@@ -3012,11 +3736,13 @@ var ENSNodeClient = class _ENSNodeClient {
3012
3736
  /**
3013
3737
  * Fetch ENSNode Registrar Actions
3014
3738
  *
3015
- * @param {RegistrarActionsRequestFilter} request.filter is
3016
- * an optional request filter configuration.
3017
- * @param {number} request.limit sets the maximum count of results in the response.
3018
- * @param {RegistrarActionsRequestOrder} request.order sets the order of
3019
- * results in the response by field and direction.
3739
+ * Retrieves a paginated list of registrar actions with optional filters.
3740
+ *
3741
+ * @param request is a request configuration.
3742
+ * @param request.page sets the page number to retrieve (1-indexed, default: 1)
3743
+ * @param request.recordsPerPage sets the number of records per page (default: 10, max: 100)
3744
+ * @param request.filters is an optional request filter configuration.
3745
+ * @param request.order sets the order of results in the response by field and direction.
3020
3746
  * @returns {RegistrarActionsResponse}
3021
3747
  *
3022
3748
  * @throws if the ENSNode request fails
@@ -3026,23 +3752,25 @@ var ENSNodeClient = class _ENSNodeClient {
3026
3752
  * @example
3027
3753
  * ```ts
3028
3754
  * import {
3029
- * registrarActionsFilter,,
3755
+ * registrarActionsFilter,
3030
3756
  * ENSNodeClient,
3031
3757
  * } from "@ensnode/ensnode-sdk";
3032
3758
  * import { namehash } from "viem/ens";
3033
3759
  *
3034
3760
  * const client: ENSNodeClient;
3035
3761
  *
3036
- * // get latest registrar action records across all indexed subregistries
3037
- * // NOTE: when no `limit` value is passed,
3038
- * // the default RESPONSE_ITEMS_PER_PAGE_DEFAULT applies.
3039
- * const registrarActions = await client.registrarActions();
3762
+ * // Get first page with default page size (10 records)
3763
+ * const response = await client.registrarActions();
3764
+ * if (response.responseCode === RegistrarActionsResponseCodes.Ok) {
3765
+ * const { registrarActions, pageContext } = response;
3766
+ * console.log(registrarActions);
3767
+ * console.log(`Page ${pageContext.page} of ${pageContext.totalPages}`);
3768
+ * }
3040
3769
  *
3041
- * // get latest 5 registrar action records across all indexed subregistries
3042
- * // NOTE: when a `limit` value is passed, it must be lower than or equal to
3043
- * // the RESPONSE_ITEMS_PER_PAGE_MAX value.
3044
- * const registrarActions = await client.registrarActions({
3045
- * limit: 5,
3770
+ * // Get second page with 25 records per page
3771
+ * const response = await client.registrarActions({
3772
+ * page: 2,
3773
+ * recordsPerPage: 25,
3046
3774
  * });
3047
3775
  *
3048
3776
  * // get latest registrar action records associated with
@@ -3056,11 +3784,16 @@ var ENSNodeClient = class _ENSNodeClient {
3056
3784
  * filters: [registrarActionsFilter.withReferral(true)],
3057
3785
  * });
3058
3786
  *
3787
+ * // get latest registrar action records for a specific decoded referrer
3788
+ * await client.registrarActions({
3789
+ * filters: [registrarActionsFilter.byDecodedReferrer("0x1234567890123456789012345678901234567890")],
3790
+ * });
3791
+ *
3059
3792
  * // get latest 10 registrar action records associated with
3060
3793
  * // subregistry managing `base.eth` name
3061
3794
  * await client.registrarActions({
3062
3795
  * filters: [registrarActionsFilter.byParentNode(namehash('base.eth'))],
3063
- * limit: 10
3796
+ * recordsPerPage: 10
3064
3797
  * });
3065
3798
  * ```
3066
3799
  */
@@ -3077,6 +3810,12 @@ var ENSNodeClient = class _ENSNodeClient {
3077
3810
  );
3078
3811
  return withReferralFilter ? { key: "withReferral", value: "true" } : null;
3079
3812
  };
3813
+ const buildDecodedReferrerArg = (filters) => {
3814
+ const decodedReferrerFilter = filters?.find(
3815
+ (f) => f.filterType === RegistrarActionsFilterTypes.ByDecodedReferrer
3816
+ );
3817
+ return decodedReferrerFilter ? { key: "decodedReferrer", value: decodedReferrerFilter.value } : null;
3818
+ };
3080
3819
  const buildOrderArg = (order) => {
3081
3820
  switch (order) {
3082
3821
  case RegistrarActionsOrders.LatestRegistrarActions: {
@@ -3093,12 +3832,75 @@ var ENSNodeClient = class _ENSNodeClient {
3093
3832
  const orderArgs = buildOrderArg(request.order);
3094
3833
  url.searchParams.set(orderArgs.key, orderArgs.value);
3095
3834
  }
3096
- if (request.itemsPerPage) {
3097
- url.searchParams.set("itemsPerPage", request.itemsPerPage.toString());
3835
+ if (request.page) {
3836
+ url.searchParams.set("page", request.page.toString());
3837
+ }
3838
+ if (request.recordsPerPage) {
3839
+ url.searchParams.set("recordsPerPage", request.recordsPerPage.toString());
3840
+ }
3841
+ const referralArg = buildWithReferralArg(request.filters);
3842
+ if (referralArg) {
3843
+ url.searchParams.set(referralArg.key, referralArg.value);
3844
+ }
3845
+ const decodedReferrerArg = buildDecodedReferrerArg(request.filters);
3846
+ if (decodedReferrerArg) {
3847
+ url.searchParams.set(decodedReferrerArg.key, decodedReferrerArg.value);
3848
+ }
3849
+ const response = await fetch(url);
3850
+ let responseData;
3851
+ try {
3852
+ responseData = await response.json();
3853
+ } catch {
3854
+ throw new Error("Malformed response data: invalid JSON");
3855
+ }
3856
+ if (!response.ok) {
3857
+ let errorResponse;
3858
+ try {
3859
+ errorResponse = deserializeErrorResponse(responseData);
3860
+ } catch {
3861
+ console.log("Registrar Actions API: handling a known server error.");
3862
+ }
3863
+ if (typeof errorResponse !== "undefined") {
3864
+ throw new Error(`Fetching ENSNode Registrar Actions Failed: ${errorResponse.message}`);
3865
+ }
3098
3866
  }
3099
- const referralArg = buildWithReferralArg(request.filters);
3100
- if (referralArg) {
3101
- url.searchParams.set(referralArg.key, referralArg.value);
3867
+ return deserializeRegistrarActionsResponse(responseData);
3868
+ }
3869
+ /**
3870
+ * Fetch Name Tokens for requested name.
3871
+ *
3872
+ * @param request.name - Name for which Name Tokens will be fetched.
3873
+ * @returns {NameTokensResponse}
3874
+ *
3875
+ * @throws if the ENSNode request fails
3876
+ * @throws if the ENSNode API returns an error response
3877
+ * @throws if the ENSNode response breaks required invariants
3878
+ *
3879
+ * @example
3880
+ * ```ts
3881
+ * import {
3882
+ * ENSNodeClient,
3883
+ * } from "@ensnode/ensnode-sdk";
3884
+ * import { namehash } from "viem/ens";
3885
+ *
3886
+ * const client: ENSNodeClient;
3887
+ *
3888
+ * // get latest name token records from the indexed subregistry based on the requested name
3889
+ * const response = await client.nameTokens({
3890
+ * name: "vitalik.eth"
3891
+ * });
3892
+ *
3893
+ * const response = await client.nameTokens({
3894
+ * domainId: "0xee6c4522aab0003e8d14cd40a6af439055fd2577951148c14b6cea9a53475835" // namehash('vitalik.eth')
3895
+ * })
3896
+ * ```
3897
+ */
3898
+ async nameTokens(request) {
3899
+ const url = new URL(`/api/name-tokens`, this.options.url);
3900
+ if (request.name !== void 0) {
3901
+ url.searchParams.set("name", request.name);
3902
+ } else {
3903
+ url.searchParams.set("domainId", request.domainId);
3102
3904
  }
3103
3905
  const response = await fetch(url);
3104
3906
  let responseData;
@@ -3112,18 +3914,18 @@ var ENSNodeClient = class _ENSNodeClient {
3112
3914
  try {
3113
3915
  errorResponse = deserializeErrorResponse(responseData);
3114
3916
  } catch {
3115
- console.log("Registrar Actions API: handling a known server error.");
3917
+ console.log("Name Tokens API: handling a known server error.");
3116
3918
  }
3117
3919
  if (typeof errorResponse !== "undefined") {
3118
- throw new Error(`Fetching ENSNode Registrar Actions Failed: ${errorResponse.message}`);
3920
+ throw new Error(`Fetching ENSNode Name Tokens Failed: ${errorResponse.message}`);
3119
3921
  }
3120
3922
  }
3121
- return deserializeRegistrarActionsResponse(responseData);
3923
+ return deserializedNameTokensResponse(responseData);
3122
3924
  }
3123
3925
  };
3124
3926
 
3125
3927
  // src/identity/identity.ts
3126
- import { getENSRootChainId as getENSRootChainId3 } from "@ensnode/datasources";
3928
+ import { getENSRootChainId as getENSRootChainId2 } from "@ensnode/datasources";
3127
3929
 
3128
3930
  // src/identity/types.ts
3129
3931
  var ResolutionStatusIds = {
@@ -3150,7 +3952,7 @@ var ResolutionStatusIds = {
3150
3952
  function buildUnresolvedIdentity(address, namespaceId, chainId) {
3151
3953
  return {
3152
3954
  resolutionStatus: ResolutionStatusIds.Unresolved,
3153
- chainId: chainId ?? getENSRootChainId3(namespaceId),
3955
+ chainId: chainId ?? getENSRootChainId2(namespaceId),
3154
3956
  address
3155
3957
  };
3156
3958
  }
@@ -3159,244 +3961,19 @@ function isResolvedIdentity(identity) {
3159
3961
  }
3160
3962
 
3161
3963
  // src/resolution/ensip19-chainid.ts
3162
- import { mainnet as mainnet2 } from "viem/chains";
3163
- import { getENSRootChainId as getENSRootChainId4 } from "@ensnode/datasources";
3964
+ import { mainnet } from "viem/chains";
3965
+ import { getENSRootChainId as getENSRootChainId3 } from "@ensnode/datasources";
3164
3966
  var getResolvePrimaryNameChainIdParam = (chainId, namespaceId) => {
3165
- const ensRootChainId = getENSRootChainId4(namespaceId);
3166
- return chainId === ensRootChainId ? mainnet2.id : chainId;
3967
+ const ensRootChainId = getENSRootChainId3(namespaceId);
3968
+ return chainId === ensRootChainId ? mainnet.id : chainId;
3167
3969
  };
3168
3970
  var translateDefaultableChainIdToChainId = (chainId, namespaceId) => {
3169
- return chainId === DEFAULT_EVM_CHAIN_ID ? getENSRootChainId4(namespaceId) : chainId;
3971
+ return chainId === DEFAULT_EVM_CHAIN_ID ? getENSRootChainId3(namespaceId) : chainId;
3170
3972
  };
3171
3973
 
3172
3974
  // src/resolution/resolver-records-selection.ts
3173
3975
  var isSelectionEmpty = (selection) => !selection.name && !selection.addresses?.length && !selection.texts?.length;
3174
3976
 
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
-
3400
3977
  // src/tracing/index.ts
3401
3978
  var TraceableENSProtocol = /* @__PURE__ */ ((TraceableENSProtocol2) => {
3402
3979
  TraceableENSProtocol2["ForwardResolution"] = "forward-resolution";
@@ -3442,6 +4019,7 @@ export {
3442
4019
  DEFAULT_EVM_COIN_TYPE,
3443
4020
  ENSNamespaceIds,
3444
4021
  ENSNodeClient,
4022
+ ENS_ROOT,
3445
4023
  ETH_COIN_TYPE,
3446
4024
  ETH_NODE,
3447
4025
  ForwardResolutionProtocolStep,
@@ -3450,6 +4028,9 @@ export {
3450
4028
  LruCache,
3451
4029
  NFTMintStatuses,
3452
4030
  NFTTransferTypes,
4031
+ NameTokenOwnershipTypes,
4032
+ NameTokensResponseCodes,
4033
+ NameTokensResponseErrorCodes,
3453
4034
  OmnichainIndexingStatusIds,
3454
4035
  PROTOCOL_ATTRIBUTE_PREFIX,
3455
4036
  PluginName,
@@ -3482,6 +4063,7 @@ export {
3482
4063
  buildEnsRainbowClientLabelSet,
3483
4064
  buildLabelSetId,
3484
4065
  buildLabelSetVersion,
4066
+ buildPageContext,
3485
4067
  buildUnresolvedIdentity,
3486
4068
  checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotBackfill,
3487
4069
  checkChainIndexingStatusSnapshotsForOmnichainStatusSnapshotCompleted,
@@ -3494,7 +4076,7 @@ export {
3494
4076
  decodeDNSEncodedLiteralName,
3495
4077
  decodeDNSEncodedName,
3496
4078
  decodeEncodedReferrer,
3497
- deserializeAccountId,
4079
+ deserializeAssetId,
3498
4080
  deserializeBlockNumber,
3499
4081
  deserializeBlockRef,
3500
4082
  deserializeBlockrange,
@@ -3515,18 +4097,30 @@ export {
3515
4097
  deserializeRegistrarActionsResponse,
3516
4098
  deserializeUnixTimestamp,
3517
4099
  deserializeUrl,
4100
+ deserializedNameTokensResponse,
3518
4101
  durationBetween,
3519
4102
  encodeLabelHash,
3520
4103
  evmChainIdToCoinType,
4104
+ formatAccountId,
4105
+ formatAssetId,
3521
4106
  formatNFTTransferEventMetadata,
4107
+ getBasenamesSubregistryId,
4108
+ getBasenamesSubregistryManagedName,
3522
4109
  getCurrencyInfo,
4110
+ getDatasourceContract,
3523
4111
  getENSRootChainId,
3524
4112
  getEthnamesSubregistryId,
4113
+ getEthnamesSubregistryManagedName,
3525
4114
  getLatestIndexedBlockRef,
4115
+ getLineanamesSubregistryId,
4116
+ getLineanamesSubregistryManagedName,
3526
4117
  getNFTTransferType,
3527
4118
  getNameHierarchy,
4119
+ getNameTokenOwnership,
4120
+ getNameWrapperAccounts,
3528
4121
  getOmnichainIndexingCursor,
3529
4122
  getOmnichainIndexingStatus,
4123
+ getParentNameFQDN,
3530
4124
  getResolvePrimaryNameChainIdParam,
3531
4125
  getTimestampForHighestOmnichainKnownBlock,
3532
4126
  getTimestampForLowestOmnichainStartBlock,
@@ -3552,6 +4146,10 @@ export {
3552
4146
  literalLabelsToLiteralName,
3553
4147
  makeENSApiPublicConfigSchema,
3554
4148
  makeSubdomainNode,
4149
+ maybeGetDatasourceContract,
4150
+ nameTokensPrerequisites,
4151
+ parseAccountId,
4152
+ parseAssetId,
3555
4153
  parseNonNegativeInteger,
3556
4154
  parseReverseName,
3557
4155
  priceDai,
@@ -3560,17 +4158,19 @@ export {
3560
4158
  registrarActionsFilter,
3561
4159
  registrarActionsPrerequisites,
3562
4160
  reverseName,
3563
- serializeAccountId,
3564
4161
  serializeAssetId,
3565
4162
  serializeChainId,
3566
4163
  serializeChainIndexingSnapshots,
3567
4164
  serializeConfigResponse,
3568
4165
  serializeCrossChainIndexingStatusSnapshotOmnichain,
3569
4166
  serializeDatetime,
4167
+ serializeDomainAssetId,
3570
4168
  serializeENSApiPublicConfig,
3571
4169
  serializeENSIndexerPublicConfig,
3572
4170
  serializeIndexedChainIds,
3573
4171
  serializeIndexingStatusResponse,
4172
+ serializeNameToken,
4173
+ serializeNameTokensResponse,
3574
4174
  serializeNamedRegistrarAction,
3575
4175
  serializeOmnichainIndexingStatusSnapshot,
3576
4176
  serializePrice,
@@ -3578,11 +4178,10 @@ export {
3578
4178
  serializeRealtimeIndexingStatusProjection,
3579
4179
  serializeReferrerDetailResponse,
3580
4180
  serializeReferrerLeaderboardPageResponse,
4181
+ serializeRegisteredNameTokens,
3581
4182
  serializeRegistrarAction,
3582
4183
  serializeRegistrarActionPricing,
3583
4184
  serializeRegistrarActionsResponse,
3584
- serializeRegistrationLifecycle,
3585
- serializeSubregistry,
3586
4185
  serializeUrl,
3587
4186
  sortChainStatusesByStartBlockAsc,
3588
4187
  stripNullBytes,