@xyo-network/xl1-protocol-sdk 2.1.9 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/ChainContextHelpers.d.ts +1 -1
- package/dist/neutral/ChainContextHelpers.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +36 -3
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
- package/dist/neutral/amount/index.d.ts +1 -1
- package/dist/neutral/amount/splitOnDecimalToString.d.ts.map +1 -1
- package/dist/neutral/amount/{XL1Amount.d.ts → xl1Amount.d.ts} +1 -1
- package/dist/neutral/amount/{XL1Amount.d.ts.map → xl1Amount.d.ts.map} +1 -1
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/tryHydrateBlock.d.ts.map +1 -1
- package/dist/neutral/block/primitives/hashFromBlockNumber.d.ts.map +1 -1
- package/dist/neutral/block/primitives/validateTransactionOpcodes.d.ts.map +1 -1
- package/dist/neutral/capabilities/resolveProviders.d.ts +6 -0
- package/dist/neutral/capabilities/resolveProviders.d.ts.map +1 -1
- package/dist/neutral/config/Actor.d.ts +216 -18
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +36 -3
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +36 -3
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +1 -1
- package/dist/neutral/config/Config.d.ts +144 -12
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +216 -18
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/ProviderBinding.d.ts +18 -0
- package/dist/neutral/config/ProviderBinding.d.ts.map +1 -0
- package/dist/neutral/config/Validation.d.ts +2 -2
- package/dist/neutral/config/adaptLegacyConfig.d.ts +9 -0
- package/dist/neutral/config/adaptLegacyConfig.d.ts.map +1 -0
- package/dist/neutral/config/index.d.ts +3 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/transports/Transport.d.ts +111 -0
- package/dist/neutral/config/transports/Transport.d.ts.map +1 -0
- package/dist/neutral/config/transports/index.d.ts +2 -0
- package/dist/neutral/config/transports/index.d.ts.map +1 -0
- package/dist/neutral/context/Actor.d.ts +216 -18
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +216 -18
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/createDeclarationPayload.d.ts +1 -1
- package/dist/neutral/createDeclarationPayload.d.ts.map +1 -1
- package/dist/neutral/createTransferPayload.d.ts +1 -1
- package/dist/neutral/createTransferPayload.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +72 -6
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +151 -81
- package/dist/neutral/getFileConfig.mjs.map +4 -4
- package/dist/neutral/index.mjs +776 -442
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/instances/Address.d.ts +1 -1
- package/dist/neutral/instances/Address.d.ts.map +1 -1
- package/dist/neutral/instances/Signature.d.ts +1 -1
- package/dist/neutral/instances/Signature.d.ts.map +1 -1
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +216 -18
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/payloads/AddressPairPayload.d.ts +1 -2
- package/dist/neutral/payloads/AddressPairPayload.d.ts.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts +1 -2
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts +1 -1
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/step/stepRewardTotal.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/time/{externalBlockNumberFromXL1BlockNumber.d.ts → externalBlockNumberFromXl1BlockNumber.d.ts} +1 -1
- package/dist/neutral/primitives/chain/time/{externalBlockNumberFromXL1BlockNumber.d.ts.map → externalBlockNumberFromXl1BlockNumber.d.ts.map} +1 -1
- package/dist/neutral/primitives/chain/time/{externalBlockRangeFromXL1BlockRange.d.ts → externalBlockRangeFromXl1BlockRange.d.ts} +1 -1
- package/dist/neutral/primitives/chain/time/{externalBlockRangeFromXL1BlockRange.d.ts.map → externalBlockRangeFromXl1BlockRange.d.ts.map} +1 -1
- package/dist/neutral/primitives/chain/time/index.d.ts +2 -2
- package/dist/neutral/primitives/datalake/PayloadLocator.d.ts.map +1 -1
- package/dist/neutral/primitives/datalake/addDataLakePayloadsToPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts +1 -1
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts.map +1 -1
- package/dist/neutral/primitives/readPayloadMapFromStore.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts +1 -1
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/activeStakeAtTimeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts +1 -1
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts +1 -1
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts +1 -1
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/state/findMostRecentBlock.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findUncles.d.ts +2 -2
- package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -1
- package/dist/neutral/services/AccountTransfersService.d.ts +1 -1
- package/dist/neutral/services/AccountTransfersService.d.ts.map +1 -1
- package/dist/neutral/services/Election.d.ts +1 -2
- package/dist/neutral/services/Election.d.ts.map +1 -1
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts +1 -1
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts.map +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +12 -16
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts +1 -1
- package/dist/neutral/simple/blockInvalidation/SimpleBlockInvalidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +3 -3
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/RestDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts +1 -2
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +2 -0
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/network/SimpleXyoNetwork.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +1 -2
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts +1 -1
- package/dist/neutral/simple/timeSync2/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.d.ts +1 -1
- package/dist/neutral/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.d.ts.map +1 -1
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts +1 -1
- package/dist/neutral/simple/transactionValidation/SimpleTransactionValidationViewer.d.ts.map +1 -1
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts +1 -2
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts.map +1 -1
- package/dist/neutral/summary/model/TransfersSummary.d.ts +1 -2
- package/dist/neutral/summary/model/TransfersSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/test/BuildBlockOptions.d.ts +1 -2
- package/dist/neutral/test/BuildBlockOptions.d.ts.map +1 -1
- package/dist/neutral/test/buildBlock.d.ts.map +1 -1
- package/dist/neutral/test/buildNextBlock.d.ts +1 -2
- package/dist/neutral/test/buildNextBlock.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomChain.d.ts +1 -2
- package/dist/neutral/test/buildRandomChain.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomGenesisBlock.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomTransaction.d.ts +1 -2
- package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -1
- package/dist/neutral/test/createGenesisBlock.d.ts +1 -2
- package/dist/neutral/test/createGenesisBlock.d.ts.map +1 -1
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts +1 -2
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts.map +1 -1
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts +1 -2
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +287 -166
- package/dist/neutral/test/index.mjs.map +4 -4
- package/dist/neutral/transaction/buildTransaction.d.ts +1 -2
- package/dist/neutral/transaction/buildTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts +1 -2
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/confirmSubmittedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/hydrateTransaction.d.ts.map +1 -1
- package/package.json +8 -10
package/dist/neutral/index.mjs
CHANGED
|
@@ -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
|
|
30
|
+
const wholeFormatter = new Intl.NumberFormat(locale, {
|
|
31
31
|
maximumFractionDigits: 0,
|
|
32
32
|
useGrouping: true
|
|
33
|
-
})
|
|
34
|
-
const
|
|
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
|
|
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/
|
|
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
|
-
|
|
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
|
-
)
|
|
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) =>
|
|
218
|
-
const
|
|
219
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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
|
|
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
|
|
940
|
+
for (const [id, cap] of this._entries) {
|
|
918
941
|
const { id: _, ...rest } = cap;
|
|
919
942
|
result[id] = rest;
|
|
920
943
|
}
|
|
@@ -1023,8 +1046,8 @@ function resolveProviders(needs, candidates, ctx, options = {}) {
|
|
|
1023
1046
|
const { surviving, rejected: preconditionRejected } = filterByPreconditions(backingFiltered, ctx);
|
|
1024
1047
|
const rejected = [...backingRejected, ...preconditionRejected];
|
|
1025
1048
|
const byCapability = groupByCapability(surviving, wanted);
|
|
1026
|
-
const { bindings, selectedById } = pickWinners(wanted, byCapability, rejected, candidates);
|
|
1027
|
-
const selected = topoSort(
|
|
1049
|
+
const { bindings, selectedById } = pickWinners(wanted, byCapability, rejected, candidates, options);
|
|
1050
|
+
const selected = topoSort(selectedById.values().toArray(), ctx);
|
|
1028
1051
|
return {
|
|
1029
1052
|
bindings,
|
|
1030
1053
|
rejected,
|
|
@@ -1083,23 +1106,36 @@ function filterByPreconditions(candidates, ctx) {
|
|
|
1083
1106
|
}
|
|
1084
1107
|
return { surviving, rejected };
|
|
1085
1108
|
}
|
|
1109
|
+
function addDescriptorCapabilities(byCapability, descriptor, wanted) {
|
|
1110
|
+
for (const moniker of descriptor.satisfies) {
|
|
1111
|
+
if (!wanted.has(moniker)) {
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
const list = byCapability.get(moniker) ?? [];
|
|
1115
|
+
list.push(descriptor);
|
|
1116
|
+
byCapability.set(moniker, list);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1086
1119
|
function groupByCapability(surviving, wanted) {
|
|
1087
1120
|
const byCapability = /* @__PURE__ */ new Map();
|
|
1088
1121
|
for (const descriptor of surviving) {
|
|
1089
|
-
|
|
1090
|
-
if (!wanted.has(moniker)) continue;
|
|
1091
|
-
const list = byCapability.get(moniker) ?? [];
|
|
1092
|
-
list.push(descriptor);
|
|
1093
|
-
byCapability.set(moniker, list);
|
|
1094
|
-
}
|
|
1122
|
+
addDescriptorCapabilities(byCapability, descriptor, wanted);
|
|
1095
1123
|
}
|
|
1096
1124
|
return byCapability;
|
|
1097
1125
|
}
|
|
1098
|
-
function pickWinners(wanted, byCapability, rejected, allCandidates) {
|
|
1126
|
+
function pickWinners(wanted, byCapability, rejected, allCandidates, options) {
|
|
1099
1127
|
const bindings = {};
|
|
1100
1128
|
const selectedById = /* @__PURE__ */ new Map();
|
|
1101
1129
|
for (const moniker of wanted) {
|
|
1102
|
-
|
|
1130
|
+
let group = byCapability.get(moniker);
|
|
1131
|
+
const pinned = options.implementations?.[moniker];
|
|
1132
|
+
if (pinned !== void 0 && pinned !== "") {
|
|
1133
|
+
const pinnedGroup = group?.filter((descriptor) => descriptor.id === pinned);
|
|
1134
|
+
if (!pinnedGroup || pinnedGroup.length === 0) {
|
|
1135
|
+
throw new MissingCapabilityError(moniker, [`requested implementation '${pinned}' not available`]);
|
|
1136
|
+
}
|
|
1137
|
+
group = pinnedGroup;
|
|
1138
|
+
}
|
|
1103
1139
|
if (!group || group.length === 0) {
|
|
1104
1140
|
throw new MissingCapabilityError(moniker, reasonsFor(moniker, rejected, allCandidates));
|
|
1105
1141
|
}
|
|
@@ -1162,14 +1198,14 @@ import {
|
|
|
1162
1198
|
zodIsFactory as zodIsFactory2,
|
|
1163
1199
|
zodToFactory as zodToFactory2
|
|
1164
1200
|
} from "@xylabs/sdk-js";
|
|
1165
|
-
import { globalRegistry as
|
|
1201
|
+
import { globalRegistry as globalRegistry14, z as z20 } from "zod/mini";
|
|
1166
1202
|
|
|
1167
1203
|
// src/config/Base.ts
|
|
1168
|
-
import { z as
|
|
1204
|
+
import { z as z19 } from "zod/mini";
|
|
1169
1205
|
|
|
1170
1206
|
// src/config/Chain.ts
|
|
1171
1207
|
import { HexZod } from "@xylabs/sdk-js";
|
|
1172
|
-
import { XyoAddressZod } from "@xyo-network/
|
|
1208
|
+
import { XyoAddressZod } from "@xyo-network/sdk-js";
|
|
1173
1209
|
import { globalRegistry, z as z2 } from "zod/mini";
|
|
1174
1210
|
var ChainConfigZod = z2.object({
|
|
1175
1211
|
id: z2.optional(HexZod).register(globalRegistry, {
|
|
@@ -1278,8 +1314,24 @@ var LogConfigZod = z8.object({
|
|
|
1278
1314
|
})
|
|
1279
1315
|
});
|
|
1280
1316
|
|
|
1317
|
+
// src/config/ProviderBinding.ts
|
|
1318
|
+
import { globalRegistry as globalRegistry7, z as z9 } from "zod";
|
|
1319
|
+
var ProviderBindingConfigZod = z9.object({
|
|
1320
|
+
implementation: z9.string().optional().register(globalRegistry7, {
|
|
1321
|
+
description: "Installed provider implementation id (descriptor id)",
|
|
1322
|
+
title: "providerBindings.implementation",
|
|
1323
|
+
type: "string"
|
|
1324
|
+
}),
|
|
1325
|
+
transport: z9.string().optional().register(globalRegistry7, {
|
|
1326
|
+
description: "Named transport from the top-level transports map",
|
|
1327
|
+
title: "providerBindings.transport",
|
|
1328
|
+
type: "string"
|
|
1329
|
+
})
|
|
1330
|
+
}).describe("Provider implementation and transport binding");
|
|
1331
|
+
var ProviderBindingsConfigZod = z9.record(z9.string(), ProviderBindingConfigZod).default({});
|
|
1332
|
+
|
|
1281
1333
|
// src/config/Providers.ts
|
|
1282
|
-
import
|
|
1334
|
+
import z11 from "zod";
|
|
1283
1335
|
|
|
1284
1336
|
// src/config/Provider.ts
|
|
1285
1337
|
import {
|
|
@@ -1287,83 +1339,83 @@ import {
|
|
|
1287
1339
|
zodIsFactory,
|
|
1288
1340
|
zodToFactory
|
|
1289
1341
|
} from "@xylabs/sdk-js";
|
|
1290
|
-
import { z as
|
|
1291
|
-
var ProviderConfigZod =
|
|
1292
|
-
moniker:
|
|
1293
|
-
labels:
|
|
1342
|
+
import { z as z10 } from "zod";
|
|
1343
|
+
var ProviderConfigZod = z10.object({
|
|
1344
|
+
moniker: z10.string(),
|
|
1345
|
+
labels: z10.array(z10.string()).optional()
|
|
1294
1346
|
}).describe("Configuration for a Provider");
|
|
1295
1347
|
var isProviderConfig = zodIsFactory(ProviderConfigZod);
|
|
1296
1348
|
var asProviderConfig = zodAsFactory2(ProviderConfigZod, "asProviderConfig");
|
|
1297
1349
|
var toProviderConfig = zodToFactory(ProviderConfigZod, "toProviderConfig");
|
|
1298
1350
|
|
|
1299
1351
|
// src/config/Providers.ts
|
|
1300
|
-
var ProvidersConfigZod =
|
|
1352
|
+
var ProvidersConfigZod = z11.array(ProviderConfigZod.loose()).describe("Configuration for providers").default([]);
|
|
1301
1353
|
|
|
1302
1354
|
// src/config/Remote.ts
|
|
1303
|
-
import { globalRegistry as
|
|
1304
|
-
var RpcRemoteConfigBaseZod =
|
|
1305
|
-
protocol:
|
|
1355
|
+
import { globalRegistry as globalRegistry8, z as z12 } from "zod";
|
|
1356
|
+
var RpcRemoteConfigBaseZod = z12.object({
|
|
1357
|
+
protocol: z12.string("http").register(globalRegistry8, {
|
|
1306
1358
|
description: "Protocol for the RPC connection",
|
|
1307
1359
|
type: "string"
|
|
1308
1360
|
})
|
|
1309
1361
|
}).describe("Base configuration for the remote RPC");
|
|
1310
1362
|
var HttpRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1311
|
-
protocol:
|
|
1363
|
+
protocol: z12.string("http").register(globalRegistry8, {
|
|
1312
1364
|
description: "Protocol for the RPC connection",
|
|
1313
1365
|
type: "string"
|
|
1314
1366
|
}).default("http"),
|
|
1315
|
-
url:
|
|
1367
|
+
url: z12.string().register(globalRegistry8, {
|
|
1316
1368
|
description: "URL for the Chain RPC API",
|
|
1317
1369
|
type: "string"
|
|
1318
1370
|
})
|
|
1319
1371
|
}).describe("Configuration for the remote RPC using Http");
|
|
1320
1372
|
var PostMessageRpcRemoteConfigZod = RpcRemoteConfigBaseZod.extend({
|
|
1321
|
-
protocol:
|
|
1373
|
+
protocol: z12.string().register(globalRegistry8, {
|
|
1322
1374
|
description: "Protocol for the RPC connection",
|
|
1323
1375
|
type: "string"
|
|
1324
1376
|
}).default("postMessage"),
|
|
1325
|
-
networkId:
|
|
1377
|
+
networkId: z12.string().register(globalRegistry8, {
|
|
1326
1378
|
description: "Network ID to use for the postMessage RPC connection",
|
|
1327
1379
|
type: "string"
|
|
1328
1380
|
}),
|
|
1329
|
-
sessionId:
|
|
1381
|
+
sessionId: z12.string().register(globalRegistry8, {
|
|
1330
1382
|
description: "Session ID to use for the postMessage RPC connection",
|
|
1331
1383
|
type: "string"
|
|
1332
1384
|
})
|
|
1333
1385
|
}).describe("Configuration for the remote RPC using postMessage");
|
|
1334
|
-
var RpcRemoteConfigZod =
|
|
1335
|
-
var RemoteConfigZod =
|
|
1386
|
+
var RpcRemoteConfigZod = z12.union([HttpRpcRemoteConfigZod, PostMessageRpcRemoteConfigZod]).describe("Configuration for a remote RPC connection, either Http or postMessage");
|
|
1387
|
+
var RemoteConfigZod = z12.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
|
|
1336
1388
|
|
|
1337
1389
|
// src/config/storage/driver/Mongo.ts
|
|
1338
1390
|
import { isDefined as isDefined4, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
1339
|
-
import { globalRegistry as
|
|
1391
|
+
import { globalRegistry as globalRegistry9, z as z13 } from "zod";
|
|
1340
1392
|
var hasMongoConfig = (config) => {
|
|
1341
1393
|
if (isUndefined5(config)) return false;
|
|
1342
1394
|
return isDefined4(config.connectionString) && isDefined4(config.database) && isDefined4(config.domain);
|
|
1343
1395
|
};
|
|
1344
|
-
var MongoConfigZod =
|
|
1396
|
+
var MongoConfigZod = z13.object({
|
|
1345
1397
|
// TODO: Create from other arguments
|
|
1346
|
-
connectionString:
|
|
1398
|
+
connectionString: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1347
1399
|
description: "MongoDB connection string",
|
|
1348
1400
|
title: "storage.mongo.connectionString",
|
|
1349
1401
|
type: "string"
|
|
1350
1402
|
}),
|
|
1351
|
-
database:
|
|
1403
|
+
database: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1352
1404
|
description: "MongoDB database name",
|
|
1353
1405
|
title: "storage.mongo.database",
|
|
1354
1406
|
type: "string"
|
|
1355
1407
|
}),
|
|
1356
|
-
domain:
|
|
1408
|
+
domain: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1357
1409
|
description: "MongoDB domain",
|
|
1358
1410
|
title: "storage.mongo.domain",
|
|
1359
1411
|
type: "string"
|
|
1360
1412
|
}),
|
|
1361
|
-
password:
|
|
1413
|
+
password: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1362
1414
|
description: "MongoDB password",
|
|
1363
1415
|
title: "storage.mongo.password",
|
|
1364
1416
|
type: "string"
|
|
1365
1417
|
}),
|
|
1366
|
-
username:
|
|
1418
|
+
username: z13.string().nonempty().optional().register(globalRegistry9, {
|
|
1367
1419
|
description: "MongoDB username",
|
|
1368
1420
|
title: "storage.mongo.username",
|
|
1369
1421
|
type: "string"
|
|
@@ -1372,23 +1424,23 @@ var MongoConfigZod = z12.object({
|
|
|
1372
1424
|
|
|
1373
1425
|
// src/config/storage/driver/S3.ts
|
|
1374
1426
|
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
1375
|
-
import { z as
|
|
1376
|
-
var S3BucketConfigZod =
|
|
1377
|
-
accessKeyId:
|
|
1378
|
-
accountId:
|
|
1379
|
-
bucket:
|
|
1380
|
-
prefix:
|
|
1381
|
-
readUrl:
|
|
1382
|
-
secretAccessKey:
|
|
1427
|
+
import { z as z14 } from "zod";
|
|
1428
|
+
var S3BucketConfigZod = z14.object({
|
|
1429
|
+
accessKeyId: z14.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
|
|
1430
|
+
accountId: z14.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
|
|
1431
|
+
bucket: z14.string().nonempty().optional().describe("S3-compatible bucket name"),
|
|
1432
|
+
prefix: z14.string().nonempty().optional().describe("Optional key prefix within the bucket"),
|
|
1433
|
+
readUrl: z14.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
|
|
1434
|
+
secretAccessKey: z14.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
|
|
1383
1435
|
});
|
|
1384
|
-
var S3ConfigZod =
|
|
1385
|
-
accessKeyId:
|
|
1386
|
-
accountId:
|
|
1436
|
+
var S3ConfigZod = z14.object({
|
|
1437
|
+
accessKeyId: z14.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
|
|
1438
|
+
accountId: z14.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
|
|
1387
1439
|
chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
|
|
1388
1440
|
finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
|
|
1389
1441
|
index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
|
|
1390
|
-
prefix:
|
|
1391
|
-
secretAccessKey:
|
|
1442
|
+
prefix: z14.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
|
|
1443
|
+
secretAccessKey: z14.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
|
|
1392
1444
|
});
|
|
1393
1445
|
function resolveS3Bucket(config, which) {
|
|
1394
1446
|
if (config === void 0) return void 0;
|
|
@@ -1412,10 +1464,10 @@ function hasS3Config(config, which = "finalized") {
|
|
|
1412
1464
|
}
|
|
1413
1465
|
|
|
1414
1466
|
// src/config/storage/Storage.ts
|
|
1415
|
-
import { globalRegistry as
|
|
1416
|
-
var StorageConfigZod =
|
|
1467
|
+
import { globalRegistry as globalRegistry10, z as z15 } from "zod";
|
|
1468
|
+
var StorageConfigZod = z15.object({
|
|
1417
1469
|
mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
|
|
1418
|
-
root:
|
|
1470
|
+
root: z15.string().optional().register(globalRegistry10, {
|
|
1419
1471
|
description: "Root directory for local storage",
|
|
1420
1472
|
title: "storage.root",
|
|
1421
1473
|
type: "string"
|
|
@@ -1424,7 +1476,7 @@ var StorageConfigZod = z14.object({
|
|
|
1424
1476
|
}).describe("Storage configuration options");
|
|
1425
1477
|
|
|
1426
1478
|
// src/config/Telemetry.ts
|
|
1427
|
-
import { globalRegistry as
|
|
1479
|
+
import { globalRegistry as globalRegistry11, z as z16 } from "zod";
|
|
1428
1480
|
var DefaultMetricsScrapePorts = {
|
|
1429
1481
|
api: 9465,
|
|
1430
1482
|
bridge: 9468,
|
|
@@ -1432,38 +1484,89 @@ var DefaultMetricsScrapePorts = {
|
|
|
1432
1484
|
producer: 9464,
|
|
1433
1485
|
rewardRedemptionApi: 9467
|
|
1434
1486
|
};
|
|
1435
|
-
var MetricsScrapeConfigZod =
|
|
1436
|
-
path:
|
|
1487
|
+
var MetricsScrapeConfigZod = z16.object({
|
|
1488
|
+
path: z16.string().default("/metrics").register(globalRegistry11, {
|
|
1437
1489
|
default: "/metrics",
|
|
1438
1490
|
description: "Path for the metrics scrape endpoint",
|
|
1439
1491
|
title: "telemetry.metrics.scrape.path",
|
|
1440
1492
|
type: "string"
|
|
1441
1493
|
}),
|
|
1442
|
-
port:
|
|
1494
|
+
port: z16.coerce.number().int().positive().optional().register(globalRegistry11, {
|
|
1443
1495
|
description: "Port for the metrics scrape endpoint",
|
|
1444
1496
|
title: "telemetry.metrics.scrape.port",
|
|
1445
1497
|
type: "number"
|
|
1446
1498
|
})
|
|
1447
1499
|
}).describe("Metrics scrape configuration");
|
|
1448
|
-
var MetricsConfigZod =
|
|
1449
|
-
var OpenTelemetryConfigZod =
|
|
1500
|
+
var MetricsConfigZod = z16.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
|
|
1501
|
+
var OpenTelemetryConfigZod = z16.object({
|
|
1450
1502
|
// OpenTelemetry options
|
|
1451
|
-
otlpEndpoint:
|
|
1503
|
+
otlpEndpoint: z16.url().optional().register(globalRegistry11, {
|
|
1452
1504
|
description: "OTLP endpoint for exporting telemetry data",
|
|
1453
1505
|
title: "telemetry.otel.otlpEndpoint",
|
|
1454
1506
|
type: "string"
|
|
1455
1507
|
})
|
|
1456
1508
|
});
|
|
1457
|
-
var TelemetryConfigZod =
|
|
1509
|
+
var TelemetryConfigZod = z16.object({
|
|
1458
1510
|
// Metrics configuration
|
|
1459
1511
|
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
1460
1512
|
// OpenTelemetry configuration
|
|
1461
1513
|
otel: OpenTelemetryConfigZod.optional().describe("OpenTelemetry configuration")
|
|
1462
1514
|
}).describe("Telemetry configuration options");
|
|
1463
1515
|
|
|
1516
|
+
// src/config/transports/Transport.ts
|
|
1517
|
+
import { globalRegistry as globalRegistry12, z as z17 } from "zod";
|
|
1518
|
+
var LmdbTransportConfigZod = z17.object({
|
|
1519
|
+
type: z17.literal("lmdb"),
|
|
1520
|
+
root: z17.string().register(globalRegistry12, {
|
|
1521
|
+
description: "Root directory for local LMDB storage",
|
|
1522
|
+
title: "transports.lmdb.root",
|
|
1523
|
+
type: "string"
|
|
1524
|
+
})
|
|
1525
|
+
}).describe("LMDB local storage transport");
|
|
1526
|
+
var MongoTransportConfigZod = z17.object({
|
|
1527
|
+
type: z17.literal("mongo"),
|
|
1528
|
+
connectionString: MongoConfigZod.shape.connectionString,
|
|
1529
|
+
database: MongoConfigZod.shape.database,
|
|
1530
|
+
domain: MongoConfigZod.shape.domain,
|
|
1531
|
+
password: MongoConfigZod.shape.password,
|
|
1532
|
+
username: MongoConfigZod.shape.username
|
|
1533
|
+
}).describe("MongoDB storage transport");
|
|
1534
|
+
var RpcTransportConfigZod = HttpRpcRemoteConfigZod.extend({ type: z17.literal("rpc") }).describe("XL1 JSON-RPC transport");
|
|
1535
|
+
var RestTransportConfigZod = z17.object({
|
|
1536
|
+
type: z17.literal("rest"),
|
|
1537
|
+
baseUrl: z17.string().register(globalRegistry12, {
|
|
1538
|
+
description: "HTTP base URL for REST reads",
|
|
1539
|
+
title: "transports.rest.baseUrl",
|
|
1540
|
+
type: "string"
|
|
1541
|
+
})
|
|
1542
|
+
}).describe("HTTP REST read transport");
|
|
1543
|
+
var S3TransportConfigZod = S3BucketConfigZod.extend({
|
|
1544
|
+
type: z17.literal("s3"),
|
|
1545
|
+
accessKeyId: z17.string().optional(),
|
|
1546
|
+
accountId: z17.string().optional(),
|
|
1547
|
+
secretAccessKey: z17.string().optional()
|
|
1548
|
+
}).describe("S3-compatible object storage transport");
|
|
1549
|
+
var EvmRpcTransportConfigZod = z17.object({
|
|
1550
|
+
type: z17.literal("evm-rpc"),
|
|
1551
|
+
url: z17.string().register(globalRegistry12, {
|
|
1552
|
+
description: "EVM JSON-RPC URL",
|
|
1553
|
+
title: "transports.evm-rpc.url",
|
|
1554
|
+
type: "string"
|
|
1555
|
+
})
|
|
1556
|
+
}).describe("EVM JSON-RPC transport");
|
|
1557
|
+
var TransportConfigZod = z17.discriminatedUnion("type", [
|
|
1558
|
+
LmdbTransportConfigZod,
|
|
1559
|
+
MongoTransportConfigZod,
|
|
1560
|
+
RpcTransportConfigZod,
|
|
1561
|
+
RestTransportConfigZod,
|
|
1562
|
+
S3TransportConfigZod,
|
|
1563
|
+
EvmRpcTransportConfigZod
|
|
1564
|
+
]);
|
|
1565
|
+
var TransportsConfigZod = z17.record(z17.string(), TransportConfigZod).default({});
|
|
1566
|
+
|
|
1464
1567
|
// src/config/Validation.ts
|
|
1465
|
-
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/
|
|
1466
|
-
import { globalRegistry as
|
|
1568
|
+
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/sdk-js";
|
|
1569
|
+
import { globalRegistry as globalRegistry13, z as z18 } from "zod";
|
|
1467
1570
|
|
|
1468
1571
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
1469
1572
|
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -1608,7 +1711,9 @@ var DEFAULT_MAX_ATTEMPTS = 10;
|
|
|
1608
1711
|
var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, toleranceMs = DEFAULT_TOLERANCE_MS, maxAttempts = DEFAULT_MAX_ATTEMPTS) => {
|
|
1609
1712
|
assertEx10(Object.keys(timeConfig ?? {}).length === 1, () => "Only one time unit should be specified in timeConfig");
|
|
1610
1713
|
const startBlock = isDefinedNotNull(startBlockNumber) ? await viewer.blockByNumber(startBlockNumber) : null;
|
|
1611
|
-
const
|
|
1714
|
+
const currentBlockResult = await viewer.currentBlock();
|
|
1715
|
+
const blockResult = isDefinedNotNull(startBlock) ? startBlock : currentBlockResult;
|
|
1716
|
+
const resolvedStartBlock = blockResult[0];
|
|
1612
1717
|
const timeInMilliseconds = getTimeConfigInMilliseconds(timeConfig);
|
|
1613
1718
|
assertEx10(timeInMilliseconds > 0, () => "Time duration must be greater than zero");
|
|
1614
1719
|
const blocksPerMillisecondRate = 1 / (12 * 1e3);
|
|
@@ -1709,7 +1814,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1709
1814
|
|
|
1710
1815
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
1711
1816
|
import { assertEx as assertEx14, exists } from "@xylabs/sdk-js";
|
|
1712
|
-
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/
|
|
1817
|
+
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/sdk-js";
|
|
1713
1818
|
import {
|
|
1714
1819
|
asTransfer,
|
|
1715
1820
|
isTransfer,
|
|
@@ -1718,7 +1823,7 @@ import {
|
|
|
1718
1823
|
|
|
1719
1824
|
// src/primitives/payload/mergeTransfers.ts
|
|
1720
1825
|
import { hexToBigInt } from "@xylabs/sdk-js";
|
|
1721
|
-
import { toXyoAddress } from "@xyo-network/
|
|
1826
|
+
import { toXyoAddress } from "@xyo-network/sdk-js";
|
|
1722
1827
|
function mergeTransfers(transfers) {
|
|
1723
1828
|
const result = {};
|
|
1724
1829
|
for (const transfer of transfers) {
|
|
@@ -1772,7 +1877,9 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1772
1877
|
const [transferIndex, transferCount] = stepTransferIndex(block, step);
|
|
1773
1878
|
const [blockBw, payloads] = hydratedBlock;
|
|
1774
1879
|
const transfersFromPool = payloads.filter(isTransfer).map((p) => asTransfer(p)).filter(exists).filter((t) => t.from === XYO_STEP_REWARD_ADDRESS);
|
|
1775
|
-
const
|
|
1880
|
+
const mergedTransfers = mergeTransfers(transfersFromPool);
|
|
1881
|
+
const rewardEntry = Object.entries(mergedTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS);
|
|
1882
|
+
const fromEntries = Object.entries(rewardEntry?.[1] ?? {});
|
|
1776
1883
|
const sortedTransferAmounts = fromEntries.toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
1777
1884
|
assertEx14(
|
|
1778
1885
|
sortedTransferAmounts.length === transferCount,
|
|
@@ -1804,7 +1911,9 @@ var asOptionalAddressPairPayload = AsObjectFactory.createOptional(isAddressPairP
|
|
|
1804
1911
|
// src/payloads/netBalancesForPayloads.ts
|
|
1805
1912
|
import { hexToBigInt as hexToBigInt2 } from "@xylabs/sdk-js";
|
|
1806
1913
|
import { span } from "@xylabs/sdk-js";
|
|
1807
|
-
import {
|
|
1914
|
+
import {
|
|
1915
|
+
toXyoAddress as toXyoAddress3
|
|
1916
|
+
} from "@xyo-network/sdk-js";
|
|
1808
1917
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
1809
1918
|
var netBalancesForPayloads = (context, payloads) => {
|
|
1810
1919
|
return span("netBalancesForPayloads", () => {
|
|
@@ -1825,7 +1934,9 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1825
1934
|
// src/payloads/netSchemasForPayloads.ts
|
|
1826
1935
|
import { hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
1827
1936
|
import { span as span2 } from "@xylabs/sdk-js";
|
|
1828
|
-
import {
|
|
1937
|
+
import {
|
|
1938
|
+
toXyoAddress as toXyoAddress4
|
|
1939
|
+
} from "@xyo-network/sdk-js";
|
|
1829
1940
|
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol-lib";
|
|
1830
1941
|
var netSchemasForPayloads = (context, payloads) => {
|
|
1831
1942
|
return span2("netSchemasForPayloads", () => {
|
|
@@ -1880,8 +1991,10 @@ async function stepRewardTotal(context, blockViewer, { block, step }, multiplier
|
|
|
1880
1991
|
payloads.find((p) => isTransfer5(p) && p.from === XYO_STEP_REWARD_ADDRESS2),
|
|
1881
1992
|
() => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`
|
|
1882
1993
|
);
|
|
1994
|
+
const netTransfers = netTransfersForPayloads(context, [stepTransfer]);
|
|
1995
|
+
const rewardEntry = Object.entries(netTransfers).find(([address]) => address === XYO_STEP_REWARD_ADDRESS2);
|
|
1883
1996
|
const rewards = assertEx15(
|
|
1884
|
-
|
|
1997
|
+
rewardEntry?.[1],
|
|
1885
1998
|
() => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`
|
|
1886
1999
|
);
|
|
1887
2000
|
const sortedTransfers = Object.entries(rewards).toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
@@ -1922,7 +2035,7 @@ async function stepsRewardTotal(context, blockViewer, steps, multipliers) {
|
|
|
1922
2035
|
return asAttoXL12(totalRewards);
|
|
1923
2036
|
}
|
|
1924
2037
|
|
|
1925
|
-
// src/primitives/chain/time/
|
|
2038
|
+
// src/primitives/chain/time/externalBlockNumberFromXl1BlockNumber.ts
|
|
1926
2039
|
import { assertEx as assertEx16, isArray } from "@xylabs/sdk-js";
|
|
1927
2040
|
import {
|
|
1928
2041
|
asBlockNumber,
|
|
@@ -1943,7 +2056,7 @@ async function externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1Bl
|
|
|
1943
2056
|
});
|
|
1944
2057
|
}
|
|
1945
2058
|
|
|
1946
|
-
// src/primitives/chain/time/
|
|
2059
|
+
// src/primitives/chain/time/externalBlockRangeFromXl1BlockRange.ts
|
|
1947
2060
|
async function externalBlockRangeFromXL1BlockRange(context, blockViewer, xl1BlockRange, externalTimeName = "ethereum") {
|
|
1948
2061
|
const start = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[0], externalTimeName);
|
|
1949
2062
|
const end = await externalBlockNumberFromXL1BlockNumber(context, blockViewer, xl1BlockRange[1], externalTimeName);
|
|
@@ -1999,13 +2112,15 @@ function readPayloadMapFromStore(store) {
|
|
|
1999
2112
|
if (isReadArchivist(store)) {
|
|
2000
2113
|
return {
|
|
2001
2114
|
get: async (hash) => {
|
|
2002
|
-
|
|
2115
|
+
const results = await store.get([hash]);
|
|
2116
|
+
return results[0];
|
|
2003
2117
|
},
|
|
2004
2118
|
getMany: async (hashes) => {
|
|
2005
2119
|
return await store.get(hashes);
|
|
2006
2120
|
},
|
|
2007
2121
|
has: async (hash) => {
|
|
2008
|
-
|
|
2122
|
+
const results = await store.get([hash]);
|
|
2123
|
+
return isDefined12(results[0]);
|
|
2009
2124
|
}
|
|
2010
2125
|
};
|
|
2011
2126
|
}
|
|
@@ -2015,13 +2130,15 @@ function payloadMapFromStore(store) {
|
|
|
2015
2130
|
if (isReadWriteArchivist(store)) {
|
|
2016
2131
|
return {
|
|
2017
2132
|
get: async (hash) => {
|
|
2018
|
-
|
|
2133
|
+
const results = await store.get([hash]);
|
|
2134
|
+
return results[0];
|
|
2019
2135
|
},
|
|
2020
2136
|
getMany: async (hashes) => {
|
|
2021
2137
|
return await store.get(hashes);
|
|
2022
2138
|
},
|
|
2023
2139
|
has: async (hash) => {
|
|
2024
|
-
|
|
2140
|
+
const results = await store.get([hash]);
|
|
2141
|
+
return isDefined12(results[0]);
|
|
2025
2142
|
},
|
|
2026
2143
|
clear: async () => {
|
|
2027
2144
|
return await store.clear();
|
|
@@ -2081,7 +2198,8 @@ async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, st
|
|
|
2081
2198
|
|
|
2082
2199
|
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
2083
2200
|
async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
2084
|
-
const
|
|
2201
|
+
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, time], staked, staker);
|
|
2202
|
+
const stakeEvents = mergedEvents.toSorted((a, b) => a.time - b.time);
|
|
2085
2203
|
let result = 0n;
|
|
2086
2204
|
for (const event of stakeEvents) {
|
|
2087
2205
|
if (event.time > time) break;
|
|
@@ -2111,7 +2229,8 @@ async function mergedAddRemoveStakeEventsByPosition(chainEvents, range, position
|
|
|
2111
2229
|
|
|
2112
2230
|
// src/primitives/stake/activeStakeAtTimeByPosition.ts
|
|
2113
2231
|
async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, position) {
|
|
2114
|
-
const
|
|
2232
|
+
const mergedEvents = await mergedAddRemoveStakeEventsByPosition(chainStakeEvents, [0, externalTime], position);
|
|
2233
|
+
const stakeEvents = mergedEvents.toSorted((a, b) => a.time - b.time);
|
|
2115
2234
|
let result = 0n;
|
|
2116
2235
|
for (const event of stakeEvents) {
|
|
2117
2236
|
if (event.time > externalTime) break;
|
|
@@ -2127,7 +2246,7 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
|
|
|
2127
2246
|
}
|
|
2128
2247
|
|
|
2129
2248
|
// src/primitives/stake/allStakersForRange.ts
|
|
2130
|
-
import { toXyoAddress as toXyoAddress5 } from "@xyo-network/
|
|
2249
|
+
import { toXyoAddress as toXyoAddress5 } from "@xyo-network/sdk-js";
|
|
2131
2250
|
async function allStakersForRange(chain, externalRange, staked) {
|
|
2132
2251
|
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, externalRange[1]], staked);
|
|
2133
2252
|
const resultWithZeros = {};
|
|
@@ -2166,16 +2285,17 @@ async function weightedStakeForRangeByPosition(context, blockViewer, stakeEvents
|
|
|
2166
2285
|
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
2167
2286
|
let weightedStakeSum = 0n;
|
|
2168
2287
|
if (isDefined14(positionId)) {
|
|
2169
|
-
const
|
|
2288
|
+
const mergedEventsResult = await mergedAddRemoveStakeEventsByPosition(
|
|
2170
2289
|
stakeEventsViewer,
|
|
2171
2290
|
[0, externalRange[1]],
|
|
2172
2291
|
positionId
|
|
2173
|
-
)
|
|
2174
|
-
|
|
2175
|
-
let currentStake = 0n;
|
|
2292
|
+
);
|
|
2293
|
+
const mergedEvents = mergedEventsResult.toSorted((a, b) => a.time - b.time);
|
|
2176
2294
|
if (isDefined14(staked) && mergedEvents.at(0)?.args.staked !== staked) {
|
|
2177
2295
|
return 0n;
|
|
2178
2296
|
}
|
|
2297
|
+
let currentTime = externalRange[0];
|
|
2298
|
+
let currentStake = 0n;
|
|
2179
2299
|
for (const event of mergedEvents) {
|
|
2180
2300
|
if (event.time > currentTime) {
|
|
2181
2301
|
weightedStakeSum += currentStake * BigInt(event.time - currentTime);
|
|
@@ -2220,7 +2340,7 @@ async function networkStakeStepRewardPositionWeight(context, blockViewer, stakeE
|
|
|
2220
2340
|
// src/primitives/state/findMostRecentBlock.ts
|
|
2221
2341
|
import { isSignedBlockBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol-lib";
|
|
2222
2342
|
var DEFAULT_NEXT_OPTIONS = { limit: 50 };
|
|
2223
|
-
var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTIONS, maxIterations =
|
|
2343
|
+
var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTIONS, maxIterations = Infinity) => {
|
|
2224
2344
|
let mostRecentBlock;
|
|
2225
2345
|
let cursor;
|
|
2226
2346
|
let batch;
|
|
@@ -2236,9 +2356,8 @@ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTI
|
|
|
2236
2356
|
if (last) {
|
|
2237
2357
|
mostRecentBlock = last;
|
|
2238
2358
|
break;
|
|
2239
|
-
} else {
|
|
2240
|
-
cursor = batch.at(-1)?._sequence;
|
|
2241
2359
|
}
|
|
2360
|
+
cursor = batch.at(-1)?._sequence;
|
|
2242
2361
|
iterations = iterations + 1;
|
|
2243
2362
|
} while (batch.length > 0 && iterations < maxIterations);
|
|
2244
2363
|
return mostRecentBlock;
|
|
@@ -2251,7 +2370,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
2251
2370
|
if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
|
|
2252
2371
|
if (blockNumber > Number.MAX_SAFE_INTEGER) throw new Error(`Block number ${blockNumber} is greater than the maximum safe integer`);
|
|
2253
2372
|
if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
|
|
2254
|
-
const cacheKey =
|
|
2373
|
+
const cacheKey = String(blockNumber);
|
|
2255
2374
|
return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
|
|
2256
2375
|
const block = assertEx17(
|
|
2257
2376
|
await blockFromBlockNumber(context, blockNumber),
|
|
@@ -2264,7 +2383,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
2264
2383
|
|
|
2265
2384
|
// src/primitives/uncle/getProducerKey.ts
|
|
2266
2385
|
function getProducerKey(block) {
|
|
2267
|
-
return block[0].addresses.toSorted().join(",");
|
|
2386
|
+
return block[0].addresses.toSorted((a, b) => a.localeCompare(b)).join(",");
|
|
2268
2387
|
}
|
|
2269
2388
|
|
|
2270
2389
|
// src/primitives/uncle/scoreUncle.ts
|
|
@@ -2273,7 +2392,7 @@ function scoreUncle(finalizedWindowedChain, blocks) {
|
|
|
2273
2392
|
if (blocks.length === 0) return 0;
|
|
2274
2393
|
let score = blocks.length;
|
|
2275
2394
|
const head = finalizedWindowedChain.at(-1);
|
|
2276
|
-
if (head && blocks[0]) {
|
|
2395
|
+
if (head !== void 0 && blocks[0] !== void 0) {
|
|
2277
2396
|
const headProducer = getProducerKey(head);
|
|
2278
2397
|
const candidateProducer = getProducerKey(blocks[0]);
|
|
2279
2398
|
if (headProducer !== candidateProducer) {
|
|
@@ -2308,6 +2427,19 @@ import {
|
|
|
2308
2427
|
exists as exists2
|
|
2309
2428
|
} from "@xylabs/sdk-js";
|
|
2310
2429
|
import { isTransactionBoundWitness as isTransactionBoundWitness2 } from "@xyo-network/xl1-protocol-lib";
|
|
2430
|
+
function extendUncleChain(block, map) {
|
|
2431
|
+
const uncle = [block];
|
|
2432
|
+
let previous = block[0].previous ? map.get(block[0].previous) : void 0;
|
|
2433
|
+
while (previous) {
|
|
2434
|
+
if (previous[0].block === uncle[0][0].block - 1) {
|
|
2435
|
+
uncle.unshift(previous);
|
|
2436
|
+
previous = previous[0].previous ? map.get(previous[0].previous) : void 0;
|
|
2437
|
+
} else {
|
|
2438
|
+
return [];
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
return uncle;
|
|
2442
|
+
}
|
|
2311
2443
|
function blocksToChains(blocks) {
|
|
2312
2444
|
const chains = [];
|
|
2313
2445
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -2315,17 +2447,7 @@ function blocksToChains(blocks) {
|
|
|
2315
2447
|
map.set(block[0]._hash, block);
|
|
2316
2448
|
}
|
|
2317
2449
|
for (const block of blocks) {
|
|
2318
|
-
|
|
2319
|
-
let previous = block[0].previous ? map.get(block[0].previous) : void 0;
|
|
2320
|
-
while (previous) {
|
|
2321
|
-
if (previous[0].block === uncle[0][0].block - 1) {
|
|
2322
|
-
uncle.unshift(previous);
|
|
2323
|
-
previous = previous[0].previous ? map.get(previous[0].previous) : void 0;
|
|
2324
|
-
} else {
|
|
2325
|
-
uncle = [];
|
|
2326
|
-
break;
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2450
|
+
const uncle = extendUncleChain(block, map);
|
|
2329
2451
|
if (uncle.length > 0) {
|
|
2330
2452
|
chains.push(uncle);
|
|
2331
2453
|
}
|
|
@@ -2362,24 +2484,24 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2362
2484
|
}
|
|
2363
2485
|
|
|
2364
2486
|
// src/config/Validation.ts
|
|
2365
|
-
var ValidationConfigZod =
|
|
2366
|
-
allowedRewardRedeemers:
|
|
2487
|
+
var ValidationConfigZod = z18.object({
|
|
2488
|
+
allowedRewardRedeemers: z18.array(XyoAddressZod2).optional().register(globalRegistry13, {
|
|
2367
2489
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
2368
2490
|
title: "allowedRewardRedeemers",
|
|
2369
2491
|
type: "array"
|
|
2370
2492
|
}),
|
|
2371
|
-
allowedRewardEscrowAccountSigners:
|
|
2493
|
+
allowedRewardEscrowAccountSigners: z18.array(XyoAddressZod2).optional().register(globalRegistry13, {
|
|
2372
2494
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2373
2495
|
title: "allowedRewardEscrowAccountSigners",
|
|
2374
2496
|
type: "array"
|
|
2375
2497
|
}),
|
|
2376
|
-
minCandidates:
|
|
2498
|
+
minCandidates: z18.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry13, {
|
|
2377
2499
|
default: DEFAULT_MIN_CANDIDATES,
|
|
2378
2500
|
description: "Minimum number of uncle candidates before selecting the best uncle",
|
|
2379
2501
|
title: "validation.minCandidates",
|
|
2380
2502
|
type: "number"
|
|
2381
2503
|
}),
|
|
2382
|
-
backoffMs:
|
|
2504
|
+
backoffMs: z18.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry13, {
|
|
2383
2505
|
default: DEFAULT_BACKOFF_MS,
|
|
2384
2506
|
description: "Back-off timeout in ms. If head age exceeds this, minCandidates is ignored",
|
|
2385
2507
|
title: "validation.backoffMs",
|
|
@@ -2388,26 +2510,28 @@ var ValidationConfigZod = z16.object({
|
|
|
2388
2510
|
});
|
|
2389
2511
|
|
|
2390
2512
|
// src/config/Base.ts
|
|
2391
|
-
var BaseConfigZod =
|
|
2392
|
-
chain:
|
|
2393
|
-
dataLake:
|
|
2394
|
-
evm:
|
|
2395
|
-
log:
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2513
|
+
var BaseConfigZod = z19.object({
|
|
2514
|
+
chain: z19._default(ChainConfigZod, ChainConfigZod.parse({})).check(z19.describe("Configuration for the chain")),
|
|
2515
|
+
dataLake: z19.optional(DataLakeConfigZod).check(z19.describe("Configuration for data lakes")),
|
|
2516
|
+
evm: z19._default(EvmConfigZod, EvmConfigZod.parse({})).check(z19.describe("Configuration for EVM-backed services")),
|
|
2517
|
+
log: z19._default(LogConfigZod, LogConfigZod.parse({})).check(z19.describe("Configuration for logging")),
|
|
2518
|
+
providerBindings: z19._default(ProviderBindingsConfigZod, ProviderBindingsConfigZod.parse({})).check(z19.describe("Per-moniker provider implementation and transport bindings")),
|
|
2519
|
+
providers: z19._default(ProvidersConfigZod, ProvidersConfigZod.parse([])).check(z19.describe("Configuration for providers")),
|
|
2520
|
+
remote: z19._default(RemoteConfigZod, RemoteConfigZod.parse({})).check(z19.describe("Configuration for remote services")),
|
|
2521
|
+
transports: z19._default(TransportsConfigZod, TransportsConfigZod.parse({})).check(z19.describe("Named connection profiles (rpc, rest, s3, lmdb, mongo, evm-rpc)")),
|
|
2522
|
+
storage: z19._default(StorageConfigZod, StorageConfigZod.parse({})).check(z19.describe("Configuration for the storage")),
|
|
2523
|
+
telemetry: z19._default(TelemetryConfigZod, TelemetryConfigZod.parse({})).check(z19.describe("Configuration for telemetry")),
|
|
2524
|
+
validation: z19._default(ValidationConfigZod, ValidationConfigZod.parse({})).check(z19.describe("Configuration for validation"))
|
|
2401
2525
|
});
|
|
2402
2526
|
|
|
2403
2527
|
// src/config/Actor.ts
|
|
2404
|
-
var AccountPathZod =
|
|
2528
|
+
var AccountPathZod = z20.string().check(z20.regex(
|
|
2405
2529
|
/^(m(\/\d+'?)+|\d+'?(\/\d+'?)*)$/,
|
|
2406
2530
|
`Invalid BIP-32 derivation path. Use either an absolute path like "m/44'/60'/0'/0/0" or a relative path like "0", "0/1", or "44'/60'/0'/0/0".`
|
|
2407
2531
|
));
|
|
2408
|
-
var ActorConfigZod =
|
|
2409
|
-
name:
|
|
2410
|
-
accountPath:
|
|
2532
|
+
var ActorConfigZod = z20.extend(BaseConfigZod, {
|
|
2533
|
+
name: z20.string(),
|
|
2534
|
+
accountPath: z20.optional(AccountPathZod).register(globalRegistry14, {
|
|
2411
2535
|
description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with "m/"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',
|
|
2412
2536
|
title: "accountPath",
|
|
2413
2537
|
type: "string"
|
|
@@ -2418,22 +2542,25 @@ var asActorConfig = zodAsFactory3(ActorConfigZod, "asActorConfig");
|
|
|
2418
2542
|
var toActorConfig = zodToFactory2(ActorConfigZod, "toActorConfig");
|
|
2419
2543
|
|
|
2420
2544
|
// src/config/Actors.ts
|
|
2421
|
-
import { z as
|
|
2422
|
-
var ActorsConfigZod =
|
|
2423
|
-
|
|
2545
|
+
import { z as z21 } from "zod/mini";
|
|
2546
|
+
var ActorsConfigZod = z21._default(
|
|
2547
|
+
z21.array(z21.looseObject(ActorConfigZod.shape)).check(z21.describe("Actor-specific configurations that override the base configuration when the actor is running")),
|
|
2424
2548
|
[]
|
|
2425
2549
|
);
|
|
2426
2550
|
|
|
2551
|
+
// src/config/adaptLegacyConfig.ts
|
|
2552
|
+
import { isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
2553
|
+
|
|
2427
2554
|
// src/config/Config.ts
|
|
2428
|
-
import { globalRegistry as
|
|
2429
|
-
var ConfigZod =
|
|
2555
|
+
import { globalRegistry as globalRegistry15, z as z22 } from "zod/mini";
|
|
2556
|
+
var ConfigZod = z22.extend(BaseConfigZod, {
|
|
2430
2557
|
actors: ActorsConfigZod,
|
|
2431
|
-
healthCheckPort:
|
|
2558
|
+
healthCheckPort: z22.optional(z22.coerce.number()).register(globalRegistry15, {
|
|
2432
2559
|
description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
|
|
2433
2560
|
title: "healthCheckPort",
|
|
2434
2561
|
type: "number"
|
|
2435
2562
|
})
|
|
2436
|
-
}).check(
|
|
2563
|
+
}).check(z22.describe("The complete configuration for the protocol, including global settings and actor-specific overrides"));
|
|
2437
2564
|
function resolveConfig(config) {
|
|
2438
2565
|
const parsedConfig = ConfigZod.parse(config);
|
|
2439
2566
|
const {
|
|
@@ -2442,26 +2569,148 @@ function resolveConfig(config) {
|
|
|
2442
2569
|
...rootConfig
|
|
2443
2570
|
} = parsedConfig;
|
|
2444
2571
|
parsedConfig.actors = actors.map((actorConfig) => {
|
|
2445
|
-
return
|
|
2572
|
+
return z22.looseObject(ActorConfigZod.shape).parse({ ...rootConfig, ...actorConfig });
|
|
2446
2573
|
});
|
|
2447
2574
|
return parsedConfig;
|
|
2448
2575
|
}
|
|
2449
2576
|
|
|
2577
|
+
// src/config/adaptLegacyConfig.ts
|
|
2578
|
+
var DEFAULT_LMDB_TRANSPORT = "local-store";
|
|
2579
|
+
var DEFAULT_RPC_TRANSPORT = "default-rpc";
|
|
2580
|
+
var DEFAULT_EVM_RPC_TRANSPORT = "default-evm-rpc";
|
|
2581
|
+
var S3_FINALIZED_TRANSPORT = "s3-finalized";
|
|
2582
|
+
var S3_CHAIN_STATE_TRANSPORT = "s3-chain-state";
|
|
2583
|
+
var S3_INDEX_TRANSPORT = "s3-index";
|
|
2584
|
+
function rpcTransportFromRemote(rpc) {
|
|
2585
|
+
if (rpc.protocol === "http" && "url" in rpc) {
|
|
2586
|
+
const http = rpc;
|
|
2587
|
+
return {
|
|
2588
|
+
type: "rpc",
|
|
2589
|
+
protocol: "http",
|
|
2590
|
+
url: http.url
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
return {
|
|
2594
|
+
type: "rpc",
|
|
2595
|
+
protocol: rpc.protocol,
|
|
2596
|
+
url: "url" in rpc ? String(rpc.url) : ""
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function s3TransportFromBucket(shared, entry, fallbackBucket) {
|
|
2600
|
+
if (!isDefined15(entry?.bucket) && !isDefined15(entry?.readUrl)) {
|
|
2601
|
+
return void 0;
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
type: "s3",
|
|
2605
|
+
accessKeyId: entry?.accessKeyId ?? shared.accessKeyId,
|
|
2606
|
+
accountId: entry?.accountId ?? shared.accountId,
|
|
2607
|
+
bucket: entry?.bucket ?? fallbackBucket,
|
|
2608
|
+
prefix: entry?.prefix ?? shared.prefix,
|
|
2609
|
+
readUrl: entry?.readUrl,
|
|
2610
|
+
secretAccessKey: entry?.secretAccessKey ?? shared.secretAccessKey
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
function synthesizeS3Transports(s3) {
|
|
2614
|
+
const shared = {
|
|
2615
|
+
accessKeyId: s3.accessKeyId,
|
|
2616
|
+
accountId: s3.accountId,
|
|
2617
|
+
prefix: s3.prefix,
|
|
2618
|
+
secretAccessKey: s3.secretAccessKey
|
|
2619
|
+
};
|
|
2620
|
+
const transports = {};
|
|
2621
|
+
const finalized = s3TransportFromBucket(shared, s3.finalized);
|
|
2622
|
+
const fallbackBucket = s3.finalized?.bucket;
|
|
2623
|
+
if (finalized) {
|
|
2624
|
+
transports[S3_FINALIZED_TRANSPORT] = finalized;
|
|
2625
|
+
}
|
|
2626
|
+
const chainState = s3TransportFromBucket(shared, s3.chainState, fallbackBucket);
|
|
2627
|
+
if (chainState) {
|
|
2628
|
+
transports[S3_CHAIN_STATE_TRANSPORT] = chainState;
|
|
2629
|
+
}
|
|
2630
|
+
const index = s3TransportFromBucket(shared, s3.index, fallbackBucket);
|
|
2631
|
+
if (index) {
|
|
2632
|
+
transports[S3_INDEX_TRANSPORT] = index;
|
|
2633
|
+
}
|
|
2634
|
+
return transports;
|
|
2635
|
+
}
|
|
2636
|
+
function hasTransport(transports, key) {
|
|
2637
|
+
return Object.hasOwn(transports, key) && transports[key] !== void 0;
|
|
2638
|
+
}
|
|
2639
|
+
function synthesizeProviderBindings(transports) {
|
|
2640
|
+
const bindings = {};
|
|
2641
|
+
if (hasTransport(transports, DEFAULT_RPC_TRANSPORT)) {
|
|
2642
|
+
bindings.BlockViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2643
|
+
bindings.MempoolViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2644
|
+
bindings.FinalizationViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2645
|
+
bindings.TransactionViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2646
|
+
bindings.AccountBalanceViewer = { transport: DEFAULT_RPC_TRANSPORT };
|
|
2647
|
+
}
|
|
2648
|
+
if (hasTransport(transports, S3_FINALIZED_TRANSPORT)) {
|
|
2649
|
+
bindings.BlockPublishRunner = { transport: S3_FINALIZED_TRANSPORT };
|
|
2650
|
+
}
|
|
2651
|
+
if (hasTransport(transports, S3_CHAIN_STATE_TRANSPORT)) {
|
|
2652
|
+
bindings.ChainStateViewer = { transport: S3_CHAIN_STATE_TRANSPORT };
|
|
2653
|
+
bindings.ChainStatePublishRunner = { transport: S3_CHAIN_STATE_TRANSPORT };
|
|
2654
|
+
}
|
|
2655
|
+
if (hasTransport(transports, S3_INDEX_TRANSPORT)) {
|
|
2656
|
+
bindings.IndexPublishRunner = { transport: S3_INDEX_TRANSPORT };
|
|
2657
|
+
}
|
|
2658
|
+
return bindings;
|
|
2659
|
+
}
|
|
2660
|
+
function adaptLegacyConfig(config) {
|
|
2661
|
+
const parsed = ConfigZod.parse(config);
|
|
2662
|
+
if (Object.keys(parsed.transports).length > 0) {
|
|
2663
|
+
return parsed;
|
|
2664
|
+
}
|
|
2665
|
+
const transports = { ...parsed.transports };
|
|
2666
|
+
if (isDefined15(parsed.storage?.root) && parsed.storage.root !== "") {
|
|
2667
|
+
transports[DEFAULT_LMDB_TRANSPORT] = { type: "lmdb", root: parsed.storage.root };
|
|
2668
|
+
}
|
|
2669
|
+
if (hasMongoConfig(parsed.storage?.mongo)) {
|
|
2670
|
+
transports["chain-mongo"] = {
|
|
2671
|
+
type: "mongo",
|
|
2672
|
+
connectionString: parsed.storage.mongo.connectionString,
|
|
2673
|
+
database: parsed.storage.mongo.database,
|
|
2674
|
+
domain: parsed.storage.mongo.domain,
|
|
2675
|
+
password: parsed.storage.mongo.password,
|
|
2676
|
+
username: parsed.storage.mongo.username
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
if (isDefined15(parsed.remote?.rpc)) {
|
|
2680
|
+
transports[DEFAULT_RPC_TRANSPORT] = rpcTransportFromRemote(parsed.remote.rpc);
|
|
2681
|
+
}
|
|
2682
|
+
if (isDefined15(parsed.evm?.jsonRpc?.url)) {
|
|
2683
|
+
transports[DEFAULT_EVM_RPC_TRANSPORT] = { type: "evm-rpc", url: parsed.evm.jsonRpc.url };
|
|
2684
|
+
}
|
|
2685
|
+
if (isDefined15(parsed.storage?.s3)) {
|
|
2686
|
+
Object.assign(transports, synthesizeS3Transports(parsed.storage.s3));
|
|
2687
|
+
}
|
|
2688
|
+
const providerBindings = {
|
|
2689
|
+
...synthesizeProviderBindings(transports),
|
|
2690
|
+
...parsed.providerBindings
|
|
2691
|
+
};
|
|
2692
|
+
return ConfigZod.parse({
|
|
2693
|
+
...parsed,
|
|
2694
|
+
providerBindings,
|
|
2695
|
+
transports
|
|
2696
|
+
});
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2450
2699
|
// src/config/HostActor.ts
|
|
2451
2700
|
import {
|
|
2452
2701
|
zodAsFactory as zodAsFactory4,
|
|
2453
2702
|
zodIsFactory as zodIsFactory3,
|
|
2454
2703
|
zodToFactory as zodToFactory3
|
|
2455
2704
|
} from "@xylabs/sdk-js";
|
|
2456
|
-
import { globalRegistry as
|
|
2457
|
-
var HostActorConfigZod =
|
|
2458
|
-
host:
|
|
2705
|
+
import { globalRegistry as globalRegistry16, z as z23 } from "zod/mini";
|
|
2706
|
+
var HostActorConfigZod = z23.extend(ActorConfigZod, {
|
|
2707
|
+
host: z23._default(z23.string(), "localhost").register(globalRegistry16, {
|
|
2459
2708
|
default: "localhost",
|
|
2460
2709
|
description: "Host for the Actor",
|
|
2461
2710
|
title: "host",
|
|
2462
2711
|
type: "string"
|
|
2463
2712
|
}),
|
|
2464
|
-
port:
|
|
2713
|
+
port: z23._default(z23.coerce.number(), 8080).register(globalRegistry16, {
|
|
2465
2714
|
default: 8080,
|
|
2466
2715
|
description: "Port for the Actor",
|
|
2467
2716
|
title: "port",
|
|
@@ -2473,30 +2722,30 @@ var asHostActorConfig = zodAsFactory4(HostActorConfigZod, "asHostActorConfig");
|
|
|
2473
2722
|
var toHostActorConfig = zodToFactory3(HostActorConfigZod, "toHostActorConfig");
|
|
2474
2723
|
|
|
2475
2724
|
// src/config/UsageMeta.ts
|
|
2476
|
-
import { z as
|
|
2477
|
-
var DescriptionSchema =
|
|
2478
|
-
var TitleSchema =
|
|
2479
|
-
var JSONSchemaMetaSchema =
|
|
2480
|
-
id:
|
|
2725
|
+
import { z as z24 } from "zod";
|
|
2726
|
+
var DescriptionSchema = z24.string();
|
|
2727
|
+
var TitleSchema = z24.string();
|
|
2728
|
+
var JSONSchemaMetaSchema = z24.object({
|
|
2729
|
+
id: z24.string().optional(),
|
|
2481
2730
|
title: TitleSchema.optional(),
|
|
2482
2731
|
description: DescriptionSchema.optional(),
|
|
2483
|
-
deprecated:
|
|
2484
|
-
}).catchall(
|
|
2732
|
+
deprecated: z24.boolean().optional()
|
|
2733
|
+
}).catchall(z24.unknown());
|
|
2485
2734
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
2486
|
-
var ChoicesSchema =
|
|
2735
|
+
var ChoicesSchema = z24.array(z24.union([z24.string(), z24.number(), z24.literal(true), z24.undefined()])).readonly();
|
|
2487
2736
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
2488
2737
|
choices: ChoicesSchema.optional(),
|
|
2489
|
-
default:
|
|
2738
|
+
default: z24.unknown().optional(),
|
|
2490
2739
|
description: DescriptionSchema,
|
|
2491
|
-
group:
|
|
2492
|
-
hidden:
|
|
2740
|
+
group: z24.string().optional(),
|
|
2741
|
+
hidden: z24.boolean().optional(),
|
|
2493
2742
|
title: TitleSchema,
|
|
2494
|
-
type:
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2743
|
+
type: z24.union([
|
|
2744
|
+
z24.literal("array"),
|
|
2745
|
+
z24.literal("count"),
|
|
2746
|
+
z24.literal("boolean"),
|
|
2747
|
+
z24.literal("number"),
|
|
2748
|
+
z24.literal("string")
|
|
2500
2749
|
])
|
|
2501
2750
|
});
|
|
2502
2751
|
function isUsageMeta(v) {
|
|
@@ -2509,7 +2758,7 @@ import {
|
|
|
2509
2758
|
zodIsFactory as zodIsFactory5,
|
|
2510
2759
|
zodToFactory as zodToFactory5
|
|
2511
2760
|
} from "@xylabs/sdk-js";
|
|
2512
|
-
import { z as
|
|
2761
|
+
import { z as z26 } from "zod/mini";
|
|
2513
2762
|
|
|
2514
2763
|
// src/model/CreatableProviderContext.zod.ts
|
|
2515
2764
|
import {
|
|
@@ -2518,17 +2767,17 @@ import {
|
|
|
2518
2767
|
zodToFactory as zodToFactory4
|
|
2519
2768
|
} from "@xylabs/sdk-js";
|
|
2520
2769
|
import { CachingContextZod } from "@xyo-network/xl1-protocol-lib";
|
|
2521
|
-
import { z as
|
|
2522
|
-
var RuntimeStatusMonitorZod =
|
|
2523
|
-
var ProviderFactoryLocatorZod =
|
|
2524
|
-
var BaseConfigContextZod =
|
|
2525
|
-
config:
|
|
2526
|
-
locator:
|
|
2770
|
+
import { z as z25 } from "zod/mini";
|
|
2771
|
+
var RuntimeStatusMonitorZod = z25.custom((val) => val !== null && val !== void 0 && typeof val === "object");
|
|
2772
|
+
var ProviderFactoryLocatorZod = z25.lazy(() => z25.custom((val) => val !== null && val !== void 0 && typeof val === "object" && "context" in val && "registry" in val));
|
|
2773
|
+
var BaseConfigContextZod = z25.extend(CachingContextZod, {
|
|
2774
|
+
config: z25.looseObject(BaseConfigZod.shape),
|
|
2775
|
+
locator: z25.optional(ProviderFactoryLocatorZod)
|
|
2527
2776
|
});
|
|
2528
|
-
var CreatableProviderContextZod =
|
|
2529
|
-
_id:
|
|
2777
|
+
var CreatableProviderContextZod = z25.lazy(() => z25.extend(BaseConfigContextZod, {
|
|
2778
|
+
_id: z25.optional(z25.string()),
|
|
2530
2779
|
locator: ProviderFactoryLocatorZod,
|
|
2531
|
-
statusReporter:
|
|
2780
|
+
statusReporter: z25.optional(RuntimeStatusMonitorZod)
|
|
2532
2781
|
}));
|
|
2533
2782
|
var isBaseConfigContext = zodIsFactory4(BaseConfigContextZod);
|
|
2534
2783
|
var asBaseConfigContext = zodAsFactory5(BaseConfigContextZod, "asBaseConfigContext");
|
|
@@ -2568,7 +2817,9 @@ var hydratedBlockToPayloadBundle = (transaction) => {
|
|
|
2568
2817
|
};
|
|
2569
2818
|
var bundle = (root, transaction) => {
|
|
2570
2819
|
const payloads = flattenHydratedBlock(transaction).flatMap((p) => PayloadBuilder6.omitStorageMeta(p));
|
|
2571
|
-
|
|
2820
|
+
const payloadBuilder = new PayloadBuilder6({ schema: PayloadBundleSchema });
|
|
2821
|
+
const builder = payloadBuilder.fields({ payloads, root });
|
|
2822
|
+
return builder.build();
|
|
2572
2823
|
};
|
|
2573
2824
|
|
|
2574
2825
|
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
@@ -2599,10 +2850,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2599
2850
|
exp
|
|
2600
2851
|
};
|
|
2601
2852
|
const elevatedHashes = await PayloadBuilder7.hashes(onChainPayloads);
|
|
2602
|
-
const script =
|
|
2603
|
-
for (const elevatedHash of elevatedHashes) {
|
|
2604
|
-
script.push(`elevate|${elevatedHash}`);
|
|
2605
|
-
}
|
|
2853
|
+
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
2606
2854
|
const fields = {
|
|
2607
2855
|
...txBoundWitnessFields,
|
|
2608
2856
|
from: from ?? (Array.isArray(signer) ? assertEx19(signer.at(0)?.address) : signer.address)
|
|
@@ -2610,7 +2858,9 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2610
2858
|
if (script.length > 0) {
|
|
2611
2859
|
fields.script = script;
|
|
2612
2860
|
}
|
|
2613
|
-
const
|
|
2861
|
+
const boundWitnessBuilder = new BoundWitnessBuilder();
|
|
2862
|
+
const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).signers(Array.isArray(signer) ? signer : [signer]);
|
|
2863
|
+
const [tx, txPayloads] = await builder.build();
|
|
2614
2864
|
return [await PayloadBuilder7.addHashMeta(tx), await PayloadBuilder7.addHashMeta(txPayloads.map((p) => asAnyPayload2(p, true)))];
|
|
2615
2865
|
}
|
|
2616
2866
|
|
|
@@ -2631,10 +2881,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
2631
2881
|
exp
|
|
2632
2882
|
};
|
|
2633
2883
|
const elevatedHashes = await PayloadBuilder8.hashes(onChainPayloads);
|
|
2634
|
-
const script =
|
|
2635
|
-
for (const elevatedHash of elevatedHashes) {
|
|
2636
|
-
script.push(`elevate|${elevatedHash}`);
|
|
2637
|
-
}
|
|
2884
|
+
const script = Array.from(elevatedHashes, (elevatedHash) => `elevate|${elevatedHash}`);
|
|
2638
2885
|
const fields = {
|
|
2639
2886
|
...txBoundWitnessFields,
|
|
2640
2887
|
from
|
|
@@ -2642,14 +2889,16 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
2642
2889
|
if (script.length > 0) {
|
|
2643
2890
|
fields.script = script;
|
|
2644
2891
|
}
|
|
2645
|
-
const
|
|
2892
|
+
const boundWitnessBuilder = new BoundWitnessBuilder2();
|
|
2893
|
+
const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]);
|
|
2894
|
+
const [tx, txPayloads] = await builder.build(false);
|
|
2646
2895
|
return [tx, txPayloads];
|
|
2647
2896
|
}
|
|
2648
2897
|
|
|
2649
2898
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
2650
2899
|
import {
|
|
2651
2900
|
delay,
|
|
2652
|
-
isDefined as
|
|
2901
|
+
isDefined as isDefined16,
|
|
2653
2902
|
isNumber
|
|
2654
2903
|
} from "@xylabs/sdk-js";
|
|
2655
2904
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -2671,22 +2920,20 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2671
2920
|
let attempts = 0;
|
|
2672
2921
|
while (true) {
|
|
2673
2922
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
2674
|
-
if (
|
|
2923
|
+
if (isDefined16(tx)) {
|
|
2675
2924
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
2676
2925
|
return tx;
|
|
2677
|
-
} else {
|
|
2678
|
-
if (isNumber(exp)) {
|
|
2679
|
-
await assertNotExpired(viewer, txHash, exp, options);
|
|
2680
|
-
}
|
|
2681
|
-
attempts++;
|
|
2682
|
-
if (attempts > maxAttempts) {
|
|
2683
|
-
options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
|
|
2684
|
-
throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
|
|
2685
|
-
} else {
|
|
2686
|
-
options?.logger?.debug(`Transaction not confirmed yet, attempt ${attempts}. Retrying...`, txHash);
|
|
2687
|
-
await delay(attemptDelay);
|
|
2688
|
-
}
|
|
2689
2926
|
}
|
|
2927
|
+
if (isNumber(exp)) {
|
|
2928
|
+
await assertNotExpired(viewer, txHash, exp, options);
|
|
2929
|
+
}
|
|
2930
|
+
attempts++;
|
|
2931
|
+
if (attempts > maxAttempts) {
|
|
2932
|
+
options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
|
|
2933
|
+
throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
|
|
2934
|
+
}
|
|
2935
|
+
options?.logger?.debug(`Transaction not confirmed yet, attempt ${attempts}. Retrying...`, txHash);
|
|
2936
|
+
await delay(attemptDelay);
|
|
2690
2937
|
}
|
|
2691
2938
|
};
|
|
2692
2939
|
|
|
@@ -2705,9 +2952,7 @@ import {
|
|
|
2705
2952
|
var tryHydrateTransaction = async ({ chainMap }, hash) => {
|
|
2706
2953
|
return await tryHydrateTypedBoundWitness(
|
|
2707
2954
|
{
|
|
2708
|
-
get(hashes)
|
|
2709
|
-
return chainMap.get(hashes);
|
|
2710
|
-
},
|
|
2955
|
+
get: (hashes) => chainMap.get(hashes),
|
|
2711
2956
|
next() {
|
|
2712
2957
|
throw new Error("Not implemented");
|
|
2713
2958
|
}
|
|
@@ -2719,9 +2964,7 @@ var tryHydrateTransaction = async ({ chainMap }, hash) => {
|
|
|
2719
2964
|
var hydrateTransaction = async ({ chainMap }, hash) => {
|
|
2720
2965
|
return await hydrateTypedBoundWitness(
|
|
2721
2966
|
{
|
|
2722
|
-
get(hashes)
|
|
2723
|
-
return chainMap.get(hashes);
|
|
2724
|
-
},
|
|
2967
|
+
get: (hashes) => chainMap.get(hashes),
|
|
2725
2968
|
next() {
|
|
2726
2969
|
throw new Error("Not implemented");
|
|
2727
2970
|
}
|
|
@@ -2982,11 +3225,13 @@ var hydratedTransactionToPayloadBundle = (transaction) => {
|
|
|
2982
3225
|
};
|
|
2983
3226
|
var bundle2 = (root, transaction) => {
|
|
2984
3227
|
const payloads = flattenHydratedTransaction(transaction);
|
|
2985
|
-
|
|
3228
|
+
const payloadBuilder = new PayloadBuilder12({ schema: PayloadBundleSchema2 });
|
|
3229
|
+
const builder = payloadBuilder.fields({ payloads, root });
|
|
3230
|
+
return builder.build();
|
|
2986
3231
|
};
|
|
2987
3232
|
|
|
2988
3233
|
// src/context/Actor.ts
|
|
2989
|
-
var ActorConfigContext =
|
|
3234
|
+
var ActorConfigContext = z26.extend(BaseConfigContextZod, { config: ActorConfigZod });
|
|
2990
3235
|
var isActorConfigContext = zodIsFactory5(ActorConfigContext);
|
|
2991
3236
|
var asActorConfigContext = zodAsFactory6(ActorConfigContext, "asActorConfigContext");
|
|
2992
3237
|
var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigContext");
|
|
@@ -3028,7 +3273,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3028
3273
|
get resolvedMoniker() {
|
|
3029
3274
|
const labels = this.labels ?? {};
|
|
3030
3275
|
const labelString = Object.entries(labels).map(([key, value]) => `${key}=${value}`).join(",");
|
|
3031
|
-
return labelString.length === 0 ?
|
|
3276
|
+
return labelString.length === 0 ? this.defaultMoniker : `${this.defaultMoniker}|${labelString}`;
|
|
3032
3277
|
}
|
|
3033
3278
|
get uniqueId() {
|
|
3034
3279
|
return this._uniqueId;
|
|
@@ -3043,8 +3288,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3043
3288
|
let scopeObject;
|
|
3044
3289
|
switch (this.scope) {
|
|
3045
3290
|
case "global": {
|
|
3046
|
-
|
|
3047
|
-
scopeObject = globalThis.xyoServiceSingletons;
|
|
3291
|
+
scopeObject = getOrCreateGlobalSingletons();
|
|
3048
3292
|
break;
|
|
3049
3293
|
}
|
|
3050
3294
|
case "context": {
|
|
@@ -3081,6 +3325,15 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3081
3325
|
}
|
|
3082
3326
|
}
|
|
3083
3327
|
};
|
|
3328
|
+
function getOrCreateGlobalSingletons() {
|
|
3329
|
+
const existing = globalThis.xyoServiceSingletons;
|
|
3330
|
+
if (existing !== void 0) {
|
|
3331
|
+
return existing;
|
|
3332
|
+
}
|
|
3333
|
+
const singletons = {};
|
|
3334
|
+
Reflect.set(globalThis, "xyoServiceSingletons", singletons);
|
|
3335
|
+
return singletons;
|
|
3336
|
+
}
|
|
3084
3337
|
|
|
3085
3338
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3086
3339
|
var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
@@ -3266,7 +3519,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3266
3519
|
);
|
|
3267
3520
|
}
|
|
3268
3521
|
has(moniker) {
|
|
3269
|
-
return
|
|
3522
|
+
return Object.hasOwn(this._registry, moniker);
|
|
3270
3523
|
}
|
|
3271
3524
|
/**
|
|
3272
3525
|
* Locates a provider factory that matches the supplied moniker and labels
|
|
@@ -3283,10 +3536,11 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3283
3536
|
merge(locator) {
|
|
3284
3537
|
const registry = { ...this.registry };
|
|
3285
3538
|
for (const moniker in locator.registry) {
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
} else {
|
|
3539
|
+
const existing = registry[moniker];
|
|
3540
|
+
if (existing === void 0) {
|
|
3289
3541
|
registry[moniker] = locator.registry[moniker];
|
|
3542
|
+
} else {
|
|
3543
|
+
existing.push(...locator.registry[moniker] ?? []);
|
|
3290
3544
|
}
|
|
3291
3545
|
}
|
|
3292
3546
|
return new _ProviderFactoryLocator(this.context, registry);
|
|
@@ -3316,13 +3570,13 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3316
3570
|
return this;
|
|
3317
3571
|
}
|
|
3318
3572
|
registered(moniker) {
|
|
3319
|
-
return
|
|
3573
|
+
return Object.hasOwn(this.registry, moniker) || (this._parent?.registered(moniker) ?? false);
|
|
3320
3574
|
}
|
|
3321
3575
|
async tryGetInstance(moniker, { start = true, labels } = {}) {
|
|
3322
3576
|
const resolvedParams = { context: this.context };
|
|
3323
3577
|
const factory = this.tryLocate(moniker, labels);
|
|
3324
|
-
if (factory) {
|
|
3325
|
-
if (this.context.singletons
|
|
3578
|
+
if (factory !== void 0) {
|
|
3579
|
+
if (Object.hasOwn(this.context.singletons, factory.uniqueId)) {
|
|
3326
3580
|
return this.context.singletons[factory.uniqueId];
|
|
3327
3581
|
}
|
|
3328
3582
|
this.logger?.debug(`Creating provider instance for moniker [${moniker}]${labels ? ` with labels [${JSON.stringify(labels)}]` : ""} using factory [${factory.uniqueId.description}]`);
|
|
@@ -3376,27 +3630,28 @@ import {
|
|
|
3376
3630
|
zodIsFactory as zodIsFactory6,
|
|
3377
3631
|
zodToFactory as zodToFactory6
|
|
3378
3632
|
} from "@xylabs/sdk-js";
|
|
3379
|
-
import { z as
|
|
3380
|
-
var HostActorConfigContext =
|
|
3633
|
+
import { z as z27 } from "zod/mini";
|
|
3634
|
+
var HostActorConfigContext = z27.extend(BaseConfigContextZod, { config: HostActorConfigZod });
|
|
3381
3635
|
var isHostActorConfigContext = zodIsFactory6(HostActorConfigContext);
|
|
3382
3636
|
var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActorConfigContext");
|
|
3383
3637
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3384
3638
|
|
|
3385
3639
|
// src/createDeclarationPayload.ts
|
|
3386
|
-
import { isDefined as
|
|
3640
|
+
import { isDefined as isDefined17 } from "@xylabs/sdk-js";
|
|
3387
3641
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3388
3642
|
import {
|
|
3389
3643
|
ChainStakeIntentSchema
|
|
3390
3644
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3391
3645
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3392
|
-
const expiration =
|
|
3393
|
-
const
|
|
3646
|
+
const expiration = isDefined17(exp) ? exp : nbf + 1e4;
|
|
3647
|
+
const payloadBuilder = new PayloadBuilder13({ schema: ChainStakeIntentSchema });
|
|
3648
|
+
const builder = payloadBuilder.fields({
|
|
3394
3649
|
from: address,
|
|
3395
3650
|
intent,
|
|
3396
3651
|
nbf,
|
|
3397
3652
|
exp: expiration
|
|
3398
|
-
})
|
|
3399
|
-
return
|
|
3653
|
+
});
|
|
3654
|
+
return builder.build();
|
|
3400
3655
|
};
|
|
3401
3656
|
|
|
3402
3657
|
// src/createTransferPayload.ts
|
|
@@ -3404,12 +3659,14 @@ import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
|
3404
3659
|
import { PayloadBuilder as PayloadBuilder14 } from "@xyo-network/sdk-js";
|
|
3405
3660
|
import { TransferSchema } from "@xyo-network/xl1-protocol-lib";
|
|
3406
3661
|
function createTransferPayload(from, transfers, context) {
|
|
3407
|
-
|
|
3662
|
+
const payloadBuilder = new PayloadBuilder14({ schema: TransferSchema });
|
|
3663
|
+
const builder = payloadBuilder.fields({
|
|
3408
3664
|
epoch: Date.now(),
|
|
3409
3665
|
from,
|
|
3410
3666
|
transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex3(v)])),
|
|
3411
3667
|
context
|
|
3412
|
-
})
|
|
3668
|
+
});
|
|
3669
|
+
return builder.build();
|
|
3413
3670
|
}
|
|
3414
3671
|
|
|
3415
3672
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
@@ -3418,26 +3675,26 @@ import {
|
|
|
3418
3675
|
asSchema as asSchema2,
|
|
3419
3676
|
isPayloadOfZodType
|
|
3420
3677
|
} from "@xyo-network/sdk-js";
|
|
3421
|
-
import { z as
|
|
3678
|
+
import { z as z29 } from "zod";
|
|
3422
3679
|
|
|
3423
3680
|
// src/eip-712/Types.ts
|
|
3424
|
-
import { z as
|
|
3425
|
-
var TypedDataDomainZod =
|
|
3426
|
-
name:
|
|
3427
|
-
version:
|
|
3428
|
-
chainId:
|
|
3429
|
-
verifyingContract:
|
|
3430
|
-
salt:
|
|
3681
|
+
import { z as z28 } from "zod";
|
|
3682
|
+
var TypedDataDomainZod = z28.object({
|
|
3683
|
+
name: z28.string().nullable().optional(),
|
|
3684
|
+
version: z28.string().nullable().optional(),
|
|
3685
|
+
chainId: z28.union([z28.string(), z28.number(), z28.bigint()]).nullable().optional(),
|
|
3686
|
+
verifyingContract: z28.string().nullable().optional(),
|
|
3687
|
+
salt: z28.union([z28.string(), z28.instanceof(Uint8Array)]).nullable().optional()
|
|
3431
3688
|
});
|
|
3432
|
-
var TypedDataFieldZod =
|
|
3433
|
-
name:
|
|
3434
|
-
type:
|
|
3689
|
+
var TypedDataFieldZod = z28.object({
|
|
3690
|
+
name: z28.string(),
|
|
3691
|
+
type: z28.string()
|
|
3435
3692
|
});
|
|
3436
|
-
var TypedDataTypesZod =
|
|
3437
|
-
var TypedDataValueZod =
|
|
3693
|
+
var TypedDataTypesZod = z28.record(z28.string(), z28.array(TypedDataFieldZod));
|
|
3694
|
+
var TypedDataValueZod = z28.record(z28.string(), z28.any());
|
|
3438
3695
|
|
|
3439
3696
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
3440
|
-
var EIP712DataPayloadFieldsZod =
|
|
3697
|
+
var EIP712DataPayloadFieldsZod = z29.object({
|
|
3441
3698
|
domain: TypedDataDomainZod,
|
|
3442
3699
|
types: TypedDataTypesZod,
|
|
3443
3700
|
values: TypedDataValueZod
|
|
@@ -3455,11 +3712,11 @@ import {
|
|
|
3455
3712
|
asSchema as asSchema3,
|
|
3456
3713
|
isPayloadOfZodType as isPayloadOfZodType2
|
|
3457
3714
|
} from "@xyo-network/sdk-js";
|
|
3458
|
-
import { z as
|
|
3459
|
-
var EIP712SignaturePayloadFieldsZod =
|
|
3460
|
-
address:
|
|
3715
|
+
import { z as z30 } from "zod";
|
|
3716
|
+
var EIP712SignaturePayloadFieldsZod = z30.object({
|
|
3717
|
+
address: z30.string(),
|
|
3461
3718
|
hash: HashZod,
|
|
3462
|
-
signature:
|
|
3719
|
+
signature: z30.string()
|
|
3463
3720
|
});
|
|
3464
3721
|
var EIP712SignaturePayloadSchema = asSchema3("network.xyo.chains.ethereum.eip712.signature", true);
|
|
3465
3722
|
var isEIP712SignaturePayload = isPayloadOfZodType2(
|
|
@@ -3543,11 +3800,11 @@ var isPositiveBigInt = (value) => {
|
|
|
3543
3800
|
var parseSignedBigInt = (value) => {
|
|
3544
3801
|
if (isNegativeBigInt(value)) {
|
|
3545
3802
|
return -hexToBigInt5(value.negative);
|
|
3546
|
-
}
|
|
3803
|
+
}
|
|
3804
|
+
if (isPositiveBigInt(value)) {
|
|
3547
3805
|
return hexToBigInt5(value.positive);
|
|
3548
|
-
} else {
|
|
3549
|
-
throw new Error("Invalid balance type");
|
|
3550
3806
|
}
|
|
3807
|
+
throw new Error("Invalid balance type");
|
|
3551
3808
|
};
|
|
3552
3809
|
var toSignedBigInt = (value) => {
|
|
3553
3810
|
return value < 0n ? { negative: toHex4(-value) } : { positive: toHex4(value) };
|
|
@@ -3570,7 +3827,7 @@ import {
|
|
|
3570
3827
|
asHash as asHash4,
|
|
3571
3828
|
assertEx as assertEx33,
|
|
3572
3829
|
exists as exists3,
|
|
3573
|
-
isDefined as
|
|
3830
|
+
isDefined as isDefined18,
|
|
3574
3831
|
ZERO_ADDRESS
|
|
3575
3832
|
} from "@xylabs/sdk-js";
|
|
3576
3833
|
import {
|
|
@@ -3664,39 +3921,38 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3664
3921
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3665
3922
|
if (isAnyPayload3(summaryResult)) {
|
|
3666
3923
|
return summaryResult;
|
|
3667
|
-
}
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
}
|
|
3684
|
-
}
|
|
3685
|
-
const balances = {};
|
|
3686
|
-
for (const [address, balance] of Object.entries(bigIntBalances)) {
|
|
3687
|
-
balances[address] = toSignedBigInt(balance);
|
|
3924
|
+
}
|
|
3925
|
+
await semaphores[step].acquire();
|
|
3926
|
+
try {
|
|
3927
|
+
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
3928
|
+
const promises = subRanges.map((subRange) => balancesStepSummaryFromRange(
|
|
3929
|
+
context,
|
|
3930
|
+
semaphores,
|
|
3931
|
+
blockViewer,
|
|
3932
|
+
summaryMap,
|
|
3933
|
+
subRange
|
|
3934
|
+
));
|
|
3935
|
+
const subResults = await Promise.all(promises);
|
|
3936
|
+
const bigIntBalances = {};
|
|
3937
|
+
for (const subResult of subResults) {
|
|
3938
|
+
for (const [address, balance] of Object.entries(subResult.balances)) {
|
|
3939
|
+
bigIntBalances[address] = (bigIntBalances[address] ?? 0n) + parseSignedBigInt(balance);
|
|
3688
3940
|
}
|
|
3689
|
-
const result = {
|
|
3690
|
-
schema: BalancesStepSummarySchema,
|
|
3691
|
-
hash: frameHead._hash,
|
|
3692
|
-
stepSize: frameSize,
|
|
3693
|
-
balances
|
|
3694
|
-
};
|
|
3695
|
-
await summaryMap.set(key, result);
|
|
3696
|
-
return result;
|
|
3697
|
-
} finally {
|
|
3698
|
-
semaphores[step].release();
|
|
3699
3941
|
}
|
|
3942
|
+
const balances = {};
|
|
3943
|
+
for (const [address, balance] of Object.entries(bigIntBalances)) {
|
|
3944
|
+
balances[address] = toSignedBigInt(balance);
|
|
3945
|
+
}
|
|
3946
|
+
const result = {
|
|
3947
|
+
schema: BalancesStepSummarySchema,
|
|
3948
|
+
hash: frameHead._hash,
|
|
3949
|
+
stepSize: frameSize,
|
|
3950
|
+
balances
|
|
3951
|
+
};
|
|
3952
|
+
await summaryMap.set(key, result);
|
|
3953
|
+
return result;
|
|
3954
|
+
} finally {
|
|
3955
|
+
semaphores[step].release();
|
|
3700
3956
|
}
|
|
3701
3957
|
}, { ...context, timeBudgetLimit: 500 });
|
|
3702
3958
|
}, { ...context, timeBudgetLimit: 500 });
|
|
@@ -3705,7 +3961,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3705
3961
|
|
|
3706
3962
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3707
3963
|
import { assertEx as assertEx27, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
3708
|
-
import { asXyoAddress } from "@xyo-network/
|
|
3964
|
+
import { asXyoAddress } from "@xyo-network/sdk-js";
|
|
3709
3965
|
import {
|
|
3710
3966
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
3711
3967
|
asXL1BlockRange as asXL1BlockRange7,
|
|
@@ -3991,7 +4247,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3991
4247
|
|
|
3992
4248
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3993
4249
|
import { assertEx as assertEx32, spanRootAsync as spanRootAsync7 } from "@xylabs/sdk-js";
|
|
3994
|
-
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/
|
|
4250
|
+
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/sdk-js";
|
|
3995
4251
|
import {
|
|
3996
4252
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
3997
4253
|
asXL1BlockRange as asXL1BlockRange9,
|
|
@@ -4051,14 +4307,16 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4051
4307
|
return balances[address] ?? AttoXL13(0n);
|
|
4052
4308
|
}
|
|
4053
4309
|
async accountBalanceHistories(addresses, config = {}) {
|
|
4054
|
-
|
|
4310
|
+
const [histories] = await this.qualifiedAccountBalanceHistories(addresses, config);
|
|
4311
|
+
return histories;
|
|
4055
4312
|
}
|
|
4056
4313
|
async accountBalanceHistory(address, config) {
|
|
4057
4314
|
return await this.spanAsync("accountBalanceHistory", async () => {
|
|
4058
4315
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : void 0;
|
|
4059
4316
|
const startingRange = asXL1BlockRange10(range ?? [0, await this.blockViewer.currentBlockNumber()], true);
|
|
4060
4317
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4061
|
-
const
|
|
4318
|
+
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
4319
|
+
const blocks = blockResults.filter(exists3);
|
|
4062
4320
|
const result = [];
|
|
4063
4321
|
for (const block of blocks) {
|
|
4064
4322
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
@@ -4068,7 +4326,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4068
4326
|
block[1].find((p) => p._hash === hash),
|
|
4069
4327
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4070
4328
|
);
|
|
4071
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4329
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined18(t.transfers[address]));
|
|
4072
4330
|
if (transfers.length === 0) {
|
|
4073
4331
|
continue;
|
|
4074
4332
|
}
|
|
@@ -4187,10 +4445,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4187
4445
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4188
4446
|
const range = asRange(headOrRange);
|
|
4189
4447
|
const headHash = asHash4(headOrRange);
|
|
4190
|
-
const [head] = assertEx33(
|
|
4448
|
+
const [head] = assertEx33(isDefined18(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4191
4449
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4192
4450
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4193
|
-
const
|
|
4451
|
+
const blockResults = await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)));
|
|
4452
|
+
const blocks = blockResults.filter(exists3);
|
|
4194
4453
|
const result = [];
|
|
4195
4454
|
for (const block of blocks) {
|
|
4196
4455
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
@@ -4200,7 +4459,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4200
4459
|
block[1].find((p) => p._hash === hash),
|
|
4201
4460
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4202
4461
|
);
|
|
4203
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4462
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined18(t.transfers[address]));
|
|
4204
4463
|
if (transfers.length === 0) {
|
|
4205
4464
|
continue;
|
|
4206
4465
|
}
|
|
@@ -4267,12 +4526,12 @@ var HydratedCache = class {
|
|
|
4267
4526
|
};
|
|
4268
4527
|
|
|
4269
4528
|
// src/utils/isZodError.ts
|
|
4270
|
-
import { z as
|
|
4529
|
+
import { z as z31 } from "zod";
|
|
4271
4530
|
var isZodError = (error) => {
|
|
4272
|
-
return error instanceof
|
|
4531
|
+
return error instanceof z31.ZodError;
|
|
4273
4532
|
};
|
|
4274
4533
|
var prettifyZodError = (error) => {
|
|
4275
|
-
return
|
|
4534
|
+
return z31.prettifyError(error);
|
|
4276
4535
|
};
|
|
4277
4536
|
|
|
4278
4537
|
// src/simple/block/SimpleBlockViewer.ts
|
|
@@ -4382,7 +4641,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4382
4641
|
}
|
|
4383
4642
|
async blocksByStep(stepLevel, stepIndex) {
|
|
4384
4643
|
return await this.spanAsync("blocksByStep", async () => {
|
|
4385
|
-
assertEx34(Number.
|
|
4644
|
+
assertEx34(Number.isSafeInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
|
|
4386
4645
|
const size = stepSize2(stepLevel);
|
|
4387
4646
|
assertEx34(
|
|
4388
4647
|
stepLevel <= blocksMaxStep,
|
|
@@ -4406,7 +4665,12 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4406
4665
|
}
|
|
4407
4666
|
async chainId(blockNumber = "latest") {
|
|
4408
4667
|
return await this.spanAsync("chainId", async () => {
|
|
4409
|
-
|
|
4668
|
+
if (blockNumber === "latest") {
|
|
4669
|
+
const headBlock = await this.finalizationViewer.headBlock();
|
|
4670
|
+
return headBlock.chain;
|
|
4671
|
+
}
|
|
4672
|
+
const block = assertEx34(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`);
|
|
4673
|
+
return block[0].chain;
|
|
4410
4674
|
}, this.context);
|
|
4411
4675
|
}
|
|
4412
4676
|
async createHandler() {
|
|
@@ -4455,9 +4719,10 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4455
4719
|
};
|
|
4456
4720
|
}
|
|
4457
4721
|
async getChainContextRead() {
|
|
4722
|
+
const headBlock = await this.finalizationViewer.head();
|
|
4458
4723
|
return {
|
|
4459
4724
|
...this.getBlockContextRead(),
|
|
4460
|
-
head:
|
|
4725
|
+
head: headBlock[0]
|
|
4461
4726
|
};
|
|
4462
4727
|
}
|
|
4463
4728
|
async startHandler() {
|
|
@@ -4504,10 +4769,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4504
4769
|
}, this.headPollIntervalMs);
|
|
4505
4770
|
}
|
|
4506
4771
|
stopHeadPolling() {
|
|
4507
|
-
if (this._headPollTimer) {
|
|
4508
|
-
|
|
4509
|
-
this._headPollTimer = null;
|
|
4772
|
+
if (!this._headPollTimer) {
|
|
4773
|
+
return;
|
|
4510
4774
|
}
|
|
4775
|
+
clearInterval(this._headPollTimer);
|
|
4776
|
+
this._headPollTimer = null;
|
|
4511
4777
|
}
|
|
4512
4778
|
};
|
|
4513
4779
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
@@ -4588,13 +4854,18 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4588
4854
|
head: void 0
|
|
4589
4855
|
};
|
|
4590
4856
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4857
|
+
let head;
|
|
4858
|
+
if (isChainQualifiedHeadConfig5(config)) {
|
|
4859
|
+
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
4860
|
+
head = headBlockResult == null ? assertEx35(
|
|
4861
|
+
void 0,
|
|
4862
|
+
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4863
|
+
) : headBlockResult[0];
|
|
4864
|
+
}
|
|
4865
|
+
const currentBlock = await this.blockViewer.currentBlock();
|
|
4866
|
+
const headBlock = head ?? currentBlock[0];
|
|
4867
|
+
const validateProtocol = value === true ? this.doValidateProtocol.bind(this) : void 0;
|
|
4868
|
+
const validateState = state === true ? this.doValidateState.bind(this) : void 0;
|
|
4598
4869
|
const chainIdAtBlockNumber = (blockNumber) => this.chainContractViewer.chainIdAtBlockNumber(blockNumber);
|
|
4599
4870
|
const qualification = { head: headBlock._hash, range: asXL1BlockRange12([0, headBlock.block], true) };
|
|
4600
4871
|
const [protocolResults, stateResults] = await Promise.all([
|
|
@@ -4617,13 +4888,16 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4617
4888
|
throw new Error("Method not implemented.");
|
|
4618
4889
|
}
|
|
4619
4890
|
async validateBlock(block, config) {
|
|
4620
|
-
|
|
4891
|
+
const results = await this.validateBlocks([block], config);
|
|
4892
|
+
return results[0];
|
|
4621
4893
|
}
|
|
4622
4894
|
async validateBlocks(blocks, config) {
|
|
4623
|
-
|
|
4895
|
+
const results = await this.qualifiedValidateBlocks(blocks, config);
|
|
4896
|
+
return results[0];
|
|
4624
4897
|
}
|
|
4625
4898
|
async validateUncle(blocks, config) {
|
|
4626
|
-
|
|
4899
|
+
const results = await this.qualifiedValidateUncle(blocks, config);
|
|
4900
|
+
return results[0];
|
|
4627
4901
|
}
|
|
4628
4902
|
async doValidateProtocol(blocks, chainIdAtBlockNumber) {
|
|
4629
4903
|
return await Promise.all(blocks.map(async (block) => {
|
|
@@ -4681,7 +4955,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4681
4955
|
return this.finalizationViewer.chainId();
|
|
4682
4956
|
}
|
|
4683
4957
|
async chainIdAtBlockNumber(blockNumber) {
|
|
4684
|
-
return await withContextCacheResponse(this.context, "chainIdAtBlockNumber",
|
|
4958
|
+
return await withContextCacheResponse(this.context, "chainIdAtBlockNumber", String(blockNumber), async () => {
|
|
4685
4959
|
let chainId = this.chainId();
|
|
4686
4960
|
let contractViewer = this;
|
|
4687
4961
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
@@ -4742,7 +5016,7 @@ var SimpleXyoClient = class {
|
|
|
4742
5016
|
import { assertEx as assertEx37, exists as exists6 } from "@xylabs/sdk-js";
|
|
4743
5017
|
import { isAnyPayload as isAnyPayload8, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
4744
5018
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
4745
|
-
import { z as
|
|
5019
|
+
import { z as z32 } from "zod/mini";
|
|
4746
5020
|
|
|
4747
5021
|
// src/simple/datalake/AbstractRestDataLake.ts
|
|
4748
5022
|
import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
@@ -4764,14 +5038,16 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
|
4764
5038
|
return this.params.endpoint;
|
|
4765
5039
|
}
|
|
4766
5040
|
async get(hashes) {
|
|
4767
|
-
|
|
5041
|
+
const results = await Promise.all(hashes.map((hash) => this.getOne(hash)));
|
|
5042
|
+
return results.filter(exists5);
|
|
4768
5043
|
}
|
|
4769
5044
|
next(_options) {
|
|
4770
5045
|
throw new Error("Method not implemented.");
|
|
4771
5046
|
}
|
|
4772
5047
|
async getOne(hash) {
|
|
4773
5048
|
try {
|
|
4774
|
-
|
|
5049
|
+
const response = await this.client.get(`${this.params.endpoint}/get/${hash}`);
|
|
5050
|
+
return asAnyPayload4(response.data);
|
|
4775
5051
|
} catch (ex) {
|
|
4776
5052
|
if (ex instanceof FetchClientError && (ex.response.status === 400 || ex.response.status === 404)) {
|
|
4777
5053
|
return void 0;
|
|
@@ -4789,7 +5065,7 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
|
4789
5065
|
if (this.allowedSchemas && !this.allowedSchemas.includes(schema)) {
|
|
4790
5066
|
return false;
|
|
4791
5067
|
}
|
|
4792
|
-
if (this.disallowedSchemas?.includes(schema)) {
|
|
5068
|
+
if (this.disallowedSchemas?.includes(schema) === true) {
|
|
4793
5069
|
return false;
|
|
4794
5070
|
}
|
|
4795
5071
|
return true;
|
|
@@ -4815,10 +5091,9 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4815
5091
|
}).filter(exists6);
|
|
4816
5092
|
if (allowedItems.length > 0) {
|
|
4817
5093
|
const result = await this.client.post(`${this.params.endpoint}/insert`, allowedItems);
|
|
4818
|
-
return
|
|
4819
|
-
} else {
|
|
4820
|
-
return [];
|
|
5094
|
+
return z32.array(PayloadZodLoose).parse(result.data);
|
|
4821
5095
|
}
|
|
5096
|
+
return [];
|
|
4822
5097
|
}
|
|
4823
5098
|
};
|
|
4824
5099
|
__publicField(RestDataLakeRunner, "defaultMoniker", DataLakeRunnerMoniker);
|
|
@@ -4874,7 +5149,7 @@ var AbstractSimpleDataLake = class extends AbstractCreatableProvider {
|
|
|
4874
5149
|
if (this.allowedSchemas && !this.allowedSchemas.includes(schema)) {
|
|
4875
5150
|
return false;
|
|
4876
5151
|
}
|
|
4877
|
-
if (this.disallowedSchemas?.includes(schema)) {
|
|
5152
|
+
if (this.disallowedSchemas?.includes(schema) === true) {
|
|
4878
5153
|
return false;
|
|
4879
5154
|
}
|
|
4880
5155
|
return true;
|
|
@@ -4888,10 +5163,12 @@ var SimpleDataLakeRunner = class extends AbstractSimpleDataLake {
|
|
|
4888
5163
|
await this.map.clear();
|
|
4889
5164
|
}
|
|
4890
5165
|
async delete(hashes) {
|
|
4891
|
-
|
|
5166
|
+
const deleteResults = await Promise.all(hashes.map(async (hash) => {
|
|
4892
5167
|
const payload = await this.map.get(hash);
|
|
4893
|
-
|
|
4894
|
-
|
|
5168
|
+
const deleted = await this.map.delete(hash);
|
|
5169
|
+
return deleted ? payload : void 0;
|
|
5170
|
+
}));
|
|
5171
|
+
return deleteResults.filter(exists7);
|
|
4895
5172
|
}
|
|
4896
5173
|
async insert(items) {
|
|
4897
5174
|
const payloads = items.filter(isAnyPayload10).filter((i) => this.isAllowed(i));
|
|
@@ -4934,7 +5211,8 @@ var SimpleFinalizationRunner = class extends AbstractCreatableProvider {
|
|
|
4934
5211
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4935
5212
|
}
|
|
4936
5213
|
async finalizeBlock(block) {
|
|
4937
|
-
|
|
5214
|
+
const results = await this.finalizeBlocks([block]);
|
|
5215
|
+
return results[0];
|
|
4938
5216
|
}
|
|
4939
5217
|
async finalizeBlocks(blocks) {
|
|
4940
5218
|
const sortedBlocks = blocks.toSorted((a, b) => a[0].block - b[0].block);
|
|
@@ -4988,7 +5266,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4988
5266
|
}
|
|
4989
5267
|
async createHandler() {
|
|
4990
5268
|
await super.createHandler();
|
|
4991
|
-
|
|
5269
|
+
const mostRecentBlock = await findMostRecentBlock(this.params.finalizedArchivist);
|
|
5270
|
+
this._chainId = assertEx38(this.config.chain.id ?? mostRecentBlock?.chain, () => "chain.id is required if empty archivist");
|
|
4992
5271
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4993
5272
|
}
|
|
4994
5273
|
async head() {
|
|
@@ -5003,13 +5282,16 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5003
5282
|
}, this.context);
|
|
5004
5283
|
}
|
|
5005
5284
|
async headBlock() {
|
|
5006
|
-
|
|
5285
|
+
const headBlock = await this.head();
|
|
5286
|
+
return headBlock[0];
|
|
5007
5287
|
}
|
|
5008
5288
|
async headHash() {
|
|
5009
|
-
|
|
5289
|
+
const headBlock = await this.headBlock();
|
|
5290
|
+
return headBlock._hash;
|
|
5010
5291
|
}
|
|
5011
5292
|
async headNumber() {
|
|
5012
|
-
|
|
5293
|
+
const headBlock = await this.headBlock();
|
|
5294
|
+
return headBlock.block;
|
|
5013
5295
|
}
|
|
5014
5296
|
getBlockContextRead() {
|
|
5015
5297
|
return {
|
|
@@ -5018,9 +5300,10 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
5018
5300
|
};
|
|
5019
5301
|
}
|
|
5020
5302
|
async getChainContextRead() {
|
|
5303
|
+
const headBlock = await this.head();
|
|
5021
5304
|
return {
|
|
5022
5305
|
...this.getBlockContextRead(),
|
|
5023
|
-
head:
|
|
5306
|
+
head: headBlock[0]
|
|
5024
5307
|
};
|
|
5025
5308
|
}
|
|
5026
5309
|
async getCurrentHead() {
|
|
@@ -5058,7 +5341,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5058
5341
|
import {
|
|
5059
5342
|
assertEx as assertEx39,
|
|
5060
5343
|
BigIntToJsonZod,
|
|
5061
|
-
isDefined as
|
|
5344
|
+
isDefined as isDefined19
|
|
5062
5345
|
} from "@xylabs/sdk-js";
|
|
5063
5346
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5064
5347
|
import {
|
|
@@ -5096,9 +5379,9 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5096
5379
|
chain,
|
|
5097
5380
|
fees
|
|
5098
5381
|
} = options ?? {};
|
|
5099
|
-
const resolvedChainId =
|
|
5100
|
-
const resolvedNbf = asXL1BlockNumber10(
|
|
5101
|
-
const resolvedExp = asXL1BlockNumber10(
|
|
5382
|
+
const resolvedChainId = isDefined19(chain) ? chain : await viewer.chainId();
|
|
5383
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined19(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5384
|
+
const resolvedExp = asXL1BlockNumber10(isDefined19(exp) ? exp : resolvedNbf + 10, true);
|
|
5102
5385
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5103
5386
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5104
5387
|
}
|
|
@@ -5142,11 +5425,13 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5142
5425
|
BigIntToJsonZod.parse(amount)
|
|
5143
5426
|
])
|
|
5144
5427
|
);
|
|
5145
|
-
const
|
|
5428
|
+
const payloadBuilder = new PayloadBuilder20({ schema: TransferSchema3 });
|
|
5429
|
+
const transferBuilder = payloadBuilder.fields({
|
|
5146
5430
|
from,
|
|
5147
5431
|
transfers: hexTransfers,
|
|
5148
5432
|
epoch: Date.now()
|
|
5149
|
-
})
|
|
5433
|
+
});
|
|
5434
|
+
const transfer = transferBuilder.build();
|
|
5150
5435
|
const [hash] = await this.addPayloadsToChain([transfer], [], options);
|
|
5151
5436
|
return hash;
|
|
5152
5437
|
}
|
|
@@ -5267,10 +5552,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5267
5552
|
const valid = blocks.map((b) => !!b);
|
|
5268
5553
|
const remainingBlockMap = [];
|
|
5269
5554
|
const remainingBlocks = blocks.map((b, i) => {
|
|
5270
|
-
if (b) {
|
|
5271
|
-
|
|
5272
|
-
return b;
|
|
5555
|
+
if (!b) {
|
|
5556
|
+
return;
|
|
5273
5557
|
}
|
|
5558
|
+
remainingBlockMap.push(i);
|
|
5559
|
+
return b;
|
|
5274
5560
|
}).filter(exists8);
|
|
5275
5561
|
assertEx40(
|
|
5276
5562
|
remainingBlockMap.length === remainingBlocks.length,
|
|
@@ -5289,7 +5575,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5289
5575
|
valid[remainingBlockMap[i]] = validated;
|
|
5290
5576
|
}
|
|
5291
5577
|
const pruneHashes = bundles.map((p, i) => {
|
|
5292
|
-
if (
|
|
5578
|
+
if (valid.at(i) !== true) {
|
|
5293
5579
|
return p._hash;
|
|
5294
5580
|
}
|
|
5295
5581
|
}).filter(exists8);
|
|
@@ -5329,10 +5615,11 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5329
5615
|
const valid = transactions.map((t) => !!t);
|
|
5330
5616
|
const remainingTransactionMap = [];
|
|
5331
5617
|
const remainingTransactions = transactions.map((t, i) => {
|
|
5332
|
-
if (t) {
|
|
5333
|
-
|
|
5334
|
-
return t;
|
|
5618
|
+
if (!t) {
|
|
5619
|
+
return;
|
|
5335
5620
|
}
|
|
5621
|
+
remainingTransactionMap.push(i);
|
|
5622
|
+
return t;
|
|
5336
5623
|
}).filter(exists8);
|
|
5337
5624
|
assertEx40(
|
|
5338
5625
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
@@ -5352,7 +5639,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5352
5639
|
valid[remainingTransactionMap[i]] = validated;
|
|
5353
5640
|
}
|
|
5354
5641
|
const pruneHashes = bundles.map((p, i) => {
|
|
5355
|
-
if (
|
|
5642
|
+
if (valid.at(i) !== true) {
|
|
5356
5643
|
return p._hash;
|
|
5357
5644
|
}
|
|
5358
5645
|
}).filter(exists8);
|
|
@@ -5586,7 +5873,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
5586
5873
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
5587
5874
|
import {
|
|
5588
5875
|
exists as exists9,
|
|
5589
|
-
isDefined as
|
|
5876
|
+
isDefined as isDefined20,
|
|
5590
5877
|
isHash as isHash2
|
|
5591
5878
|
} from "@xylabs/sdk-js";
|
|
5592
5879
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -5647,7 +5934,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5647
5934
|
let cursor = void 0;
|
|
5648
5935
|
if (isHash2(providedCursor)) {
|
|
5649
5936
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
5650
|
-
if (
|
|
5937
|
+
if (isDefined20(p)) {
|
|
5651
5938
|
cursor = p._sequence;
|
|
5652
5939
|
}
|
|
5653
5940
|
}
|
|
@@ -5657,7 +5944,8 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5657
5944
|
cursor
|
|
5658
5945
|
});
|
|
5659
5946
|
const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
|
|
5660
|
-
|
|
5947
|
+
const hydratedBlocks = await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)));
|
|
5948
|
+
return hydratedBlocks.filter(exists9);
|
|
5661
5949
|
}
|
|
5662
5950
|
async pendingTransactions({
|
|
5663
5951
|
cursor: providedCursor,
|
|
@@ -5666,7 +5954,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5666
5954
|
let cursor = void 0;
|
|
5667
5955
|
if (isHash2(providedCursor)) {
|
|
5668
5956
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
5669
|
-
if (
|
|
5957
|
+
if (isDefined20(p)) {
|
|
5670
5958
|
cursor = p._sequence;
|
|
5671
5959
|
}
|
|
5672
5960
|
}
|
|
@@ -5678,12 +5966,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5678
5966
|
});
|
|
5679
5967
|
this.logger?.debug(`Fetched pending transactions: ${bundles.length} bundles`);
|
|
5680
5968
|
const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
|
|
5681
|
-
const hydratedWithBundle =
|
|
5682
|
-
filteredBundles.map(async (bundle3) => {
|
|
5683
|
-
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
5684
|
-
return isDefined19(tx) ? { bundle: bundle3, tx } : void 0;
|
|
5685
|
-
})
|
|
5686
|
-
)).filter(exists9);
|
|
5969
|
+
const hydratedWithBundle = await this.hydratePendingBundles(filteredBundles);
|
|
5687
5970
|
const currentBlock = await this.windowedBlockViewer.currentBlock();
|
|
5688
5971
|
const currentBlockNumber = currentBlock[0].block;
|
|
5689
5972
|
const evaluated = await Promise.all(
|
|
@@ -5704,9 +5987,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5704
5987
|
})
|
|
5705
5988
|
);
|
|
5706
5989
|
this.gcHandoutStats(currentBlockNumber);
|
|
5707
|
-
const inclusionCandidates =
|
|
5708
|
-
if (await this.isInclusionCandidate(tx, currentBlock, false)) return { bundle: bundle3, tx };
|
|
5709
|
-
}))).filter(exists9);
|
|
5990
|
+
const inclusionCandidates = await this.filterInclusionCandidates(validTransactions, currentBlock);
|
|
5710
5991
|
const selectionRatio = this.params.mempoolSelectionRatio ?? DEFAULT_MEMPOOL_SELECTION_RATIO;
|
|
5711
5992
|
const nonDemoted = inclusionCandidates.filter(({ bundle: bundle3 }) => !this.isDemoted(bundle3._hash));
|
|
5712
5993
|
const demoted = inclusionCandidates.filter(({ bundle: bundle3 }) => this.isDemoted(bundle3._hash));
|
|
@@ -5730,12 +6011,27 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5730
6011
|
async deleteBundledTransaction(bundle3) {
|
|
5731
6012
|
await this.pendingTransactionsArchivist.delete([bundle3._hash]);
|
|
5732
6013
|
}
|
|
6014
|
+
async filterInclusionCandidates(validTransactions, currentBlock) {
|
|
6015
|
+
const inclusionResults = await Promise.all(validTransactions.map(async ({ bundle: bundle3, tx }) => {
|
|
6016
|
+
if (await this.isInclusionCandidate(tx, currentBlock, false)) return { bundle: bundle3, tx };
|
|
6017
|
+
}));
|
|
6018
|
+
return inclusionResults.filter(exists9);
|
|
6019
|
+
}
|
|
5733
6020
|
gcHandoutStats(currentBlockNumber) {
|
|
5734
6021
|
const ttl = this.handoutStatsTtlBlocks;
|
|
5735
6022
|
for (const [hash, stats] of this._handoutStats) {
|
|
5736
6023
|
if (currentBlockNumber - stats.firstHandoutAt > ttl) this._handoutStats.delete(hash);
|
|
5737
6024
|
}
|
|
5738
6025
|
}
|
|
6026
|
+
async hydratePendingBundles(filteredBundles) {
|
|
6027
|
+
const hydratedResults = await Promise.all(
|
|
6028
|
+
filteredBundles.map(async (bundle3) => {
|
|
6029
|
+
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
6030
|
+
return isDefined20(tx) ? { bundle: bundle3, tx } : void 0;
|
|
6031
|
+
})
|
|
6032
|
+
);
|
|
6033
|
+
return hydratedResults.filter(exists9);
|
|
6034
|
+
}
|
|
5739
6035
|
/**
|
|
5740
6036
|
* Evaluates a transaction to determine if it should be purged from the mempool.
|
|
5741
6037
|
* @param tx The transaction to evaluate
|
|
@@ -5793,7 +6089,7 @@ SimpleMempoolViewer = __decorateClass([
|
|
|
5793
6089
|
function deduplicateWithBundleBySigner(items) {
|
|
5794
6090
|
const seen = /* @__PURE__ */ new Set();
|
|
5795
6091
|
return items.filter(({ tx }) => {
|
|
5796
|
-
const key = tx[0].addresses.toSorted().join(",");
|
|
6092
|
+
const key = tx[0].addresses.toSorted((a, b) => a.localeCompare(b)).join(",");
|
|
5797
6093
|
if (seen.has(key)) return false;
|
|
5798
6094
|
seen.add(key);
|
|
5799
6095
|
return true;
|
|
@@ -5859,13 +6155,12 @@ var SimpleXyoNetwork = class {
|
|
|
5859
6155
|
const response = await fetchJsonGet(url);
|
|
5860
6156
|
if (isNetworkStatus(response.data)) {
|
|
5861
6157
|
return response.data;
|
|
5862
|
-
} else {
|
|
5863
|
-
if (response.status === 200) {
|
|
5864
|
-
this.logger?.error("Unknown network status response", response.data);
|
|
5865
|
-
return unknownStatus;
|
|
5866
|
-
}
|
|
5867
|
-
return errorStatus;
|
|
5868
6158
|
}
|
|
6159
|
+
if (response.status === 200) {
|
|
6160
|
+
this.logger?.error("Unknown network status response", response.data);
|
|
6161
|
+
return unknownStatus;
|
|
6162
|
+
}
|
|
6163
|
+
return errorStatus;
|
|
5869
6164
|
} catch (error) {
|
|
5870
6165
|
this.logger?.error("Error fetching network status", error);
|
|
5871
6166
|
return errorStatus;
|
|
@@ -6032,7 +6327,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6032
6327
|
};
|
|
6033
6328
|
|
|
6034
6329
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
6035
|
-
import { isDefined as
|
|
6330
|
+
import { isDefined as isDefined21 } from "@xylabs/sdk-js";
|
|
6036
6331
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
6037
6332
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
6038
6333
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -6045,7 +6340,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
6045
6340
|
stakeEvents(range, { name } = {}) {
|
|
6046
6341
|
const positions = this.positionsFromRange(range);
|
|
6047
6342
|
const events = this.eventsFromPositions(positions);
|
|
6048
|
-
if (
|
|
6343
|
+
if (isDefined21(name)) {
|
|
6049
6344
|
return events.filter((event) => event.name === name);
|
|
6050
6345
|
}
|
|
6051
6346
|
return events;
|
|
@@ -6111,7 +6406,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6111
6406
|
|
|
6112
6407
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6113
6408
|
import { assertEx as assertEx43 } from "@xylabs/sdk-js";
|
|
6114
|
-
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/
|
|
6409
|
+
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6115
6410
|
import {
|
|
6116
6411
|
StakeTotalsViewerMoniker,
|
|
6117
6412
|
StakeViewerMoniker
|
|
@@ -6209,7 +6504,7 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6209
6504
|
|
|
6210
6505
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6211
6506
|
import { assertEx as assertEx44, toAddress } from "@xylabs/sdk-js";
|
|
6212
|
-
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/
|
|
6507
|
+
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6213
6508
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6214
6509
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6215
6510
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
@@ -6393,7 +6688,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6393
6688
|
import {
|
|
6394
6689
|
asHash as asHash5,
|
|
6395
6690
|
assertEx as assertEx45,
|
|
6396
|
-
isDefined as
|
|
6691
|
+
isDefined as isDefined22
|
|
6397
6692
|
} from "@xylabs/sdk-js";
|
|
6398
6693
|
import {
|
|
6399
6694
|
asTimePayload as asTimePayload2,
|
|
@@ -6417,7 +6712,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6417
6712
|
const [block, payloads] = assertEx45(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6418
6713
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6419
6714
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6420
|
-
const timePayload = asTimePayload2(
|
|
6715
|
+
const timePayload = asTimePayload2(isDefined22(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
6421
6716
|
if (timePayload === void 0) return 0;
|
|
6422
6717
|
switch (toDomain) {
|
|
6423
6718
|
case "xl1": {
|
|
@@ -6446,7 +6741,8 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6446
6741
|
async currentTime(domain) {
|
|
6447
6742
|
switch (domain) {
|
|
6448
6743
|
case "xl1": {
|
|
6449
|
-
|
|
6744
|
+
const currentBlock = await this.blockViewer.currentBlock();
|
|
6745
|
+
return ["xl1", currentBlock?.[0].block ?? -1];
|
|
6450
6746
|
}
|
|
6451
6747
|
case "epoch": {
|
|
6452
6748
|
return ["epoch", Date.now()];
|
|
@@ -6490,7 +6786,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6490
6786
|
xl1Hash: assertEx45(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6491
6787
|
epoch: Date.now()
|
|
6492
6788
|
};
|
|
6493
|
-
if (
|
|
6789
|
+
if (isDefined22(this.ethProvider)) {
|
|
6494
6790
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
6495
6791
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
6496
6792
|
timePayload.ethereum = ethereum;
|
|
@@ -6558,13 +6854,18 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6558
6854
|
head: void 0
|
|
6559
6855
|
};
|
|
6560
6856
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6857
|
+
let head;
|
|
6858
|
+
if (isChainQualifiedHeadConfig6(config)) {
|
|
6859
|
+
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
6860
|
+
head = headBlockResult == null ? assertEx46(
|
|
6861
|
+
void 0,
|
|
6862
|
+
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6863
|
+
) : headBlockResult[0];
|
|
6864
|
+
}
|
|
6865
|
+
const currentBlock = await this.blockViewer.currentBlock();
|
|
6866
|
+
const headBlock = head ?? currentBlock[0];
|
|
6867
|
+
const validateProtocol = value === true ? this.doValidateProtocol.bind(this) : void 0;
|
|
6868
|
+
const validateState = state === true ? this.doValidateState.bind(this) : void 0;
|
|
6568
6869
|
const chainId = headBlock.chain;
|
|
6569
6870
|
const qualification = { head: headBlock._hash, range: asXL1BlockRange13([0, headBlock.block], true) };
|
|
6570
6871
|
const [protocolResults, stateResults] = await Promise.all([
|
|
@@ -6587,10 +6888,12 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6587
6888
|
throw new Error("Method not implemented.");
|
|
6588
6889
|
}
|
|
6589
6890
|
async validateTransaction(block, config) {
|
|
6590
|
-
|
|
6891
|
+
const results = await this.validateTransactions([block], config);
|
|
6892
|
+
return results[0];
|
|
6591
6893
|
}
|
|
6592
6894
|
async validateTransactions(transactions, config) {
|
|
6593
|
-
|
|
6895
|
+
const results = await this.qualifiedValidateTransactions(transactions, config);
|
|
6896
|
+
return results[0];
|
|
6594
6897
|
}
|
|
6595
6898
|
async doValidateProtocol(transactions, chainId) {
|
|
6596
6899
|
return await Promise.all(transactions.map(async (tx) => {
|
|
@@ -6888,8 +7191,8 @@ var LoggerStatusReporter = class {
|
|
|
6888
7191
|
}
|
|
6889
7192
|
report(name, status, progress) {
|
|
6890
7193
|
this.statusMap[name] = status;
|
|
6891
|
-
const starting = Object.
|
|
6892
|
-
const started = Object.
|
|
7194
|
+
const starting = Object.values(this.statusMap).map((value) => value === "starting" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
7195
|
+
const started = Object.values(this.statusMap).map((value) => value === "started" ? 1 : 0).reduce((a, b) => a + b, 0);
|
|
6893
7196
|
this.logger.info(`${started}/${starting + started} ${name} status: ${status}`, { progress });
|
|
6894
7197
|
}
|
|
6895
7198
|
};
|
|
@@ -6980,7 +7283,7 @@ import {
|
|
|
6980
7283
|
} from "@xyo-network/xl1-protocol-lib";
|
|
6981
7284
|
|
|
6982
7285
|
// src/test/buildBlock.ts
|
|
6983
|
-
import { assertEx as assertEx49, isDefined as
|
|
7286
|
+
import { assertEx as assertEx49, isDefined as isDefined23 } from "@xylabs/sdk-js";
|
|
6984
7287
|
import {
|
|
6985
7288
|
asAnyPayload as asAnyPayload5,
|
|
6986
7289
|
BoundWitnessBuilder as BoundWitnessBuilder3,
|
|
@@ -7050,6 +7353,26 @@ var isBuildNextBlockOptions = (value) => {
|
|
|
7050
7353
|
function calculateCompletedStepReward(step, balance) {
|
|
7051
7354
|
return AttoXL14(StepRewardFractions[step][0] * balance / StepRewardFractions[step][1]);
|
|
7052
7355
|
}
|
|
7356
|
+
function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStepRewardAddress2, stepRewardPoolBalance) {
|
|
7357
|
+
const completedStepRewardTransfers = [];
|
|
7358
|
+
const step_hashes = [];
|
|
7359
|
+
for (const [i, step] of StepSizes14.entries()) {
|
|
7360
|
+
if (blockNumber < step) {
|
|
7361
|
+
break;
|
|
7362
|
+
}
|
|
7363
|
+
if (blockNumber % step === 0) {
|
|
7364
|
+
if (StepRewardFractions[i][0] > 0 && chainStepRewardAddress2 !== XYO_ZERO_ADDRESS2) {
|
|
7365
|
+
const completedStepRewardHolderAddress = rewardAddressFromStepIdentity({ block: blockNumber, step });
|
|
7366
|
+
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7367
|
+
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7368
|
+
}
|
|
7369
|
+
step_hashes.push(assertEx49(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7370
|
+
} else if (isDefined23(inStepHashes.at(i))) {
|
|
7371
|
+
step_hashes.push(inStepHashes[i]);
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
return { completedStepRewardTransfers, step_hashes };
|
|
7375
|
+
}
|
|
7053
7376
|
async function buildBlock(options) {
|
|
7054
7377
|
const previousBlockNumber = isBuildGenesisBlockOptions(options) ? -1 : options.previousBlockNumber;
|
|
7055
7378
|
const blockNumber = asXL1BlockNumber13(previousBlockNumber + 1, true);
|
|
@@ -7064,7 +7387,6 @@ async function buildBlock(options) {
|
|
|
7064
7387
|
protocol = XL1_PROTOCOL_VERSION,
|
|
7065
7388
|
signers
|
|
7066
7389
|
} = options;
|
|
7067
|
-
const step_hashes = [];
|
|
7068
7390
|
for (const [tx] of txs) {
|
|
7069
7391
|
if (tx.nbf > blockNumber) {
|
|
7070
7392
|
throw new Error(`Transaction ${await PayloadBuilder25.hash(tx)} not valid for block ${blockNumber} - NBF is ${tx.nbf}`);
|
|
@@ -7073,24 +7395,13 @@ async function buildBlock(options) {
|
|
|
7073
7395
|
throw new Error(`Transaction ${await PayloadBuilder25.hash(tx)} not valid for block ${blockNumber} - EXP is ${tx.exp}`);
|
|
7074
7396
|
}
|
|
7075
7397
|
}
|
|
7076
|
-
const completedStepRewardTransfers =
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
const completedStepRewardHolderAddress = rewardAddressFromStepIdentity({ block: blockNumber, step });
|
|
7084
|
-
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7085
|
-
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7086
|
-
}
|
|
7087
|
-
step_hashes.push(assertEx49(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7088
|
-
} else {
|
|
7089
|
-
if (isDefined22(inStepHashes.at(i))) {
|
|
7090
|
-
step_hashes.push(inStepHashes[i]);
|
|
7091
|
-
}
|
|
7092
|
-
}
|
|
7093
|
-
}
|
|
7398
|
+
const { step_hashes, completedStepRewardTransfers } = buildStepHashes(
|
|
7399
|
+
blockNumber,
|
|
7400
|
+
inStepHashes,
|
|
7401
|
+
previousBlockHash,
|
|
7402
|
+
chainStepRewardAddress2,
|
|
7403
|
+
stepRewardPoolBalance
|
|
7404
|
+
);
|
|
7094
7405
|
const previous = previousBlockHash ?? null;
|
|
7095
7406
|
const block = blockNumber;
|
|
7096
7407
|
const txElevatedPayloads = await validateTransactionsOpcodes(txs);
|
|
@@ -7100,13 +7411,15 @@ async function buildBlock(options) {
|
|
|
7100
7411
|
...txElevatedPayloads,
|
|
7101
7412
|
...completedStepRewardTransfers
|
|
7102
7413
|
];
|
|
7103
|
-
const
|
|
7414
|
+
const boundWitnessBuilder = new BoundWitnessBuilder3();
|
|
7415
|
+
const builder = boundWitnessBuilder.fields({
|
|
7104
7416
|
block,
|
|
7105
7417
|
chain: chainId,
|
|
7106
7418
|
previous,
|
|
7107
7419
|
step_hashes,
|
|
7108
7420
|
protocol
|
|
7109
|
-
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads))
|
|
7421
|
+
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7422
|
+
const [bw, txPayloads] = await builder.build();
|
|
7110
7423
|
assertEx49(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7111
7424
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7112
7425
|
}
|
|
@@ -7162,7 +7475,8 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7162
7475
|
const additionalPayloads = (payloads ?? []).filter((payload) => !isAllowedBlockPayload3(payload));
|
|
7163
7476
|
const sender = account ?? await Account2.random();
|
|
7164
7477
|
if (elevatedPayloads.length === 0) {
|
|
7165
|
-
const
|
|
7478
|
+
const defaultReceiver = await Account2.random();
|
|
7479
|
+
const receiver = receiverAddress ?? defaultReceiver.address;
|
|
7166
7480
|
const transferPayload = createTransferPayload(sender.address, { [receiver]: 1n });
|
|
7167
7481
|
elevatedPayloads.push(transferPayload);
|
|
7168
7482
|
}
|
|
@@ -7193,12 +7507,14 @@ import {
|
|
|
7193
7507
|
defaultTransactionFees as defaultTransactionFees4
|
|
7194
7508
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7195
7509
|
async function createProducerChainStakeIntent(from, exp, nbf = 0) {
|
|
7196
|
-
|
|
7510
|
+
const payloadBuilder = new PayloadBuilder27({ schema: ChainStakeIntentSchema2 });
|
|
7511
|
+
const builder = payloadBuilder.fields({
|
|
7197
7512
|
from,
|
|
7198
7513
|
exp,
|
|
7199
7514
|
nbf,
|
|
7200
7515
|
intent: "producer"
|
|
7201
|
-
})
|
|
7516
|
+
});
|
|
7517
|
+
return await PayloadBuilder27.addHashMeta(builder.build());
|
|
7202
7518
|
}
|
|
7203
7519
|
|
|
7204
7520
|
// src/test/createGenesisBlock.ts
|
|
@@ -7242,13 +7558,20 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7242
7558
|
remaining = remaining - 1;
|
|
7243
7559
|
lastBlock = block;
|
|
7244
7560
|
}
|
|
7245
|
-
const
|
|
7561
|
+
const defaultReceiver = await Account4.random();
|
|
7562
|
+
const resolvedReceiverAddresses = receiverAddresses ?? [defaultReceiver.address];
|
|
7246
7563
|
let saltCounter = 0;
|
|
7247
7564
|
while (remaining > 0) {
|
|
7248
7565
|
saltCounter += 1;
|
|
7249
|
-
const
|
|
7566
|
+
const idPayloadBuilder = new PayloadBuilder29({ schema: IdSchema2 });
|
|
7567
|
+
const idBuilder = idPayloadBuilder.fields({ salt: `${Date.now()}-${saltCounter}` });
|
|
7568
|
+
const payloads = [idBuilder.build()];
|
|
7250
7569
|
saltCounter += 1;
|
|
7251
|
-
const additionalPrivatePayloads = remaining % 2 === 0 ?
|
|
7570
|
+
const additionalPrivatePayloads = remaining % 2 === 0 ? (() => {
|
|
7571
|
+
const privatePayloadBuilder = new PayloadBuilder29({ schema: asSchema9("network.xyo.private", true) });
|
|
7572
|
+
const privateBuilder = privatePayloadBuilder.fields({ salt: `${Date.now()}-${saltCounter}` });
|
|
7573
|
+
return [privateBuilder.build()];
|
|
7574
|
+
})() : [];
|
|
7252
7575
|
const txs = [];
|
|
7253
7576
|
for (const receiverAddress of resolvedReceiverAddresses) {
|
|
7254
7577
|
txs.push(await buildRandomTransaction(
|
|
@@ -7346,8 +7669,8 @@ var getUrl = (host, port) => {
|
|
|
7346
7669
|
var TODO = true;
|
|
7347
7670
|
|
|
7348
7671
|
// src/validation/schema/Mnemonic.ts
|
|
7349
|
-
import { z as
|
|
7350
|
-
var MnemonicStringZod =
|
|
7672
|
+
import { z as z33 } from "zod";
|
|
7673
|
+
var MnemonicStringZod = z33.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine(
|
|
7351
7674
|
(s) => [12, 15, 18, 21, 24].includes(s.split(" ").length),
|
|
7352
7675
|
{ message: "Mnemonic must contain 12, 15, 18, 21, or 24 words." }
|
|
7353
7676
|
).describe("BIP-39 mnemonic string");
|
|
@@ -7402,6 +7725,7 @@ export {
|
|
|
7402
7725
|
EIP712DataPayloadSchema,
|
|
7403
7726
|
EIP712SignaturePayloadFieldsZod,
|
|
7404
7727
|
EIP712SignaturePayloadSchema,
|
|
7728
|
+
EvmRpcTransportConfigZod,
|
|
7405
7729
|
GlobalMetaSchema,
|
|
7406
7730
|
HostActorConfigContext,
|
|
7407
7731
|
HostActorConfigZod,
|
|
@@ -7409,13 +7733,17 @@ export {
|
|
|
7409
7733
|
HydratedBoundWitnessWithStorageMetaZod,
|
|
7410
7734
|
HydratedCache,
|
|
7411
7735
|
JSONSchemaMetaSchema,
|
|
7736
|
+
LmdbTransportConfigZod,
|
|
7412
7737
|
LoggerStatusReporter,
|
|
7413
7738
|
MemoryPermissionsStore,
|
|
7414
7739
|
MissingCapabilityError,
|
|
7415
7740
|
MnemonicStringZod,
|
|
7741
|
+
MongoTransportConfigZod,
|
|
7416
7742
|
PRODUCER_DIVERSITY_BONUS,
|
|
7417
7743
|
PayloadLocator,
|
|
7418
7744
|
PostMessageRpcRemoteConfigZod,
|
|
7745
|
+
ProviderBindingConfigZod,
|
|
7746
|
+
ProviderBindingsConfigZod,
|
|
7419
7747
|
ProviderConfigZod,
|
|
7420
7748
|
ProviderFactory,
|
|
7421
7749
|
ProviderFactoryLocator,
|
|
@@ -7426,12 +7754,15 @@ export {
|
|
|
7426
7754
|
RestDataLakeRunner,
|
|
7427
7755
|
RestDataLakeViewer,
|
|
7428
7756
|
RestSyncViewer,
|
|
7757
|
+
RestTransportConfigZod,
|
|
7429
7758
|
RewardMultipliers,
|
|
7430
7759
|
RouterDataLakeConfigZod,
|
|
7431
7760
|
RpcRemoteConfigBaseZod,
|
|
7432
7761
|
RpcRemoteConfigZod,
|
|
7762
|
+
RpcTransportConfigZod,
|
|
7433
7763
|
RuntimeStatusMonitor,
|
|
7434
7764
|
RuntimeStatusMonitorZod,
|
|
7765
|
+
S3TransportConfigZod,
|
|
7435
7766
|
SchemasStepSummarySchema,
|
|
7436
7767
|
ShiftedBigInt,
|
|
7437
7768
|
SimpleAccountBalanceViewer,
|
|
@@ -7463,6 +7794,8 @@ export {
|
|
|
7463
7794
|
TestGenesisBlockRewardAddress,
|
|
7464
7795
|
TransactionBuilder,
|
|
7465
7796
|
TransfersStepSummarySchema,
|
|
7797
|
+
TransportConfigZod,
|
|
7798
|
+
TransportsConfigZod,
|
|
7466
7799
|
TypedDataDomainZod,
|
|
7467
7800
|
TypedDataFieldZod,
|
|
7468
7801
|
TypedDataTypesZod,
|
|
@@ -7478,6 +7811,7 @@ export {
|
|
|
7478
7811
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS,
|
|
7479
7812
|
activeStakeAtTimeByAddress,
|
|
7480
7813
|
activeStakeAtTimeByPosition,
|
|
7814
|
+
adaptLegacyConfig,
|
|
7481
7815
|
addDataLakePayloads,
|
|
7482
7816
|
addDataLakePayloadsToPayloads,
|
|
7483
7817
|
allHashesPresent,
|