@xyo-network/xl1-protocol-sdk 1.26.19 → 1.26.21

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.
@@ -2408,7 +2408,13 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
2408
2408
  () => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
2409
2409
  );
2410
2410
  const endBlockEpoch = resolvedEndBlock.$epoch;
2411
+ if (!Number.isFinite(startBlockEpoch) || !Number.isFinite(endBlockEpoch)) {
2412
+ throw new TypeError("Block has missing or invalid $epoch");
2413
+ }
2411
2414
  const actualTimeDifference = startBlockEpoch - endBlockEpoch;
2415
+ if (actualTimeDifference === 0) {
2416
+ throw new Error("Start and end blocks have identical timestamps");
2417
+ }
2412
2418
  const timeDelta = Math.abs(actualTimeDifference - targetTimeMs);
2413
2419
  if (timeDelta <= toleranceMs) {
2414
2420
  return resolvedEndBlock.block;
@@ -2421,6 +2427,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
2421
2427
  const adjustmentFactor = actualTimeDifference / targetTimeMs;
2422
2428
  adjustedBlocksBack = Math.floor(estimatedBlocksBack / adjustmentFactor);
2423
2429
  }
2430
+ adjustedBlocksBack = Number.isFinite(adjustedBlocksBack) && adjustedBlocksBack >= 1 ? adjustedBlocksBack : 1;
2424
2431
  return await findEndBlockRecursive(
2425
2432
  viewer,
2426
2433
  startBlock,