@ensnode/ensnode-sdk 0.0.0-next-20260427074811 → 0.0.0-next-20260428182432

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { ENSNamespaceIds as ENSNamespaceIds7 } from "@ensnode/datasources";
2
+ import { ENSNamespaceIds as ENSNamespaceIds4 } from "@ensnode/datasources";
3
3
 
4
4
  // src/ens/index.ts
5
5
  import { ENSNamespaceIds, getENSRootChainId } from "@ensnode/datasources";
@@ -3932,98 +3932,6 @@ function hasOmnigraphApiConfigSupport(config) {
3932
3932
  };
3933
3933
  }
3934
3934
 
3935
- // src/registrars/basenames-subregistry.ts
3936
- import { asInterpretedName } from "enssdk";
3937
- import {
3938
- DatasourceNames as DatasourceNames2,
3939
- ENSNamespaceIds as ENSNamespaceIds4,
3940
- maybeGetDatasource as maybeGetDatasource2
3941
- } from "@ensnode/datasources";
3942
- function getBasenamesSubregistryId(namespace) {
3943
- const datasource = maybeGetDatasource2(namespace, DatasourceNames2.Basenames);
3944
- if (!datasource) {
3945
- throw new Error(`Datasource not found for ${namespace} ${DatasourceNames2.Basenames}`);
3946
- }
3947
- const address = datasource.contracts.BaseRegistrar?.address;
3948
- if (address === void 0 || Array.isArray(address)) {
3949
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3950
- }
3951
- return { chainId: datasource.chain.id, address };
3952
- }
3953
- function getBasenamesSubregistryManagedName(namespaceId) {
3954
- switch (namespaceId) {
3955
- case ENSNamespaceIds4.Mainnet:
3956
- return asInterpretedName("base.eth");
3957
- case ENSNamespaceIds4.Sepolia:
3958
- case ENSNamespaceIds4.SepoliaV2:
3959
- return asInterpretedName("basetest.eth");
3960
- case ENSNamespaceIds4.EnsTestEnv:
3961
- throw new Error(
3962
- `No registrar managed name is known for the 'basenames' subregistry within the "${namespaceId}" namespace.`
3963
- );
3964
- }
3965
- }
3966
-
3967
- // src/registrars/ethnames-subregistry.ts
3968
- import { asInterpretedName as asInterpretedName2 } from "enssdk";
3969
- import {
3970
- DatasourceNames as DatasourceNames3,
3971
- ENSNamespaceIds as ENSNamespaceIds5,
3972
- maybeGetDatasource as maybeGetDatasource3
3973
- } from "@ensnode/datasources";
3974
- function getEthnamesSubregistryId(namespace) {
3975
- const datasource = maybeGetDatasource3(namespace, DatasourceNames3.ENSRoot);
3976
- if (!datasource) {
3977
- throw new Error(`Datasource not found for ${namespace} ${DatasourceNames3.ENSRoot}`);
3978
- }
3979
- const address = datasource.contracts.BaseRegistrar?.address;
3980
- if (address === void 0 || Array.isArray(address)) {
3981
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
3982
- }
3983
- return { chainId: datasource.chain.id, address };
3984
- }
3985
- function getEthnamesSubregistryManagedName(namespaceId) {
3986
- switch (namespaceId) {
3987
- case ENSNamespaceIds5.Mainnet:
3988
- case ENSNamespaceIds5.Sepolia:
3989
- case ENSNamespaceIds5.SepoliaV2:
3990
- case ENSNamespaceIds5.EnsTestEnv:
3991
- return asInterpretedName2("eth");
3992
- }
3993
- }
3994
-
3995
- // src/registrars/lineanames-subregistry.ts
3996
- import { asInterpretedName as asInterpretedName3 } from "enssdk";
3997
- import {
3998
- DatasourceNames as DatasourceNames4,
3999
- ENSNamespaceIds as ENSNamespaceIds6,
4000
- maybeGetDatasource as maybeGetDatasource4
4001
- } from "@ensnode/datasources";
4002
- function getLineanamesSubregistryId(namespace) {
4003
- const datasource = maybeGetDatasource4(namespace, DatasourceNames4.Lineanames);
4004
- if (!datasource) {
4005
- throw new Error(`Datasource not found for ${namespace} ${DatasourceNames4.Lineanames}`);
4006
- }
4007
- const address = datasource.contracts.BaseRegistrar?.address;
4008
- if (address === void 0 || Array.isArray(address)) {
4009
- throw new Error(`BaseRegistrar contract not found or has multiple addresses for ${namespace}`);
4010
- }
4011
- return { chainId: datasource.chain.id, address };
4012
- }
4013
- function getLineanamesSubregistryManagedName(namespaceId) {
4014
- switch (namespaceId) {
4015
- case ENSNamespaceIds6.Mainnet:
4016
- return asInterpretedName3("linea.eth");
4017
- case ENSNamespaceIds6.Sepolia:
4018
- case ENSNamespaceIds6.SepoliaV2:
4019
- return asInterpretedName3("linea-sepolia.eth");
4020
- case ENSNamespaceIds6.EnsTestEnv:
4021
- throw new Error(
4022
- `No registrar managed name is known for the 'Lineanames' subregistry within the "${namespaceId}" namespace.`
4023
- );
4024
- }
4025
- }
4026
-
4027
3935
  // src/registrars/registration-expiration.ts
