@xyo-network/xl1-protocol-sdk 2.2.0 → 3.0.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.
Files changed (107) hide show
  1. package/dist/neutral/ChainContextHelpers.d.ts +1 -1
  2. package/dist/neutral/ChainContextHelpers.d.ts.map +1 -1
  3. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +35 -2
  4. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
  5. package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
  6. package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
  7. package/dist/neutral/amount/index.d.ts +1 -1
  8. package/dist/neutral/amount/splitOnDecimalToString.d.ts.map +1 -1
  9. package/dist/neutral/amount/{XL1Amount.d.ts → xl1Amount.d.ts} +1 -1
  10. package/dist/neutral/amount/{XL1Amount.d.ts.map → xl1Amount.d.ts.map} +1 -1
  11. package/dist/neutral/block/hydrate/hydrateBlock.d.ts.map +1 -1
  12. package/dist/neutral/block/hydrate/tryHydrateBlock.d.ts.map +1 -1
  13. package/dist/neutral/block/primitives/hashFromBlockNumber.d.ts.map +1 -1
  14. package/dist/neutral/block/primitives/validateTransactionOpcodes.d.ts.map +1 -1
  15. package/dist/neutral/capabilities/Capability.d.ts +1 -8
  16. package/dist/neutral/capabilities/Capability.d.ts.map +1 -1
  17. package/dist/neutral/capabilities/Provider.d.ts +14 -23
  18. package/dist/neutral/capabilities/Provider.d.ts.map +1 -1
  19. package/dist/neutral/capabilities/connectionTypes.d.ts +9 -0
  20. package/dist/neutral/capabilities/connectionTypes.d.ts.map +1 -0
  21. package/dist/neutral/capabilities/index.d.ts +1 -0
  22. package/dist/neutral/capabilities/index.d.ts.map +1 -1
  23. package/dist/neutral/capabilities/resolveProviders.d.ts +27 -20
  24. package/dist/neutral/capabilities/resolveProviders.d.ts.map +1 -1
  25. package/dist/neutral/config/Actor.d.ts +216 -12
  26. package/dist/neutral/config/Actor.d.ts.map +1 -1
  27. package/dist/neutral/config/Actors.d.ts +41 -2
  28. package/dist/neutral/config/Actors.d.ts.map +1 -1
  29. package/dist/neutral/config/Base.d.ts +41 -2
  30. package/dist/neutral/config/Base.d.ts.map +1 -1
  31. package/dist/neutral/config/Config.d.ts +152 -8
  32. package/dist/neutral/config/Config.d.ts.map +1 -1
  33. package/dist/neutral/config/HostActor.d.ts +216 -12
  34. package/dist/neutral/config/HostActor.d.ts.map +1 -1
  35. package/dist/neutral/config/ProviderBinding.d.ts +4 -5
  36. package/dist/neutral/config/ProviderBinding.d.ts.map +1 -1
  37. package/dist/neutral/config/adaptLegacyConfig.d.ts +2 -3
  38. package/dist/neutral/config/adaptLegacyConfig.d.ts.map +1 -1
  39. package/dist/neutral/config/connections/index.d.ts +6 -0
  40. package/dist/neutral/config/connections/index.d.ts.map +1 -0
  41. package/dist/neutral/config/index.d.ts +2 -0
  42. package/dist/neutral/config/index.d.ts.map +1 -1
  43. package/dist/neutral/config/normalizeConnectionsConfig.d.ts +20 -0
  44. package/dist/neutral/config/normalizeConnectionsConfig.d.ts.map +1 -0
  45. package/dist/neutral/config/transports/Transport.d.ts +18 -3
  46. package/dist/neutral/config/transports/Transport.d.ts.map +1 -1
  47. package/dist/neutral/context/Actor.d.ts +216 -12
  48. package/dist/neutral/context/Actor.d.ts.map +1 -1
  49. package/dist/neutral/context/HostActor.d.ts +216 -12
  50. package/dist/neutral/context/HostActor.d.ts.map +1 -1
  51. package/dist/neutral/createDeclarationPayload.d.ts.map +1 -1
  52. package/dist/neutral/createTransferPayload.d.ts.map +1 -1
  53. package/dist/neutral/getFileConfig.d.ts +70 -4
  54. package/dist/neutral/getFileConfig.d.ts.map +1 -1
  55. package/dist/neutral/getFileConfig.mjs +206 -192
  56. package/dist/neutral/getFileConfig.mjs.map +4 -4
  57. package/dist/neutral/index.mjs +953 -656
  58. package/dist/neutral/index.mjs.map +4 -4
  59. package/dist/neutral/model/CreatableProviderContext.zod.d.ts +216 -12
  60. package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
  61. package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -1
  62. package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts.map +1 -1
  63. package/dist/neutral/primitives/chain/time/{externalBlockNumberFromXL1BlockNumber.d.ts → externalBlockNumberFromXl1BlockNumber.d.ts} +1 -1
  64. package/dist/neutral/primitives/chain/time/{externalBlockNumberFromXL1BlockNumber.d.ts.map → externalBlockNumberFromXl1BlockNumber.d.ts.map} +1 -1
  65. package/dist/neutral/primitives/chain/time/{externalBlockRangeFromXL1BlockRange.d.ts → externalBlockRangeFromXl1BlockRange.d.ts} +1 -1
  66. package/dist/neutral/primitives/chain/time/{externalBlockRangeFromXL1BlockRange.d.ts.map → externalBlockRangeFromXl1BlockRange.d.ts.map} +1 -1
  67. package/dist/neutral/primitives/chain/time/index.d.ts +2 -2
  68. package/dist/neutral/primitives/datalake/PayloadLocator.d.ts.map +1 -1
  69. package/dist/neutral/primitives/datalake/addDataLakePayloadsToPayloads.d.ts.map +1 -1
  70. package/dist/neutral/primitives/readPayloadMapFromStore.d.ts.map +1 -1
  71. package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -1
  72. package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts.map +1 -1
  73. package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
  74. package/dist/neutral/primitives/state/findMostRecentBlock.d.ts.map +1 -1
  75. package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -1
  76. package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +3 -6
  77. package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
  78. package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
  79. package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts.map +1 -1
  80. package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -1
  81. package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts.map +1 -1
  82. package/dist/neutral/simple/datalake/RestDataLakeRunner.d.ts.map +1 -1
  83. package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
  84. package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -1
  85. package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -1
  86. package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
  87. package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +1 -1
  88. package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
  89. package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +2 -0
  90. package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
  91. package/dist/neutral/simple/network/SimpleXyoNetwork.d.ts.map +1 -1
  92. package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts.map +1 -1
  93. package/dist/neutral/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.d.ts.map +1 -1
  94. package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts.map +1 -1
  95. package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -1
  96. package/dist/neutral/test/buildBlock.d.ts.map +1 -1
  97. package/dist/neutral/test/buildRandomChain.d.ts.map +1 -1
  98. package/dist/neutral/test/buildRandomGenesisBlock.d.ts.map +1 -1
  99. package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -1
  100. package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts.map +1 -1
  101. package/dist/neutral/test/index.mjs +344 -279
  102. package/dist/neutral/test/index.mjs.map +4 -4
  103. package/dist/neutral/transaction/buildTransaction.d.ts.map +1 -1
  104. package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
  105. package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts.map +1 -1
  106. package/dist/neutral/transaction/hydrateTransaction.d.ts.map +1 -1
  107. package/package.json +8 -8
@@ -27,11 +27,13 @@ var splitOnDecimalToString = (value, places = 18, maxDecimal = places, maxCharac
27
27
  const wholeCharacters = whole.toString(10).length;
28
28
  const calcMaxDecimalCharacters = maxCharacters === -1 ? places : wholeCharacters > maxCharacters ? 0 : maxCharacters - wholeCharacters;
29
29
  const maxDecimalCharacters = Math.min(maxDecimal, calcMaxDecimalCharacters);
30
- const formattedWhole = new Intl.NumberFormat(locale, {
30
+ const wholeFormatter = new Intl.NumberFormat(locale, {
31
31
  maximumFractionDigits: 0,
32
32
  useGrouping: true
33
- }).format(whole);
34
- const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((part) => part.type === "decimal")?.value ?? ".";
33
+ });
34
+ const formattedWhole = wholeFormatter.format(whole);
35
+ const decimalFormatter = new Intl.NumberFormat(locale);
36
+ const decimalSeparator = decimalFormatter.formatToParts(1.1).find((part) => part.type === "decimal")?.value ?? ".";
35
37
  let paddedDecimal = decimal.toString().padStart(places, "0").slice(0, maxDecimalCharacters);
36
38
  while (paddedDecimal.length > minDecimals && paddedDecimal.endsWith("0")) {
37
39
  paddedDecimal = paddedDecimal.slice(0, -1);
@@ -54,7 +56,7 @@ var ShiftedBigInt = class _ShiftedBigInt {
54
56
  this.value = typeof value === "bigint" ? value : value.value;
55
57
  this.config = {
56
58
  ..._ShiftedBigInt.defaultConfig,
57
- ...typeof value === "bigint" ? {} : value.config,
59
+ ...typeof value !== "bigint" && value.config,
58
60
  ...config
59
61
  };
60
62
  }
@@ -98,7 +100,7 @@ var ShiftedBigInt = class _ShiftedBigInt {
98
100
  }
99
101
  };
100
102
 
101
- // src/amount/XL1Amount.ts
103
+ // src/amount/xl1Amount.ts
102
104
  import { assertEx } from "@xylabs/sdk-js";
103
105
  import {
104
106
  AttoXL1,
@@ -170,7 +172,7 @@ var XL1Amount = class _XL1Amount {
170
172
  }
171
173
  toString(places = Number(XL1Places.atto), config = {}) {
172
174
  assertEx(allowedPlaces.includes(BigInt(places)), () => `Invalid conversion places (${places} not in ${allowedPlaces.join(", ")})`);
173
- return new ShiftedBigInt(
175
+ const shifted = new ShiftedBigInt(
174
176
  this.value,
175
177
  {
176
178
  places,
@@ -180,7 +182,8 @@ var XL1Amount = class _XL1Amount {
180
182
  maxCharacters: places,
181
183
  ...config
182
184
  }
183
- ).toShortString();
185
+ );
186
+ return shifted.toShortString();
184
187
  }
185
188
  };
186
189
 
@@ -214,10 +217,11 @@ import { isUndefined } from "@xylabs/sdk-js";
214
217
  import { isAnyPayload, PayloadBuilder } from "@xyo-network/sdk-js";
215
218
  async function addDataLakePayloadsToPayloads(hashes, payloads, dataLakeViewer) {
216
219
  if (isUndefined(dataLakeViewer)) return [payloads, []];
217
- const missingPayloadHashes = hashes.filter((hash) => !payloads.some((p) => p._hash === hash));
218
- const payloadsFromDataLake = await PayloadBuilder.addHashMeta(
219
- await PayloadBuilder.addHashMeta((await dataLakeViewer.get(missingPayloadHashes)).filter(isAnyPayload))
220
- );
220
+ const missingPayloadHashes = hashes.filter((hash) => payloads.every((p) => p._hash !== hash));
221
+ const dataLakeResults = await dataLakeViewer.get(missingPayloadHashes);
222
+ const filteredDataLakePayloads = dataLakeResults.filter(isAnyPayload);
223
+ const payloadsWithHashMeta = await PayloadBuilder.addHashMeta(filteredDataLakePayloads);
224
+ const payloadsFromDataLake = await PayloadBuilder.addHashMeta(payloadsWithHashMeta);
221
225
  return [[...payloads, ...payloadsFromDataLake], payloadsFromDataLake.map((p) => p._hash)];
222
226
  }
223
227
 
@@ -280,10 +284,7 @@ var PayloadLocator = class {
280
284
  const buckets = hashes.map(() => []);
281
285
  for (const dl of this.datalakes) {
282
286
  const fetched = await Promise.all(hashes.map(async (h) => await this.fetchOne(dl, h)));
283
- for (const [i, p] of fetched.entries()) {
284
- if (isUndefined2(p)) continue;
285
- buckets[i].push({ payload: p, source: dl.name });
286
- }
287
+ collectFetchedIntoBuckets(fetched, dl, buckets);
287
288
  }
288
289
  for (const [i, h] of hashes.entries()) result.set(h, buckets[i]);
289
290
  return result;
@@ -297,16 +298,27 @@ var PayloadLocator = class {
297
298
  const needHashes = [];
298
299
  for (const h of hashes) if (remaining.has(h)) needHashes.push(h);
299
300
  const fetched = await Promise.all(needHashes.map(async (h) => await this.fetchOne(dl, h)));
300
- for (const [i, h] of needHashes.entries()) {
301
- const p = fetched[i];
302
- if (isUndefined2(p)) continue;
303
- result.set(h, { payload: p, source: dl.name });
304
- remaining.delete(h);
305
- }
301
+ collectFirstFetched(needHashes, fetched, dl, result, remaining);
306
302
  }
307
303
  return result;
308
304
  }
309
305
  };
306
+ function collectFetchedIntoBuckets(fetched, dl, buckets) {
307
+ for (const [i, p] of fetched.entries()) {
308
+ if (!isUndefined2(p)) {
309
+ buckets[i].push({ payload: p, source: dl.name });
310
+ }
311
+ }
312
+ }
313
+ function collectFirstFetched(needHashes, fetched, dl, result, remaining) {
314
+ for (const [i, h] of needHashes.entries()) {
315
+ const p = fetched[i];
316
+ if (!isUndefined2(p)) {
317
+ result.set(h, { payload: p, source: dl.name });
318
+ remaining.delete(h);
319
+ }
320
+ }
321
+ }
310
322
 
311
323
  // src/block/hydrate/BoundWitnessHydrator.ts
312
324
  var DEFAULT_CACHE_MAX = 5e3;
@@ -629,15 +641,18 @@ var hydrateBlock = async (context, hash, maxDepth = 1, minDepth = maxDepth) => {
629
641
  assertEx5(block, () => `block ${hash} not found`)
630
642
  ), () => `hash ${hash} is not a BlockBoundWitness`);
631
643
  if (maxDepth === 0) return [bw, []];
632
- const blkPayloads = (await chainMap.get(bw.payload_hashes)).map((p) => asAnyPayload(p, true));
644
+ const blockPayloadResults = await chainMap.get(bw.payload_hashes);
645
+ const blkPayloads = blockPayloadResults.map((p) => asAnyPayload(p, true));
633
646
  if (minDepth === 1) assertEx5(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`);
634
647
  if (maxDepth === 1) return [bw, blkPayloads];
635
648
  const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta);
636
649
  const transactionsPayloadHashes = transactions.flatMap((tx) => tx.payload_hashes);
637
- const transactionsPayloads = (await chainMap.get(transactionsPayloadHashes)).map((p) => asAnyPayload(p, true));
650
+ const transactionPayloadResults = await chainMap.get(transactionsPayloadHashes);
651
+ const transactionsPayloads = transactionPayloadResults.map((p) => asAnyPayload(p, true));
638
652
  assertEx5(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`);
639
653
  const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap((p) => p._hash));
640
- const allPayloads = (await chainMap.get([...allPayloadsHashes])).map((p) => asAnyPayload(p, true));
654
+ const allPayloadResults = await chainMap.get([...allPayloadsHashes]);
655
+ const allPayloads = allPayloadResults.map((p) => asAnyPayload(p, true));
641
656
  const allPayloadsFiltered = allPayloads.filter((p) => allPayloadsHashes.has(p._hash));
