@ensnode/ensnode-sdk 0.0.0-next-20260216102612 → 0.0.0-next-20260216122402

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -47,7 +47,7 @@ __export(index_exports, {
47
47
  DEFAULT_EVM_COIN_TYPE: () => DEFAULT_EVM_COIN_TYPE,
48
48
  ENCODED_REFERRER_BYTE_LENGTH: () => ENCODED_REFERRER_BYTE_LENGTH,
49
49
  ENCODED_REFERRER_BYTE_OFFSET: () => ENCODED_REFERRER_BYTE_OFFSET,
50
- ENSNamespaceIds: () => import_datasources.ENSNamespaceIds,
50
+ ENSNamespaceIds: () => import_datasources2.ENSNamespaceIds,
51
51
  ENSNodeClient: () => ENSNodeClient,
52
52
  ENS_ROOT: () => ENS_ROOT,
53
53
  ETH_COIN_TYPE: () => ETH_COIN_TYPE,
@@ -149,7 +149,7 @@ __export(index_exports, {
149
149
  getCurrencyInfo: () => getCurrencyInfo,
150
150
  getDatasourceContract: () => getDatasourceContract,
151
151
  getDefaultEnsNodeUrl: () => getDefaultEnsNodeUrl,
152
- getENSRootChainId: () => import_datasources2.getENSRootChainId,
152
+ getENSRootChainId: () => import_datasources3.getENSRootChainId,
153
153
  getENSv1Registry: () => getENSv1Registry,
154
154
  getENSv2RootRegistry: () => getENSv2RootRegistry,
155
155
  getENSv2RootRegistryId: () => getENSv2RootRegistryId,
@@ -276,6 +276,37 @@ __export(index_exports, {
276
276
  });
277
277
  module.exports = __toCommonJS(index_exports);
278
278
 
279
+ // src/client-error.ts
280
+ var ClientError = class _ClientError extends Error {
281
+ details;
282
+ constructor(message, details) {
283
+ super(message);
284
+ this.name = "ClientError";
285
+ this.details = details;
286
+ }
287
+ static fromErrorResponse({ message, details }) {
288
+ return new _ClientError(message, details);
289
+ }
290
+ };
291
+
292
+ // src/deployments.ts
293
+ var import_datasources = require("@ensnode/datasources");
294
+ var DEFAULT_ENSNODE_API_URL_MAINNET = "https://api.alpha.ensnode.io";
295
+ var DEFAULT_ENSNODE_API_URL_SEPOLIA = "https://api.alpha-sepolia.ensnode.io";
296
+ var getDefaultEnsNodeUrl = (namespace) => {
297
+ const effectiveNamespace = namespace ?? import_datasources.ENSNamespaceIds.Mainnet;
298
+ switch (effectiveNamespace) {
299
+ case import_datasources.ENSNamespaceIds.Mainnet:
300
+ return new URL(DEFAULT_ENSNODE_API_URL_MAINNET);
301
+ case import_datasources.ENSNamespaceIds.Sepolia:
302
+ return new URL(DEFAULT_ENSNODE_API_URL_SEPOLIA);
303
+ default:
304
+ throw new Error(
305
+ `ENSNamespaceId ${effectiveNamespace} does not have a default ENSNode URL defined`
306
+ );
307
+ }
308
+ };
309
+
279
310
  // src/ensapi/config/deserialize.ts
280
311
  var import_v45 = require("zod/v4");
281
312
 
@@ -294,7 +325,7 @@ var import_viem8 = require("viem");
294
325
  var import_v4 = require("zod/v4");
295
326
 
296
327
  // src/ens/index.ts
297
- var import_datasources2 = require("@ensnode/datasources");
328
+ var import_datasources3 = require("@ensnode/datasources");
298
329
 
299
330
  // src/ens/coin-type.ts
300
331
  var import_utils = require("@ensdomains/address-encoder/utils");
@@ -483,7 +514,7 @@ var makeSubdomainNode = (labelHash, node) => (0, import_viem5.keccak256)((0, imp
483
514
  var uint256ToHex32 = (num) => (0, import_viem5.toHex)(num, { size: 32 });
484
515
 
485
516
  // src/ens/types.ts
486
- var import_datasources = require("@ensnode/datasources");
517
+ var import_datasources2 = require("@ensnode/datasources");
487
518
 
488
519
  // src/shared/currencies.ts
489
520
  var import_viem6 = require("viem");
@@ -714,9 +745,9 @@ var makeBlockRefSchema = (valueLabel = "Value") => import_v4.z.strictObject(
714
745
  error: `${valueLabel} must be a valid BlockRef object.`
715
746
  }
716
747
  );
717
- var makeENSNamespaceIdSchema = (valueLabel = "ENSNamespaceId") => import_v4.z.enum(import_datasources.ENSNamespaceIds, {
748
+ var makeENSNamespaceIdSchema = (valueLabel = "ENSNamespaceId") => import_v4.z.enum(import_datasources2.ENSNamespaceIds, {
718
749
  error() {
719
- return `Invalid ${valueLabel}. Supported ENS namespace IDs are: ${Object.keys(import_datasources.ENSNamespaceIds).join(", ")}`;
750
+ return `Invalid ${valueLabel}. Supported ENS namespace IDs are: ${Object.keys(import_datasources2.ENSNamespaceIds).join(", ")}`;
720
751
  }
721
752
  });
722
753
  var makePriceAmountSchema = (valueLabel = "Amount") => import_v4.z.coerce.bigint({
@@ -779,7 +810,7 @@ var makeReinterpretedNameSchema = (valueLabel = "Reinterpreted Name") => import_
779
810
  }).transform(reinterpretName);
780
811
 
781
812
  // src/ensindexer/config/is-subgraph-compatible.ts
782
- var import_datasources3 = require("@ensnode/datasources");
813
+ var import_datasources4 = require("@ensnode/datasources");
783
814
 
784
815
  // src/ensindexer/config/types.ts
785
816
  var PluginName = /* @__PURE__ */ ((PluginName2) => {
@@ -799,7 +830,7 @@ function isSubgraphCompatible(config) {
799
830
  const onlySubgraphPluginActivated = config.plugins.length === 1 && config.plugins[0] === "subgraph" /* Subgraph */;
800
831
  const isSubgraphLabelSet = config.labelSet.labelSetId === "subgraph" && config.labelSet.labelSetVersion === 0;
801
832
  const isEnsTestEnvLabelSet = config.labelSet.labelSetId === "ens-test-env" && config.labelSet.labelSetVersion === 0;
802
- const labelSetIsSubgraphCompatible = isSubgraphLabelSet || config.namespace === import_datasources3.ENSNamespaceIds.EnsTestEnv && isEnsTestEnvLabelSet;
833
+ const labelSetIsSubgraphCompatible = isSubgraphLabelSet || config.namespace === import_datasources4.ENSNamespaceIds.EnsTestEnv && isEnsTestEnvLabelSet;
803
834
  return onlySubgraphPluginActivated && labelSetIsSubgraphCompatible;
804
835
  }
805
836
 
@@ -930,6 +961,11 @@ ${(0, import_v45.prettifyError)(error)}
930
961
  }
931
962
  }
932
963
 
964
+ // src/ensapi/api/config/deserialize.ts
965
+ function deserializeConfigResponse(serializedResponse) {
966
+ return deserializeENSApiPublicConfig(serializedResponse);
967
+ }
968
+
933
969
  // src/ensindexer/config/deserialize.ts
934
970
  var import_v46 = require("zod/v4");
935
971
  function deserializeENSIndexerPublicConfig(maybeConfig, valueLabel) {
@@ -1996,20 +2032,15 @@ function serializeENSApiPublicConfig(config) {
1996
2032
  };
1997
2033
  }
1998
2034
 
1999
- // src/api/config/deserialize.ts
2000
- function deserializeConfigResponse(serializedResponse) {
2001
- return deserializeENSApiPublicConfig(serializedResponse);
2002
- }
2003
-
2004
- // src/api/config/serialize.ts
2035
+ // src/ensapi/api/config/serialize.ts
2005
2036
  function serializeConfigResponse(response) {
2006
2037
  return serializeENSApiPublicConfig(response);
2007
2038
  }
2008
2039
 
2009
- // src/api/indexing-status/deserialize.ts
2040
+ // src/ensapi/api/indexing-status/deserialize.ts
2010
2041
  var import_v420 = require("zod/v4");
2011
2042
 
2012
- // src/api/indexing-status/response.ts
2043
+ // src/ensapi/api/indexing-status/response.ts
2013
2044
  var IndexingStatusResponseCodes = {
2014
2045
  /**
2015
2046
  * Represents that the indexing status is available.
@@ -2021,7 +2052,7 @@ var IndexingStatusResponseCodes = {
2021
2052
  Error: "error"
2022
2053
  };
2023
2054
 
2024
- // src/api/indexing-status/zod-schemas.ts
2055
+ // src/ensapi/api/indexing-status/zod-schemas.ts
2025
2056
  var import_v419 = require("zod/v4");
2026
2057
  var makeIndexingStatusResponseOkSchema = (valueLabel = "Indexing Status Response OK") => import_v419.z.strictObject({
2027
2058
  responseCode: import_v419.z.literal(IndexingStatusResponseCodes.Ok),
@@ -2043,7 +2074,7 @@ var makeSerializedIndexingStatusResponseSchema = (valueLabel = "Serialized Index
2043
2074
  makeIndexingStatusResponseErrorSchema(valueLabel)
2044
2075
  ]);
2045
2076
 
2046
- // src/api/indexing-status/deserialize.ts
2077
+ // src/ensapi/api/indexing-status/deserialize.ts
2047
2078
  function buildUnvalidatedIndexingStatusResponse(serializedResponse) {
2048
2079
  if (serializedResponse.responseCode !== IndexingStatusResponseCodes.Ok) {
2049
2080
  return serializedResponse;
@@ -2065,7 +2096,7 @@ ${(0, import_v420.prettifyError)(parsed.error)}
2065
2096
  return parsed.data;
2066
2097
  }
2067
2098
 
2068
- // src/api/indexing-status/serialize.ts
2099
+ // src/ensapi/api/indexing-status/serialize.ts
2069
2100
  function serializeIndexingStatusResponse(response) {
2070
2101
  switch (response.responseCode) {
2071
2102
  case IndexingStatusResponseCodes.Ok:
@@ -2078,31 +2109,16 @@ function serializeIndexingStatusResponse(response) {
2078
2109
  }
2079
2110
  }
2080
2111
 
2081
- // src/api/name-tokens/deserialize.ts
2112
+ // src/ensapi/api/name-tokens/deserialize.ts
2082
2113
  var import_v425 = require("zod/v4");
2083
2114
 
2084
- // src/api/name-tokens/zod-schemas.ts
2115
+ // src/ensapi/api/name-tokens/zod-schemas.ts
2085
2116
  var import_viem14 = require("viem");
2086
2117
  var import_v424 = require("zod/v4");
2087
2118
 
2088
- // src/tokenscope/assets.ts
2089
- var import_viem13 = require("viem");
2090
- var import_v422 = require("zod/v4");
2091
-
2092
- // src/tokenscope/zod-schemas.ts
2093
- var import_caip3 = require("caip");
2094
- var import_viem12 = require("viem");
2095
- var import_v421 = require("zod/v4");
2096
-
2097
- // src/shared/types.ts
2098
- var AssetNamespaces = {
2099
- ERC721: "erc721",
2100
- ERC1155: "erc1155"
2101
- };
2102
-
2103
2119
  // src/tokenscope/name-token.ts
2104
- var import_viem11 = require("viem");
2105
- var import_datasources5 = require("@ensnode/datasources");
2120
+ var import_viem13 = require("viem");
2121
+ var import_datasources6 = require("@ensnode/datasources");
2106
2122
 
2107
2123
  // src/shared/account-id.ts
2108
2124
  var import_viem10 = require("viem");
@@ -2111,9 +2127,9 @@ var accountIdEqual = (a, b) => {
2111
2127
  };
2112
2128
 
2113
2129
  // src/shared/datasource-contract.ts
2114
- var import_datasources4 = require("@ensnode/datasources");
2130
+ var import_datasources5 = require("@ensnode/datasources");
2115
2131
  var maybeGetDatasourceContract = (namespaceId, datasourceName, contractName) => {
2116
- const datasource = (0, import_datasources4.maybeGetDatasource)(namespaceId, datasourceName);
2132
+ const datasource = (0, import_datasources5.maybeGetDatasource)(namespaceId, datasourceName);
2117
2133
  if (!datasource) return void 0;
2118
2134
  const address = datasource.contracts[contractName]?.address;
2119
2135
  if (address === void 0 || Array.isArray(address)) return void 0;
@@ -2136,83 +2152,20 @@ var makeContractMatcher = (namespace, b) => (datasourceName, contractName) => {
2136
2152
  return a && accountIdEqual(a, b);
2137
2153
  };
2138
2154
 
2139
- // src/tokenscope/name-token.ts
2140
- var NameTokenOwnershipTypes = {
2141
- /**
2142
- * Name Token is owned by NameWrapper account.
2143
- */
2144
- NameWrapper: "namewrapper",
2145
- /**
2146
- * Name Token is owned fully onchain.
2147
- *
2148
- * This ownership type can only apply to direct subnames of `.eth`
2149
- */
2150
- FullyOnchain: "fully-onchain",
2151
- /**
2152
- * Name Token ownership has been transferred to the null address.
2153
- */
2154
- Burned: "burned",
2155
- /**
2156
- * Name Token ownership is unknown.
2157
- */
2158
- Unknown: "unknown"
2155
+ // src/tokenscope/assets.ts
2156
+ var import_viem12 = require("viem");
2157
+ var import_v422 = require("zod/v4");
2158
+
2159
+ // src/tokenscope/zod-schemas.ts
2160
+ var import_caip3 = require("caip");
2161
+ var import_viem11 = require("viem");
2162
+ var import_v421 = require("zod/v4");
2163
+
2164
+ // src/shared/types.ts
2165
+ var AssetNamespaces = {
2166
+ ERC721: "erc721",
2167
+ ERC1155: "erc1155"
2159
2168
  };
2160
- function serializeNameToken(nameToken) {
2161
- return {
2162
- token: serializeAssetId(nameToken.token),
2163
- ownership: nameToken.ownership,
2164
- mintStatus: nameToken.mintStatus
2165
- };
2166
- }
2167
- function getNameWrapperAccounts(namespaceId) {
2168
- const ethnamesNameWrapperAccount = getDatasourceContract(
2169
- namespaceId,
2170
- import_datasources5.DatasourceNames.ENSRoot,
2171
- "NameWrapper"
2172
- );
2173
- const lineanamesNameWrapperAccount = maybeGetDatasourceContract(
2174
- namespaceId,
2175
- import_datasources5.DatasourceNames.Lineanames,
2176
- "NameWrapper"
2177
- );
2178
- const nameWrapperAccounts = [
2179
- // NameWrapper for direct subnames of .eth is defined for all ENS namespaces
2180
- ethnamesNameWrapperAccount
2181
- ];
2182
- if (lineanamesNameWrapperAccount) {
2183
- nameWrapperAccounts.push(lineanamesNameWrapperAccount);
2184
- }
2185
- return nameWrapperAccounts;
2186
- }
2187
- function getNameTokenOwnership(namespaceId, name, owner) {
2188
- const nameWrapperAccounts = getNameWrapperAccounts(namespaceId);
2189
- const hasNameWrapperOwnership = nameWrapperAccounts.some(
2190
- (nameWrapperAccount) => accountIdEqual(owner, nameWrapperAccount)
2191
- );
2192
- if (hasNameWrapperOwnership) {
2193
- return {
2194
- ownershipType: NameTokenOwnershipTypes.NameWrapper,
2195
- owner
2196
- };
2197
- }
2198
- if ((0, import_viem11.isAddressEqual)(owner.address, import_viem11.zeroAddress)) {
2199
- return {
2200
- ownershipType: NameTokenOwnershipTypes.Burned,
2201
- owner
2202
- };
2203
- }
2204
- const parentName = getParentNameFQDN(name);
2205
- if (parentName === "eth") {
2206
- return {
2207
- ownershipType: NameTokenOwnershipTypes.FullyOnchain,
2208
- owner
2209
- };
2210
- }
2211
- return {
2212
- ownershipType: NameTokenOwnershipTypes.Unknown,
2213
- owner
2214
- };
2215
- }
2216
2169
 
2217
2170
  // src/tokenscope/zod-schemas.ts
2218
2171
  var tokenIdSchemaSerializable = import_v421.z.string();
@@ -2250,7 +2203,7 @@ var makeAssetIdStringSchema = (valueLabel = "Asset ID String Schema") => import_
2250
2203
  }, makeAssetIdSchema(valueLabel));
2251
2204
  function invariant_nameTokenOwnershipHasNonZeroAddressOwner(ctx) {
2252
2205
  const ownership = ctx.value;
2253
- if (ctx.value.owner.address === import_viem12.zeroAddress) {
2206
+ if (ctx.value.owner.address === import_viem11.zeroAddress) {
2254
2207
  ctx.issues.push({
2255
2208
  code: "custom",
2256
2209
  input: ctx.value,
@@ -2276,7 +2229,7 @@ var makeNameTokenOwnershipUnknownSchema = (valueLabel = "Name Token Ownership Un
2276
2229
  }).check(invariant_nameTokenOwnershipHasNonZeroAddressOwner);
2277
2230
  function invariant_nameTokenOwnershipHasZeroAddressOwner(ctx) {
2278
2231
  const ownership = ctx.value;
2279
- if (ctx.value.owner.address !== import_viem12.zeroAddress) {
2232
+ if (ctx.value.owner.address !== import_viem11.zeroAddress) {
2280
2233
  ctx.issues.push({
2281
2234
  code: "custom",
2282
2235
  input: ctx.value,
@@ -2454,11 +2407,11 @@ var NFTTransferTypes = {
2454
2407
  };
2455
2408
  var getNFTTransferType = (from, to, allowMintedRemint, metadata, currentlyIndexedOwner) => {
2456
2409
  const isIndexed = currentlyIndexedOwner !== void 0;
2457
- const isIndexedAsMinted = isIndexed && !(0, import_viem13.isAddressEqual)(currentlyIndexedOwner, import_viem13.zeroAddress);
2458
- const isMint = (0, import_viem13.isAddressEqual)(from, import_viem13.zeroAddress);
2459
- const isBurn = (0, import_viem13.isAddressEqual)(to, import_viem13.zeroAddress);
2460
- const isSelfTransfer = (0, import_viem13.isAddressEqual)(from, to);
2461
- if (isIndexed && !(0, import_viem13.isAddressEqual)(currentlyIndexedOwner, from)) {
2410
+ const isIndexedAsMinted = isIndexed && !(0, import_viem12.isAddressEqual)(currentlyIndexedOwner, import_viem12.zeroAddress);
2411
+ const isMint = (0, import_viem12.isAddressEqual)(from, import_viem12.zeroAddress);
2412
+ const isBurn = (0, import_viem12.isAddressEqual)(to, import_viem12.zeroAddress);
2413
+ const isSelfTransfer = (0, import_viem12.isAddressEqual)(from, to);
2414
+ if (isIndexed && !(0, import_viem12.isAddressEqual)(currentlyIndexedOwner, from)) {
2462
2415
  if (isMint && allowMintedRemint) {
2463
2416
  } else {
2464
2417
  throw new Error(
@@ -2540,14 +2493,92 @@ ${formatNFTTransferEventMetadata(metadata)}`
2540
2493
  }
2541
2494
  };
2542
2495
 
2543
- // src/api/shared/errors/zod-schemas.ts
2496
+ // src/tokenscope/name-token.ts
2497
+ var NameTokenOwnershipTypes = {
2498
+ /**
2499
+ * Name Token is owned by NameWrapper account.
2500
+ */
2501
+ NameWrapper: "namewrapper",
2502
+ /**
2503
+ * Name Token is owned fully onchain.
2504
+ *
2505
+ * This ownership type can only apply to direct subnames of `.eth`
2506
+ */
2507
+ FullyOnchain: "fully-onchain",
2508
+ /**
2509
+ * Name Token ownership has been transferred to the null address.
2510
+ */
2511
+ Burned: "burned",
2512
+ /**
2513
+ * Name Token ownership is unknown.
2514
+ */
2515
+ Unknown: "unknown"
2516
+ };
2517
+ function serializeNameToken(nameToken) {
2518
+ return {
2519
+ token: serializeAssetId(nameToken.token),
2520
+ ownership: nameToken.ownership,
2521
+ mintStatus: nameToken.mintStatus
2522
+ };
2523
+ }
2524
+ function getNameWrapperAccounts(namespaceId) {
2525
+ const ethnamesNameWrapperAccount = getDatasourceContract(
2526
+ namespaceId,
2527
+ import_datasources6.DatasourceNames.ENSRoot,
2528
+ "NameWrapper"
2529
+ );
2530
+ const lineanamesNameWrapperAccount = maybeGetDatasourceContract(
2531
+ namespaceId,
2532
+ import_datasources6.DatasourceNames.Lineanames,
2533
+ "NameWrapper"
2534
+ );
2535
+ const nameWrapperAccounts = [
2536
+ // NameWrapper for direct subnames of .eth is defined for all ENS namespaces
2537
+ ethnamesNameWrapperAccount
2538
+ ];
2539
+ if (lineanamesNameWrapperAccount) {
2540
+ nameWrapperAccounts.push(lineanamesNameWrapperAccount);
2541
+ }
2542
+ return nameWrapperAccounts;
2543
+ }
2544
+ function getNameTokenOwnership(namespaceId, name, owner) {
2545
+ const nameWrapperAccounts = getNameWrapperAccounts(namespaceId);
2546
+ const hasNameWrapperOwnership = nameWrapperAccounts.some(
2547
+ (nameWrapperAccount) => accountIdEqual(owner, nameWrapperAccount)
2548
+ );
2549
+ if (hasNameWrapperOwnership) {
2550
+ return {
2551
+ ownershipType: NameTokenOwnershipTypes.NameWrapper,
2552
+ owner
2553
+ };
2554
+ }
2555
+ if ((0, import_viem13.isAddressEqual)(owner.address, import_viem13.zeroAddress)) {
2556
+ return {
2557
+ ownershipType: NameTokenOwnershipTypes.Burned,
2558
+ owner
2559
+ };
2560
+ }
2561
+ const parentName = getParentNameFQDN(name);
2562
+ if (parentName === "eth") {
2563
+ return {
2564
+ ownershipType: NameTokenOwnershipTypes.FullyOnchain,
2565
+ owner
2566
+ };
2567
+ }
2568
+ return {
2569
+ ownershipType: NameTokenOwnershipTypes.Unknown,
2570
+ owner
2571
+ };
2572
+ }
2573
+
2574
+ // src/ensapi/api/shared/errors/zod-schemas.ts
2544
2575
  var import_v423 = require("zod/v4");
2545
2576
  var ErrorResponseSchema = import_v423.z.object({
2546
2577
  message: import_v423.z.string(),
2547
2578
  details: import_v423.z.optional(import_v423.z.unknown())
2548
2579
  });
2549
2580
 
2550
- // src/api/name-tokens/response.ts
2581
+ // src/ensapi/api/name-tokens/response.ts
2551
2582
  var NameTokensResponseCodes = {
2552
2583
  /**
2553
2584
  * Represents a response when Name Tokens API can respond with requested data.
@@ -2582,7 +2613,7 @@ var NameTokensResponseErrorCodes = {
2582
2613
  IndexingStatusUnsupported: "unsupported-indexing-status"
2583
2614
  };
2584
2615
 
2585
- // src/api/name-tokens/zod-schemas.ts
2616
+ // src/ensapi/api/name-tokens/zod-schemas.ts
2586
2617
  var makeRegisteredNameTokenSchema = (valueLabel = "Registered Name Token", serializable) => import_v424.z.object({
2587
2618
  domainId: makeNodeSchema(`${valueLabel}.domainId`),
2588
2619
  name: makeReinterpretedNameSchema(valueLabel),
@@ -2659,7 +2690,7 @@ var makeNameTokensResponseSchema = (valueLabel = "Name Tokens Response", seriali
2659
2690
  ]);
2660
2691
  };
2661
2692
 
2662
- // src/api/name-tokens/deserialize.ts
2693
+ // src/ensapi/api/name-tokens/deserialize.ts
2663
2694
  function deserializedNameTokensResponse(maybeResponse) {
2664
2695
  const parsed = makeNameTokensResponseSchema("Name Tokens Response", false).safeParse(
2665
2696
  maybeResponse
@@ -2672,7 +2703,7 @@ ${(0, import_v425.prettifyError)(parsed.error)}
2672
2703
  return parsed.data;
2673
2704
  }
2674
2705
 
2675
- // src/api/name-tokens/prerequisites.ts
2706
+ // src/ensapi/api/name-tokens/prerequisites.ts
2676
2707
  var nameTokensPrerequisites = Object.freeze({
2677
2708
  /**
2678
2709
  * Required plugins to enable Name Tokens API routes.
@@ -2711,7 +2742,7 @@ var nameTokensPrerequisites = Object.freeze({
2711
2742
  }
2712
2743
  });
2713
2744
 
2714
- // src/api/name-tokens/serialize.ts
2745
+ // src/ensapi/api/name-tokens/serialize.ts
2715
2746
  function serializeRegisteredNameTokens({
2716
2747
  domainId,
2717
2748
  name,
@@ -2739,10 +2770,10 @@ function serializeNameTokensResponse(response) {
2739
2770
  }
2740
2771
  }
2741
2772
 
2742
- // src/api/registrar-actions/deserialize.ts
2773
+ // src/ensapi/api/registrar-actions/deserialize.ts
2743
2774
  var import_v429 = require("zod/v4");
2744
2775
 
2745
- // src/api/registrar-actions/zod-schemas.ts
2776
+ // src/ensapi/api/registrar-actions/zod-schemas.ts
2746
2777
  var import_ens7 = require("viem/ens");
2747
2778
  var import_v428 = require("zod/v4");
2748
2779
 
@@ -2927,14 +2958,14 @@ var makeRegistrarActionSchema = (valueLabel = "Registrar Action") => import_v426
2927
2958
  makeRegistrarActionRenewalSchema(`${valueLabel} Renewal`)
2928
2959
  ]);
2929
2960
 
2930
- // src/api/shared/pagination/zod-schemas.ts
2961
+ // src/ensapi/api/shared/pagination/zod-schemas.ts
2931
2962
  var import_v427 = require("zod/v4");
2932
2963
 
2933
- // src/api/shared/pagination/request.ts
2964
+ // src/ensapi/api/shared/pagination/request.ts
2934
2965
  var RECORDS_PER_PAGE_DEFAULT = 10;
2935
2966
  var RECORDS_PER_PAGE_MAX = 100;
2936
2967
 
2937
- // src/api/shared/pagination/zod-schemas.ts
2968
+ // src/ensapi/api/shared/pagination/zod-schemas.ts
2938
2969
  var makeRequestPageParamsSchema = (valueLabel = "RequestPageParams") => import_v427.z.object({
2939
2970
  page: makePositiveIntegerSchema(`${valueLabel}.page`),
2940
2971
  recordsPerPage: makePositiveIntegerSchema(`${valueLabel}.recordsPerPage`).max(
@@ -2996,7 +3027,7 @@ var makeResponsePageContextSchema = (valueLabel = "ResponsePageContext") => impo
2996
3027
  makeResponsePageContextSchemaWithRecords(valueLabel)
2997
3028
  ]);
2998
3029
 
2999
- // src/api/registrar-actions/response.ts
3030
+ // src/ensapi/api/registrar-actions/response.ts
3000
3031
  var RegistrarActionsResponseCodes = {
3001
3032
  /**
3002
3033
  * Represents that Registrar Actions are available.
@@ -3008,7 +3039,7 @@ var RegistrarActionsResponseCodes = {
3008
3039
  Error: "error"
3009
3040
  };
3010
3041
 
3011
- // src/api/registrar-actions/zod-schemas.ts
3042
+ // src/ensapi/api/registrar-actions/zod-schemas.ts
3012
3043
  function invariant_registrationLifecycleNodeMatchesName(ctx) {
3013
3044
  const { name, action } = ctx.value;
3014
3045
  const expectedNode = action.registrationLifecycle.node;
@@ -3040,7 +3071,7 @@ var makeRegistrarActionsResponseSchema = (valueLabel = "Registrar Actions Respon
3040
3071
  makeRegistrarActionsResponseErrorSchema(valueLabel)
3041
3072
  ]);
3042
3073
 
3043
- // src/api/registrar-actions/deserialize.ts
3074
+ // src/ensapi/api/registrar-actions/deserialize.ts
3044
3075
  function deserializeRegistrarActionsResponse(maybeResponse) {
3045
3076
  const parsed = makeRegistrarActionsResponseSchema().safeParse(maybeResponse);
3046
3077
  if (parsed.error) {
@@ -3053,7 +3084,7 @@ ${(0, import_v429.prettifyError)(parsed.error)}
3053
3084
  return parsed.data;
3054
3085
  }
3055
3086
 
3056
- // src/api/registrar-actions/request.ts
3087
+ // src/ensapi/api/registrar-actions/request.ts
3057
3088
  var RegistrarActionsFilterTypes = {
3058
3089
  BySubregistryNode: "bySubregistryNode",
3059
3090
  WithEncodedReferral: "withEncodedReferral",
@@ -3065,7 +3096,7 @@ var RegistrarActionsOrders = {
3065
3096
  LatestRegistrarActions: "orderBy[timestamp]=desc"
3066
3097
  };
3067
3098
 
3068
- // src/api/registrar-actions/filters.ts
3099
+ // src/ensapi/api/registrar-actions/filters.ts
3069
3100
  function byParentNode(parentNode) {
3070
3101
  if (typeof parentNode === "undefined") {
3071
3102
  return void 0;
@@ -3118,7 +3149,7 @@ var registrarActionsFilter = {
3118
3149
  endTimestamp
3119
3150
  };
3120
3151
 
3121
- // src/api/registrar-actions/prerequisites.ts
3152
+ // src/ensapi/api/registrar-actions/prerequisites.ts
3122
3153
  var registrarActionsPrerequisites = Object.freeze({
3123
3154
  /**
3124
3155
  * Required plugins to enable Registrar Actions API routes.
@@ -3168,108 +3199,7 @@ var registrarActionsPrerequisites = Object.freeze({
3168
3199
  }
3169
3200
  });
3170
3201
 
3171
- // src/registrars/basenames-subregistry.ts
3172
- var import_datasources6 = require("@ensnode/datasources");
3173
- function getBasenamesSubregistryId(namespace) {
3174
- const datasource = (0, import_datasources6.maybeGetDatasource)(namespace, import_datasources6.DatasourceNames.Basenames);
3175
- if (!datasource) {
3176
- throw new Error(`Datasource not found for ${namespace} ${import_datasources6.DatasourceNames.Basenames}`);
3177
- }
3178
- const address = datasource.contracts.BaseRegistrar?.address;
3179
- if (address === void 0 || Array.isArray(address)) {
3180
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3181
- }
3182
- return {
3183
- chainId: datasource.chain.id,
3184
- address
3185
- };
3186
- }
3187
- function getBasenamesSubregistryManagedName(namespaceId) {
3188
- switch (namespaceId) {
3189
- case import_datasources6.ENSNamespaceIds.Mainnet:
3190
- return "base.eth";
3191
- case import_datasources6.ENSNamespaceIds.Sepolia:
3192
- case import_datasources6.ENSNamespaceIds.SepoliaV2:
3193
- return "basetest.eth";
3194
- case import_datasources6.ENSNamespaceIds.EnsTestEnv:
3195
- throw new Error(
3196
- `No registrar managed name is known for the 'basenames' subregistry within the "${namespaceId}" namespace.`
3197
- );
3198
- }
3199
- }
3200
-
3201
- // src/registrars/ethnames-subregistry.ts
3202
- var import_datasources7 = require("@ensnode/datasources");
3203
- function getEthnamesSubregistryId(namespace) {
3204
- const datasource = (0, import_datasources7.maybeGetDatasource)(namespace, import_datasources7.DatasourceNames.ENSRoot);
3205
- if (!datasource) {
3206
- throw new Error(`Datasource not found for ${namespace} ${import_datasources7.DatasourceNames.ENSRoot}`);
3207
- }
3208
- const address = datasource.contracts.BaseRegistrar?.address;
3209
- if (address === void 0 || Array.isArray(address)) {
3210
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3211
- }
3212
- return {
3213
- chainId: datasource.chain.id,
3214
- address
3215
- };
3216
- }
3217
- function getEthnamesSubregistryManagedName(namespaceId) {
3218
- switch (namespaceId) {
3219
- case import_datasources7.ENSNamespaceIds.Mainnet:
3220
- case import_datasources7.ENSNamespaceIds.Sepolia:
3221
- case import_datasources7.ENSNamespaceIds.SepoliaV2:
3222
- case import_datasources7.ENSNamespaceIds.EnsTestEnv:
3223
- return "eth";
3224
- }
3225
- }
3226
-
3227
- // src/registrars/lineanames-subregistry.ts
3228
- var import_datasources8 = require("@ensnode/datasources");
3229
- function getLineanamesSubregistryId(namespace) {
3230
- const datasource = (0, import_datasources8.maybeGetDatasource)(namespace, import_datasources8.DatasourceNames.Lineanames);
3231
- if (!datasource) {
3232
- throw new Error(`Datasource not found for ${namespace} ${import_datasources8.DatasourceNames.Lineanames}`);
3233
- }
3234
- const address = datasource.contracts.BaseRegistrar?.address;
3235
- if (address === void 0 || Array.isArray(address)) {
3236
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3237
- }
3238
- return {
3239
- chainId: datasource.chain.id,
3240
- address
3241
- };
3242
- }
3243
- function getLineanamesSubregistryManagedName(namespaceId) {
3244
- switch (namespaceId) {
3245
- case import_datasources8.ENSNamespaceIds.Mainnet:
3246
- return "linea.eth";
3247
- case import_datasources8.ENSNamespaceIds.Sepolia:
3248
- case import_datasources8.ENSNamespaceIds.SepoliaV2:
3249
- return "linea-sepolia.eth";
3250
- case import_datasources8.ENSNamespaceIds.EnsTestEnv:
3251
- throw new Error(
3252
- `No registrar managed name is known for the 'Lineanames' subregistry within the "${namespaceId}" namespace.`
3253
- );
3254
- }
3255
- }
3256
-
3257
- // src/registrars/registration-expiration.ts
3258
- function isRegistrationExpired(info, now) {
3259
- if (info.expiry == null) return false;
3260
- return info.expiry <= now;
3261
- }
3262
- function isRegistrationFullyExpired(info, now) {
3263
- if (info.expiry == null) return false;
3264
- return now >= info.expiry + (info.gracePeriod ?? 0n);
3265
- }
3266
- function isRegistrationInGracePeriod(info, now) {
3267
- if (info.expiry == null) return false;
3268
- if (info.gracePeriod == null) return false;
3269
- return info.expiry <= now && info.expiry + info.gracePeriod > now;
3270
- }
3271
-
3272
- // src/api/registrar-actions/serialize.ts
3202
+ // src/ensapi/api/registrar-actions/serialize.ts
3273
3203
  function serializeNamedRegistrarAction({
3274
3204
  action,
3275
3205
  name
@@ -3293,7 +3223,7 @@ function serializeRegistrarActionsResponse(response) {
3293
3223
  }
3294
3224
  }
3295
3225
 
3296
- // src/api/shared/errors/deserialize.ts
3226
+ // src/ensapi/api/shared/errors/deserialize.ts
3297
3227
  var import_v430 = require("zod/v4");
3298
3228
  function deserializeErrorResponse(maybeErrorResponse) {
3299
3229
  const parsed = ErrorResponseSchema.safeParse(maybeErrorResponse);
@@ -3305,7 +3235,7 @@ ${(0, import_v430.prettifyError)(parsed.error)}
3305
3235
  return parsed.data;
3306
3236
  }
3307
3237
 
3308
- // src/api/shared/pagination/build-page-context.ts
3238
+ // src/ensapi/api/shared/pagination/build-page-context.ts
3309
3239
  function buildPageContext(page, recordsPerPage, totalRecords) {
3310
3240
  const totalPages = Math.max(1, Math.ceil(totalRecords / recordsPerPage));
3311
3241
  if (page > totalPages) {
@@ -3340,37 +3270,6 @@ function buildPageContext(page, recordsPerPage, totalRecords) {
3340
3270
  };
3341
3271
  }
3342
3272
 
3343
- // src/client-error.ts
3344
- var ClientError = class _ClientError extends Error {
3345
- details;
3346
- constructor(message, details) {
3347
- super(message);
3348
- this.name = "ClientError";
3349
- this.details = details;
3350
- }
3351
- static fromErrorResponse({ message, details }) {
3352
- return new _ClientError(message, details);
3353
- }
3354
- };
3355
-
3356
- // src/deployments.ts
3357
- var import_datasources9 = require("@ensnode/datasources");
3358
- var DEFAULT_ENSNODE_API_URL_MAINNET = "https://api.alpha.ensnode.io";
3359
- var DEFAULT_ENSNODE_API_URL_SEPOLIA = "https://api.alpha-sepolia.ensnode.io";
3360
- var getDefaultEnsNodeUrl = (namespace) => {
3361
- const effectiveNamespace = namespace ?? import_datasources9.ENSNamespaceIds.Mainnet;
3362
- switch (effectiveNamespace) {
3363
- case import_datasources9.ENSNamespaceIds.Mainnet:
3364
- return new URL(DEFAULT_ENSNODE_API_URL_MAINNET);
3365
- case import_datasources9.ENSNamespaceIds.Sepolia:
3366
- return new URL(DEFAULT_ENSNODE_API_URL_SEPOLIA);
3367
- default:
3368
- throw new Error(
3369
- `ENSNamespaceId ${effectiveNamespace} does not have a default ENSNode URL defined`
3370
- );
3371
- }
3372
- };
3373
-
3374
3273
  // src/client.ts
3375
3274
  var ENSNodeClient = class _ENSNodeClient {
3376
3275
  options;
@@ -3863,7 +3762,7 @@ var makeLatestRenewalId = (domainId, registrationIndex) => `${makeRegistrationId
3863
3762
  var makeRenewalId = (domainId, registrationIndex, index = 0) => `${makeRegistrationId(domainId, registrationIndex)}/${index}`;
3864
3763
 
3865
3764
  // src/identity/identity.ts
3866
- var import_datasources10 = require("@ensnode/datasources");
3765
+ var import_datasources7 = require("@ensnode/datasources");
3867
3766
 
3868
3767
  // src/identity/types.ts
3869
3768
  var ResolutionStatusIds = {
@@ -3890,7 +3789,7 @@ var ResolutionStatusIds = {
3890
3789
  function buildUnresolvedIdentity(address, namespaceId, chainId) {
3891
3790
  return {
3892
3791
  resolutionStatus: ResolutionStatusIds.Unresolved,
3893
- chainId: chainId ?? (0, import_datasources10.getENSRootChainId)(namespaceId),
3792
+ chainId: chainId ?? (0, import_datasources7.getENSRootChainId)(namespaceId),
3894
3793
  address
3895
3794
  };
3896
3795
  }
@@ -3898,6 +3797,107 @@ function isResolvedIdentity(identity) {
3898
3797
  return identity.resolutionStatus !== ResolutionStatusIds.Unresolved;
3899
3798
  }
3900
3799
 
3800
+ // src/registrars/basenames-subregistry.ts
3801
+ var import_datasources8 = require("@ensnode/datasources");
3802
+ function getBasenamesSubregistryId(namespace) {
3803
+ const datasource = (0, import_datasources8.maybeGetDatasource)(namespace, import_datasources8.DatasourceNames.Basenames);
3804
+ if (!datasource) {
3805
+ throw new Error(`Datasource not found for ${namespace} ${import_datasources8.DatasourceNames.Basenames}`);
3806
+ }
3807
+ const address = datasource.contracts.BaseRegistrar?.address;
3808
+ if (address === void 0 || Array.isArray(address)) {
3809
+ throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3810
+ }
3811
+ return {
3812
+ chainId: datasource.chain.id,
3813
+ address
3814
+ };
3815
+ }
3816
+ function getBasenamesSubregistryManagedName(namespaceId) {
3817
+ switch (namespaceId) {
3818
+ case import_datasources8.ENSNamespaceIds.Mainnet:
3819
+ return "base.eth";
3820
+ case import_datasources8.ENSNamespaceIds.Sepolia:
3821
+ case import_datasources8.ENSNamespaceIds.SepoliaV2:
3822
+ return "basetest.eth";
3823
+ case import_datasources8.ENSNamespaceIds.EnsTestEnv:
3824
+ throw new Error(
3825
+ `No registrar managed name is known for the 'basenames' subregistry within the "${namespaceId}" namespace.`
3826
+ );
3827
+ }
3828
+ }
3829
+
3830
+ // src/registrars/ethnames-subregistry.ts
3831
+ var import_datasources9 = require("@ensnode/datasources");
3832
+ function getEthnamesSubregistryId(namespace) {
3833
+ const datasource = (0, import_datasources9.maybeGetDatasource)(namespace, import_datasources9.DatasourceNames.ENSRoot);
3834
+ if (!datasource) {
3835
+ throw new Error(`Datasource not found for ${namespace} ${import_datasources9.DatasourceNames.ENSRoot}`);
3836
+ }
3837
+ const address = datasource.contracts.BaseRegistrar?.address;
3838
+ if (address === void 0 || Array.isArray(address)) {
3839
+ throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3840
+ }
3841
+ return {
3842
+ chainId: datasource.chain.id,
3843
+ address
3844
+ };
3845
+ }
3846
+ function getEthnamesSubregistryManagedName(namespaceId) {
3847
+ switch (namespaceId) {
3848
+ case import_datasources9.ENSNamespaceIds.Mainnet:
3849
+ case import_datasources9.ENSNamespaceIds.Sepolia:
3850
+ case import_datasources9.ENSNamespaceIds.SepoliaV2:
3851
+ case import_datasources9.ENSNamespaceIds.EnsTestEnv:
3852
+ return "eth";
3853
+ }
3854
+ }
3855
+
3856
+ // src/registrars/lineanames-subregistry.ts
3857
+ var import_datasources10 = require("@ensnode/datasources");
3858
+ function getLineanamesSubregistryId(namespace) {
3859
+ const datasource = (0, import_datasources10.maybeGetDatasource)(namespace, import_datasources10.DatasourceNames.Lineanames);
3860
+ if (!datasource) {
3861
+ throw new Error(`Datasource not found for ${namespace} ${import_datasources10.DatasourceNames.Lineanames}`);
3862
+ }
3863
+ const address = datasource.contracts.BaseRegistrar?.address;
3864
+ if (address === void 0 || Array.isArray(address)) {
3865
+ throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3866
+ }
3867
+ return {
3868
+ chainId: datasource.chain.id,
3869
+ address
3870
+ };
3871
+ }
3872
+ function getLineanamesSubregistryManagedName(namespaceId) {
3873
+ switch (namespaceId) {
3874
+ case import_datasources10.ENSNamespaceIds.Mainnet:
3875
+ return "linea.eth";
3876
+ case import_datasources10.ENSNamespaceIds.Sepolia:
3877
+ case import_datasources10.ENSNamespaceIds.SepoliaV2:
3878
+ return "linea-sepolia.eth";
3879
+ case import_datasources10.ENSNamespaceIds.EnsTestEnv:
3880
+ throw new Error(
3881
+ `No registrar managed name is known for the 'Lineanames' subregistry within the "${namespaceId}" namespace.`
3882
+ );
3883
+ }
3884
+ }
3885
+
3886
+ // src/registrars/registration-expiration.ts
3887
+ function isRegistrationExpired(info, now) {
3888
+ if (info.expiry == null) return false;
3889
+ return info.expiry <= now;
3890
+ }
3891
+ function isRegistrationFullyExpired(info, now) {
3892
+ if (info.expiry == null) return false;
3893
+ return now >= info.expiry + (info.gracePeriod ?? 0n);
3894
+ }
3895
+ function isRegistrationInGracePeriod(info, now) {
3896
+ if (info.expiry == null) return false;
3897
+ if (info.gracePeriod == null) return false;
3898
+ return info.expiry <= now && info.expiry + info.gracePeriod > now;
3899
+ }
3900
+
3901
3901
  // src/resolution/ensip19-chainid.ts
3902
3902
  var import_chains = require("viem/chains");
3903
3903
  var import_datasources11 = require("@ensnode/datasources");