@xyo-network/xl1-protocol-sdk 2.0.0 → 2.0.2

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.
@@ -1,7 +1,7 @@
1
1
  import type { Hash } from '@xylabs/sdk-js';
2
2
  import type { BoundWitness, Payload } from '@xyo-network/sdk-js';
3
3
  import { LRUCache } from 'lru-cache';
4
- import type { NamedDataLake } from '../../primitives/datalake/index.ts';
4
+ import type { NamedDataLake, PayloadLocation } from '../../primitives/datalake/index.ts';
5
5
  import { PayloadLocator } from '../../primitives/datalake/index.ts';
6
6
  import type { HydrateFunction } from '../../utils/index.ts';
7
7
  /** Valid recursion depths for BoundWitness hydration. */
@@ -38,16 +38,33 @@ export declare class BoundWitnessHydrator<TBw extends BoundWitness, THydrated> {
38
38
  */
39
39
  constructor(params: BoundWitnessHydratorParams<TBw, THydrated>);
40
40
  hydrate(input: Hash | TBw, maxDepth?: HydrationDepth, minDepth?: HydrationDepth): Promise<THydrated>;
41
+ /**
42
+ * Like hydrateWithProvenance, but queries every datalake for every hash and returns the full
43
+ * list of sources per hash. Bypasses the single-source LRU caches so that a prior first-found
44
+ * cache hit cannot suppress discovery of additional sources.
45
+ */
46
+ hydrateWithAllProvenance(input: Hash | TBw, maxDepth?: HydrationDepth, minDepth?: HydrationDepth): Promise<[THydrated, Map<Hash, PayloadLocation[]>]>;
41
47
  hydrateWithProvenance(input: Hash | TBw, maxDepth?: HydrationDepth, minDepth?: HydrationDepth): Promise<[THydrated, Map<Hash, string>]>;
42
48
  /** Returns an adapter compatible with HydratedCache. The context arg is ignored. */
43
49
  toHydrateFunction(): HydrateFunction<THydrated>;
44
50
  tryHydrate(input: Hash | TBw, maxDepth?: HydrationDepth): Promise<THydrated | undefined>;
51
+ tryHydrateWithAllProvenance(input: Hash | TBw, maxDepth?: HydrationDepth): Promise<[THydrated, Map<Hash, PayloadLocation[]>] | undefined>;
45
52
  tryHydrateWithProvenance(input: Hash | TBw, maxDepth?: HydrationDepth): Promise<[THydrated, Map<Hash, string>] | undefined>;
46
53
  protected appendDirectPayloads(bw: TBw, sources: Map<Hash, string>, minDepth: HydrationDepth, orderedHashes: Set<Hash>, orderedPayloads: Payload[]): Promise<void>;
54
+ protected appendDirectPayloadsAll(bw: TBw, sources: Map<Hash, PayloadLocation[]>, minDepth: HydrationDepth, orderedHashes: Set<Hash>, orderedPayloads: Payload[]): Promise<void>;
47
55
  protected appendNestedPayloads(sources: Map<Hash, string>, minDepth: HydrationDepth, orderedHashes: Set<Hash>, orderedPayloads: Payload[]): Promise<void>;
56
+ protected appendNestedPayloadsAll(sources: Map<Hash, PayloadLocation[]>, minDepth: HydrationDepth, orderedHashes: Set<Hash>, orderedPayloads: Payload[]): Promise<void>;
48
57
  protected fetchByHash(hash: Hash, sources: Map<Hash, string>): Promise<Payload | undefined>;
49
58
  protected fetchByHashes(hashes: Hash[], sources: Map<Hash, string>): Promise<Map<Hash, Payload>>;
59
+ /**
60
+ * Exhaustive variant: bypasses both LRU caches and queries every datalake. The picked payload
61
+ * (locations[0].payload) is the first in registration order; the DataLakeViewer's content-addressed
62
+ * fetch guarantees all entries for a given hash are equivalent.
63
+ */
64
+ protected fetchByHashesAll(hashes: Hash[], sources: Map<Hash, PayloadLocation[]>): Promise<Map<Hash, Payload>>;
50
65
  protected hydrateInternal(input: Hash | TBw, maxDepth: HydrationDepth, minDepth: HydrationDepth): Promise<[THydrated, Map<Hash, string>]>;
66
+ protected hydrateInternalAll(input: Hash | TBw, maxDepth: HydrationDepth, minDepth: HydrationDepth): Promise<[THydrated, Map<Hash, PayloadLocation[]>]>;
51
67
  protected resolveBoundWitness(input: Hash | TBw, sources: Map<Hash, string>): Promise<TBw>;
68
+ protected resolveBoundWitnessAll(input: Hash | TBw, sources: Map<Hash, PayloadLocation[]>): Promise<TBw>;
52
69
  }