4028
3936
  function isRegistrationExpired(info, now) {
4029
3937
  if (info.expiry == null) return false;
@@ -4370,13 +4278,13 @@ var TtlCache = class {
4370
4278
 
4371
4279
  // src/shared/config/indexed-blockranges.ts
4372
4280
  import {
4373
- maybeGetDatasource as maybeGetDatasource5
4281
+ maybeGetDatasource as maybeGetDatasource2
4374
4282
  } from "@ensnode/datasources";
4375
4283
  function buildIndexedBlockranges(namespace, pluginsDatasourceNames) {
4376
4284
  const indexedBlockranges = /* @__PURE__ */ new Map();
4377
4285
  for (const [, datasourceNames] of pluginsDatasourceNames) {
4378
4286
  for (const datasourceName of datasourceNames) {
4379
- const datasource = maybeGetDatasource5(namespace, datasourceName);
4287
+ const datasource = maybeGetDatasource2(namespace, datasourceName);
4380
4288
  if (!datasource) continue;
4381
4289
  const datasourceChainId = datasource.chain.id;
4382
4290
  const datasourceContracts = Object.values(datasource.contracts);
@@ -4451,6 +4359,155 @@ function interpretDnszonehashValue(value) {
4451
4359
  return value;
4452
4360
  }
4453
4361
 
4362
+ // src/shared/managed-names.ts
4363
+ import {
4364
+ asInterpretedName,
4365
+ ENS_ROOT_NAME,
4366
+ namehashInterpretedName as namehashInterpretedName3,
4367
+ stringifyAccountId
4368
+ } from "enssdk";
4369
+ import { DatasourceNames as DatasourceNames2 } from "@ensnode/datasources";
4370
+
4371
+ // src/shared/to-json.ts
4372
+ var toJson = (value, options) => JSON.stringify(
4373
+ value,
4374
+ (_key, val) => typeof val === "bigint" ? String(val) : val,
4375
+ options?.pretty ? 2 : void 0
4376
+ );
4377
+
4378
+ // src/shared/managed-names.ts
4379
+ var MANAGED_NAME_BY_NAMESPACE = {
4380
+ sepolia: {
4381
+ "base.eth": "basetest.eth",
4382
+ "linea.eth": "linea-sepolia.eth"
4383
+ }
4384
+ };
4385
+ var getContractsByManagedName = (namespace) => {
4386
+ const ensRootRegistry = getDatasourceContract(
4387
+ namespace,
4388
+ DatasourceNames2.ENSRoot,
4389
+ "ENSv1Registry"
4390
+ );
4391
+ const ensRootRegistryOld = getDatasourceContract(
4392
+ namespace,
4393
+ DatasourceNames2.ENSRoot,
4394
+ "ENSv1RegistryOld"
4395
+ );
4396
+ const ethnamesNameWrapper = getDatasourceContract(
4397
+ namespace,
4398
+ DatasourceNames2.ENSRoot,
4399
+ "NameWrapper"
4400
+ );
4401
+ const basenamesRegistry = maybeGetDatasourceContract(
4402
+ namespace,
4403
+ DatasourceNames2.Basenames,
4404
+ "Registry"
4405
+ );
4406
+ const lineanamesRegistry = maybeGetDatasourceContract(
4407
+ namespace,
4408
+ DatasourceNames2.Lineanames,
4409
+ "Registry"
4410
+ );
4411
+ const lineanamesNameWrapper = maybeGetDatasourceContract(
4412
+ namespace,
4413
+ DatasourceNames2.Lineanames,
4414
+ "NameWrapper"
4415
+ );
4416
+ return {
4417
+ [ENS_ROOT_NAME]: {
4418
+ registry: ensRootRegistry,
4419
+ contracts: [ensRootRegistry, ensRootRegistryOld]
4420
+ },
4421
+ eth: {
4422
+ registry: ensRootRegistry,
4423
+ contracts: [
4424
+ getDatasourceContract(namespace, DatasourceNames2.ENSRoot, "BaseRegistrar"),
4425
+ getDatasourceContract(namespace, DatasourceNames2.ENSRoot, "LegacyEthRegistrarController"),
4426
+ getDatasourceContract(namespace, DatasourceNames2.ENSRoot, "WrappedEthRegistrarController"),
4427
+ getDatasourceContract(
4428
+ namespace,
4429
+ DatasourceNames2.ENSRoot,
4430
+ "UnwrappedEthRegistrarController"
4431
+ ),
4432
+ getDatasourceContract(
4433
+ namespace,
4434
+ DatasourceNames2.ENSRoot,
4435
+ "UniversalRegistrarRenewalWithReferrer"
4436
+ ),
4437
+ ethnamesNameWrapper
4438
+ ]
4439
+ },
4440
+ ...basenamesRegistry && {
4441
+ "base.eth": {
4442
+ registry: basenamesRegistry,
4443
+ contracts: [
4444
+ basenamesRegistry,
4445
+ maybeGetDatasourceContract(namespace, DatasourceNames2.Basenames, "BaseRegistrar"),
4446
+ maybeGetDatasourceContract(namespace, DatasourceNames2.Basenames, "EARegistrarController"),
4447
+ maybeGetDatasourceContract(namespace, DatasourceNames2.Basenames, "RegistrarController"),
4448
+ maybeGetDatasourceContract(
4449
+ namespace,
4450
+ DatasourceNames2.Basenames,
4451
+ "UpgradeableRegistrarController"
4452
+ )
4453
+ ].filter((c) => !!c)
4454
+ }
4455
+ },
4456
+ ...lineanamesRegistry && {
4457
+ "linea.eth": {
4458
+ registry: lineanamesRegistry,
4459
+ contracts: [
4460
+ lineanamesRegistry,
4461
+ maybeGetDatasourceContract(namespace, DatasourceNames2.Lineanames, "BaseRegistrar"),
4462
+ maybeGetDatasourceContract(
4463
+ namespace,
4464
+ DatasourceNames2.Lineanames,
4465
+ "EthRegistrarController"
4466
+ ),
4467
+ lineanamesNameWrapper
4468
+ ].filter((c) => !!c)
4469
+ }
4470
+ }
4471
+ };
4472
+ };
4473
+ var cache = /* @__PURE__ */ new Map();
4474
+ var getManagedName = (namespace, contract) => {
4475
+ const cacheKey = `${namespace}:${stringifyAccountId(contract)}`;
4476
+ const cached = cache.get(cacheKey);
4477
+ if (cached !== void 0) return cached;
4478
+ for (const [managedName, group] of Object.entries(getContractsByManagedName(namespace))) {
4479
+ const isAnyOfTheContracts = group.contracts.some(
4480
+ (_contract) => accountIdEqual(_contract, contract)
4481
+ );
4482
+ if (isAnyOfTheContracts) {
4483
+ const namespaceSpecific = MANAGED_NAME_BY_NAMESPACE[namespace]?.[managedName];
4484
+ const name = asInterpretedName(namespaceSpecific ?? managedName);
4485
+ const node = namehashInterpretedName3(name);
4486
+ const result = { name, node, registry: group.registry };
4487
+ cache.set(cacheKey, result);
4488
+ return result;
4489
+ }
4490
+ }
4491
+ throw new Error(
4492
+ `The following contract ${toJson(contract, { pretty: true })} does not have a configured Managed Name in namespace '${namespace}'.`
4493
+ );
4494
+ };
4495
+ var isNameWrapper = (namespace, contract) => {
4496
+ const ethnamesNameWrapper = getDatasourceContract(
4497
+ namespace,
4498
+ DatasourceNames2.ENSRoot,
4499
+ "NameWrapper"
4500
+ );
4501
+ if (accountIdEqual(ethnamesNameWrapper, contract)) return true;
4502
+ const lineanamesNameWrapper = maybeGetDatasourceContract(
4503
+ namespace,
4504
+ DatasourceNames2.Lineanames,
4505
+ "NameWrapper"
4506
+ );
4507
+ if (lineanamesNameWrapper && accountIdEqual(lineanamesNameWrapper, contract)) return true;
4508
+ return false;
4509
+ };
4510
+
4454
4511
  // src/shared/namespace-specific-value.ts
4455
4512
  function getNamespaceSpecificValue(namespace, value) {
4456
4513
  return value[namespace] ?? value.default;
@@ -4469,26 +4526,51 @@ var replaceBigInts = (obj, replacer) => {
4469
4526
  };
4470
4527
 
4471
4528
  // src/shared/root-registry.ts
4472
- import { makeRegistryId } from "enssdk";
4473
- import { DatasourceNames as DatasourceNames5 } from "@ensnode/datasources";
4474
- var getENSv1Registry = (namespace) => getDatasourceContract(namespace, DatasourceNames5.ENSRoot, "ENSv1Registry");
4529
+ import {
4530
+ makeENSv1RegistryId,
4531
+ makeENSv1VirtualRegistryId,
4532
+ makeENSv2RegistryId
4533
+ } from "enssdk";
4534
+ import { DatasourceNames as DatasourceNames3 } from "@ensnode/datasources";
4535
+ var getENSv1Registry = (namespace) => getDatasourceContract(namespace, DatasourceNames3.ENSRoot, "ENSv1Registry");
4536
+ var getENSv1RootRegistryId = (namespace) => makeENSv1RegistryId(getENSv1Registry(namespace));
4475
4537
  var isENSv1Registry = (namespace, contract) => accountIdEqual(getENSv1Registry(namespace), contract);
4476
- var getENSv2RootRegistry = (namespace) => getDatasourceContract(namespace, DatasourceNames5.ENSv2Root, "RootRegistry");
4477
- var getENSv2RootRegistryId = (namespace) => makeRegistryId(getENSv2RootRegistry(namespace));
4538
+ var getENSv2RootRegistry = (namespace) => getDatasourceContract(namespace, DatasourceNames3.ENSv2Root, "RootRegistry");
4539
+ var getENSv2RootRegistryId = (namespace) => makeENSv2RegistryId(getENSv2RootRegistry(namespace));
4478
4540
  var isENSv2RootRegistry = (namespace, contract) => accountIdEqual(getENSv2RootRegistry(namespace), contract);
4479
- var maybeGetENSv2RootRegistry = (namespace) => maybeGetDatasourceContract(namespace, DatasourceNames5.ENSv2Root, "RootRegistry");
4541
+ var maybeGetENSv2RootRegistry = (namespace) => maybeGetDatasourceContract(namespace, DatasourceNames3.ENSv2Root, "RootRegistry");
4480
4542
  var maybeGetENSv2RootRegistryId = (namespace) => {
4481
4543
  const root = maybeGetENSv2RootRegistry(namespace);
4482
4544
  if (!root) return void 0;
4483
- return makeRegistryId(root);
4545
+ return makeENSv2RegistryId(root);
4546
+ };
4547
+ var getRootRegistryId = (namespace) => maybeGetENSv2RootRegistryId(namespace) ?? getENSv1RootRegistryId(namespace);
4548
+ var getRootRegistryIds = (namespace) => {
4549
+ const v1RootRegistryId = getENSv1RootRegistryId(namespace);
4550
+ const v2RootRegistryId = maybeGetENSv2RootRegistryId(namespace);
4551
+ const basenamesRegistry = maybeGetDatasourceContract(
4552
+ namespace,
4553
+ DatasourceNames3.Basenames,
4554
+ "Registry"
4555
+ );
4556
+ const lineanamesRegistry = maybeGetDatasourceContract(
4557
+ namespace,
4558
+ DatasourceNames3.Lineanames,
4559
+ "Registry"
4560
+ );
4561
+ return [
4562
+ v1RootRegistryId,
4563
+ basenamesRegistry && makeENSv1VirtualRegistryId(
4564
+ basenamesRegistry,
4565
+ getManagedName(namespace, basenamesRegistry).node
4566
+ ),
4567
+ lineanamesRegistry && makeENSv1VirtualRegistryId(
4568
+ lineanamesRegistry,
4569
+ getManagedName(namespace, lineanamesRegistry).node
4570
+ ),
4571
+ v2RootRegistryId
4572
+ ].filter((id) => !!id);
4484
4573
  };
4485
-
4486
- // src/shared/to-json.ts
4487
- var toJson = (value, options) => JSON.stringify(
4488
- value,
4489
- (_key, val) => typeof val === "bigint" ? String(val) : val,
4490
- options?.pretty ? 2 : void 0
4491
- );
4492
4574
 
4493
4575
  // src/shared/url.ts
4494
4576
  function isHttpProtocol(url) {
@@ -4590,7 +4672,7 @@ export {
4590
4672
  DEFAULT_ENSNODE_URL_SEPOLIA,
4591
4673
  ENCODED_REFERRER_BYTE_LENGTH,
4592
4674
  ENCODED_REFERRER_BYTE_OFFSET,
4593
- ENSNamespaceIds7 as ENSNamespaceIds,
4675
+ ENSNamespaceIds4 as ENSNamespaceIds,
4594
4676
  EXPECTED_ENCODED_REFERRER_PADDING,
4595
4677
  EnsApiIndexingStatusResponseCodes,
4596
4678
  EnsIndexerClient,
@@ -4683,21 +4765,17 @@ export {
4683
4765
  deserializedNameTokensResponse,
4684
4766
  durationBetween,
4685
4767
  formatNFTTransferEventMetadata,
4686
- getBasenamesSubregistryId,
4687
- getBasenamesSubregistryManagedName,
4688
4768
  getCurrencyInfo,
4689
4769
  getDatasourceContract,
4690
4770
  getDefaultEnsNodeUrl,
4691
4771
  getENSRootChainId,
4692
4772
  getENSv1Registry,
4773
+ getENSv1RootRegistryId,
4693
4774
  getENSv2RootRegistry,
4694
4775
  getENSv2RootRegistryId,
4695
- getEthnamesSubregistryId,
4696
- getEthnamesSubregistryManagedName,
4697
4776
  getHighestKnownBlockTimestamp,
4698
4777
  getLatestIndexedBlockRef,
4699
- getLineanamesSubregistryId,
4700
- getLineanamesSubregistryManagedName,
4778
+ getManagedName,
4701
4779
  getNFTTransferType,
4702
4780
  getNameTokenOwnership,
4703
4781
  getNameWrapperAccounts,
@@ -4705,6 +4783,8 @@ export {
4705
4783
  getOmnichainIndexingCursor,
4706
4784
  getOmnichainIndexingStatus,
4707
4785
  getResolvePrimaryNameChainIdParam,
4786
+ getRootRegistryId,
4787
+ getRootRegistryIds,
4708
4788
  getTimestampForHighestOmnichainKnownBlock,
4709
4789
  getTimestampForLowestOmnichainStartBlock,
4710
4790
  hasNullByte,
@@ -4723,6 +4803,7 @@ export {
4723
4803
  isENSv1Registry,
4724
4804
  isENSv2RootRegistry,
4725
4805
  isHttpProtocol,
4806
+ isNameWrapper,
4726
4807
  isPccFuseSet,
4727
4808
  isPriceCurrencyEqual,
4728
4809
  isPriceEqual,