@ensnode/ensnode-sdk 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +65 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -224
- package/dist/index.d.ts +169 -224
- package/dist/index.js +65 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -850,7 +850,7 @@ import { z as z8 } from "zod/v4";
|
|
|
850
850
|
|
|
851
851
|
// src/shared/block-ref.ts
|
|
852
852
|
function isBefore(blockA, blockB) {
|
|
853
|
-
return blockA.number < blockB.number
|
|
853
|
+
return blockA.number < blockB.number;
|
|
854
854
|
}
|
|
855
855
|
function isEqualTo(blockA, blockB) {
|
|
856
856
|
return blockA.number === blockB.number && blockA.timestamp === blockB.timestamp;
|
|
@@ -904,18 +904,29 @@ function mergeBlockNumberRanges(...ranges) {
|
|
|
904
904
|
}
|
|
905
905
|
let minStartBlock;
|
|
906
906
|
let maxEndBlock;
|
|
907
|
+
let hasUnboundedStart = false;
|
|
908
|
+
let hasUnboundedEnd = false;
|
|
907
909
|
for (const range of ranges) {
|
|
908
|
-
if (range.startBlock
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
910
|
+
if (range.startBlock === void 0) {
|
|
911
|
+
hasUnboundedStart = true;
|
|
912
|
+
} else if (minStartBlock === void 0 || range.startBlock < minStartBlock) {
|
|
913
|
+
minStartBlock = range.startBlock;
|
|
912
914
|
}
|
|
913
|
-
if (range.endBlock
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
915
|
+
if (range.endBlock === void 0) {
|
|
916
|
+
hasUnboundedEnd = true;
|
|
917
|
+
} else if (maxEndBlock === void 0 || range.endBlock > maxEndBlock) {
|
|
918
|
+
maxEndBlock = range.endBlock;
|
|
919
|
+
}
|
|
920
|
+
if (hasUnboundedStart && hasUnboundedEnd) {
|
|
921
|
+
return buildBlockNumberRange(void 0, void 0);
|
|
917
922
|
}
|
|
918
923
|
}
|
|
924
|
+
if (hasUnboundedStart) {
|
|
925
|
+
minStartBlock = void 0;
|
|
926
|
+
}
|
|
927
|
+
if (hasUnboundedEnd) {
|
|
928
|
+
maxEndBlock = void 0;
|
|
929
|
+
}
|
|
919
930
|
return buildBlockNumberRange(minStartBlock, maxEndBlock);
|
|
920
931
|
}
|
|
921
932
|
function buildBlockRefRange(startBlock, endBlock) {
|
|
@@ -1066,12 +1077,31 @@ function getLatestIndexedBlockRef(indexingStatus, chainId) {
|
|
|
1066
1077
|
}
|
|
1067
1078
|
return chainIndexingStatus.latestIndexedBlock;
|
|
1068
1079
|
}
|
|
1080
|
+
function getHighestKnownBlockTimestamp(chains) {
|
|
1081
|
+
if (chains.length === 0) {
|
|
1082
|
+
throw new Error(
|
|
1083
|
+
"Invariant violation: at least one chain is required to determine the highest known block timestamp"
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
const startBlockTimestamps = chains.map((chain) => chain.config.startBlock.timestamp);
|
|
1087
|
+
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
1088
|
+
const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
|
|
1089
|
+
const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
|
|
1090
|
+
return Math.max(
|
|
1091
|
+
...startBlockTimestamps,
|
|
1092
|
+
...endBlockTimestamps,
|
|
1093
|
+
...backfillEndBlockTimestamps,
|
|
1094
|
+
...latestKnownBlockTimestamps
|
|
1095
|
+
);
|
|
1096
|
+
}
|
|
1069
1097
|
function buildCrossChainIndexingStatusSnapshotOmnichain(omnichainSnapshot, snapshotTime) {
|
|
1098
|
+
const chains = Array.from(omnichainSnapshot.chains.values());
|
|
1099
|
+
const adjustedSnapshotTime = Math.max(snapshotTime, getHighestKnownBlockTimestamp(chains));
|
|
1070
1100
|
return validateCrossChainIndexingStatusSnapshot({
|
|
1071
1101
|
strategy: CrossChainIndexingStrategyIds.Omnichain,
|
|
1072
1102
|
slowestChainIndexingCursor: omnichainSnapshot.omnichainIndexingCursor,
|
|
1073
1103
|
omnichainSnapshot,
|
|
1074
|
-
snapshotTime
|
|
1104
|
+
snapshotTime: adjustedSnapshotTime
|
|
1075
1105
|
});
|
|
1076
1106
|
}
|
|
1077
1107
|
|
|
@@ -1599,16 +1629,7 @@ function invariant_slowestChainEqualsToOmnichainSnapshotTime(ctx) {
|
|
|
1599
1629
|
function invariant_snapshotTimeIsTheHighestKnownBlockTimestamp(ctx) {
|
|
1600
1630
|
const { snapshotTime, omnichainSnapshot } = ctx.value;
|
|
1601
1631
|
const chains = Array.from(omnichainSnapshot.chains.values());
|
|
1602
|
-
const
|
|
1603
|
-
const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
|
|
1604
|
-
const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
|
|
1605
|
-
const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
|
|
1606
|
-
const highestKnownBlockTimestamp = Math.max(
|
|
1607
|
-
...startBlockTimestamps,
|
|
1608
|
-
...endBlockTimestamps,
|
|
1609
|
-
...backfillEndBlockTimestamps,
|
|
1610
|
-
...latestKnownBlockTimestamps
|
|
1611
|
-
);
|
|
1632
|
+
const highestKnownBlockTimestamp = getHighestKnownBlockTimestamp(chains);
|
|
1612
1633
|
if (snapshotTime < highestKnownBlockTimestamp) {
|
|
1613
1634
|
ctx.issues.push({
|
|
1614
1635
|
code: "custom",
|
|
@@ -2916,6 +2937,14 @@ var RegistrarActionsFilterTypes = {
|
|
|
2916
2937
|
EndTimestamp: "endTimestamp"
|
|
2917
2938
|
};
|
|
2918
2939
|
var RegistrarActionsOrders = {
|
|
2940
|
+
/**
|
|
2941
|
+
* Returns registrar actions newest-first.
|
|
2942
|
+
*
|
|
2943
|
+
* Sorts by block timestamp descending. Because each action's identifier encodes
|
|
2944
|
+
* all ordering-relevant onchain properties, this also correctly orders actions
|
|
2945
|
+
* that share the same block timestamp by the chronological order in which they
|
|
2946
|
+
* were executed within the block.
|
|
2947
|
+
*/
|
|
2919
2948
|
LatestRegistrarActions: "orderBy[timestamp]=desc"
|
|
2920
2949
|
};
|
|
2921
2950
|
|
|
@@ -3576,13 +3605,6 @@ var EnsApiClient = class _EnsApiClient {
|
|
|
3576
3605
|
var ENSNodeClient = class extends EnsApiClient {
|
|
3577
3606
|
};
|
|
3578
3607
|
|
|
3579
|
-
// src/ensdb/ensnode-metadata.ts
|
|
3580
|
-
var EnsNodeMetadataKeys = {
|
|
3581
|
-
EnsDbVersion: "ensdb_version",
|
|
3582
|
-
EnsIndexerPublicConfig: "ensindexer_public_config",
|
|
3583
|
-
EnsIndexerIndexingStatus: "ensindexer_indexing_status"
|
|
3584
|
-
};
|
|
3585
|
-
|
|
3586
3608
|
// src/ensindexer/api/config/deserialize.ts
|
|
3587
3609
|
function deserializeEnsIndexerConfigResponse(maybeResponse) {
|
|
3588
3610
|
return deserializeEnsIndexerPublicConfig(maybeResponse, "EnsIndexerConfigResponse");
|
|
@@ -4457,18 +4479,14 @@ var TtlCache = class {
|
|
|
4457
4479
|
import {
|
|
4458
4480
|
maybeGetDatasource as maybeGetDatasource5
|
|
4459
4481
|
} from "@ensnode/datasources";
|
|
4460
|
-
function buildIndexedBlockranges(namespace,
|
|
4482
|
+
function buildIndexedBlockranges(namespace, pluginsDatasourceNames) {
|
|
4461
4483
|
const indexedBlockranges = /* @__PURE__ */ new Map();
|
|
4462
|
-
for (const [
|
|
4463
|
-
for (const
|
|
4464
|
-
const
|
|
4465
|
-
if (!
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
);
|
|
4469
|
-
}
|
|
4470
|
-
const datasourceChainId = requiredDatasource.chain.id;
|
|
4471
|
-
const datasourceContracts = Object.values(requiredDatasource.contracts);
|
|
4484
|
+
for (const [, datasourceNames] of pluginsDatasourceNames) {
|
|
4485
|
+
for (const datasourceName of datasourceNames) {
|
|
4486
|
+
const datasource = maybeGetDatasource5(namespace, datasourceName);
|
|
4487
|
+
if (!datasource) continue;
|
|
4488
|
+
const datasourceChainId = datasource.chain.id;
|
|
4489
|
+
const datasourceContracts = Object.values(datasource.contracts);
|
|
4472
4490
|
for (const datasourceContract of datasourceContracts) {
|
|
4473
4491
|
const currentChainIndexedBlockrange = indexedBlockranges.get(datasourceChainId);
|
|
4474
4492
|
const contractIndexedBlockrange = buildBlockNumberRange(
|
|
@@ -4615,6 +4633,12 @@ var isENSv1Registry = (namespace, contract) => accountIdEqual(getENSv1Registry(n
|
|
|
4615
4633
|
var getENSv2RootRegistry = (namespace) => getDatasourceContract(namespace, DatasourceNames5.ENSv2Root, "RootRegistry");
|
|
4616
4634
|
var getENSv2RootRegistryId = (namespace) => makeRegistryId(getENSv2RootRegistry(namespace));
|
|
4617
4635
|
var isENSv2RootRegistry = (namespace, contract) => accountIdEqual(getENSv2RootRegistry(namespace), contract);
|
|
4636
|
+
var maybeGetENSv2RootRegistry = (namespace) => maybeGetDatasourceContract(namespace, DatasourceNames5.ENSv2Root, "RootRegistry");
|
|
4637
|
+
var maybeGetENSv2RootRegistryId = (namespace) => {
|
|
4638
|
+
const root = maybeGetENSv2RootRegistry(namespace);
|
|
4639
|
+
if (!root) return void 0;
|
|
4640
|
+
return makeRegistryId(root);
|
|
4641
|
+
};
|
|
4618
4642
|
|
|
4619
4643
|
// src/shared/url.ts
|
|
4620
4644
|
function isHttpProtocol(url) {
|
|
@@ -4690,7 +4714,6 @@ export {
|
|
|
4690
4714
|
EnsApiIndexingStatusResponseCodes,
|
|
4691
4715
|
EnsIndexerClient,
|
|
4692
4716
|
EnsIndexerIndexingStatusResponseCodes,
|
|
4693
|
-
EnsNodeMetadataKeys,
|
|
4694
4717
|
ForwardResolutionProtocolStep,
|
|
4695
4718
|
IndexingStatusResponseCodes,
|
|
4696
4719
|
LINEANAMES_NODE,
|
|
@@ -4804,6 +4827,7 @@ export {
|
|
|
4804
4827
|
getENSv2RootRegistryId,
|
|
4805
4828
|
getEthnamesSubregistryId,
|
|
4806
4829
|
getEthnamesSubregistryManagedName,
|
|
4830
|
+
getHighestKnownBlockTimestamp,
|
|
4807
4831
|
getLatestIndexedBlockRef,
|
|
4808
4832
|
getLineanamesSubregistryId,
|
|
4809
4833
|
getLineanamesSubregistryManagedName,
|
|
@@ -4875,6 +4899,8 @@ export {
|
|
|
4875
4899
|
makeSerializedEnsApiPublicConfigSchema,
|
|
4876
4900
|
makeSubdomainNode,
|
|
4877
4901
|
maybeGetDatasourceContract,
|
|
4902
|
+
maybeGetENSv2RootRegistry,
|
|
4903
|
+
maybeGetENSv2RootRegistryId,
|
|
4878
4904
|
mergeBlockNumberRanges,
|
|
4879
4905
|
nameTokensPrerequisites,
|
|
4880
4906
|
parseAccountId,
|