@ensnode/ensnode-sdk 0.0.0-next-20260318183438 → 0.0.0-next-20260319162148

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
@@ -170,6 +170,7 @@ __export(index_exports, {
170
170
  getENSv2RootRegistryId: () => getENSv2RootRegistryId,
171
171
  getEthnamesSubregistryId: () => getEthnamesSubregistryId,
172
172
  getEthnamesSubregistryManagedName: () => getEthnamesSubregistryManagedName,
173
+ getHighestKnownBlockTimestamp: () => getHighestKnownBlockTimestamp,
173
174
  getLatestIndexedBlockRef: () => getLatestIndexedBlockRef,
174
175
  getLineanamesSubregistryId: () => getLineanamesSubregistryId,
175
176
  getLineanamesSubregistryManagedName: () => getLineanamesSubregistryManagedName,
@@ -1388,12 +1389,31 @@ function getLatestIndexedBlockRef(indexingStatus, chainId) {
1388
1389
  }
1389
1390
  return chainIndexingStatus.latestIndexedBlock;
1390
1391
  }
1392
+ function getHighestKnownBlockTimestamp(chains) {
1393
+ if (chains.length === 0) {
1394
+ throw new Error(
1395
+ "Invariant violation: at least one chain is required to determine the highest known block timestamp"
1396
+ );
1397
+ }
1398
+ const startBlockTimestamps = chains.map((chain) => chain.config.startBlock.timestamp);
1399
+ const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
1400
+ const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
1401
+ const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
1402
+ return Math.max(
1403
+ ...startBlockTimestamps,
1404
+ ...endBlockTimestamps,
1405
+ ...backfillEndBlockTimestamps,
1406
+ ...latestKnownBlockTimestamps
1407
+ );
1408
+ }
1391
1409
  function buildCrossChainIndexingStatusSnapshotOmnichain(omnichainSnapshot, snapshotTime) {
1410
+ const chains = Array.from(omnichainSnapshot.chains.values());
1411
+ const adjustedSnapshotTime = Math.max(snapshotTime, getHighestKnownBlockTimestamp(chains));
1392
1412
  return validateCrossChainIndexingStatusSnapshot({
1393
1413
  strategy: CrossChainIndexingStrategyIds.Omnichain,
1394
1414
  slowestChainIndexingCursor: omnichainSnapshot.omnichainIndexingCursor,
1395
1415
  omnichainSnapshot,
1396
- snapshotTime
1416
+ snapshotTime: adjustedSnapshotTime
1397
1417
  });
1398
1418
  }
1399
1419
 
@@ -1921,16 +1941,7 @@ function invariant_slowestChainEqualsToOmnichainSnapshotTime(ctx) {
1921
1941
  function invariant_snapshotTimeIsTheHighestKnownBlockTimestamp(ctx) {
1922
1942
  const { snapshotTime, omnichainSnapshot } = ctx.value;
1923
1943
  const chains = Array.from(omnichainSnapshot.chains.values());
1924
- const startBlockTimestamps = chains.map((chain) => chain.config.startBlock.timestamp);
1925
- const endBlockTimestamps = chains.map((chain) => chain.config).filter((chainConfig) => chainConfig.rangeType === RangeTypeIds.Bounded).map((chainConfig) => chainConfig.endBlock.timestamp);
1926
- const backfillEndBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Backfill).map((chain) => chain.backfillEndBlock.timestamp);
1927
- const latestKnownBlockTimestamps = chains.filter((chain) => chain.chainStatus === ChainIndexingStatusIds.Following).map((chain) => chain.latestKnownBlock.timestamp);
1928
- const highestKnownBlockTimestamp = Math.max(
1929
- ...startBlockTimestamps,
1930
- ...endBlockTimestamps,
1931
- ...backfillEndBlockTimestamps,
1932
- ...latestKnownBlockTimestamps
1933
- );
1944
+ const highestKnownBlockTimestamp = getHighestKnownBlockTimestamp(chains);
1934
1945
  if (snapshotTime < highestKnownBlockTimestamp) {
1935
1946
  ctx.issues.push({
1936
1947
  code: "custom",