642
657
  if (maxDepth === 2) assertEx5(allHashesPresent(
643
658
  [...allPayloadsHashes],
@@ -657,7 +672,8 @@ import { assertEx as assertEx6 } from "@xylabs/sdk-js";
657
672
  import { isBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta as isTransactionBoundWitnessWithStorageMeta2 } from "@xyo-network/xl1-protocol-lib";
658
673
  var tryHydrateBlock = async (archivist, hash, maxDepth = 1) => {
659
674
  assertEx6(maxDepth >= 0, () => "maxDepth must be greater than or equal to 0");
660
- const bw = (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta);
675
+ const archivistResults = await archivist.get([hash]);
676
+ const bw = archivistResults.find(isBlockBoundWitnessWithStorageMeta);
661
677
  if (!bw) return void 0;
662
678
  if (maxDepth === 0) return [bw, []];
663
679
  const blkPayloads = await archivist.get(bw.payload_hashes);
@@ -720,7 +736,7 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4 }
720
736
  // src/block/primitives/blockFromBlockNumber.ts
721
737
  async function blockFromBlockNumber(context, blockNumber) {
722
738
  return await spanAsync("blockFromBlockNumber", async () => {
723
- const cacheKey = `${blockNumber}`;
739
+ const cacheKey = String(blockNumber);
724
740
  const { chainMap, head } = context;
725
741
  return await withContextCacheResponse(context, "blockFromBlockNumber", cacheKey, async () => {
726
742
  const [result] = await chainMap.get([head._hash]);
@@ -818,7 +834,8 @@ function deepCalculateFramesFromRange(range, startingStep = StepSizes2.length -
818
834
 
819
835
  // src/block/primitives/hashFromBlockNumber.ts
820
836
  async function hashFromBlockNumber(context, blockNumber) {
821
- return (await blockFromBlockNumber(context, blockNumber))._hash;
837
+ const block = await blockFromBlockNumber(context, blockNumber);
838
+ return block._hash;
822
839
  }
823
840
 
824
841
  // src/block/primitives/model.ts
@@ -847,35 +864,41 @@ import {
847
864
  PayloadBuilder as PayloadBuilder3
848
865
  } from "@xyo-network/sdk-js";
849
866
  import { isExecutable } from "@xyo-network/xl1-protocol-lib";
867
+ async function processElevateOperation(opCode, args, txBw, txPayloads) {
868
+ const [hash, ...rest] = args;
869
+ const txPayloadsWithStorageMeta = await PayloadBuilder3.addStorageMeta(txPayloads);
870
+ assertEx7(rest.length === 0, () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Too many Arguments`);
871
+ if (isHash(hash)) {
872
+ assertEx7(
873
+ txBw.payload_hashes.includes(hash),
874
+ () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Hash not in payload hashes => ${toSafeJsonString2(txBw, 20)}`
875
+ );
876
+ return assertEx7(
877
+ txPayloadsWithStorageMeta.find((p) => p._hash === hash),
878
+ () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Payload not found`
879
+ );
880
+ }
881
+ throw new Error(`Invalid elevate operation ${opCode} ${args.join(", ")} - Invalid hash`);
882
+ }
883
+ async function processOperation(opCode, args, txBw, txPayloads) {
884
+ switch (opCode) {
885
+ case "elevate": {
886
+ return await processElevateOperation(opCode, args, txBw, txPayloads);
887
+ }
888
+ default: {
889
+ throw new Error(`Invalid opCode ${opCode}`);
890
+ }
891
+ }
892
+ }
850
893
  async function validateTransactionsOpcodes(txs) {
851
894
  const txElevatedPayloads = [];
852
895
  for (const [txBw, txPayloads] of txs) {
853
896
  if (isExecutable(txBw)) {
854
897
  const operations = txBw.script.map((op) => op.split("|"));
855
898
  for (const [opCode, ...args] of operations) {
856
- switch (opCode) {
857
- case "elevate": {
858
- const [hash, ...rest] = args;
859
- const txPayloadsWithStorageMeta = await PayloadBuilder3.addStorageMeta(txPayloads);
860
- assertEx7(rest.length === 0, () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Too many Arguments`);
861
- if (isHash(hash)) {
862
- assertEx7(
863
- txBw.payload_hashes.includes(hash),
864
- () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Hash not in payload hashes => ${toSafeJsonString2(txBw, 20)}`
865
- );
866
- const txPayload = assertEx7(
867
- txPayloadsWithStorageMeta.find((p) => p._hash === hash),
868
- () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Payload not found`
869
- );
870
- txElevatedPayloads.push(txPayload);
871
- } else {
872
- throw new Error(`Invalid elevate operation ${opCode} ${args.join(", ")} - Invalid hash`);
873
- }
874
- break;
875
- }
876
- default: {
877
- throw new Error(`Invalid opCode ${opCode}`);
878
- }
899
+ const txPayload = await processOperation(opCode, args, txBw, txPayloads);
900
+ if (txPayload !== void 0) {
901
+ txElevatedPayloads.push(txPayload);
879
902
  }
880
903
  }
881
904
  }
@@ -893,7 +916,7 @@ function backingsSatisfied(required, available) {
893
916
  }
894
917
  function unmetBackings(required, available) {
895
918
  return required.filter((need) => {
896
- return !available.some((a) => a.backing === need.backing && (a.mode === "write" || need.mode === "read"));
919
+ return available.every((a) => !(a.backing === need.backing && (a.mode === "write" || need.mode === "read")));
897
920
  });
898
921
  }
899
922
 
@@ -914,7 +937,7 @@ var CapabilityRegistry = class {
914
937
  }
915
938
  toJson() {
916
939
  const result = {};
917
- for (const [id, cap] of this._entries.entries()) {
940
+ for (const [id, cap] of this._entries) {
918
941
  const { id: _, ...rest } = cap;
919
942
  result[id] = rest;
920
943
  }
@@ -994,6 +1017,18 @@ function filterViewerBySurface(viewer, surface) {
994
1017
  };
995
1018
  }
996
1019
 
1020
+ // src/capabilities/connectionTypes.ts
1021
+ function descriptorConnectionTypes(descriptor) {
1022
+ return descriptor.connectionTypes ?? [];
1023
+ }
1024
+ function descriptorMatchesConnectionType(descriptor, connectionType) {
1025
+ const types = descriptorConnectionTypes(descriptor);
1026
+ if (types.length === 0) {
1027
+ return true;
1028
+ }
1029
+ return types.includes(connectionType);
1030
+ }
1031
+
997
1032
  // src/capabilities/factoryBrand.ts
998
1033
  function backedFactory(_backings, factory) {
999
1034
  return factory;
@@ -1006,6 +1041,7 @@ function factoryBackingsCompatible(declared, available) {
1006
1041
  }
1007
1042
 
1008
1043
  // src/capabilities/resolveProviders.ts
1044
+ import { isDefined as isDefined4 } from "@xylabs/sdk-js";
1009
1045
  var MissingCapabilityError = class extends Error {
1010
1046
  moniker;
1011
1047
  reasons;
@@ -1017,150 +1053,206 @@ var MissingCapabilityError = class extends Error {
1017
1053
  this.reasons = reasons;
1018
1054
  }
1019
1055
  };
1056
+ var AmbiguousProviderError = class extends Error {
1057
+ candidates;
1058
+ moniker;
1059
+ constructor(moniker, candidates) {
1060
+ const ids = candidates.map((descriptor) => descriptor.id);
1061
+ super(
1062
+ `Multiple providers satisfy capability '${moniker}' for the requested connection: ${ids.join(", ")}`
1063
+ );
1064
+ this.name = "AmbiguousProviderError";
1065
+ this.moniker = moniker;
1066
+ this.candidates = ids;
1067
+ }
1068
+ };
1069
+ var UnboundProviderError = class extends Error {
1070
+ moniker;
1071
+ constructor(moniker) {
1072
+ super(`Provider "${moniker}" has no providerBindings.connection`);
1073
+ this.name = "UnboundProviderError";
1074
+ this.moniker = moniker;
1075
+ }
1076
+ };
1077
+ var UnknownConnectionError = class extends Error {
1078
+ connectionName;
1079
+ moniker;
1080
+ constructor(moniker, connectionName) {
1081
+ super(
1082
+ `providerBindings.${moniker}.connection references unknown connection "${connectionName}"`
1083
+ );
1084
+ this.name = "UnknownConnectionError";
1085
+ this.moniker = moniker;
1086
+ this.connectionName = connectionName;
1087
+ }
1088
+ };
1020
1089
  function resolveProviders(needs, candidates, ctx, options = {}) {
1021
- const wanted = expandNeeds(needs, ctx);
1022
- const { backingFiltered, backingRejected } = filterByBackings(candidates, options.availableBackings);
1023
- const { surviving, rejected: preconditionRejected } = filterByPreconditions(backingFiltered, ctx);
1024
- const rejected = [...backingRejected, ...preconditionRejected];
1025
- const byCapability = groupByCapability(surviving, wanted);
1026
- const { bindings, selectedById } = pickWinners(wanted, byCapability, rejected, candidates, options);
1027
- const selected = topoSort([...selectedById.values()], ctx);
1090
+ const rejected = [];
1091
+ const { preconditionFiltered, preconditionRejected } = filterByPreconditions(candidates, ctx);
1092
+ rejected.push(...preconditionRejected);
1093
+ const wanted = new Set(needs);
1094
+ const bindings = {};
1095
+ const selectedById = /* @__PURE__ */ new Map();
1096
+ const candidatesByMoniker = indexCandidatesByMoniker(preconditionFiltered);
1097
+ expandBindingClosure(
1098
+ wanted,
1099
+ bindings,
1100
+ selectedById,
1101
+ candidatesByMoniker,
1102
+ rejected,
1103
+ candidates,
1104
+ options
1105
+ );
1106
+ const selected = topoSort(selectedById.values().toArray(), bindings, selectedById);
1028
1107
  return {
1029
1108
  bindings,
1030
1109
  rejected,
1031
1110
  selected
1032
1111
  };
1033
1112
  }
1034
- function filterByBackings(candidates, availableBackings) {
1035
- if (!availableBackings) {
1036
- return { backingFiltered: [...candidates], backingRejected: [] };
1113
+ function expandBindingClosure(wanted, bindings, selectedById, candidatesByMoniker, rejected, allCandidates, options) {
1114
+ let grew = true;
1115
+ while (grew) {
1116
+ grew = false;
1117
+ for (const moniker of [...wanted].toSorted((a, b) => a.localeCompare(b))) {
1118
+ if (!Object.hasOwn(bindings, moniker)) {
1119
+ grew = bindMoniker(
1120
+ moniker,
1121
+ wanted,
1122
+ bindings,
1123
+ selectedById,
1124
+ candidatesByMoniker,
1125
+ rejected,
1126
+ allCandidates,
1127
+ options
1128
+ ) || grew;
1129
+ }
1130
+ }
1037
1131
  }
1038
- const backingFiltered = [];
1039
- const backingRejected = [];
1040
- for (const descriptor of candidates) {
1041
- if (backingsSatisfied(descriptor.backings, availableBackings)) {
1042
- backingFiltered.push(descriptor);
1043
- } else {
1044
- const missing = unmetBackings(descriptor.backings, availableBackings);
1045
- const rendered = missing.map((m) => `${m.backing}:${m.mode}`).join(", ");
1046
- backingRejected.push({ descriptor, reason: `missing backings [${rendered}]` });
1132
+ }
1133
+ function bindMoniker(moniker, wanted, bindings, selectedById, candidatesByMoniker, rejected, allCandidates, options) {
1134
+ const connectionName = connectionNameForMoniker(moniker, options);
1135
+ const connection = options.connections?.[connectionName];
1136
+ if (!isDefined4(connection)) {
1137
+ throw new UnknownConnectionError(moniker, connectionName);
1138
+ }
1139
+ const group = candidatesByMoniker.get(moniker) ?? [];
1140
+ const { filtered, rejected: connectionRejected } = filterByConnection(
1141
+ group,
1142
+ connection.type,
1143
+ connectionName
1144
+ );
1145
+ rejected.push(...connectionRejected);
1146
+ if (filtered.length === 0) {
1147
+ throw new MissingCapabilityError(moniker, reasonsFor(moniker, rejected, allCandidates));
1148
+ }
1149
+ if (filtered.length > 1) {
1150
+ throw new AmbiguousProviderError(moniker, filtered);
1151
+ }
1152
+ const winner = filtered[0];
1153
+ bindings[moniker] = winner.id;
1154
+ selectedById.set(winner.id, winner);
1155
+ let grew = false;
1156
+ for (const dep of winner.dependencies ?? []) {
1157
+ if (!wanted.has(dep)) {
1158
+ wanted.add(dep);
1159
+ grew = true;
1047
1160
  }
1048
1161
  }
1049
- return { backingFiltered, backingRejected };
1162
+ return grew;
1050
1163
  }
1051
- function expandNeeds(needs, ctx) {
1052
- const wanted = new Set(needs);
1053
- const stack = [...needs];
1054
- while (stack.length > 0) {
1055
- const moniker = stack.pop();
1056
- const cap = ctx.capabilities.tryGet(moniker);
1057
- if (!cap?.implies) continue;
1058
- for (const dep of cap.implies) {
1059
- if (!wanted.has(dep)) {
1060
- wanted.add(dep);
1061
- stack.push(dep);
1062
- }
1164
+ function connectionNameForMoniker(moniker, options) {
1165
+ const binding = options.providerBindings?.[moniker];
1166
+ const connectionName = binding?.connection ?? binding?.transport;
1167
+ if (!isDefined4(connectionName) || connectionName === "") {
1168
+ throw new UnboundProviderError(moniker);
1169
+ }
1170
+ return connectionName;
1171
+ }
1172
+ function indexCandidatesByMoniker(candidates) {
1173
+ const byMoniker = /* @__PURE__ */ new Map();
1174
+ for (const descriptor of candidates) {
1175
+ for (const moniker of descriptor.satisfies) {
1176
+ const list = byMoniker.get(moniker) ?? [];
1177
+ list.push(descriptor);
1178
+ byMoniker.set(moniker, list);
1063
1179
  }
1064
1180
  }
1065
- return wanted;
1181
+ return byMoniker;
1066
1182
  }
1067
- function filterByPreconditions(candidates, ctx) {
1068
- const surviving = [];
1183
+ function filterByConnection(group, connectionType, connectionName) {
1069
1184
  const rejected = [];
1185
+ const filtered = group.filter((descriptor) => {
1186
+ const matches = descriptorMatchesConnectionType(descriptor, connectionType);
1187
+ if (!matches) {
1188
+ const types = descriptor.connectionTypes;
1189
+ rejected.push({
1190
+ descriptor,
1191
+ reason: `connection "${connectionName}" is type "${connectionType}" but descriptor supports [${types.join(", ")}]`
1192
+ });
1193
+ }
1194
+ return matches;
1195
+ });
1196
+ return { filtered, rejected };
1197
+ }
1198
+ function filterByPreconditions(candidates, ctx) {
1199
+ const preconditionFiltered = [];
1200
+ const preconditionRejected = [];
1070
1201
  for (const descriptor of candidates) {
1071
1202
  try {
1072
1203
  if (descriptor.preconditions(ctx)) {
1073
- surviving.push(descriptor);
1204
+ preconditionFiltered.push(descriptor);
1074
1205
  } else {
1075
- rejected.push({ descriptor, reason: "preconditions returned false" });
1206
+ preconditionRejected.push({ descriptor, reason: "preconditions returned false" });
1076
1207
  }
1077
1208
  } catch (err) {
1078
- rejected.push({
1209
+ preconditionRejected.push({
1079
1210
  descriptor,
1080
1211
  reason: `preconditions threw: ${err instanceof Error ? err.message : String(err)}`
1081
1212
  });
1082
1213
  }
1083
1214
  }
1084
- return { surviving, rejected };
1215
+ return { preconditionFiltered, preconditionRejected };
1085
1216
  }
1086
- function groupByCapability(surviving, wanted) {
1087
- const byCapability = /* @__PURE__ */ new Map();
1088
- for (const descriptor of surviving) {
1089
- for (const moniker of descriptor.satisfies) {
1090
- if (!wanted.has(moniker)) continue;
1091
- const list = byCapability.get(moniker) ?? [];
1092
- list.push(descriptor);
1093
- byCapability.set(moniker, list);
1094
- }
1217
+ function reasonsFor(moniker, rejected, allCandidates) {
1218
+ const candidatesForMoniker = allCandidates.filter((candidate) => candidate.satisfies.includes(moniker));
1219
+ if (candidatesForMoniker.length === 0) {
1220
+ return [];
1095
1221
  }
1096
- return byCapability;
1222
+ return rejected.filter((rejection) => rejection.descriptor.satisfies.includes(moniker)).map((rejection) => `${rejection.descriptor.id}: ${rejection.reason}`);
1097
1223
  }
1098
- function pickWinners(wanted, byCapability, rejected, allCandidates, options) {
1099
- const bindings = {};
1100
- const selectedById = /* @__PURE__ */ new Map();
1101
- for (const moniker of wanted) {
1102
- let group = byCapability.get(moniker);
1103
- const pinned = options.implementations?.[moniker];
1104
- if (pinned) {
1105
- const pinnedGroup = group?.filter((descriptor) => descriptor.id === pinned);
1106
- if (!pinnedGroup || pinnedGroup.length === 0) {
1107
- throw new MissingCapabilityError(moniker, [`requested implementation '${pinned}' not available`]);
1108
- }
1109
- group = pinnedGroup;
1110
- }
1111
- if (!group || group.length === 0) {
1112
- throw new MissingCapabilityError(moniker, reasonsFor(moniker, rejected, allCandidates));
1113
- }
1114
- const sorted = group.toSorted(compareDescriptors);
1115
- const winner = sorted[0];
1116
- bindings[moniker] = winner.id;
1117
- selectedById.set(winner.id, winner);
1118
- for (const loser of sorted.slice(1)) {
1119
- rejected.push({
1120
- descriptor: loser,
1121
- reason: `tier ${loser.tier} lost to ${winner.id} (tier ${winner.tier}) for ${moniker}`
1122
- });
1224
+ function topoSort(descriptors, bindings, selectedById) {
1225
+ const monikerToDescriptor = /* @__PURE__ */ new Map();
1226
+ for (const [moniker, id] of Object.entries(bindings)) {
1227
+ const descriptor = selectedById.get(id);
1228
+ if (descriptor !== void 0) {
1229
+ monikerToDescriptor.set(moniker, descriptor);
1123
1230
  }
1124
1231
  }
1125
- return { bindings, selectedById };
1126
- }
1127
- function reasonsFor(moniker, rejected, allCandidates) {
1128
- const candidatesForMoniker = allCandidates.filter((c) => c.satisfies.includes(moniker));
1129
- if (candidatesForMoniker.length === 0) return [];
1130
- return rejected.filter((r) => r.descriptor.satisfies.includes(moniker)).map((r) => `${r.descriptor.id}: ${r.reason}`);
1131
- }
1132
- function compareDescriptors(a, b) {
1133
- if (a.tier !== b.tier) return a.tier - b.tier;
1134
- const pa = a.priority ?? 0;
1135
- const pb = b.priority ?? 0;
1136
- if (pa !== pb) return pb - pa;
1137
- return a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
1138
- }
1139
- function topoSort(descriptors, ctx) {
1140
- const byMoniker = /* @__PURE__ */ new Map();
1141
- for (const d of descriptors) for (const m of d.satisfies) byMoniker.set(m, d);
1142
1232
  const order = [];
1143
1233
  const seen = /* @__PURE__ */ new Set();
1144
1234
  const visiting = /* @__PURE__ */ new Set();
1145
- const visit = (d) => {
1146
- if (seen.has(d.id)) return;
1147
- if (visiting.has(d.id)) {
1148
- throw new Error(`Cycle detected through provider ${d.id}`);
1149
- }
1150
- visiting.add(d.id);
1151
- for (const moniker of d.satisfies) {
1152
- const cap = ctx.capabilities.tryGet(moniker);
1153
- if (!cap?.implies) continue;
1154
- for (const dep of cap.implies) {
1155
- const depDesc = byMoniker.get(dep);
1156
- if (depDesc) visit(depDesc);
1235
+ const visit = (descriptor) => {
1236
+ if (seen.has(descriptor.id)) {
1237
+ return;
1238
+ }
1239
+ if (visiting.has(descriptor.id)) {
1240
+ return;
1241
+ }
1242
+ visiting.add(descriptor.id);
1243
+ for (const depMoniker of descriptor.dependencies ?? []) {
1244
+ const depDescriptor = monikerToDescriptor.get(depMoniker);
1245
+ if (depDescriptor !== void 0) {
1246
+ visit(depDescriptor);
1157
1247
  }
1158
1248
  }
1159
- visiting.delete(d.id);
1160
- seen.add(d.id);
1161
- order.push(d);
1249
+ visiting.delete(descriptor.id);
1250
+ seen.add(descriptor.id);
1251
+ order.push(descriptor);
1162
1252
  };
1163
- for (const d of descriptors) visit(d);
1253
+ for (const descriptor of descriptors) {
1254
+ visit(descriptor);
1255
+ }
1164
1256
  return order;
1165
1257
  }
1166
1258
 
@@ -1192,16 +1284,191 @@ var ChainConfigZod = z2.object({
1192
1284
  })
1193
1285
  });
1194
1286
 
1287
+ // src/config/transports/Transport.ts
1288
+ import { globalRegistry as globalRegistry4, z as z6 } from "zod";
1289
+
1290
+ // src/config/Remote.ts
1291
+ import { globalRegistry as globalRegistry2, z as z3 } from "zod";
1292
+ var RpcRemoteConfigBaseZod = z3.object({
1293
+ protocol: z3.string("http").register(globalRegistry2, {
1294
+ description: "Protocol for the RPC connection",
1295
+ type: "string"
1296
+ })
1297
+ }).describe("Base configuration for the remote RPC");
1298
+ var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
1299
+ protocol: z3.string("http").register(globalRegistry2, {
1300
+ description: "Protocol for the RPC connection",
1301
+ type: "string"
1302
+ }).default("http"),
1303
+ url: z3.string().register(globalRegistry2, {
1304
+ description: "URL for the Chain RPC API",
1305
+ type: "string"
1306
+ })
1307
+ }).describe("Configuration for the remote RPC using Http");
1308
+ var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
1309
+ protocol: z3.string().register(globalRegistry2, {
1310
+ description: "Protocol for the RPC connection",
1311
+ type: "string"
1312
+ }).default("postMessage"),
1313
+ networkId: z3.string().register(globalRegistry2, {
1314
+ description: "Network ID to use for the postMessage RPC connection",
1315
+ type: "string"
1316
+ }),
1317
+ sessionId: z3.string().register(globalRegistry2, {
1318
+ description: "Session ID to use for the postMessage RPC connection",
1319
+ type: "string"
1320
+ })
1321
+ }).describe("Configuration for the remote RPC using postMessage");
1322
+ var RpcRemoteConfigZod = z3.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
1323
+ var RemoteConfigZod = z3.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
1324
+
1325
+ // src/config/storage/driver/Mongo.ts
1326
+ import { isDefined as isDefined5, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
1327
+ import { globalRegistry as globalRegistry3, z as z4 } from "zod";
1328
+ var hasMongoConfig = (config) => {
1329
+ if (isUndefined5(config)) return false;
1330
+ return isDefined5(config.connectionString) && isDefined5(config.database) && isDefined5(config.domain);
1331
+ };
1332
+ var MongoConfigZod = z4.object({
1333
+ // TODO: Create from other arguments
1334
+ connectionString: z4.string().nonempty().optional().register(globalRegistry3, {
1335
+ description: "MongoDB connection string",
1336
+ title: "storage.mongo.connectionString",
1337
+ type: "string"
1338
+ }),
1339
+ database: z4.string().nonempty().optional().register(globalRegistry3, {
1340
+ description: "MongoDB database name",
1341
+ title: "storage.mongo.database",
1342
+ type: "string"
1343
+ }),
1344
+ domain: z4.string().nonempty().optional().register(globalRegistry3, {
1345
+ description: "MongoDB domain",
1346
+ title: "storage.mongo.domain",
1347
+ type: "string"
1348
+ }),
1349
+ password: z4.string().nonempty().optional().register(globalRegistry3, {
1350
+ description: "MongoDB password",
1351
+ title: "storage.mongo.password",
1352
+ type: "string"
1353
+ }),
1354
+ username: z4.string().nonempty().optional().register(globalRegistry3, {
1355
+ description: "MongoDB username",
1356
+ title: "storage.mongo.username",
1357
+ type: "string"
1358
+ })
1359
+ });
1360
+
1361
+ // src/config/storage/driver/S3.ts
1362
+ import { isDefined as isDefined6 } from "@xylabs/sdk-js";
1363
+ import { z as z5 } from "zod";
1364
+ var S3BucketConfigZod = z5.object({
1365
+ accessKeyId: z5.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
1366
+ accountId: z5.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
1367
+ bucket: z5.string().nonempty().optional().describe("S3-compatible bucket name"),
1368
+ prefix: z5.string().nonempty().optional().describe("Optional key prefix within the bucket"),
1369
+ readUrl: z5.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
1370
+ secretAccessKey: z5.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
1371
+ });
1372
+ var S3ConfigZod = z5.object({
1373
+ accessKeyId: z5.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
1374
+ accountId: z5.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
1375
+ chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
1376
+ finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
1377
+ index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
1378
+ prefix: z5.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
1379
+ secretAccessKey: z5.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
1380
+ });
1381
+ function resolveS3Bucket(config, which) {
1382
+ if (config === void 0) return void 0;
1383
+ const entry = config[which];
1384
+ const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
1385
+ const accountId = entry?.accountId ?? config.accountId;
1386
+ const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
1387
+ const bucket = entry?.bucket ?? config.finalized?.bucket;
1388
+ if (!isDefined6(accessKeyId) || !isDefined6(accountId) || !isDefined6(secretAccessKey) || !isDefined6(bucket)) return void 0;
1389
+ return {
1390
+ accessKeyId,
1391
+ accountId,
1392
+ bucket,
1393
+ prefix: entry?.prefix ?? config.prefix,
1394
+ readUrl: entry?.readUrl,
1395
+ secretAccessKey
1396
+ };
1397
+ }
1398
+ function hasS3Config(config, which = "finalized") {
1399
+ return resolveS3Bucket(config, which) !== void 0;
1400
+ }
1401
+
1402
+ // src/config/transports/Transport.ts
1403
+ var LmdbTransportConfigZod = z6.object({
1404
+ access: z6.enum(["read", "write"]).optional().register(globalRegistry4, {
1405
+ description: "Access mode for this LMDB connection (read or write)",
1406
+ title: "transports.lmdb.access",
1407
+ type: "string"
1408
+ }),
1409
+ root: z6.string().register(globalRegistry4, {
1410
+ description: "Root directory for local LMDB storage",
1411
+ title: "transports.lmdb.root",
1412
+ type: "string"
1413
+ }),
1414
+ store: z6.string().optional().register(globalRegistry4, {
1415
+ description: "Logical store name within the LMDB root (e.g. finalized-chain, mempool)",
1416
+ title: "transports.lmdb.store",
1417
+ type: "string"
1418
+ }),
1419
+ type: z6.literal("lmdb")
1420
+ }).describe("LMDB local storage transport");
1421
+ var MongoTransportConfigZod = z6.object({
1422
+ type: z6.literal("mongo"),
1423
+ connectionString: MongoConfigZod.shape.connectionString,
1424
+ database: MongoConfigZod.shape.database,
1425
+ domain: MongoConfigZod.shape.domain,
1426
+ password: MongoConfigZod.shape.password,
1427
+ username: MongoConfigZod.shape.username
1428
+ }).describe("MongoDB storage transport");
1429
+ var RpcTransportConfigZod = HttpRpcRemoteConfigZod.extend({ type: z6.literal("rpc") }).describe("XL1 JSON-RPC transport");
1430
+ var RestTransportConfigZod = z6.object({
1431
+ type: z6.literal("rest"),
1432
+ baseUrl: z6.string().register(globalRegistry4, {
1433
+ description: "HTTP base URL for REST reads",
1434
+ title: "transports.rest.baseUrl",
1435
+ type: "string"
1436
+ })
1437
+ }).describe("HTTP REST read transport");
1438
+ var S3TransportConfigZod = S3BucketConfigZod.extend({
1439
+ type: z6.literal("s3"),
1440
+ accessKeyId: z6.string().optional(),
1441
+ accountId: z6.string().optional(),
1442
+ secretAccessKey: z6.string().optional()
1443
+ }).describe("S3-compatible object storage transport");
1444
+ var EvmRpcTransportConfigZod = z6.object({
1445
+ type: z6.literal("evm-rpc"),
1446
+ url: z6.string().register(globalRegistry4, {
1447
+ description: "EVM JSON-RPC URL",
1448
+ title: "transports.evm-rpc.url",
1449
+ type: "string"
1450
+ })
1451
+ }).describe("EVM JSON-RPC transport");
1452
+ var TransportConfigZod = z6.discriminatedUnion("type", [
1453
+ LmdbTransportConfigZod,
1454
+ MongoTransportConfigZod,
1455
+ RpcTransportConfigZod,
1456
+ RestTransportConfigZod,
1457
+ S3TransportConfigZod,
1458
+ EvmRpcTransportConfigZod
1459
+ ]);
1460
+ var TransportsConfigZod = z6.record(z6.string(), TransportConfigZod).default({});
1461
+
1195
1462
  // src/config/DataLake/DataLake.ts
1196
- import { z as z6 } from "zod";
1463
+ import { z as z10 } from "zod";
1197
1464
 
1198
1465
  // src/config/DataLake/RestDataLakeConfig.ts
1199
- import { globalRegistry as globalRegistry3, z as z4 } from "zod";
1466
+ import { globalRegistry as globalRegistry6, z as z8 } from "zod";
1200
1467
 
1201
1468
  // src/config/DataLake/DataLakeRemoteConfig.ts
1202
- import { globalRegistry as globalRegistry2, z as z3 } from "zod";
1203
- var DataLakeDriverConfigBaseZod = z3.object({
1204
- driver: z3.string().register(globalRegistry2, {
1469
+ import { globalRegistry as globalRegistry5, z as z7 } from "zod";
1470
+ var DataLakeDriverConfigBaseZod = z7.object({
1471
+ driver: z7.string().register(globalRegistry5, {
1205
1472
  description: "Driver for the data lake",
1206
1473
  type: "string"
1207
1474
  })
@@ -1209,55 +1476,55 @@ var DataLakeDriverConfigBaseZod = z3.object({
1209
1476
 
1210
1477
  // src/config/DataLake/RestDataLakeConfig.ts
1211
1478
  var RestDataLakeConfigZod = DataLakeDriverConfigBaseZod.extend({
1212
- driver: z4.literal("rest").register(globalRegistry3, {
1479
+ driver: z8.literal("rest").register(globalRegistry6, {
1213
1480
  description: "Driver for the REST data lake",
1214
1481
  type: "string"
1215
1482
  }),
1216
- url: z4.string().register(globalRegistry3, {
1483
+ url: z8.string().register(globalRegistry6, {
1217
1484
  description: "URL for the REST data lake",
1218
1485
  type: "string"
1219
1486
  })
1220
1487
  }).describe("Configuration for the REST data lake driver");
1221
1488
 
1222
1489
  // src/config/DataLake/RouterDataLakeConfig.ts
1223
- import { globalRegistry as globalRegistry4, z as z5 } from "zod";
1224
- var RouterDataLakeConfigZod = z5.object({
1225
- driver: z5.literal("router").register(globalRegistry4, {
1490
+ import { globalRegistry as globalRegistry7, z as z9 } from "zod";
1491
+ var RouterDataLakeConfigZod = z9.object({
1492
+ driver: z9.literal("router").register(globalRegistry7, {
1226
1493
  description: "Driver for the router data lake",
1227
1494
  type: "string"
1228
1495
  }),
1229
- children: z5.array(z5.lazy(() => DataLakeConfigZod)).register(globalRegistry4, {
1496
+ children: z9.array(z9.lazy(() => DataLakeConfigZod)).register(globalRegistry7, {
1230
1497
  description: "Child data lake drivers",
1231
1498
  type: "array"
1232
1499
  })
1233
1500
  }).describe("Configuration for the router data lake driver");
1234
1501
 
1235
1502
  // src/config/DataLake/DataLake.ts
1236
- var DataLakeConfigZod = z6.lazy(() => z6.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
1503
+ var DataLakeConfigZod = z10.lazy(() => z10.union([RestDataLakeConfigZod, RouterDataLakeConfigZod])).describe("Configuration for a data lake");
1237
1504
 
1238
1505
  // src/config/Evm.ts
1239
- import { globalRegistry as globalRegistry5, z as z7 } from "zod";
1240
- var EvmInfuraConfigZod = z7.object({
1241
- projectId: z7.string().optional().register(globalRegistry5, {
1506
+ import { globalRegistry as globalRegistry8, z as z11 } from "zod";
1507
+ var EvmInfuraConfigZod = z11.object({
1508
+ projectId: z11.string().optional().register(globalRegistry8, {
1242
1509
  description: "Infura project ID",
1243
1510
  title: "evm.infura.projectId",
1244
1511
  type: "string"
1245
1512
  }),
1246
- projectSecret: z7.string().optional().register(globalRegistry5, {
1513
+ projectSecret: z11.string().optional().register(globalRegistry8, {
1247
1514
  description: "Infura project secret",
1248
1515
  title: "evm.infura.projectSecret",
1249
1516
  type: "string"
1250
1517
  })
1251
1518
  });
1252
- var EvmJsonRpcConfigZod = z7.object({
1253
- url: z7.url().optional().register(globalRegistry5, {
1519
+ var EvmJsonRpcConfigZod = z11.object({
1520
+ url: z11.url().optional().register(globalRegistry8, {
1254
1521
  description: "JSON-RPC URL",
1255
1522
  title: "evm.jsonRpc.url",
1256
1523
  type: "string"
1257
1524
  })
1258
1525
  });
1259
- var EvmConfigZod = z7.object({
1260
- chainId: z7.string().optional().register(globalRegistry5, {
1526
+ var EvmConfigZod = z11.object({
1527
+ chainId: z11.string().optional().register(globalRegistry8, {
1261
1528
  description: "EVM chain ID",
1262
1529
  title: "evm.chainId",
1263
1530
  type: "string"
@@ -1268,17 +1535,17 @@ var EvmConfigZod = z7.object({
1268
1535
 
1269
1536
  // src/config/Log.ts
1270
1537
  import { LogLevel } from "@xylabs/sdk-js";
1271
- import { globalRegistry as globalRegistry6, z as z8 } from "zod";
1538
+ import { globalRegistry as globalRegistry9, z as z12 } from "zod";
1272
1539
  var LogLevelNames = Object.keys(LogLevel);
1273
- var LogConfigZod = z8.object({
1274
- logLevel: z8.enum(LogLevelNames).default("info").register(globalRegistry6, {
1540
+ var LogConfigZod = z12.object({
1541
+ logLevel: z12.enum(LogLevelNames).default("info").register(globalRegistry9, {
1275
1542
  choices: LogLevelNames,
1276
1543
  default: "info",
1277
1544
  description: "Desired process verbosity",
1278
1545
  title: "logLevel",
1279
1546
  type: "string"
1280
1547
  }),
1281
- silent: z8.boolean().default(false).register(globalRegistry6, {
1548
+ silent: z12.boolean().default(false).register(globalRegistry9, {
1282
1549
  default: false,
1283
1550
  description: "Whether to run in silent mode",
1284
1551
  title: "silent",
@@ -1287,23 +1554,23 @@ var LogConfigZod = z8.object({
1287
1554
  });
1288
1555
 
1289
1556
  // src/config/ProviderBinding.ts
1290
- import { globalRegistry as globalRegistry7, z as z9 } from "zod";
1291
- var ProviderBindingConfigZod = z9.object({
1292
- implementation: z9.string().optional().register(globalRegistry7, {
1293
- description: "Installed provider implementation id (descriptor id)",
1294
- title: "providerBindings.implementation",
1557
+ import { globalRegistry as globalRegistry10, z as z13 } from "zod";
1558
+ var ProviderBindingConfigZod = z13.object({
1559
+ connection: z13.string().optional().register(globalRegistry10, {
1560
+ description: "Named connection from the top-level connections map",
1561
+ title: "providerBindings.connection",
1295
1562
  type: "string"
1296
1563
  }),
1297
- transport: z9.string().optional().register(globalRegistry7, {
1298
- description: "Named transport from the top-level transports map",
1564
+ transport: z13.string().optional().register(globalRegistry10, {
1565
+ description: "Deprecated alias for connection (kept in sync during migration)",
1299
1566
  title: "providerBindings.transport",
1300
1567
  type: "string"
1301
1568
  })
1302
- }).describe("Provider implementation and transport binding");
1303
- var ProviderBindingsConfigZod = z9.record(z9.string(), ProviderBindingConfigZod).default({});
1569
+ }).describe("Provider connection binding");
1570
+ var ProviderBindingsConfigZod = z13.record(z13.string(), ProviderBindingConfigZod).default({});
1304
1571
 
1305
1572
  // src/config/Providers.ts
1306
- import z11 from "zod";
1573
+ import z15 from "zod";
1307
1574
 
1308
1575
  // src/config/Provider.ts
1309
1576
  import {
@@ -1311,135 +1578,23 @@ import {
1311
1578
  zodIsFactory,
1312
1579
  zodToFactory
1313
1580
  } from "@xylabs/sdk-js";
1314
- import { z as z10 } from "zod";
1315
- var ProviderConfigZod = z10.object({
1316
- moniker: z10.string(),
1317
- labels: z10.array(z10.string()).optional()
1581
+ import { z as z14 } from "zod";
1582
+ var ProviderConfigZod = z14.object({
1583
+ moniker: z14.string(),
1584
+ labels: z14.array(z14.string()).optional()
1318
1585
  }).describe("Configuration for a Provider");
1319
1586
  var isProviderConfig = zodIsFactory(ProviderConfigZod);
1320
1587
  var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
1321
1588
  var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
1322
1589
 
1323
1590
  // src/config/Providers.ts
1324
- var ProvidersConfigZod = z11.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
1325
-
1326
- // src/config/Remote.ts
1327
- import { globalRegistry as globalRegistry8, z as z12 } from "zod";
1328
- var RpcRemoteConfigBaseZod = z12.object({
1329
- protocol: z12.string("http").register(globalRegistry8, {
1330
- description: "Protocol for the RPC connection",
1331
- type: "string"
1332
- })
1333
- }).describe("Base configuration for the remote RPC");
1334
- var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
1335
- protocol: z12.string("http").register(globalRegistry8, {
1336
- description: "Protocol for the RPC connection",
1337
- type: "string"
1338
- }).default("http"),
1339
- url: z12.string().register(globalRegistry8, {
1340
- description: "URL for the Chain RPC API",
1341
- type: "string"
1342
- })
1343
- }).describe("Configuration for the remote RPC using Http");
1344
- var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
1345
- protocol: z12.string().register(globalRegistry8, {
1346
- description: "Protocol for the RPC connection",
1347
- type: "string"
1348
- }).default("postMessage"),
1349
- networkId: z12.string().register(globalRegistry8, {
1350
- description: "Network ID to use for the postMessage RPC connection",
1351
- type: "string"
1352
- }),
1353
- sessionId: z12.string().register(globalRegistry8, {
1354
- description: "Session ID to use for the postMessage RPC connection",
1355
- type: "string"
1356
- })
1357
- }).describe("Configuration for the remote RPC using postMessage");
1358
- var RpcRemoteConfigZod = z12.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
1359
- var RemoteConfigZod = z12.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
1360
-
1361
- // src/config/storage/driver/Mongo.ts
1362
- import { isDefined as isDefined4, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
1363
- import { globalRegistry as globalRegistry9, z as z13 } from "zod";
1364
- var hasMongoConfig = (config) => {
1365
- if (isUndefined5(config)) return false;
1366
- return isDefined4(config.connectionString) && isDefined4(config.database) && isDefined4(config.domain);
1367
- };
1368
- var MongoConfigZod = z13.object({
1369
- // TODO: Create from other arguments
1370
- connectionString: z13.string().nonempty().optional().register(globalRegistry9, {
1371
- description: "MongoDB connection string",
1372
- title: "storage.mongo.connectionString",
1373
- type: "string"
1374
- }),
1375
- database: z13.string().nonempty().optional().register(globalRegistry9, {
1376
- description: "MongoDB database name",
1377
- title: "storage.mongo.database",
1378
- type: "string"
1379
- }),
1380
- domain: z13.string().nonempty().optional().register(globalRegistry9, {
1381
- description: "MongoDB domain",
1382
- title: "storage.mongo.domain",
1383
- type: "string"
1384
- }),
1385
- password: z13.string().nonempty().optional().register(globalRegistry9, {
1386
- description: "MongoDB password",
1387
- title: "storage.mongo.password",
1388
- type: "string"
1389
- }),
1390
- username: z13.string().nonempty().optional().register(globalRegistry9, {
1391
- description: "MongoDB username",
1392
- title: "storage.mongo.username",
1393
- type: "string"
1394
- })
1395
- });
1396
-
1397
- // src/config/storage/driver/S3.ts
1398
- import { isDefined as isDefined5 } from "@xylabs/sdk-js";
1399
- import { z as z14 } from "zod";
1400
- var S3BucketConfigZod = z14.object({
1401
- accessKeyId: z14.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
1402
- accountId: z14.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
1403
- bucket: z14.string().nonempty().optional().describe("S3-compatible bucket name"),
1404
- prefix: z14.string().nonempty().optional().describe("Optional key prefix within the bucket"),
1405
- readUrl: z14.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
1406
- secretAccessKey: z14.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
1407
- });
1408
- var S3ConfigZod = z14.object({
1409
- accessKeyId: z14.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
1410
- accountId: z14.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
1411
- chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
1412
- finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
1413
- index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
1414
- prefix: z14.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
1415
- secretAccessKey: z14.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
1416
- });
1417
- function resolveS3Bucket(config, which) {
1418
- if (config === void 0) return void 0;
1419
- const entry = config[which];
1420
- const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
1421
- const accountId = entry?.accountId ?? config.accountId;
1422
- const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
1423
- const bucket = entry?.bucket ?? config.finalized?.bucket;
1424
- if (!isDefined5(accessKeyId) || !isDefined5(accountId) || !isDefined5(secretAccessKey) || !isDefined5(bucket)) return void 0;
1425
- return {
1426
- accessKeyId,
1427
- accountId,
1428
- bucket,
1429
- prefix: entry?.prefix ?? config.prefix,
1430
- readUrl: entry?.readUrl,
1431
- secretAccessKey
1432
- };
1433
- }
1434
- function hasS3Config(config, which = "finalized") {
1435
- return resolveS3Bucket(config, which) !== void 0;
1436
- }
1591
+ var ProvidersConfigZod = z15.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
1437
1592
 
1438
1593
  // src/config/storage/Storage.ts
1439
- import { globalRegistry as globalRegistry10, z as z15 } from "zod";
1440
- var StorageConfigZod = z15.object({
1594
+ import { globalRegistry as globalRegistry11, z as z16 } from "zod";
1595
+ var StorageConfigZod = z16.object({
1441
1596
  mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
1442
- root: z15.string().optional().register(globalRegistry10, {
1597
+ root: z16.string().optional().register(globalRegistry11, {
1443
1598
  description: "Root directory for local storage",
1444
1599
  title: "storage.root",
1445
1600
  type: "string"
@@ -1448,7 +1603,7 @@ var StorageConfigZod = z15.object({
1448
1603
  }).describe("Storage configuration options");
1449
1604
 
1450
1605
  // src/config/Telemetry.ts
1451
- import { globalRegistry as globalRegistry11, z as z16 } from "zod";
1606
+ import { globalRegistry as globalRegistry12, z as z17 } from "zod";
1452
1607
  var DefaultMetricsScrapePorts = {
1453
1608
  api: 9465,
1454
1609
  bridge: 9468,
@@ -1456,86 +1611,35 @@ var DefaultMetricsScrapePorts = {
1456
1611
  producer: 9464,
1457
1612
  rewardRedemptionApi: 9467
1458
1613
  };
1459
- var MetricsScrapeConfigZod = z16.object({
1460
- path: z16.string().default("/metrics").register(globalRegistry11, {
1614
+ var MetricsScrapeConfigZod = z17.object({
1615
+ path: z17.string().default("/metrics").register(globalRegistry12, {
1461
1616
  default: "/metrics",
1462
1617
  description: "Path for the metrics scrape endpoint",
1463
1618
  title: "telemetry.metrics.scrape.path",
1464
1619
  type: "string"
1465
1620
  }),
1466
- port: z16.coerce.number().int().positive().optional().register(globalRegistry11, {
1621
+ port: z17.coerce.number().int().positive().optional().register(globalRegistry12, {
1467
1622
  description: "Port for the metrics scrape endpoint",
1468
1623
  title: "telemetry.metrics.scrape.port",
1469
1624
  type: "number"
1470
1625
  })
1471
1626
  }).describe("Metrics scrape configuration");
1472
- var MetricsConfigZod = z16.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
1473
- var OpenTelemetryConfigZod = z16.object({
1627
+ var MetricsConfigZod = z17.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
1628
+ var OpenTelemetryConfigZod = z17.object({
1474
1629
  // OpenTelemetry options
1475
- otlpEndpoint: z16.url().optional().register(globalRegistry11, {
1630
+ otlpEndpoint: z17.url().optional().register(globalRegistry12, {
1476
1631
  description: "OTLP endpoint for exporting telemetry data",
1477
1632
  title: "telemetry.otel.otlpEndpoint",
1478
1633
  type: "string"
1479
1634
  })
1480
1635
  });
1481
- var TelemetryConfigZod = z16.object({
1636
+ var TelemetryConfigZod = z17.object({
1482
1637
  // Metrics configuration
1483
1638
  metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
1484
1639
  // OpenTelemetry configuration
1485
1640
  otel: OpenTelemetryConfigZod.optional().describe("OpenTelemetry configuration")
1486
1641
  }).describe("Telemetry configuration options");
1487
1642
 
1488
- // src/config/transports/Transport.ts
1489
- import { globalRegistry as globalRegistry12, z as z17 } from "zod";
1490
- var LmdbTransportConfigZod = z17.object({
1491
- type: z17.literal("lmdb"),
1492
- root: z17.string().register(globalRegistry12, {
1493
- description: "Root directory for local LMDB storage",
1494
- title: "transports.lmdb.root",
1495
- type: "string"
1496
- })
1497
- }).describe("LMDB local storage transport");
1498
- var MongoTransportConfigZod = z17.object({
1499
- type: z17.literal("mongo"),
1500
- connectionString: MongoConfigZod.shape.connectionString,
1501
- database: MongoConfigZod.shape.database,
1502
- domain: MongoConfigZod.shape.domain,
1503
- password: MongoConfigZod.shape.password,
1504
- username: MongoConfigZod.shape.username
1505
- }).describe("MongoDB storage transport");
1506
- var RpcTransportConfigZod = HttpRpcRemoteConfigZod.extend({ type: z17.literal("rpc") }).describe("XL1 JSON-RPC transport");
1507
- var RestTransportConfigZod = z17.object({
1508
- type: z17.literal("rest"),
1509
- baseUrl: z17.string().register(globalRegistry12, {
1510
- description: "HTTP base URL for REST reads",
1511
- title: "transports.rest.baseUrl",
1512
- type: "string"
1513
- })
1514
- }).describe("HTTP REST read transport");
1515
- var S3TransportConfigZod = S3BucketConfigZod.extend({
1516
- type: z17.literal("s3"),
1517
- accessKeyId: z17.string().optional(),
1518
- accountId: z17.string().optional(),
1519
- secretAccessKey: z17.string().optional()
1520
- }).describe("S3-compatible object storage transport");
1521
- var EvmRpcTransportConfigZod = z17.object({
1522
- type: z17.literal("evm-rpc"),
1523
- url: z17.string().register(globalRegistry12, {
1524
- description: "EVM JSON-RPC URL",
1525
- title: "transports.evm-rpc.url",
1526
- type: "string"
1527
- })
1528
- }).describe("EVM JSON-RPC transport");
1529
- var TransportConfigZod = z17.discriminatedUnion("type", [
1530
- LmdbTransportConfigZod,
1531
- MongoTransportConfigZod,
1532
- RpcTransportConfigZod,
1533
- RestTransportConfigZod,
1534
- S3TransportConfigZod,
1535
- EvmRpcTransportConfigZod
1536
- ]);
1537
- var TransportsConfigZod = z17.record(z17.string(), TransportConfigZod).default({});
1538
-
1539
1643
  // src/config/Validation.ts
1540
1644
  import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
1541
1645
  import { globalRegistry as globalRegistry13, z as z18 } from "zod";
@@ -1559,11 +1663,11 @@ function blockRangeSteps(range, steps) {
1559
1663
  }
1560
1664
 
1561
1665
  // src/primitives/block/rate/blockRate.ts
1562
- import { isDefined as isDefined7, isFalsy } from "@xylabs/sdk-js";
1666
+ import { isDefined as isDefined8, isFalsy } from "@xylabs/sdk-js";
1563
1667
  import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
1564
1668
 
1565
1669
  // src/primitives/block/rate/timeHelpers.ts
1566
- import { assertEx as assertEx8, isDefined as isDefined6 } from "@xylabs/sdk-js";
1670
+ import { assertEx as assertEx8, isDefined as isDefined7 } from "@xylabs/sdk-js";
1567
1671
  var rateMultipliers = {
1568
1672
  millis: 1,
1569
1673
  seconds: 1e3,
@@ -1581,7 +1685,7 @@ var timeDurations = (timeInMs) => ({
1581
1685
  weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
1582
1686
  });
1583
1687
  var getTimeConfigInMilliseconds = (timeConfig) => {
1584
- const assertedTimeConfig = assertEx8(isDefined6(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
1688
+ const assertedTimeConfig = assertEx8(isDefined7(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
1585
1689
  let totalMilliseconds = 0;
1586
1690
  if ("years" in assertedTimeConfig) {
1587
1691
  totalMilliseconds += assertedTimeConfig.years * 31536e6;
@@ -1620,13 +1724,13 @@ var blockRate = (startBlock, endBlock, timeUnit) => {
1620
1724
  throw new Error("Time difference must be greater than 0");
1621
1725
  }
1622
1726
  const rate = heightDifference / timeDifference;
1623
- const timeUnitValue = isDefined7(timeUnit) ? timeUnit : "millis";
1624
- const returnedTimeDifference = isDefined7(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
1727
+ const timeUnitValue = isDefined8(timeUnit) ? timeUnit : "millis";
1728
+ const returnedTimeDifference = isDefined8(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
1625
1729
  const timePerBlock = returnedTimeDifference / heightDifference;
1626
1730
  return {
1627
1731
  range: asXL1BlockRange([startingBlock.block, endingBlock.block], true),
1628
1732
  span: heightDifference,
1629
- rate: isDefined7(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
1733
+ rate: isDefined8(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
1630
1734
  timeUnit: timeUnitValue,
1631
1735
  timeDifference: returnedTimeDifference,
1632
1736
  timePerBlock
@@ -1674,7 +1778,7 @@ var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit
1674
1778
  // src/primitives/block/rate/timeRate.ts
1675
1779
  import {
1676
1780
  assertEx as assertEx10,
1677
- isDefined as isDefined8,
1781
+ isDefined as isDefined9,
1678
1782
  isDefinedNotNull
1679
1783
  } from "@xylabs/sdk-js";
1680
1784
  import { asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol-lib";
@@ -1683,7 +1787,9 @@ var DEFAULT_MAX_ATTEMPTS = 10;
1683
1787
  var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, toleranceMs = DEFAULT_TOLERANCE_MS, maxAttempts = DEFAULT_MAX_ATTEMPTS) => {
1684
1788
  assertEx10(Object.keys(timeConfig ?? {}).length === 1, () => "Only one time unit should be specified in timeConfig");
1685
1789
  const startBlock = isDefinedNotNull(startBlockNumber) ? await viewer.blockByNumber(startBlockNumber) : null;
1686
- const resolvedStartBlock = isDefinedNotNull(startBlock) ? startBlock[0] : (await viewer.currentBlock())[0];
1790
+ const currentBlockResult = await viewer.currentBlock();
1791
+ const blockResult = isDefinedNotNull(startBlock) ? startBlock : currentBlockResult;
1792
+ const resolvedStartBlock = blockResult[0];
1687
1793
  const timeInMilliseconds = getTimeConfigInMilliseconds(timeConfig);
1688
1794
  assertEx10(timeInMilliseconds > 0, () => "Time duration must be greater than zero");
1689
1795
  const blocksPerMillisecondRate = 1 / (12 * 1e3);
@@ -1711,7 +1817,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
1711
1817
  }
1712
1818
  const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
1713
1819
  const resolvedEndBlock = assertEx10(
1714
- isDefined8(endBlock?.[0]) ? endBlock[0] : void 0,
1820
+ isDefined9(endBlock?.[0]) ? endBlock[0] : void 0,
1715
1821
  () => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
1716
1822
  );
1717
1823
  const endBlockEpoch = resolvedEndBlock.$epoch;
@@ -1748,7 +1854,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
1748
1854
  // src/primitives/chain/getWindowedChain.ts
1749
1855
  import {
1750
1856
  assertEx as assertEx11,
1751
- isDefined as isDefined9,
1857
+ isDefined as isDefined10,
1752
1858
  isNull,
1753
1859
  spanRootAsync
1754
1860
  } from "@xylabs/sdk-js";
@@ -1762,7 +1868,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
1762
1868
  while (currentBlock !== null && newChain.length < maxWindowSize) {
1763
1869
  const currentBlockNumber = currentBlock[0].block;
1764
1870
  const nextBlock = newChain[0];
1765
- if (isDefined9(nextBlock)) {
1871
+ if (isDefined10(nextBlock)) {
1766
1872
  const nextBlockNumber = nextBlock[0].block;
1767
1873
  assertEx11(
1768
1874
  currentBlockNumber === nextBlockNumber - 1,
@@ -1847,7 +1953,9 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
1847
1953
  const [transferIndex, transferCount] = stepTransferIndex(block, step);
1848
1954
  const [blockBw, payloads] = hydratedBlock;
1849
1955
  const transfersFromPool = payloads.filter(isTransfer).map((p) => asTransfer(p)).filter(exists).filter((t) => t.from === XYO_STEP_REWARD_ADDRESS);
1850
- const fromEntries = Object.entries(mergeTransfers(transfersFromPool)[XYO_STEP_REWARD_ADDRESS]);
1956
+ const mergedTransfers = mergeTransfers(transfersFromPool);
1957
+ const rewardEntry = Object.entries(mergedTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS);
1958
+ const fromEntries = Object.entries(rewardEntry?.[1] ?? {});
1851
1959
  const sortedTransferAmounts = fromEntries.toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
1852
1960
  assertEx14(
1853
1961
  sortedTransferAmounts.length === transferCount,
@@ -1857,7 +1965,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
1857
1965
  }
1858
1966
 
1859
1967
  // src/primitives/chain/step/stepRewardTotal.ts
1860
- import { assertEx as assertEx15, isDefined as isDefined10 } from "@xylabs/sdk-js";
1968
+ import { assertEx as assertEx15, isDefined as isDefined11 } from "@xylabs/sdk-js";
1861
1969
  import {
1862
1970
  asAttoXL1,
1863
1971
  asXL1BlockRange as asXL1BlockRange5,
@@ -1950,7 +2058,7 @@ function stepInRange(step, range) {
1950
2058
  return stepRange[0] >= range[0] && stepRange[1] <= range[1];
1951
2059
  }
1952
2060
  async function stepRewardTotal(context, blockViewer, { block, step }, multipliers) {
1953
- const cacheKey = `${block}|${step}|${isDefined10(multipliers)}`;
2061
+ const cacheKey = `${block}|${step}|${isDefined11(multipliers)}`;
1954
2062
  return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
1955
2063
  const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
1956
2064
  assertEx15(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
@@ -1959,8 +2067,10 @@ async function stepRewardTotal(context, blockViewer, { block, step }, multiplier
1959
2067
  payloads.find((p) => isTransfer5(p) && p.from === XYO_STEP_REWARD_ADDRESS2),
1960
2068
  () => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`
1961
2069
  );
2070
+ const netTransfers = netTransfersForPayloads(context, [stepTransfer]);
2071
+ const rewardEntry = Object.entries(netTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS2);
1962
2072
  const rewards = assertEx15(
1963
- netTransfersForPayloads(context, [stepTransfer])[XYO_STEP_REWARD_ADDRESS2],
2073
+ rewardEntry?.[1],
1964
2074
  () => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`
1965
2075
  );
1966
2076
  const sortedTransfers = Object.entries(rewards).toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
@@ -2001,7 +2111,7 @@ async function stepsRewardTotal(context, blockViewer, steps, multipliers) {
2001
2111
  return asAttoXL12(totalRewards);
2002
2112
  }
2003
2113
 
2004
- // src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts
2114
+ // src/primitives/chain/time/externalBlockNumberFromXl1BlockNumber.ts
2005
2115
  import { assertEx as assertEx16, isArray } from "@xylabs/sdk-js";
2006
2116
  import {
2007
2117
  asBlockNumber,
@@ -2022,7 +2132,7 @@ async function externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1Bl
2022
2132
  });
2023
2133
  }
2024
2134
 
2025
- // src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts
2135
+ // src/primitives/chain/time/externalBlockRangeFromXl1BlockRange.ts
2026
2136
  async function externalBlockRangeFromXL1BlockRange(context, blockViewer, xl1BlockRange, externalTimeName = "ethereum") {
2027
2137
  const start = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[0], externalTimeName);
2028
2138
  const end = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[1], externalTimeName);
@@ -2039,7 +2149,7 @@ async function externalBlockRangeFromStep(context, blockViewer, stepIdentity) {
2039
2149
  }
2040
2150
 
2041
2151
  // src/primitives/mapToMapType.ts
2042
- import { isDefined as isDefined11 } from "@xylabs/sdk-js";
2152
+ import { isDefined as isDefined12 } from "@xylabs/sdk-js";
2043
2153
  function mapToMapType(map) {
2044
2154
  return {
2045
2155
  get: (key) => map.get(key),
@@ -2058,7 +2168,7 @@ function mapToMapType(map) {
2058
2168
  const result = [];
2059
2169
  for (const key of keys) {
2060
2170
  const value = map.get(key);
2061
- if (isDefined11(value)) {
2171
+ if (isDefined12(value)) {
2062
2172
  result.push(value);
2063
2173
  }
2064
2174
  }
@@ -2073,18 +2183,20 @@ function mapToMapType(map) {
2073
2183
  }
2074
2184
 
2075
2185
  // src/primitives/readPayloadMapFromStore.ts
2076
- import { isDefined as isDefined12 } from "@xylabs/sdk-js";
2186
+ import { isDefined as isDefined13 } from "@xylabs/sdk-js";
2077
2187
  function readPayloadMapFromStore(store) {
2078
2188
  if (isReadArchivist(store)) {
2079
2189
  return {
2080
2190
  get: async (hash) => {
2081
- return (await store.get([hash]))[0];
2191
+ const results = await store.get([hash]);
2192
+ return results[0];
2082
2193
  },
2083
2194
  getMany: async (hashes) => {
2084
2195
  return await store.get(hashes);
2085
2196
  },
2086
2197
  has: async (hash) => {
2087
- return isDefined12((await store.get([hash]))[0]);
2198
+ const results = await store.get([hash]);
2199
+ return isDefined13(results[0]);
2088
2200
  }
2089
2201
  };
2090
2202
  }
@@ -2094,13 +2206,15 @@ function payloadMapFromStore(store) {
2094
2206
  if (isReadWriteArchivist(store)) {
2095
2207
  return {
2096
2208
  get: async (hash) => {
2097
- return (await store.get([hash]))[0];
2209
+ const results = await store.get([hash]);
2210
+ return results[0];
2098
2211
  },
2099
2212
  getMany: async (hashes) => {
2100
2213
  return await store.get(hashes);
2101
2214
  },
2102
2215
  has: async (hash) => {
2103
- return isDefined12((await store.get([hash]))[0]);
2216
+ const results = await store.get([hash]);
2217
+ return isDefined13(results[0]);
2104
2218
  },
2105
2219
  clear: async () => {
2106
2220
  return await store.clear();
@@ -2146,7 +2260,7 @@ function rewardFromBlockNumber(blockNumber) {
2146
2260
  import { XYO_NETWORK_STAKING_ADDRESS } from "@xyo-network/xl1-protocol-lib";
2147
2261
 
2148
2262
  // src/primitives/stake/activeStakeAtTimeByAddress.ts
2149
- import { isDefined as isDefined13 } from "@xylabs/sdk-js";
2263
+ import { isDefined as isDefined14 } from "@xylabs/sdk-js";
2150
2264
 
2151
2265
  // src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
2152
2266
  async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
@@ -2160,12 +2274,13 @@ async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, st
2160
2274
 
2161
2275
  // src/primitives/stake/activeStakeAtTimeByAddress.ts
2162
2276
  async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
2163
- const stakeEvents = (await mergedAddRemoveStakeEventsByStaker(chain, [0, time], staked, staker)).toSorted((a, b) => a.time - b.time);
2277
+ const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, time], staked, staker);
2278
+ const stakeEvents = mergedEvents.toSorted((a, b) => a.time - b.time);
2164
2279
  let result = 0n;
2165
2280
  for (const event of stakeEvents) {
2166
2281
  if (event.time > time) break;
2167
2282
  if (event.args.staked !== staked) continue;
2168
- if (isDefined13(staker) && event.args.staker !== staker) continue;
2283
+ if (isDefined14(staker) && event.args.staker !== staker) continue;
2169
2284
  if (event.name === "StakeAdded") {
2170
2285
  result += event.args.amount;
2171
2286
  } else if (event.name === "StakeRemoved") {
@@ -2190,7 +2305,8 @@ async function mergedAddRemoveStakeEventsByPosition(chainEvents, range, position
2190
2305
 
2191
2306
  // src/primitives/stake/activeStakeAtTimeByPosition.ts
2192
2307
  async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, position) {
2193
- const stakeEvents = (await mergedAddRemoveStakeEventsByPosition(chainStakeEvents, [0, externalTime], position)).toSorted((a, b) => a.time - b.time);
2308
+ const mergedEvents = await mergedAddRemoveStakeEventsByPosition(chainStakeEvents, [0, externalTime], position);
2309
+ const stakeEvents = mergedEvents.toSorted((a, b) => a.time - b.time);
2194
2310
  let result = 0n;
2195
2311
  for (const event of stakeEvents) {
2196
2312
  if (event.time > externalTime) break;
@@ -2238,23 +2354,24 @@ async function allStakersForStep(context, blockViewer, stakeEventsViewer, stepCo
2238
2354
  }
2239
2355
 
2240
2356
  // src/primitives/stake/weightedStakeForRangeByPosition.ts
2241
- import { isDefined as isDefined14 } from "@xylabs/sdk-js";
2357
+ import { isDefined as isDefined15 } from "@xylabs/sdk-js";
2242
2358
  import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol-lib";
2243
2359
  async function weightedStakeForRangeByPosition(context, blockViewer, stakeEventsViewer, externalRange, staked, positionId) {
2244
- const cacheKey = isDefined14(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
2360
+ const cacheKey = isDefined15(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
2245
2361
  return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
2246
2362
  let weightedStakeSum = 0n;
2247
- if (isDefined14(positionId)) {
2248
- const mergedEvents = (await mergedAddRemoveStakeEventsByPosition(
2363
+ if (isDefined15(positionId)) {
2364
+ const mergedEventsResult = await mergedAddRemoveStakeEventsByPosition(
2249
2365
  stakeEventsViewer,
2250
2366
  [0, externalRange[1]],
2251
2367
  positionId
2252
- )).toSorted((a, b) => a.time - b.time);
2253
- let currentTime = externalRange[0];
2254
- let currentStake = 0n;
2255
- if (isDefined14(staked) && mergedEvents.at(0)?.args.staked !== staked) {
2368
+ );
2369
+ const mergedEvents = mergedEventsResult.toSorted((a, b) => a.time - b.time);
2370
+ if (isDefined15(staked) && mergedEvents.at(0)?.args.staked !== staked) {
2256
2371
  return 0n;
2257
2372
  }
2373
+ let currentTime = externalRange[0];
2374
+ let currentStake = 0n;
2258
2375
  for (const event of mergedEvents) {
2259
2376
  if (event.time > currentTime) {
2260
2377
  weightedStakeSum += currentStake * BigInt(event.time - currentTime);
@@ -2299,7 +2416,7 @@ async function networkStakeStepRewardPositionWeight(context, blockViewer, stakeE
2299
2416
  // src/primitives/state/findMostRecentBlock.ts
2300
2417
  import { isSignedBlockBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol-lib";
2301
2418
  var DEFAULT_NEXT_OPTIONS = { limit: 50 };
2302
- var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTIONS, maxIterations = Number.POSITIVE_INFINITY) => {
2419
+ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTIONS, maxIterations = Infinity) => {
2303
2420
  let mostRecentBlock;
2304
2421
  let cursor;
2305
2422
  let batch;
@@ -2315,9 +2432,8 @@ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTI
2315
2432
  if (last) {
2316
2433
  mostRecentBlock = last;
2317
2434
  break;
2318
- } else {
2319
- cursor = batch.at(-1)?._sequence;
2320
2435
  }
2436
+ cursor = batch.at(-1)?._sequence;
2321
2437
  iterations = iterations + 1;
2322
2438
  } while (batch.length > 0 && iterations < maxIterations);
2323
2439
  return mostRecentBlock;
@@ -2330,7 +2446,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
2330
2446
  if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
2331
2447
  if (blockNumber > Number.MAX_SAFE_INTEGER) throw new Error(`Block number ${blockNumber} is greater than the maximum safe integer`);
2332
2448
  if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
2333
- const cacheKey = `${blockNumber}`;
2449
+ const cacheKey = String(blockNumber);
2334
2450
  return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
2335
2451
  const block = assertEx17(
2336
2452
  await blockFromBlockNumber(context, blockNumber),
@@ -2343,7 +2459,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
2343
2459
 
2344
2460
  // src/primitives/uncle/getProducerKey.ts
2345
2461
  function getProducerKey(block) {
2346
- return block[0].addresses.toSorted().join(",");
2462
+ return block[0].addresses.toSorted((a, b) => a.localeCompare(b)).join(",");
2347
2463
  }
2348
2464
 
2349
2465
  // src/primitives/uncle/scoreUncle.ts
@@ -2352,7 +2468,7 @@ function scoreUncle(finalizedWindowedChain, blocks) {
2352
2468
  if (blocks.length === 0) return 0;
2353
2469
  let score = blocks.length;
2354
2470
  const head = finalizedWindowedChain.at(-1);
2355
- if (head && blocks[0]) {
2471
+ if (head !== void 0 && blocks[0] !== void 0) {
2356
2472
  const headProducer = getProducerKey(head);
2357
2473
  const candidateProducer = getProducerKey(blocks[0]);
2358
2474
  if (headProducer !== candidateProducer) {
@@ -2387,6 +2503,19 @@ import {
2387
2503
  exists as exists2
2388
2504
  } from "@xylabs/sdk-js";
2389
2505
  import { isTransactionBoundWitness as isTransactionBoundWitness2 } from "@xyo-network/xl1-protocol-lib";
2506
+ function extendUncleChain(block, map) {
2507
+ const uncle = [block];
2508
+ let previous = block[0].previous ? map.get(block[0].previous) : void 0;
2509
+ while (previous) {
2510
+ if (previous[0].block === uncle[0][0].block - 1) {
2511
+ uncle.unshift(previous);
2512
+ previous = previous[0].previous ? map.get(previous[0].previous) : void 0;
2513
+ } else {
2514
+ return [];
2515
+ }
2516
+ }
2517
+ return uncle;
2518
+ }
2390
2519
  function blocksToChains(blocks) {
2391
2520
  const chains = [];
2392
2521
  const map = /* @__PURE__ */ new Map();
@@ -2394,17 +2523,7 @@ function blocksToChains(blocks) {
2394
2523
  map.set(block[0]._hash, block);
2395
2524
  }
2396
2525
  for (const block of blocks) {
2397
- let uncle = [block];
2398
- let previous = block[0].previous ? map.get(block[0].previous) : void 0;
2399
- while (previous) {
2400
- if (previous[0].block === uncle[0][0].block - 1) {
2401
- uncle.unshift(previous);
2402
- previous = previous[0].previous ? map.get(previous[0].previous) : void 0;
2403
- } else {
2404
- uncle = [];
2405
- break;
2406
- }
2407
- }
2526
+ const uncle = extendUncleChain(block, map);
2408
2527
  if (uncle.length > 0) {
2409
2528
  chains.push(uncle);
2410
2529
  }
@@ -2472,10 +2591,11 @@ var BaseConfigZod = z19.object({
2472
2591
  dataLake: z19.optional(DataLakeConfigZod).check(z19.describe("Configuration for data lakes")),
2473
2592
  evm: z19._default(EvmConfigZod, EvmConfigZod.parse({})).check(z19.describe("Configuration for EVM-backed services")),
2474
2593
  log: z19._default(LogConfigZod, LogConfigZod.parse({})).check(z19.describe("Configuration for logging")),
2475
- providerBindings: z19._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z19.describe("Per-moniker provider implementation and transport bindings")),
2594
+ connections: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
2595
+ providerBindings: z19._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z19.describe("Per-moniker provider connection bindings")),
2476
2596
  providers: z19._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z19.describe("Configuration for providers")),
2477
2597
  remote: z19._default(RemoteConfigZod, RemoteConfigZod.parse({})).check(z19.describe("Configuration for remote services")),
2478
- transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
2598
+ transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Deprecated alias for connections (kept in sync during migration)")),
2479
2599
  storage: z19._default(StorageConfigZod, StorageConfigZod.parse({})).check(z19.describe("Configuration for the storage")),
2480
2600
  telemetry: z19._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z19.describe("Configuration for telemetry")),
2481
2601
  validation: z19._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z19.describe("Configuration for validation"))
@@ -2506,7 +2626,7 @@ var ActorsConfigZod = z21._default(
2506
2626
  );
2507
2627
 
2508
2628
  // src/config/adaptLegacyConfig.ts
2509
- import { isDefined as isDefined15 } from "@xylabs/sdk-js";
2629
+ import { isDefined as isDefined16 } from "@xylabs/sdk-js";
2510
2630
 
2511
2631
  // src/config/Config.ts
2512
2632
  import { globalRegistry as globalRegistry15, z as z22 } from "zod/mini";
@@ -2531,6 +2651,44 @@ function resolveConfig(config) {
2531
2651
  return parsedConfig;
2532
2652
  }
2533
2653
 
2654
+ // src/config/normalizeConnectionsConfig.ts
2655
+ function mergeConnectionMaps(transports, connections) {
2656
+ return { ...transports, ...connections };
2657
+ }
2658
+ function normalizeProviderBinding(binding) {
2659
+ const connectionName = binding.connection ?? binding.transport;
2660
+ if (connectionName === void 0 || connectionName === "") {
2661
+ return binding;
2662
+ }
2663
+ return {
2664
+ ...binding,
2665
+ connection: connectionName,
2666
+ transport: connectionName
2667
+ };
2668
+ }
2669
+ function normalizeProviderBindings(bindings) {
2670
+ const normalized = {};
2671
+ for (const [moniker, binding] of Object.entries(bindings)) {
2672
+ if (binding === void 0) continue;
2673
+ normalized[moniker] = normalizeProviderBinding(binding);
2674
+ }
2675
+ return normalized;
2676
+ }
2677
+ function normalizeConnectionsConfig(config) {
2678
+ const transports = config.transports ?? {};
2679
+ const connections = config.connections ?? {};
2680
+ const merged = mergeConnectionMaps(transports, connections);
2681
+ return {
2682
+ ...config,
2683
+ connections: merged,
2684
+ providerBindings: normalizeProviderBindings(config.providerBindings ?? {}),
2685
+ transports: merged
2686
+ };
2687
+ }
2688
+ function hasDeclaredConnectionProfiles(config) {
2689
+ return Object.keys(config.transports ?? {}).length > 0 || Object.keys(config.connections ?? {}).length > 0;
2690
+ }
2691
+
2534
2692
  // src/config/adaptLegacyConfig.ts
2535
2693
  var DEFAULT_LMDB_TRANSPORT = "local-store";
2536
2694
  var DEFAULT_RPC_TRANSPORT = "default-rpc";
@@ -2554,7 +2712,7 @@ function rpcTransportFromRemote(rpc) {
2554
2712
  };
2555
2713
  }
2556
2714
  function s3TransportFromBucket(shared, entry, fallbackBucket) {
2557
- if (!isDefined15(entry?.bucket) && !isDefined15(entry?.readUrl)) {
2715
+ if (!isDefined16(entry?.bucket) && !isDefined16(entry?.readUrl)) {
2558
2716
  return void 0;
2559
2717
  }
2560
2718
  return {
@@ -2590,34 +2748,82 @@ function synthesizeS3Transports(s3) {
2590
2748
  }
2591
2749
  return transports;
2592
2750
  }
2593
- function synthesizeProviderBindings(transports) {
2751
+ function hasTransport(transports, key) {
2752
+ return Object.hasOwn(transports, key) && transports[key] !== void 0;
2753
+ }
2754
+ function bindMoniker2(bindings, moniker, connectionName) {
2755
+ bindings[moniker] = { connection: connectionName, transport: connectionName };
2756
+ }
2757
+ var LMDB_MONIKERS = [
2758
+ "AccountBalanceViewer",
2759
+ "BlockRewardViewer",
2760
+ "BlockRunner",
2761
+ "BlockValidationViewer",
2762
+ "BlockViewer",
2763
+ "ChainContractViewer",
2764
+ "DeadLetterQueueRunner",
2765
+ "DeadLetterQueueViewer",
2766
+ "FinalizationRunner",
2767
+ "FinalizationViewer",
2768
+ "MempoolRunner",
2769
+ "MempoolViewer",
2770
+ "StakeEventsViewer",
2771
+ "StakeTotalsViewer",
2772
+ "StakeViewer",
2773
+ "TimeSyncViewer",
2774
+ "TransactionValidationViewer",
2775
+ "TransactionViewer",
2776
+ "WindowedBlockViewer",
2777
+ "XyoConnection",
2778
+ "XyoGateway",
2779
+ "XyoRunner",
2780
+ "XyoViewer"
2781
+ ];
2782
+ function synthesizeLmdbProviderBindings(transports) {
2594
2783
  const bindings = {};
2595
- if (transports[DEFAULT_RPC_TRANSPORT]) {
2596
- bindings.BlockViewer = { transport: DEFAULT_RPC_TRANSPORT };
2597
- bindings.MempoolViewer = { transport: DEFAULT_RPC_TRANSPORT };
2598
- bindings.FinalizationViewer = { transport: DEFAULT_RPC_TRANSPORT };
2599
- bindings.TransactionViewer = { transport: DEFAULT_RPC_TRANSPORT };
2600
- bindings.AccountBalanceViewer = { transport: DEFAULT_RPC_TRANSPORT };
2601
- }
2602
- if (transports[S3_FINALIZED_TRANSPORT]) {
2603
- bindings.BlockPublishRunner = { transport: S3_FINALIZED_TRANSPORT };
2784
+ if (!hasTransport(transports, DEFAULT_LMDB_TRANSPORT)) {
2785
+ return bindings;
2604
2786
  }
2605
- if (transports[S3_CHAIN_STATE_TRANSPORT]) {
2606
- bindings.ChainStateViewer = { transport: S3_CHAIN_STATE_TRANSPORT };
2607
- bindings.ChainStatePublishRunner = { transport: S3_CHAIN_STATE_TRANSPORT };
2787
+ for (const moniker of LMDB_MONIKERS) {
2788
+ bindMoniker2(bindings, moniker, DEFAULT_LMDB_TRANSPORT);
2608
2789
  }
2609
- if (transports[S3_INDEX_TRANSPORT]) {
2610
- bindings.IndexPublishRunner = { transport: S3_INDEX_TRANSPORT };
2790
+ return bindings;
2791
+ }
2792
+ function synthesizeProviderBindings(transports) {
2793
+ const bindings = {};
2794
+ if (hasTransport(transports, DEFAULT_RPC_TRANSPORT)) {
2795
+ bindMoniker2(bindings, "BlockViewer", DEFAULT_RPC_TRANSPORT);
2796
+ bindMoniker2(bindings, "MempoolViewer", DEFAULT_RPC_TRANSPORT);
2797
+ bindMoniker2(bindings, "FinalizationViewer", DEFAULT_RPC_TRANSPORT);
2798
+ bindMoniker2(bindings, "TransactionViewer", DEFAULT_RPC_TRANSPORT);
2799
+ bindMoniker2(bindings, "AccountBalanceViewer", DEFAULT_RPC_TRANSPORT);
2800
+ }
2801
+ if (hasTransport(transports, S3_FINALIZED_TRANSPORT)) {
2802
+ bindMoniker2(bindings, "BlockPublishRunner", S3_FINALIZED_TRANSPORT);
2803
+ }
2804
+ if (hasTransport(transports, S3_CHAIN_STATE_TRANSPORT)) {
2805
+ bindMoniker2(bindings, "ChainStateViewer", S3_CHAIN_STATE_TRANSPORT);
2806
+ bindMoniker2(bindings, "ChainStatePublishRunner", S3_CHAIN_STATE_TRANSPORT);
2807
+ }
2808
+ if (hasTransport(transports, S3_INDEX_TRANSPORT)) {
2809
+ bindMoniker2(bindings, "IndexPublishRunner", S3_INDEX_TRANSPORT);
2810
+ }
2811
+ if (hasTransport(transports, DEFAULT_EVM_RPC_TRANSPORT)) {
2812
+ bindMoniker2(bindings, "ChainContractViewer", DEFAULT_EVM_RPC_TRANSPORT);
2813
+ bindMoniker2(bindings, "StakeEventsViewer", DEFAULT_EVM_RPC_TRANSPORT);
2814
+ bindMoniker2(bindings, "StakeTotalsViewer", DEFAULT_EVM_RPC_TRANSPORT);
2815
+ bindMoniker2(bindings, "StakeViewer", DEFAULT_EVM_RPC_TRANSPORT);
2816
+ bindMoniker2(bindings, "TimeSyncViewer", DEFAULT_EVM_RPC_TRANSPORT);
2611
2817
  }
2612
2818
  return bindings;
2613
2819
  }
2614
2820
  function adaptLegacyConfig(config) {
2615
2821
  const parsed = ConfigZod.parse(config);
2616
- if (Object.keys(parsed.transports).length > 0) {
2617
- return parsed;
2822
+ if (hasDeclaredConnectionProfiles(parsed)) {
2823
+ return ConfigZod.parse(normalizeConnectionsConfig(parsed));
2618
2824
  }
2619
- const transports = { ...parsed.transports };
2620
- if (isDefined15(parsed.storage?.root) && parsed.storage.root !== "") {
2825
+ const transports = { ...parsed.transports, ...parsed.connections };
2826
+ if (isDefined16(parsed.storage?.root) && parsed.storage.root !== "") {
2621
2827
  transports[DEFAULT_LMDB_TRANSPORT] = { type: "lmdb", root: parsed.storage.root };
2622
2828
  }
2623
2829
  if (hasMongoConfig(parsed.storage?.mongo)) {
@@ -2630,24 +2836,26 @@ function adaptLegacyConfig(config) {
2630
2836
  username: parsed.storage.mongo.username
2631
2837
  };
2632
2838
  }
2633
- if (isDefined15(parsed.remote?.rpc)) {
2839
+ if (isDefined16(parsed.remote?.rpc)) {
2634
2840
  transports[DEFAULT_RPC_TRANSPORT] = rpcTransportFromRemote(parsed.remote.rpc);
2635
2841
  }
2636
- if (isDefined15(parsed.evm?.jsonRpc?.url)) {
2842
+ if (isDefined16(parsed.evm?.jsonRpc?.url)) {
2637
2843
  transports[DEFAULT_EVM_RPC_TRANSPORT] = { type: "evm-rpc", url: parsed.evm.jsonRpc.url };
2638
2844
  }
2639
- if (isDefined15(parsed.storage?.s3)) {
2845
+ if (isDefined16(parsed.storage?.s3)) {
2640
2846
  Object.assign(transports, synthesizeS3Transports(parsed.storage.s3));
2641
2847
  }
2642
2848
  const providerBindings = {
2849
+ ...synthesizeLmdbProviderBindings(transports),
2643
2850
  ...synthesizeProviderBindings(transports),
2644
2851
  ...parsed.providerBindings
2645
2852
  };
2646
- return ConfigZod.parse({
2853
+ return ConfigZod.parse(normalizeConnectionsConfig({
2647
2854
  ...parsed,
2855
+ connections: transports,
2648
2856
  providerBindings,
2649
2857
  transports
2650
- });
2858
+ }));
2651
2859
  }
2652
2860
 
2653
2861
  // src/config/HostActor.ts
@@ -2722,8 +2930,8 @@ import {
2722
2930
  } from "@xylabs/sdk-js";
2723
2931
  import { CachingContextZod } from "@xyo-network/xl1-protocol-lib";
2724
2932
  import { z as z25 } from "zod/mini";
2725
- var RuntimeStatusMonitorZod = z25.custom((val) => val && typeof val === "object");
2726
- var ProviderFactoryLocatorZod = z25.lazy(() => z25.custom((val) => val && typeof val === "object" && "context" in val && "registry" in val));
2933
+ var RuntimeStatusMonitorZod = z25.custom((val) => val !== null && val !== void 0 && typeof val === "object");
2934
+ var ProviderFactoryLocatorZod = z25.lazy(() => z25.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
2727
2935
  var BaseConfigContextZod = z25.extend(CachingContextZod, {
2728
2936
  config: z25.looseObject(BaseConfigZod.shape),
2729
2937
  locator: z25.optional(ProviderFactoryLocatorZod)
@@ -2771,7 +2979,9 @@ var hydratedBlockToPayloadBundle = (transaction) => {
2771
2979
  };
2772
2980
  var bundle = (root, transaction) => {
2773
2981
  const payloads = flattenHydratedBlock(transaction).flatMap((p) => PayloadBuilder6.omitStorageMeta(p));
2774
- return new PayloadBuilder6({ schema: PayloadBundleSchema }).fields({ payloads, root }).build();
2982
+ const payloadBuilder = new PayloadBuilder6({ schema: PayloadBundleSchema });
2983
+ const builder = payloadBuilder.fields({ payloads, root });
2984
+ return builder.build();
2775
2985
  };
2776
2986
 
2777
2987
  // src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
@@ -2802,10 +3012,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
2802
3012
  exp
2803
3013
  };
2804
3014
  const elevatedHashes = await PayloadBuilder7.hashes(onChainPayloads);
2805
- const script = [];
2806
- for (const elevatedHash of elevatedHashes) {
2807
- script.push(`elevate|${elevatedHash}`);
2808
- }
3015
+ const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
2809
3016
  const fields = {
2810
3017
  ...txBoundWitnessFields,
2811
3018
  from: from ?? (Array.isArray(signer) ? assertEx19(signer.at(0)?.address) : signer.address)
@@ -2813,7 +3020,9 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
2813
3020
  if (script.length > 0) {
2814
3021
  fields.script = script;
2815
3022
  }
2816
- const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).signers(Array.isArray(signer) ? signer : [signer]).build();
3023
+ const boundWitnessBuilder = new BoundWitnessBuilder();
3024
+ const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).signers(Array.isArray(signer) ? signer : [signer]);
3025
+ const [tx, txPayloads] = await builder.build();
2817
3026
  return [await PayloadBuilder7.addHashMeta(tx), await PayloadBuilder7.addHashMeta(txPayloads.map((p) => asAnyPayload2(p, true)))];
2818
3027
  }
2819
3028
 
@@ -2834,10 +3043,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
2834
3043
  exp
2835
3044
  };
2836
3045
  const elevatedHashes = await PayloadBuilder8.hashes(onChainPayloads);
2837
- const script = [];
2838
- for (const elevatedHash of elevatedHashes) {
2839
- script.push(`elevate|${elevatedHash}`);
2840
- }
3046
+ const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
2841
3047
  const fields = {
2842
3048
  ...txBoundWitnessFields,
2843
3049
  from
@@ -2845,14 +3051,16 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
2845
3051
  if (script.length > 0) {
2846
3052
  fields.script = script;
2847
3053
  }
2848
- const [tx, txPayloads] = await new BoundWitnessBuilder2().fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).build(false);
3054
+ const boundWitnessBuilder = new BoundWitnessBuilder2();
3055
+ const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]);
3056
+ const [tx, txPayloads] = await builder.build(false);
2849
3057
  return [tx, txPayloads];
2850
3058
  }
2851
3059
 
2852
3060
  // src/transaction/confirmSubmittedTransaction.ts
2853
3061
  import {
2854
3062
  delay,
2855
- isDefined as isDefined16,
3063
+ isDefined as isDefined17,
2856
3064
  isNumber
2857
3065
  } from "@xylabs/sdk-js";
2858
3066
  var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
@@ -2874,22 +3082,20 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
2874
3082
  let attempts = 0;
2875
3083
  while (true) {
2876
3084
  const tx = await viewer.transaction.byHash(txHash) ?? void 0;
2877
- if (isDefined16(tx)) {
3085
+ if (isDefined17(tx)) {
2878
3086
  options?.logger?.debug("Transaction confirmed", txHash);
2879
3087
  return tx;
2880
- } else {
2881
- if (isNumber(exp)) {
2882
- await assertNotExpired(viewer, txHash, exp, options);
2883
- }
2884
- attempts++;
2885
- if (attempts > maxAttempts) {
2886
- options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
2887
- throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
2888
- } else {
2889
- options?.logger?.debug(`Transaction not confirmed yet, attempt ${attempts}. Retrying...`, txHash);
2890
- await delay(attemptDelay);
2891
- }
2892
3088
  }
3089
+ if (isNumber(exp)) {
3090
+ await assertNotExpired(viewer, txHash, exp, options);
3091
+ }
3092
+ attempts++;
3093
+ if (attempts > maxAttempts) {
3094
+ options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
3095
+ throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
3096
+ }
3097
+ options?.logger?.debug(`Transaction not confirmed yet, attempt ${attempts}. Retrying...`, txHash);
3098
+ await delay(attemptDelay);
2893
3099
  }
2894
3100
  };
2895
3101
 
@@ -2908,9 +3114,7 @@ import {
2908
3114
  var tryHydrateTransaction = async ({ chainMap }, hash) => {
2909
3115
  return await tryHydrateTypedBoundWitness(
2910
3116
  {
2911
- get(hashes) {
2912
- return chainMap.get(hashes);
2913
- },
3117
+ get: (hashes) => chainMap.get(hashes),
2914
3118
  next() {
2915
3119
  throw new Error("Not implemented");
2916
3120
  }
@@ -2922,9 +3126,7 @@ var tryHydrateTransaction = async ({ chainMap }, hash) => {
2922
3126
  var hydrateTransaction = async ({ chainMap }, hash) => {
2923
3127
  return await hydrateTypedBoundWitness(
2924
3128
  {
2925
- get(hashes) {
2926
- return chainMap.get(hashes);
2927
- },
3129
+ get: (hashes) => chainMap.get(hashes),
2928
3130
  next() {
2929
3131
  throw new Error("Not implemented");
2930
3132
  }
@@ -3185,7 +3387,9 @@ var hydratedTransactionToPayloadBundle = (transaction) => {
3185
3387
  };
3186
3388
  var bundle2 = (root, transaction) => {
3187
3389
  const payloads = flattenHydratedTransaction(transaction);
3188
- return new PayloadBuilder12({ schema: PayloadBundleSchema2 }).fields({ payloads, root }).build();
3390
+ const payloadBuilder = new PayloadBuilder12({ schema: PayloadBundleSchema2 });
3391
+ const builder = payloadBuilder.fields({ payloads, root });
3392
+ return builder.build();
3189
3393
  };
3190
3394
 
3191
3395
  // src/context/Actor.ts
@@ -3231,7 +3435,7 @@ var ProviderFactory = class _ProviderFactory {
3231
3435
  get resolvedMoniker() {
3232
3436
  const labels = this.labels ?? {};
3233
3437
  const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
3234
- return labelString.length === 0 ? `${this.defaultMoniker}` : `${this.defaultMoniker}|${labelString}`;
3438
+ return labelString.length === 0 ? this.defaultMoniker : `${this.defaultMoniker}|${labelString}`;
3235
3439
  }
3236
3440
  get uniqueId() {
3237
3441
  return this._uniqueId;
@@ -3246,8 +3450,7 @@ var ProviderFactory = class _ProviderFactory {
3246
3450
  let scopeObject;
3247
3451
  switch (this.scope) {
3248
3452
  case "global": {
3249
- globalThis.xyoServiceSingletons ??= {};
3250
- scopeObject = globalThis.xyoServiceSingletons;
3453
+ scopeObject = getOrCreateGlobalSingletons();
3251
3454
  break;
3252
3455
  }
3253
3456
  case "context": {
@@ -3284,6 +3487,15 @@ var ProviderFactory = class _ProviderFactory {
3284
3487
  }
3285
3488
  }
3286
3489
  };
3490
+ function getOrCreateGlobalSingletons() {
3491
+ const existing = globalThis.xyoServiceSingletons;
3492
+ if (existing !== void 0) {
3493
+ return existing;
3494
+ }
3495
+ const singletons = {};
3496
+ Reflect.set(globalThis, "xyoServiceSingletons", singletons);
3497
+ return singletons;
3498
+ }
3287
3499
 
3288
3500
  // src/CreatableProvider/AbstractCreatableProvider.ts
3289
3501
  var AbstractCreatableProvider = class extends AbstractCreatable {
@@ -3469,7 +3681,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
3469
3681
  );
3470
3682
  }
3471
3683
  has(moniker) {
3472
- return !!this._registry[moniker];
3684
+ return Object.hasOwn(this._registry, moniker);
3473
3685
  }
3474
3686
  /**
3475
3687
  * Locates a provider factory that matches the supplied moniker and labels
@@ -3486,10 +3698,11 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
3486
3698
  merge(locator) {
3487
3699
  const registry = { ...this.registry };
3488
3700
  for (const moniker in locator.registry) {
3489
- if (registry[moniker]) {
3490
- registry[moniker].push(...locator.registry[moniker] ?? []);
3491
- } else {
3701
+ const existing = registry[moniker];
3702
+ if (existing === void 0) {
3492
3703
  registry[moniker] = locator.registry[moniker];
3704
+ } else {
3705
+ existing.push(...locator.registry[moniker] ?? []);
3493
3706
  }
3494
3707
  }
3495
3708
  return new _ProviderFactoryLocator(this.context, registry);
@@ -3519,13 +3732,13 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
3519
3732
  return this;
3520
3733
  }
3521
3734
  registered(moniker) {
3522
- return !!this.registry[moniker] || (this._parent?.registered(moniker) ?? false);
3735
+ return Object.hasOwn(this.registry, moniker) || (this._parent?.registered(moniker) ?? false);
3523
3736
  }
3524
3737
  async tryGetInstance(moniker, { start = true, labels } = {}) {
3525
3738
  const resolvedParams = { context: this.context };
3526
3739
  const factory = this.tryLocate(moniker, labels);
3527
- if (factory) {
3528
- if (this.context.singletons[factory.uniqueId]) {
3740
+ if (factory !== void 0) {
3741
+ if (Object.hasOwn(this.context.singletons, factory.uniqueId)) {
3529
3742
  return this.context.singletons[factory.uniqueId];
3530
3743
  }
3531
3744
  this.logger?.debug(`Creating provider instance for moniker [${moniker}]${labels ? ` with labels [${JSON.stringify(labels)}]` : ""} using factory [${factory.uniqueId.description}]`);
@@ -3586,20 +3799,21 @@ var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActo
3586
3799
  var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
3587
3800
 
3588
3801
  // src/createDeclarationPayload.ts
3589
- import { isDefined as isDefined17 } from "@xylabs/sdk-js";
3802
+ import { isDefined as isDefined18 } from "@xylabs/sdk-js";
3590
3803
  import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
3591
3804
  import {
3592
3805
  ChainStakeIntentSchema
3593
3806
  } from "@xyo-network/xl1-protocol-lib";
3594
3807
  var createDeclarationIntent = (address, intent, nbf, exp) => {
3595
- const expiration = isDefined17(exp) ? exp : nbf + 1e4;
3596
- const redeclarationIntent = new PayloadBuilder13({ schema: ChainStakeIntentSchema }).fields({
3808
+ const expiration = isDefined18(exp) ? exp : nbf + 1e4;
3809
+ const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
3810
+ const builder = payloadBuilder.fields({
3597
3811
  from: address,
3598
3812
  intent,
3599
3813
  nbf,
3600
3814
  exp: expiration
3601
- }).build();
3602
- return redeclarationIntent;
3815
+ });
3816
+ return builder.build();
3603
3817
  };
3604
3818
 
3605
3819
  // src/createTransferPayload.ts
@@ -3607,12 +3821,14 @@ import { toHex as toHex3 } from "@xylabs/sdk-js";
3607
3821
  import { PayloadBuilder as PayloadBuilder14 } from "@xyo-network/sdk-js";
3608
3822
  import { TransferSchema } from "@xyo-network/xl1-protocol-lib";
3609
3823
  function createTransferPayload(from, transfers, context) {
3610
- return new PayloadBuilder14({ schema: TransferSchema }).fields({
3824
+ const payloadBuilder = new PayloadBuilder14({ schema: TransferSchema });
3825
+ const builder = payloadBuilder.fields({
3611
3826
  epoch: Date.now(),
3612
3827
  from,
3613
3828
  transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex3(v)])),
3614
3829
  context
3615
- }).build();
3830
+ });
3831
+ return builder.build();
3616
3832
  }
3617
3833
 
3618
3834
  // src/eip-712/Payloads/EIP712Data.ts
@@ -3746,11 +3962,11 @@ var isPositiveBigInt = (value) => {
3746
3962
  var parseSignedBigInt = (value) => {
3747
3963
  if (isNegativeBigInt(value)) {
3748
3964
  return -hexToBigInt5(value.negative);
3749
- } else if (isPositiveBigInt(value)) {
3965
+ }
3966
+ if (isPositiveBigInt(value)) {
3750
3967
  return hexToBigInt5(value.positive);
3751
- } else {
3752
- throw new Error("Invalid balance type");
3753
3968
  }
3969
+ throw new Error("Invalid balance type");
3754
3970
  };
3755
3971
  var toSignedBigInt = (value) => {
3756
3972
  return value < 0n ? { negative: toHex4(-value) } : { positive: toHex4(value) };
@@ -3773,7 +3989,7 @@ import {
3773
3989
  asHash as asHash4,
3774
3990
  assertEx as assertEx33,
3775
3991
  exists as exists3,
3776
- isDefined as isDefined18,
3992
+ isDefined as isDefined19,
3777
3993
  ZERO_ADDRESS
3778
3994
  } from "@xylabs/sdk-js";
3779
3995
  import {
@@ -3867,39 +4083,38 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
3867
4083
  const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
3868
4084
  if (isAnyPayload3(summaryResult)) {
3869
4085
  return summaryResult;
3870
- } else {
3871
- await semaphores[step].acquire();
3872
- try {
3873
- const subRanges = deepCalculateFramesFromRange(range, step - 1);
3874
- const promises = subRanges.map((subRange) => balancesStepSummaryFromRange(
3875
- context,
3876
- semaphores,
3877
- blockViewer,
3878
- summaryMap,
3879
- subRange
3880
- ));
3881
- const subResults = await Promise.all(promises);
3882
- const bigIntBalances = {};
3883
- for (const subResult of subResults) {
3884
- for (const [address, balance] of Object.entries(subResult.balances)) {
3885
- bigIntBalances[address] = (bigIntBalances[address] ?? 0n) + parseSignedBigInt(balance);
3886
- }
3887
- }
3888
- const balances = {};
3889
- for (const [address, balance] of Object.entries(bigIntBalances)) {
3890
- balances[address] = toSignedBigInt(balance);
4086
+ }
4087
+ await semaphores[step].acquire();
4088
+ try {
4089
+ const subRanges = deepCalculateFramesFromRange(range, step - 1);
4090
+ const promises = subRanges.map((subRange) => balancesStepSummaryFromRange(
4091
+ context,
4092
+ semaphores,
4093
+ blockViewer,
4094
+ summaryMap,
4095
+ subRange
4096
+ ));
4097
+ const subResults = await Promise.all(promises);
4098
+ const bigIntBalances = {};
4099
+ for (const subResult of subResults) {
4100
+ for (const [address, balance] of Object.entries(subResult.balances)) {
4101
+ bigIntBalances[address] = (bigIntBalances[address] ?? 0n) + parseSignedBigInt(balance);
3891
4102
  }
3892
- const result = {
3893
- schema: BalancesStepSummarySchema,
3894
- hash: frameHead._hash,
3895
- stepSize: frameSize,
3896
- balances
3897
- };
3898
- await summaryMap.set(key, result);
3899
- return result;
3900
- } finally {
3901
- semaphores[step].release();
3902
4103
  }
4104
+ const balances = {};
4105
+ for (const [address, balance] of Object.entries(bigIntBalances)) {
4106
+ balances[address] = toSignedBigInt(balance);
4107
+ }
4108
+ const result = {
4109
+ schema: BalancesStepSummarySchema,
4110
+ hash: frameHead._hash,
4111
+ stepSize: frameSize,
4112
+ balances
4113
+ };
4114
+ await summaryMap.set(key, result);
4115
+ return result;
4116
+ } finally {
4117
+ semaphores[step].release();
3903
4118
  }
3904
4119
  }, { ...context, timeBudgetLimit: 500 });
3905
4120
  }, { ...context, timeBudgetLimit: 500 });
@@ -4254,14 +4469,16 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4254
4469
  return balances[address] ?? AttoXL13(0n);
4255
4470
  }
4256
4471
  async accountBalanceHistories(addresses, config = {}) {
4257
- return (await this.qualifiedAccountBalanceHistories(addresses, config))[0];
4472
+ const [histories] = await this.qualifiedAccountBalanceHistories(addresses, config);
4473
+ return histories;
4258
4474
  }
4259
4475
  async accountBalanceHistory(address, config) {
4260
4476
  return await this.spanAsync("accountBalanceHistory", async () => {
4261
4477
  const range = isChainQualifiedRangeConfig4(config) ? config.range : void 0;
4262
4478
  const startingRange = asXL1BlockRange10(range ?? [0, await this.blockViewer.currentBlockNumber()], true);
4263
4479
  const blockNumbers = await this.distillTransferHistory(address, startingRange);
4264
- const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
4480
+ const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
4481
+ const blocks = blockResults.filter(exists3);
4265
4482
  const result = [];
4266
4483
  for (const block of blocks) {
4267
4484
  const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
@@ -4271,7 +4488,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4271
4488
  block[1].find((p) => p._hash === hash),
4272
4489
  () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
4273
4490
  );
4274
- }).filter(exists3).filter((t) => t.from === address || isDefined18(t.transfers[address]));
4491
+ }).filter(exists3).filter((t) => t.from === address || isDefined19(t.transfers[address]));
4275
4492
  if (transfers.length === 0) {
4276
4493
  continue;
4277
4494
  }
@@ -4390,10 +4607,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4390
4607
  return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
4391
4608
  const range = asRange(headOrRange);
4392
4609
  const headHash = asHash4(headOrRange);
4393
- const [head] = assertEx33(isDefined18(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
4610
+ const [head] = assertEx33(isDefined19(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
4394
4611
  const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
4395
4612
  const blockNumbers = await this.distillTransferHistory(address, startingRange);
4396
- const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
4613
+ const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
4614
+ const blocks = blockResults.filter(exists3);
4397
4615
  const result = [];
4398
4616
  for (const block of blocks) {
4399
4617
  const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
@@ -4403,7 +4621,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
4403
4621
  block[1].find((p) => p._hash === hash),
4404
4622
  () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
4405
4623
  );
4406
- }).filter(exists3).filter((t) => t.from === address || isDefined18(t.transfers[address]));
4624
+ }).filter(exists3).filter((t) => t.from === address || isDefined19(t.transfers[address]));
4407
4625
  if (transfers.length === 0) {
4408
4626
  continue;
4409
4627
  }
@@ -4585,7 +4803,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4585
4803
  }
4586
4804
  async blocksByStep(stepLevel, stepIndex) {
4587
4805
  return await this.spanAsync("blocksByStep", async () => {
4588
- assertEx34(Number.isInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
4806
+ assertEx34(Number.isSafeInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
4589
4807
  const size = stepSize2(stepLevel);
4590
4808
  assertEx34(
4591
4809
  stepLevel <= blocksMaxStep,
@@ -4609,7 +4827,12 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4609
4827
  }
4610
4828
  async chainId(blockNumber = "latest") {
4611
4829
  return await this.spanAsync("chainId", async () => {
4612
- return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx34(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
4830
+ if (blockNumber === "latest") {
4831
+ const headBlock = await this.finalizationViewer.headBlock();
4832
+ return headBlock.chain;
4833
+ }
4834
+ const block = assertEx34(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`);
4835
+ return block[0].chain;
4613
4836
  }, this.context);
4614
4837
  }
4615
4838
  async createHandler() {
@@ -4658,9 +4881,10 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4658
4881
  };
4659
4882
  }
4660
4883
  async getChainContextRead() {
4884
+ const headBlock = await this.finalizationViewer.head();
4661
4885
  return {
4662
4886
  ...this.getBlockContextRead(),
4663
- head: (await this.finalizationViewer.head())[0]
4887
+ head: headBlock[0]
4664
4888
  };
4665
4889
  }
4666
4890
  async startHandler() {
@@ -4707,10 +4931,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4707
4931
  }, this.headPollIntervalMs);
4708
4932
  }
4709
4933
  stopHeadPolling() {
4710
- if (this._headPollTimer) {
4711
- clearInterval(this._headPollTimer);
4712
- this._headPollTimer = null;
4934
+ if (!this._headPollTimer) {
4935
+ return;
4713
4936
  }
4937
+ clearInterval(this._headPollTimer);
4938
+ this._headPollTimer = null;
4714
4939
  }
4715
4940
  };
4716
4941
  __publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
@@ -4791,13 +5016,18 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
4791
5016
  head: void 0
4792
5017
  };
4793
5018
  const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
4794
- const head = isChainQualifiedHeadConfig5(config) ? assertEx35(
4795
- (await this.blockViewer.blockByHash(config.head))?.[0],
4796
- () => `Specified a head that is not in the chain [${config.head}]`
4797
- ) : void 0;
4798
- const headBlock = head ?? (await this.blockViewer.currentBlock())[0];
4799
- const validateProtocol = value ? this.doValidateProtocol.bind(this) : void 0;
4800
- const validateState = state ? this.doValidateState.bind(this) : void 0;
5019
+ let head;
5020
+ if (isChainQualifiedHeadConfig5(config)) {
5021
+ const headBlockResult = await this.blockViewer.blockByHash(config.head);
5022
+ head = headBlockResult == null ? assertEx35(
5023
+ void 0,
5024
+ () => `Specified a head that is not in the chain [${config.head}]`
5025
+ ) : headBlockResult[0];
5026
+ }
5027
+ const currentBlock = await this.blockViewer.currentBlock();
5028
+ const headBlock = head ?? currentBlock[0];
5029
+ const validateProtocol = value === true ? this.doValidateProtocol.bind(this) : void 0;
5030
+ const validateState = state === true ? this.doValidateState.bind(this) : void 0;
4801
5031
  const chainIdAtBlockNumber = (blockNumber) => this.chainContractViewer.chainIdAtBlockNumber(blockNumber);
4802
5032
  const qualification = { head: headBlock._hash, range: asXL1BlockRange12([0, headBlock.block], true) };
4803
5033
  const [protocolResults, stateResults] = await Promise.all([
@@ -4820,13 +5050,16 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
4820
5050
  throw new Error("Method not implemented.");
4821
5051
  }
4822
5052
  async validateBlock(block, config) {
4823
- return (await this.validateBlocks([block], config))[0];
5053
+ const results = await this.validateBlocks([block], config);
5054
+ return results[0];
4824
5055
  }
4825
5056
  async validateBlocks(blocks, config) {
4826
- return (await this.qualifiedValidateBlocks(blocks, config))[0];
5057
+ const results = await this.qualifiedValidateBlocks(blocks, config);
5058
+ return results[0];
4827
5059
  }
4828
5060
  async validateUncle(blocks, config) {
4829
- return (await this.qualifiedValidateUncle(blocks, config))[0];
5061
+ const results = await this.qualifiedValidateUncle(blocks, config);
5062
+ return results[0];
4830
5063
  }
4831
5064
  async doValidateProtocol(blocks, chainIdAtBlockNumber) {
4832
5065
  return await Promise.all(blocks.map(async (block) => {
@@ -4884,7 +5117,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
4884
5117
  return this.finalizationViewer.chainId();
4885
5118
  }
4886
5119
  async chainIdAtBlockNumber(blockNumber) {
4887
- return await withContextCacheResponse(this.context, "chainIdAtBlockNumber", `${blockNumber}`, async () => {
5120
+ return await withContextCacheResponse(this.context, "chainIdAtBlockNumber", String(blockNumber), async () => {
4888
5121
  let chainId = this.chainId();
4889
5122
  let contractViewer = this;
4890
5123
  let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
@@ -4967,14 +5200,16 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
4967
5200
  return this.params.endpoint;
4968
5201
  }
4969
5202
  async get(hashes) {
4970
- return (await Promise.all(hashes.map((hash) => this.getOne(hash)))).filter(exists5);
5203
+ const results = await Promise.all(hashes.map((hash) => this.getOne(hash)));
5204
+ return results.filter(exists5);
4971
5205
  }
4972
5206
  next(_options) {
4973
5207
  throw new Error("Method not implemented.");
4974
5208
  }
4975
5209
  async getOne(hash) {
4976
5210
  try {
4977
- return asAnyPayload4((await this.client.get(`${this.params.endpoint}/get/${hash}`)).data);
5211
+ const response = await this.client.get(`${this.params.endpoint}/get/${hash}`);
5212
+ return asAnyPayload4(response.data);
4978
5213
  } catch (ex) {
4979
5214
  if (ex instanceof FetchClientError && (ex.response.status === 400 || ex.response.status === 404)) {
4980
5215
  return void 0;
@@ -4992,7 +5227,7 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
4992
5227
  if (this.allowedSchemas && !this.allowedSchemas.includes(schema)) {
4993
5228
  return false;
4994
5229
  }
4995
- if (this.disallowedSchemas?.includes(schema)) {
5230
+ if (this.disallowedSchemas?.includes(schema) === true) {
4996
5231
  return false;
4997
5232
  }
4998
5233
  return true;
@@ -5019,9 +5254,8 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
5019
5254
  if (allowedItems.length > 0) {
5020
5255
  const result = await this.client.post(`${this.params.endpoint}/insert`, allowedItems);
5021
5256
  return z32.array(PayloadZodLoose).parse(result.data);
5022
- } else {
5023
- return [];
5024
5257
  }
5258
+ return [];
5025
5259
  }
5026
5260
  };
5027
5261
  __publicField(RestDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker);
@@ -5077,7 +5311,7 @@ var AbstractSimpleDataLake = class extends AbstractCreatableProvider {
5077
5311
  if (this.allowedSchemas && !this.allowedSchemas.includes(schema)) {
5078
5312
  return false;
5079
5313
  }
5080
- if (this.disallowedSchemas?.includes(schema)) {
5314
+ if (this.disallowedSchemas?.includes(schema) === true) {
5081
5315
  return false;
5082
5316
  }
5083
5317
  return true;
@@ -5091,10 +5325,12 @@ var SimpleDataLakeRunner = class extends AbstractSimpleDataLake {
5091
5325
  await this.map.clear();
5092
5326
  }
5093
5327
  async delete(hashes) {
5094
- return (await Promise.all(hashes.map(async (hash) => {
5328
+ const deleteResults = await Promise.all(hashes.map(async (hash) => {
5095
5329
  const payload = await this.map.get(hash);
5096
- return await this.map.delete(hash) ? payload : void 0;
5097
- }))).filter(exists7);
5330
+ const deleted = await this.map.delete(hash);
5331
+ return deleted ? payload : void 0;
5332
+ }));
5333
+ return deleteResults.filter(exists7);
5098
5334
  }
5099
5335
  async insert(items) {
5100
5336
  const payloads = items.filter(isAnyPayload10).filter((i) => this.isAllowed(i));
@@ -5137,7 +5373,8 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
5137
5373
  this._store = { chainMap: this.params.finalizedArchivist };
5138
5374
  }
5139
5375
  async finalizeBlock(block) {
5140
- return (await this.finalizeBlocks([block]))[0];
5376
+ const results = await this.finalizeBlocks([block]);
5377
+ return results[0];
5141
5378
  }
5142
5379
  async finalizeBlocks(blocks) {
5143
5380
  const sortedBlocks = blocks.toSorted((a, b) => a[0].block - b[0].block);
@@ -5191,7 +5428,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
5191
5428
  }
5192
5429
  async createHandler() {
5193
5430
  await super.createHandler();
5194
- this._chainId = assertEx38(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
5431
+ const mostRecentBlock = await findMostRecentBlock(this.params.finalizedArchivist);
5432
+ this._chainId = assertEx38(this.config.chain.id ?? mostRecentBlock?.chain, () => "chain.id is required if empty archivist");
5195
5433
  this._store = { chainMap: this.params.finalizedArchivist };
5196
5434
  }
5197
5435
  async head() {
@@ -5206,13 +5444,16 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
5206
5444
  }, this.context);
5207
5445
  }
5208
5446
  async headBlock() {
5209
- return (await this.head())[0];
5447
+ const headBlock = await this.head();
5448
+ return headBlock[0];
5210
5449
  }
5211
5450
  async headHash() {
5212
- return (await this.headBlock())._hash;
5451
+ const headBlock = await this.headBlock();
5452
+ return headBlock._hash;
5213
5453
  }
5214
5454
  async headNumber() {
5215
- return (await this.headBlock()).block;
5455
+ const headBlock = await this.headBlock();
5456
+ return headBlock.block;
5216
5457
  }
5217
5458
  getBlockContextRead() {
5218
5459
  return {
@@ -5221,9 +5462,10 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
5221
5462
  };
5222
5463
  }
5223
5464
  async getChainContextRead() {
5465
+ const headBlock = await this.head();
5224
5466
  return {
5225
5467
  ...this.getBlockContextRead(),
5226
- head: (await this.head())[0]
5468
+ head: headBlock[0]
5227
5469
  };
5228
5470
  }
5229
5471
  async getCurrentHead() {
@@ -5261,7 +5503,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
5261
5503
  import {
5262
5504
  assertEx as assertEx39,
5263
5505
  BigIntToJsonZod,
5264
- isDefined as isDefined19
5506
+ isDefined as isDefined20
5265
5507
  } from "@xylabs/sdk-js";
5266
5508
  import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
5267
5509
  import {
@@ -5299,9 +5541,9 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
5299
5541
  chain,
5300
5542
  fees
5301
5543
  } = options ?? {};
5302
- const resolvedChainId = isDefined19(chain) ? chain : await viewer.chainId();
5303
- const resolvedNbf = asXL1BlockNumber10(isDefined19(nbf) ? nbf : await viewer.currentBlockNumber(), true);
5304
- const resolvedExp = asXL1BlockNumber10(isDefined19(exp) ? exp : resolvedNbf + 10, true);
5544
+ const resolvedChainId = isDefined20(chain) ? chain : await viewer.chainId();
5545
+ const resolvedNbf = asXL1BlockNumber10(isDefined20(nbf) ? nbf : await viewer.currentBlockNumber(), true);
5546
+ const resolvedExp = asXL1BlockNumber10(isDefined20(exp) ? exp : resolvedNbf + 10, true);
5305
5547
  const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
5306
5548
  return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
5307
5549
  }
@@ -5345,11 +5587,13 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
5345
5587
  BigIntToJsonZod.parse(amount)
5346
5588
  ])
5347
5589
  );
5348
- const transfer = new PayloadBuilder20({ schema: TransferSchema3 }).fields({
5590
+ const payloadBuilder = new PayloadBuilder20({ schema: TransferSchema3 });
5591
+ const transferBuilder = payloadBuilder.fields({
5349
5592
  from,
5350
5593
  transfers: hexTransfers,
5351
5594
  epoch: Date.now()
5352
- }).build();
5595
+ });
5596
+ const transfer = transferBuilder.build();
5353
5597
  const [hash] = await this.addPayloadsToChain([transfer], [], options);
5354
5598
  return hash;
5355
5599
  }
@@ -5470,10 +5714,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5470
5714
  const valid = blocks.map((b) => !!b);
5471
5715
  const remainingBlockMap = [];
5472
5716
  const remainingBlocks = blocks.map((b, i) => {
5473
- if (b) {
5474
- remainingBlockMap.push(i);
5475
- return b;
5717
+ if (!b) {
5718
+ return;
5476
5719
  }
5720
+ remainingBlockMap.push(i);
5721
+ return b;
5477
5722
  }).filter(exists8);
5478
5723
  assertEx40(
5479
5724
  remainingBlockMap.length === remainingBlocks.length,
@@ -5492,7 +5737,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5492
5737
  valid[remainingBlockMap[i]] = validated;
5493
5738
  }
5494
5739
  const pruneHashes = bundles.map((p, i) => {
5495
- if (!valid[i]) {
5740
+ if (valid.at(i) !== true) {
5496
5741
  return p._hash;
5497
5742
  }
5498
5743
  }).filter(exists8);
@@ -5532,10 +5777,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5532
5777
  const valid = transactions.map((t) => !!t);
5533
5778
  const remainingTransactionMap = [];
5534
5779
  const remainingTransactions = transactions.map((t, i) => {
5535
- if (t) {
5536
- remainingTransactionMap.push(i);
5537
- return t;
5780
+ if (!t) {
5781
+ return;
5538
5782
  }
5783
+ remainingTransactionMap.push(i);
5784
+ return t;
5539
5785
  }).filter(exists8);
5540
5786
  assertEx40(
5541
5787
  remainingTransactionMap.length === remainingTransactions.length,
@@ -5555,7 +5801,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
5555
5801
  valid[remainingTransactionMap[i]] = validated;
5556
5802
  }
5557
5803
  const pruneHashes = bundles.map((p, i) => {
5558
- if (!valid[i]) {
5804
+ if (valid.at(i) !== true) {
5559
5805
  return p._hash;
5560
5806
  }
5561
5807
  }).filter(exists8);
@@ -5789,7 +6035,7 @@ SimpleMempoolRunner = __decorateClass([
5789
6035
  // src/simple/mempool/SimpleMempoolViewer.ts
5790
6036
  import {
5791
6037
  exists as exists9,
5792
- isDefined as isDefined20,
6038
+ isDefined as isDefined21,
5793
6039
  isHash as isHash2
5794
6040
  } from "@xylabs/sdk-js";
5795
6041
  import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
@@ -5850,7 +6096,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5850
6096
  let cursor = void 0;
5851
6097
  if (isHash2(providedCursor)) {
5852
6098
  const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
5853
- if (isDefined20(p)) {
6099
+ if (isDefined21(p)) {
5854
6100
  cursor = p._sequence;
5855
6101
  }
5856
6102
  }
@@ -5860,7 +6106,8 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5860
6106
  cursor
5861
6107
  });
5862
6108
  const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
5863
- return (await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)))).filter(exists9);
6109
+ const hydratedBlocks = await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)));
6110
+ return hydratedBlocks.filter(exists9);
5864
6111
  }
5865
6112
  async pendingTransactions({
5866
6113
  cursor: providedCursor,
@@ -5869,7 +6116,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5869
6116
  let cursor = void 0;
5870
6117
  if (isHash2(providedCursor)) {
5871
6118
  const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
5872
- if (isDefined20(p)) {
6119
+ if (isDefined21(p)) {
5873
6120
  cursor = p._sequence;
5874
6121
  }
5875
6122
  }
@@ -5881,12 +6128,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5881
6128
  });
5882
6129
  this.logger?.debug(`Fetched pending transactions: ${bundles.length} bundles`);
5883
6130
  const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
5884
- const hydratedWithBundle = (await Promise.all(
5885
- filteredBundles.map(async (bundle3) => {
5886
- const tx = await bundledPayloadToHydratedTransaction(bundle3);
5887
- return isDefined20(tx) ? { bundle: bundle3, tx } : void 0;
5888
- })
5889
- )).filter(exists9);
6131
+ const hydratedWithBundle = await this.hydratePendingBundles(filteredBundles);
5890
6132
  const currentBlock = await this.windowedBlockViewer.currentBlock();
5891
6133
  const currentBlockNumber = currentBlock[0].block;
5892
6134
  const evaluated = await Promise.all(
@@ -5907,9 +6149,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5907
6149
  })
5908
6150
  );
5909
6151
  this.gcHandoutStats(currentBlockNumber);
5910
- const inclusionCandidates = (await Promise.all(validTransactions.map(async ({ bundle: bundle3, tx }) => {
5911
- if (await this.isInclusionCandidate(tx, currentBlock, false)) return { bundle: bundle3, tx };
5912
- }))).filter(exists9);
6152
+ const inclusionCandidates = await this.filterInclusionCandidates(validTransactions, currentBlock);
5913
6153
  const selectionRatio = this.params.mempoolSelectionRatio ?? DEFAULT_MEMPOOL_SELECTION_RATIO;
5914
6154
  const nonDemoted = inclusionCandidates.filter(({ bundle: bundle3 }) => !this.isDemoted(bundle3._hash));
5915
6155
  const demoted = inclusionCandidates.filter(({ bundle: bundle3 }) => this.isDemoted(bundle3._hash));
@@ -5933,12 +6173,27 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
5933
6173
  async deleteBundledTransaction(bundle3) {
5934
6174
  await this.pendingTransactionsArchivist.delete([bundle3._hash]);
5935
6175
  }
6176
+ async filterInclusionCandidates(validTransactions, currentBlock) {
6177
+ const inclusionResults = await Promise.all(validTransactions.map(async ({ bundle: bundle3, tx }) => {
6178
+ if (await this.isInclusionCandidate(tx, currentBlock, false)) return { bundle: bundle3, tx };
6179
+ }));
6180
+ return inclusionResults.filter(exists9);
6181
+ }
5936
6182
  gcHandoutStats(currentBlockNumber) {
5937
6183
  const ttl = this.handoutStatsTtlBlocks;
5938
6184
  for (const [hash, stats] of this._handoutStats) {
5939
6185
  if (currentBlockNumber - stats.firstHandoutAt > ttl) this._handoutStats.delete(hash);
5940
6186
  }
5941
6187
  }
6188
+ async hydratePendingBundles(filteredBundles) {
6189
+ const hydratedResults = await Promise.all(
6190
+ filteredBundles.map(async (bundle3) => {
6191
+ const tx = await bundledPayloadToHydratedTransaction(bundle3);
6192
+ return isDefined21(tx) ? { bundle: bundle3, tx } : void 0;
6193
+ })
6194
+ );
6195
+ return hydratedResults.filter(exists9);
6196
+ }
5942
6197
  /**
5943
6198
  * Evaluates a transaction to determine if it should be purged from the mempool.
5944
6199
  * @param tx The transaction to evaluate
@@ -5996,7 +6251,7 @@ SimpleMempoolViewer = __decorateClass([
5996
6251
  function deduplicateWithBundleBySigner(items) {
5997
6252
  const seen = /* @__PURE__ */ new Set();
5998
6253
  return items.filter(({ tx }) => {
5999
- const key = tx[0].addresses.toSorted().join(",");
6254
+ const key = tx[0].addresses.toSorted((a, b) => a.localeCompare(b)).join(",");
6000
6255
  if (seen.has(key)) return false;
6001
6256
  seen.add(key);
6002
6257
  return true;
@@ -6062,13 +6317,12 @@ var SimpleXyoNetwork = class {
6062
6317
  const response = await fetchJsonGet(url);
6063
6318
  if (isNetworkStatus(response.data)) {
6064
6319
  return response.data;
6065
- } else {
6066
- if (response.status === 200) {
6067
- this.logger?.error("Unknown network status response", response.data);
6068
- return unknownStatus;
6069
- }
6070
- return errorStatus;
6071
6320
  }
6321
+ if (response.status === 200) {
6322
+ this.logger?.error("Unknown network status response", response.data);
6323
+ return unknownStatus;
6324
+ }
6325
+ return errorStatus;
6072
6326
  } catch (error) {
6073
6327
  this.logger?.error("Error fetching network status", error);
6074
6328
  return errorStatus;
@@ -6235,7 +6489,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
6235
6489
  };
6236
6490
 
6237
6491
  // src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
6238
- import { isDefined as isDefined21 } from "@xylabs/sdk-js";
6492
+ import { isDefined as isDefined22 } from "@xylabs/sdk-js";
6239
6493
  import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
6240
6494
  var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
6241
6495
  moniker = SimpleStakeEventsViewer.defaultMoniker;
@@ -6248,7 +6502,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
6248
6502
  stakeEvents(range, { name } = {}) {
6249
6503
  const positions = this.positionsFromRange(range);
6250
6504
  const events = this.eventsFromPositions(positions);
6251
- if (isDefined21(name)) {
6505
+ if (isDefined22(name)) {
6252
6506
  return events.filter((event) => event.name === name);
6253
6507
  }
6254
6508
  return events;
@@ -6596,7 +6850,7 @@ RestSyncViewer = __decorateClass([
6596
6850
  import {
6597
6851
  asHash as asHash5,
6598
6852
  assertEx as assertEx45,
6599
- isDefined as isDefined22
6853
+ isDefined as isDefined23
6600
6854
  } from "@xylabs/sdk-js";
6601
6855
  import {
6602
6856
  asTimePayload as asTimePayload2,
@@ -6620,7 +6874,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
6620
6874
  const [block, payloads] = assertEx45(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
6621
6875
  const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
6622
6876
  const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
6623
- const timePayload = asTimePayload2(isDefined22(hash) ? payloads.find((p) => p._hash === hash) : void 0);
6877
+ const timePayload = asTimePayload2(isDefined23(hash) ? payloads.find((p) => p._hash === hash) : void 0);
6624
6878
  if (timePayload === void 0) return 0;
6625
6879
  switch (toDomain) {
6626
6880
  case "xl1": {
@@ -6649,7 +6903,8 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
6649
6903
  async currentTime(domain) {
6650
6904
  switch (domain) {
6651
6905
  case "xl1": {
6652
- return ["xl1", (await this.blockViewer.currentBlock())?.[0].block ?? -1];
6906
+ const currentBlock = await this.blockViewer.currentBlock();
6907
+ return ["xl1", currentBlock?.[0].block ?? -1];
6653
6908
  }
6654
6909
  case "epoch": {
6655
6910
  return ["epoch", Date.now()];
@@ -6693,7 +6948,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
6693
6948
  xl1Hash: assertEx45(xl1Hash, () => "No xl1 hash available from time sync service"),
6694
6949
  epoch: Date.now()
6695
6950
  };
6696
- if (isDefined22(this.ethProvider)) {
6951
+ if (isDefined23(this.ethProvider)) {
6697
6952
  const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
6698
6953
  const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
6699
6954
  timePayload.ethereum = ethereum;
@@ -6761,13 +7016,18 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
6761
7016
  head: void 0
6762
7017
  };
6763
7018
  const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
6764
- const head = isChainQualifiedHeadConfig6(config) ? assertEx46(
6765
- (await this.blockViewer.blockByHash(config.head))?.[0],
6766
- () => `Specified a head that is not in the chain [${config.head}]`
6767
- ) : void 0;
6768
- const headBlock = head ?? (await this.blockViewer.currentBlock())[0];
6769
- const validateProtocol = value ? this.doValidateProtocol.bind(this) : void 0;
6770
- const validateState = state ? this.doValidateState.bind(this) : void 0;
7019
+ let head;
7020
+ if (isChainQualifiedHeadConfig6(config)) {
7021
+ const headBlockResult = await this.blockViewer.blockByHash(config.head);
7022
+ head = headBlockResult == null ? assertEx46(
7023
+ void 0,
7024
+ () => `Specified a head that is not in the chain [${config.head}]`
7025
+ ) : headBlockResult[0];
7026
+ }
7027
+ const currentBlock = await this.blockViewer.currentBlock();
7028
+ const headBlock = head ?? currentBlock[0];
7029
+ const validateProtocol = value === true ? this.doValidateProtocol.bind(this) : void 0;
7030
+ const validateState = state === true ? this.doValidateState.bind(this) : void 0;
6771
7031
  const chainId = headBlock.chain;
6772
7032
  const qualification = { head: headBlock._hash, range: asXL1BlockRange13([0, headBlock.block], true) };
6773
7033
  const [protocolResults, stateResults] = await Promise.all([
@@ -6790,10 +7050,12 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
6790
7050
  throw new Error("Method not implemented.");
6791
7051
  }
6792
7052
  async validateTransaction(block, config) {
6793
- return (await this.validateTransactions([block], config))[0];
7053
+ const results = await this.validateTransactions([block], config);
7054
+ return results[0];
6794
7055
  }
6795
7056
  async validateTransactions(transactions, config) {
6796
- return (await this.qualifiedValidateTransactions(transactions, config))[0];
7057
+ const results = await this.qualifiedValidateTransactions(transactions, config);
7058
+ return results[0];
6797
7059
  }
6798
7060
  async doValidateProtocol(transactions, chainId) {
6799
7061
  return await Promise.all(transactions.map(async (tx) => {
@@ -7091,8 +7353,8 @@ var LoggerStatusReporter = class {
7091
7353
  }
7092
7354
  report(name, status, progress) {
7093
7355
  this.statusMap[name] = status;
7094
- const starting = Object.entries(this.statusMap).map(([, value]) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
7095
- const started = Object.entries(this.statusMap).map(([, value]) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
7356
+ const starting = Object.values(this.statusMap).map((value) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
7357
+ const started = Object.values(this.statusMap).map((value) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
7096
7358
  this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, { progress });
7097
7359
  }
7098
7360
  };
@@ -7183,7 +7445,7 @@ import {
7183
7445
  } from "@xyo-network/xl1-protocol-lib";
7184
7446
 
7185
7447
  // src/test/buildBlock.ts
7186
- import { assertEx as assertEx49, isDefined as isDefined23 } from "@xylabs/sdk-js";
7448
+ import { assertEx as assertEx49, isDefined as isDefined24 } from "@xylabs/sdk-js";
7187
7449
  import {
7188
7450
  asAnyPayload as asAnyPayload5,
7189
7451
  BoundWitnessBuilder as BoundWitnessBuilder3,
@@ -7253,6 +7515,26 @@ var isBuildNextBlockOptions = (value) => {
7253
7515
  function calculateCompletedStepReward(step, balance) {
7254
7516
  return AttoXL14(StepRewardFractions[step][0] * balance / StepRewardFractions[step][1]);
7255
7517
  }
7518
+ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStepRewardAddress2, stepRewardPoolBalance) {
7519
+ const completedStepRewardTransfers = [];
7520
+ const step_hashes = [];
7521
+ for (const [i, step] of StepSizes14.entries()) {
7522
+ if (blockNumber < step) {
7523
+ break;
7524
+ }
7525
+ if (blockNumber % step === 0) {
7526
+ if (StepRewardFractions[i][0] > 0 && chainStepRewardAddress2 !== XYO_ZERO_ADDRESS2) {
7527
+ const completedStepRewardHolderAddress = rewardAddressFromStepIdentity({ block: blockNumber, step });
7528
+ const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
7529
+ completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
7530
+ }
7531
+ step_hashes.push(assertEx49(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
7532
+ } else if (isDefined24(inStepHashes.at(i))) {
7533
+ step_hashes.push(inStepHashes[i]);
7534
+ }
7535
+ }
7536
+ return { completedStepRewardTransfers, step_hashes };
7537
+ }
7256
7538
  async function buildBlock(options) {
7257
7539
  const previousBlockNumber = isBuildGenesisBlockOptions(options) ? -1 : options.previousBlockNumber;
7258
7540
  const blockNumber = asXL1BlockNumber13(previousBlockNumber + 1, true);
@@ -7267,7 +7549,6 @@ async function buildBlock(options) {
7267
7549
  protocol = XL1_PROTOCOL_VERSION,
7268
7550
  signers
7269
7551
  } = options;
7270
- const step_hashes = [];
7271
7552
  for (const [tx] of txs) {
7272
7553
  if (tx.nbf > blockNumber) {
7273
7554
  throw new Error(`Transaction ${await PayloadBuilder25.hash(tx)} not valid for block ${blockNumber} - NBF is ${tx.nbf}`);
@@ -7276,24 +7557,13 @@ async function buildBlock(options) {
7276
7557
  throw new Error(`Transaction ${await PayloadBuilder25.hash(tx)} not valid for block ${blockNumber} - EXP is ${tx.exp}`);
7277
7558
  }
7278
7559
  }
7279
- const completedStepRewardTransfers = [];
7280
- for (const [i, step] of StepSizes14.entries()) {
7281
- if (blockNumber < step) {
7282
- break;
7283
- }
7284
- if (blockNumber % step === 0) {
7285
- if (StepRewardFractions[i][0] > 0 && chainStepRewardAddress2 !== XYO_ZERO_ADDRESS2) {
7286
- const completedStepRewardHolderAddress = rewardAddressFromStepIdentity({ block: blockNumber, step });
7287
- const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
7288
- completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
7289
- }
7290
- step_hashes.push(assertEx49(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
7291
- } else {
7292
- if (isDefined23(inStepHashes.at(i))) {
7293
- step_hashes.push(inStepHashes[i]);
7294
- }
7295
- }
7296
- }
7560
+ const { step_hashes, completedStepRewardTransfers } = buildStepHashes(
7561
+ blockNumber,
7562
+ inStepHashes,
7563
+ previousBlockHash,
7564
+ chainStepRewardAddress2,
7565
+ stepRewardPoolBalance
7566
+ );
7297
7567
  const previous = previousBlockHash ?? null;
7298
7568
  const block = blockNumber;
7299
7569
  const txElevatedPayloads = await validateTransactionsOpcodes(txs);
@@ -7303,13 +7573,15 @@ async function buildBlock(options) {
7303
7573
  ...txElevatedPayloads,
7304
7574
  ...completedStepRewardTransfers
7305
7575
  ];
7306
- const [bw, txPayloads] = await new BoundWitnessBuilder3().fields({
7576
+ const boundWitnessBuilder = new BoundWitnessBuilder3();
7577
+ const builder = boundWitnessBuilder.fields({
7307
7578
  block,
7308
7579
  chain: chainId,
7309
7580
  previous,
7310
7581
  step_hashes,
7311
7582
  protocol
7312
- }).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads)).build();
7583
+ }).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
7584
+ const [bw, txPayloads] = await builder.build();
7313
7585
  assertEx49(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
7314
7586
  return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
7315
7587
  }
@@ -7365,7 +7637,8 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
7365
7637
  const additionalPayloads = (payloads ?? []).filter((payload) => !isAllowedBlockPayload3(payload));
7366
7638
  const sender = account ?? await Account2.random();
7367
7639
  if (elevatedPayloads.length === 0) {
7368
- const receiver = receiverAddress ?? (await Account2.random()).address;
7640
+ const defaultReceiver = await Account2.random();
7641
+ const receiver = receiverAddress ?? defaultReceiver.address;
7369
7642
  const transferPayload = createTransferPayload(sender.address, { [receiver]: 1n });
7370
7643
  elevatedPayloads.push(transferPayload);
7371
7644
  }
@@ -7396,12 +7669,14 @@ import {
7396
7669
  defaultTransactionFees as defaultTransactionFees4
7397
7670
  } from "@xyo-network/xl1-protocol-lib";
7398
7671
  async function createProducerChainStakeIntent(from, exp, nbf = 0) {
7399
- return await PayloadBuilder27.addHashMeta(new PayloadBuilder27({ schema: ChainStakeIntentSchema2 }).fields({
7672
+ const payloadBuilder = new PayloadBuilder27({ schema: ChainStakeIntentSchema2 });
7673
+ const builder = payloadBuilder.fields({
7400
7674
  from,
7401
7675
  exp,
7402
7676
  nbf,
7403
7677
  intent: "producer"
7404
- }).build());
7678
+ });
7679
+ return await PayloadBuilder27.addHashMeta(builder.build());
7405
7680
  }
7406
7681
 
7407
7682
  // src/test/createGenesisBlock.ts
@@ -7445,13 +7720,20 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
7445
7720
  remaining = remaining - 1;
7446
7721
  lastBlock = block;
7447
7722
  }
7448
- const resolvedReceiverAddresses = receiverAddresses ?? [(await Account4.random()).address];
7723
+ const defaultReceiver = await Account4.random();
7724
+ const resolvedReceiverAddresses = receiverAddresses ?? [defaultReceiver.address];
7449
7725
  let saltCounter = 0;
7450
7726
  while (remaining > 0) {
7451
7727
  saltCounter += 1;
7452
- const payloads = [new PayloadBuilder29({ schema: IdSchema2 }).fields({ salt: `${Date.now()}-${saltCounter}` }).build()];
7728
+ const idPayloadBuilder = new PayloadBuilder29({ schema: IdSchema2 });
7729
+ const idBuilder = idPayloadBuilder.fields({ salt: `${Date.now()}-${saltCounter}` });
7730
+ const payloads = [idBuilder.build()];
7453
7731
  saltCounter += 1;
7454
- const additionalPrivatePayloads = remaining % 2 === 0 ? [new PayloadBuilder29({ schema: asSchema9("network.xyo.private", true) }).fields({ salt: `${Date.now()}-${saltCounter}` }).build()] : [];
7732
+ const additionalPrivatePayloads = remaining % 2 === 0 ? (() => {
7733
+ const privatePayloadBuilder = new PayloadBuilder29({ schema: asSchema9("network.xyo.private", true) });
7734
+ const privateBuilder = privatePayloadBuilder.fields({ salt: `${Date.now()}-${saltCounter}` });
7735
+ return [privateBuilder.build()];
7736
+ })() : [];
7455
7737
  const txs = [];
7456
7738
  for (const receiverAddress of resolvedReceiverAddresses) {
7457
7739
  txs.push(await buildRandomTransaction(
@@ -7583,6 +7865,7 @@ export {
7583
7865
  ActorConfigZod,
7584
7866
  ActorsConfigZod,
7585
7867
  AddressPairSchema,
7868
+ AmbiguousProviderError,
7586
7869
  BalancesStepSummarySchema,
7587
7870
  BaseConfigContextZod,
7588
7871
  BaseConfigZod,
@@ -7592,6 +7875,8 @@ export {
7592
7875
  COIN_TYPES,
7593
7876
  ChainIndexingServiceStateSchema,
7594
7877
  ConfigZod,
7878
+ TransportConfigZod as ConnectionConfigZod,
7879
+ TransportsConfigZod as ConnectionsConfigZod,
7595
7880
  CreatableProviderContextZod,
7596
7881
  DEFAULT_BACKOFF_MS,
7597
7882
  DEFAULT_MAX_ATTEMPTS,
@@ -7605,6 +7890,7 @@ export {
7605
7890
  EIP712DataPayloadSchema,
7606
7891
  EIP712SignaturePayloadFieldsZod,
7607
7892
  EIP712SignaturePayloadSchema,
7893
+ EvmRpcTransportConfigZod as EvmConnectionConfigZod,
7608
7894
  EvmRpcTransportConfigZod,
7609
7895
  GlobalMetaSchema,
7610
7896
  HostActorConfigContext,
@@ -7613,11 +7899,13 @@ export {
7613
7899
  HydratedBoundWitnessWithStorageMetaZod,
7614
7900
  HydratedCache,
7615
7901
  JSONSchemaMetaSchema,
7902
+ LmdbTransportConfigZod as LmdbConnectionConfigZod,
7616
7903
  LmdbTransportConfigZod,
7617
7904
  LoggerStatusReporter,
7618
7905
  MemoryPermissionsStore,
7619
7906
  MissingCapabilityError,
7620
7907
  MnemonicStringZod,
7908
+ MongoTransportConfigZod as MongoConnectionConfigZod,
7621
7909
  MongoTransportConfigZod,
7622
7910
  PRODUCER_DIVERSITY_BONUS,
7623
7911
  PayloadLocator,
@@ -7630,6 +7918,7 @@ export {
7630
7918
  ProviderFactoryLocatorZod,
7631
7919
  ProvidersConfigZod,
7632
7920
  RemoteConfigZod,
7921
+ RestTransportConfigZod as RestConnectionConfigZod,
7633
7922
  RestDataLakeConfigZod,
7634
7923
  RestDataLakeRunner,
7635
7924
  RestDataLakeViewer,
@@ -7637,11 +7926,13 @@ export {
7637
7926
  RestTransportConfigZod,
7638
7927
  RewardMultipliers,
7639
7928
  RouterDataLakeConfigZod,
7929
+ RpcTransportConfigZod as RpcConnectionConfigZod,
7640
7930
  RpcRemoteConfigBaseZod,
7641
7931
  RpcRemoteConfigZod,
7642
7932
  RpcTransportConfigZod,
7643
7933
  RuntimeStatusMonitor,
7644
7934
  RuntimeStatusMonitorZod,
7935
+ S3TransportConfigZod as S3ConnectionConfigZod,
7645
7936
  S3TransportConfigZod,
7646
7937
  SchemasStepSummarySchema,
7647
7938
  ShiftedBigInt,
@@ -7680,6 +7971,8 @@ export {
7680
7971
  TypedDataFieldZod,
7681
7972
  TypedDataTypesZod,
7682
7973
  TypedDataValueZod,
7974
+ UnboundProviderError,
7975
+ UnknownConnectionError,
7683
7976
  UsageMetaSchema,
7684
7977
  VIEWER_BRANCH_KEYS,
7685
7978
  WALLET_COMPLIANCE,
@@ -7755,6 +8048,8 @@ export {
7755
8048
  createTransactionHydrator,
7756
8049
  createTransferPayload,
7757
8050
  deepCalculateFramesFromRange,
8051
+ descriptorConnectionTypes,
8052
+ descriptorMatchesConnectionType,
7758
8053
  externalBlockNumberFromXL1BlockNumber,
7759
8054
  externalBlockRangeFromStep,
7760
8055
  externalBlockRangeFromXL1BlockRange,
@@ -7776,6 +8071,7 @@ export {
7776
8071
  getTimeConfigInMilliseconds,
7777
8072
  getUrl,
7778
8073
  getWindowedChain,
8074
+ hasDeclaredConnectionProfiles,
7779
8075
  hasLabels,
7780
8076
  hasMongoConfig,
7781
8077
  hasS3Config,
@@ -7822,6 +8118,7 @@ export {
7822
8118
  netTransfersForPayloads,
7823
8119
  networkBackedFactory,
7824
8120
  networkStakeStepRewardPositionWeight,
8121
+ normalizeConnectionsConfig,
7825
8122
  parseSignedBigInt,
7826
8123
  payloadMapFromStore,
7827
8124
  prettifyZodError,