53
70
  //# sourceMappingURL=BoundWitnessHydrator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BoundWitnessHydrator.d.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AAC,IAAI,EAAE,OAAO,CAAC,CAAC;cAYd,eAAe,CAC7B,KAAK,EAAE,IAAI,GAAG,GAAG,EACjB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;cAqB1B,kBAAkB,CAChC,KAAK,EAAE,IAAI,GAAG,GAAG,EACjB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;cAqBrC,mBAAmB,CAAC,KAAK,EAAE,IAAI,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;cAYhF,sBAAsB,CAAC,KAAK,EAAE,IAAI,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;CAY/G"}
@@ -1 +1 @@
1
- {"version":3,"file":"deepCalculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/deepCalculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAKlE,oDAAoD;AACpD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,SAAuB,GAAG,aAAa,EAAE,CAqBvH"}
1
+ {"version":3,"file":"deepCalculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/deepCalculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAKlE,oDAAoD;AACpD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,SAAI,GAA6B,aAAa,EAAE,CAuB9H"}
@@ -339,6 +339,14 @@ var BoundWitnessHydrator = class {
339
339
  const [hydrated] = await this.hydrateInternal(input, maxDepth, minDepth);
340
340
  return hydrated;
341
341
  }
342
+ /**
343
+ * Like hydrateWithProvenance, but queries every datalake for every hash and returns the full
344
+ * list of sources per hash. Bypasses the single-source LRU caches so that a prior first-found
345
+ * cache hit cannot suppress discovery of additional sources.
346
+ */
347
+ async hydrateWithAllProvenance(input, maxDepth = 1, minDepth = maxDepth) {
348
+ return await this.hydrateInternalAll(input, maxDepth, minDepth);
349
+ }
342
350
  async hydrateWithProvenance(input, maxDepth = 1, minDepth = maxDepth) {
343
351
  return await this.hydrateInternal(input, maxDepth, minDepth);
344
352
  }
@@ -353,6 +361,13 @@ var BoundWitnessHydrator = class {
353
361
  return void 0;
354
362
  }
355
363
  }
364
+ async tryHydrateWithAllProvenance(input, maxDepth = 1) {
365
+ try {
366
+ return await this.hydrateWithAllProvenance(input, maxDepth);
367
+ } catch {
368
+ return void 0;
369
+ }
370
+ }
356
371
  async tryHydrateWithProvenance(input, maxDepth = 1) {
357
372
  try {
358
373
  return await this.hydrateWithProvenance(input, maxDepth);
@@ -373,6 +388,19 @@ var BoundWitnessHydrator = class {
373
388
  orderedPayloads.push(p);
374
389
  }
375
390
  }
391
+ async appendDirectPayloadsAll(bw, sources, minDepth, orderedHashes, orderedPayloads) {
392
+ const fetched = await this.fetchByHashesAll(bw.payload_hashes, sources);
393
+ if (minDepth >= 1) {
394
+ const missing = bw.payload_hashes.filter((h) => !fetched.has(h));
395
+ assertEx4(missing.length === 0, () => `Unable to find all payloads for BoundWitness: missing ${missing.join(", ")}`);
396
+ }
397
+ for (const h of bw.payload_hashes) {
398
+ const p = fetched.get(h);
399
+ if (isUndefined3(p) || orderedHashes.has(h)) continue;
400
+ orderedHashes.add(h);
401
+ orderedPayloads.push(p);
402
+ }
403
+ }
376
404
  async appendNestedPayloads(sources, minDepth, orderedHashes, orderedPayloads) {
377
405
  const nestedHashes = [];
378
406
  for (const p of orderedPayloads) {
@@ -393,6 +421,26 @@ var BoundWitnessHydrator = class {
393
421
  orderedPayloads.push(p);
394
422
  }
395
423
  }
424
+ async appendNestedPayloadsAll(sources, minDepth, orderedHashes, orderedPayloads) {
425
+ const nestedHashes = [];
426
+ for (const p of orderedPayloads) {
427
+ if (!this.isNestedBoundWitness(p)) continue;
428
+ for (const h of p.payload_hashes) {
429
+ if (!orderedHashes.has(h)) nestedHashes.push(h);
430
+ }
431
+ }
432
+ const fetched = await this.fetchByHashesAll(nestedHashes, sources);
433
+ if (minDepth >= 2) {
434
+ const missing = nestedHashes.filter((h) => !fetched.has(h));
435
+ assertEx4(missing.length === 0, () => `Unable to find all nested payloads for BoundWitness: missing ${missing.join(", ")}`);
436
+ }
437
+ for (const h of nestedHashes) {
438
+ const p = fetched.get(h);
439
+ if (isUndefined3(p) || orderedHashes.has(h)) continue;
440
+ orderedHashes.add(h);
441
+ orderedPayloads.push(p);
442
+ }
443
+ }
396
444
  async fetchByHash(hash, sources) {
397
445
  const cached = this.payloadCache.get(hash);
398
446
  if (isDefined(cached)) {
@@ -430,6 +478,22 @@ var BoundWitnessHydrator = class {
430
478
  }
431
479
  return result;
432
480
  }
481
+ /**
482
+ * Exhaustive variant: bypasses both LRU caches and queries every datalake. The picked payload
483
+ * (locations[0].payload) is the first in registration order; the DataLakeViewer's content-addressed
484
+ * fetch guarantees all entries for a given hash are equivalent.
485
+ */
486
+ async fetchByHashesAll(hashes, sources) {
487
+ const result = /* @__PURE__ */ new Map();
488
+ if (hashes.length === 0) return result;
489
+ const located = await this.locator.findAll(hashes);
490
+ for (const [h, locations] of located) {
491
+ if (locations.length === 0) continue;
492
+ result.set(h, locations[0].payload);
493
+ sources.set(h, locations);
494
+ }
495
+ return result;
496
+ }
433
497
  async hydrateInternal(input, maxDepth, minDepth) {
434
498
  assertEx4(maxDepth >= 0 && maxDepth <= 2, () => `maxDepth must be 0, 1, or 2 (got ${maxDepth})`);
435
499
  assertEx4(minDepth >= 0 && minDepth <= 2, () => `minDepth must be 0, 1, or 2 (got ${minDepth})`);
@@ -447,6 +511,23 @@ var BoundWitnessHydrator = class {
447
511
  }
448
512
  return [this.asHydrated([bw, orderedPayloads], true), sources];
449
513
  }
514
+ async hydrateInternalAll(input, maxDepth, minDepth) {
515
+ assertEx4(maxDepth >= 0 && maxDepth <= 2, () => `maxDepth must be 0, 1, or 2 (got ${maxDepth})`);
516
+ assertEx4(minDepth >= 0 && minDepth <= 2, () => `minDepth must be 0, 1, or 2 (got ${minDepth})`);
517
+ assertEx4(maxDepth >= minDepth, () => `maxDepth (${maxDepth}) must be >= minDepth (${minDepth})`);
518
+ const sources = /* @__PURE__ */ new Map();
519
+ const bw = await this.resolveBoundWitnessAll(input, sources);
520
+ if (maxDepth === 0) {
521
+ return [this.asHydrated([bw, []], true), sources];
522
+ }
523
+ const orderedHashes = /* @__PURE__ */ new Set();
524
+ const orderedPayloads = [];
525
+ await this.appendDirectPayloadsAll(bw, sources, minDepth, orderedHashes, orderedPayloads);
526
+ if (maxDepth === 2) {
527
+ await this.appendNestedPayloadsAll(sources, minDepth, orderedHashes, orderedPayloads);
528
+ }
529
+ return [this.asHydrated([bw, orderedPayloads], true), sources];
530
+ }
450
531
  async resolveBoundWitness(input, sources) {
451
532
  if (typeof input === "string") {
452
533
  const fetched = assertEx4(
@@ -458,6 +539,18 @@ var BoundWitnessHydrator = class {
458
539
  const withMeta = "_hash" in input ? input : await PayloadBuilder2.addStorageMeta(input);
459
540
  return this.asBoundWitness(withMeta, true);
460
541
  }
542
+ async resolveBoundWitnessAll(input, sources) {
543
+ if (typeof input === "string") {
544
+ const fetched = await this.fetchByHashesAll([input], sources);
545
+ const payload = assertEx4(
546
+ fetched.get(input),
547
+ () => `BoundWitness ${input} not found in any datalake`
548
+ );
549
+ return this.asBoundWitness(payload, true);
550
+ }
551
+ const withMeta = "_hash" in input ? input : await PayloadBuilder2.addStorageMeta(input);
552
+ return this.asBoundWitness(withMeta, true);
553
+ }
461
554
  };
462
555
 
463
556
  // src/block/hydrate/createBlockHydrator.ts
@@ -780,11 +873,11 @@ function calculateFramesFromRange(range, step) {
780
873
  }
781
874
 
782
875
  // src/block/primitives/frames/deepCalculateFramesFromRange.ts
783
- import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol-lib";
784
- function deepCalculateFramesFromRange(range, startingStep = StepSizes2.length - 1) {
876
+ function deepCalculateFramesFromRange(range, startingStep = 5) {
785
877
  const fitted = [];
786
878
  let remaining = [range];
787
- for (let step = startingStep; step >= 0; step--) {
879
+ const actualStartingStep = Math.min(startingStep, 5);
880
+ for (let step = actualStartingStep; step >= 0; step--) {
788
881
  const newRemaining = [];
789
882
  for (const range2 of remaining) {
790
883
  const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range2, step);
@@ -1408,11 +1501,11 @@ import { AddressZod as AddressZod2 } from "@xylabs/sdk-js";
1408
1501
  import { globalRegistry as globalRegistry11, z as z15 } from "zod";
1409
1502
 
1410
1503
  // src/primitives/block/range/blockRangeSteps.ts
1411
- import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
1504
+ import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol-lib";
1412
1505
  function blockRangeSteps(range, steps) {
1413
1506
  const result = [];
1414
1507
  for (const step of steps) {
1415
- const stepSize2 = StepSizes3[step];
1508
+ const stepSize2 = StepSizes2[step];
1416
1509
  const startOfFirstStepCandidate = range[0] - range[0] % stepSize2 + stepSize2;
1417
1510
  const startOfFirstStep = asXL1BlockNumber2(
1418
1511
  startOfFirstStepCandidate,
@@ -1525,7 +1618,7 @@ import { assertEx as assertEx9 } from "@xylabs/sdk-js";
1525
1618
  import {
1526
1619
  asXL1BlockRange as asXL1BlockRange2,
1527
1620
  isValidStep,
1528
- StepSizes as StepSizes4
1621
+ StepSizes as StepSizes3
1529
1622
  } from "@xyo-network/xl1-protocol-lib";
1530
1623
  var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
1531
1624
  const end = start + step * count;
@@ -1534,7 +1627,7 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
1534
1627
  };
1535
1628
  var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
1536
1629
  assertEx9(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
1537
- const step = StepSizes4[stepIndex];
1630
+ const step = StepSizes3[stepIndex];
1538
1631
  return await stepRate(viewer, start, step, count, timeUnit);
1539
1632
  };
1540
1633
 
@@ -1676,23 +1769,23 @@ function mergeTransfers(transfers) {
1676
1769
  }
1677
1770
 
1678
1771
  // src/primitives/step/stepBlockRange.ts
1679
- import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
1772
+ import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes4 } from "@xyo-network/xl1-protocol-lib";
1680
1773
  function stepBlockRange({ block, step }) {
1681
- const stepSize2 = StepSizes5[step];
1774
+ const stepSize2 = StepSizes4[step];
1682
1775
  const start = block - stepSize2;
1683
1776
  return asXL1BlockRange4([start, start + stepSize2 - 1], { name: "stepBlockRange" });
1684
1777
  }
1685
1778
 
1686
1779
  // src/primitives/step/stepTransferIndex.ts
1687
1780
  import { assertEx as assertEx12 } from "@xylabs/sdk-js";
1688
- import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
1781
+ import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
1689
1782
  function stepTransferIndex(block, step) {
1690
1783
  let rewardTransferCount = 0;
1691
1784
  let rewardTransferIndex = -1;
1692
- for (let i = 3; i < StepSizes6.length; i++) {
1693
- const stepSize2 = StepSizes6[i];
1785
+ for (let i = 3; i < StepSizes5.length; i++) {
1786
+ const stepSize2 = StepSizes5[i];
1694
1787
  if (block % stepSize2 === 0) {
1695
- if (stepSize2 === StepSizes6[step]) {
1788
+ if (stepSize2 === StepSizes5[step]) {
1696
1789
  rewardTransferIndex = rewardTransferCount;
1697
1790
  }
1698
1791
  rewardTransferCount++;
@@ -1704,9 +1797,9 @@ function stepTransferIndex(block, step) {
1704
1797
 
1705
1798
  // src/primitives/chain/step/stepRewardBlock.ts
1706
1799
  import { assertEx as assertEx13 } from "@xylabs/sdk-js";
1707
- import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
1800
+ import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
1708
1801
  async function stepRewardBlock(context, blockViewer, { block, step }) {
1709
- assertEx13(block % StepSizes7[step] === 0, () => `Block must be the first block of the step [${StepSizes7[step]}], got ${block}`);
1802
+ assertEx13(block % StepSizes6[step] === 0, () => `Block must be the first block of the step [${StepSizes6[step]}], got ${block}`);
1710
1803
  return assertEx13(await blockViewer.blockByNumber(block), () => `Could not find block for block number ${block}`);
1711
1804
  }
1712
1805
 
@@ -3516,7 +3609,7 @@ import {
3516
3609
  BlockViewerMoniker,
3517
3610
  isChainQualifiedHeadConfig as isChainQualifiedHeadConfig4,
3518
3611
  isChainQualifiedRangeConfig as isChainQualifiedRangeConfig4,
3519
- StepSizes as StepSizes11,
3612
+ StepSizes as StepSizes10,
3520
3613
  TransferSchema as TransferSchema2
3521
3614
  } from "@xyo-network/xl1-protocol-lib";
3522
3615
  import { Semaphore } from "async-mutex";
@@ -3576,7 +3669,7 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
3576
3669
  import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
3577
3670
  import { assertEx as assertEx26 } from "@xylabs/sdk-js";
3578
3671
  import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
3579
- import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
3672
+ import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
3580
3673
  async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
3581
3674
  const cacheKey = `${range[0]}|${range[1]}`;
3582
3675
  return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
@@ -3597,8 +3690,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
3597
3690
  balances
3598
3691
  };
3599
3692
  }, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
3600
- const step = StepSizes8.indexOf(asXL1BlockNumber5(frameSize, true));
3601
- assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
3693
+ const step = StepSizes7.indexOf(asXL1BlockNumber5(frameSize, true));
3694
+ assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes7.join(", ")}`);
3602
3695
  const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
3603
3696
  if (isAnyPayload3(summaryResult)) {
3604
3697
  return summaryResult;
@@ -3683,7 +3776,7 @@ import {
3683
3776
  isHashMeta,
3684
3777
  PayloadBuilder as PayloadBuilder17
3685
3778
  } from "@xyo-network/sdk-js";
3686
- import { StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
3779
+ import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
3687
3780
  async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
3688
3781
  const [frameHead] = assertEx28(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
3689
3782
  const frameSize = range[1] - range[0] + 1;
@@ -3705,8 +3798,8 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
3705
3798
  schemas
3706
3799
  });
3707
3800
  } else {
3708
- const step = StepSizes9.indexOf(frameSize);
3709
- assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
3801
+ const step = StepSizes8.indexOf(frameSize);
3802
+ assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
3710
3803
  const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
3711
3804
  if (isAnyPayload4(summaryResult)) {
3712
3805
  result = summaryResult;
@@ -3777,7 +3870,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
3777
3870
  // src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
3778
3871
  import { assertEx as assertEx30, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
3779
3872
  import { isAnyPayload as isAnyPayload5 } from "@xyo-network/sdk-js";
3780
- import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
3873
+ import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
3781
3874
  function transfersSummaryKey(frameHeadHash, frameSize) {
3782
3875
  return `${frameHeadHash}|${frameSize}`;
3783
3876
  }
@@ -3804,8 +3897,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
3804
3897
  transfers
3805
3898
  };
3806
3899
  } else {
3807
- const step = StepSizes10.indexOf(asXL1BlockNumber6(frameSize, true));
3808
- assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
3900
+ const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
3901
+ assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
3809
3902
  const key = transfersSummaryKey(frameHead._hash, frameSize);
3810
3903
  const summaryResult = await summaryMap.get(key);
3811
3904
  if (isAnyPayload5(summaryResult)) {
@@ -3896,9 +3989,9 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
3896
3989
  // src/simple/accountBalance/SimpleAccountBalanceViewer.ts
3897
3990
  var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
3898
3991
  moniker = SimpleAccountBalanceViewer.defaultMoniker;
3899
- _balanceStepSemaphores = StepSizes11.map(() => new Semaphore(20));
3992
+ _balanceStepSemaphores = StepSizes10.map(() => new Semaphore(20));
3900
3993
  _blockViewer;
3901
- _transferStepSemaphores = StepSizes11.map(() => new Semaphore(20));
3994
+ _transferStepSemaphores = StepSizes10.map(() => new Semaphore(20));
3902
3995
  get balancesSummaryMap() {
3903
3996
  return this.params.balancesSummaryMap;
3904
3997
  }
@@ -4019,7 +4112,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4019
4112
  }
4020
4113
  async distillTransferHistory(address, range, max = 50) {
4021
4114
  return await this.spanAsync("distillTransferHistory", async () => {
4022
- if (range[1] - range[0] <= StepSizes11[0] || max <= 1) {
4115
+ if (range[1] - range[0] <= StepSizes10[0] || max <= 1) {
4023
4116
  return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber7(n, true));
4024
4117
  }
4025
4118
  const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true));
@@ -4034,7 +4127,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4034
4127
  });
4035
4128
  const resultBlockNumbers = /* @__PURE__ */ new Set();
4036
4129
  for (const [frame] of sortedTransferSummaryPairs) {
4037
- if (frame[1] - frame[0] + 1 > StepSizes11[0]) {
4130
+ if (frame[1] - frame[0] + 1 > StepSizes10[0]) {
4038
4131
  const values = await this.distillTransferHistory(address, asXL1BlockRange10([frame[0], frame[1] - 1], true), max - resultBlockNumbers.size);
4039
4132
  for (const value of values) {
4040
4133
  resultBlockNumbers.add(value);