@xyo-network/xl1-protocol-sdk 1.16.22 → 1.16.24
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/ChainServiceCollectionV2.d.ts +3 -3
- package/dist/neutral/ChainServiceCollectionV2.d.ts.map +1 -1
- package/dist/neutral/block/primitives/index.d.ts +0 -1
- package/dist/neutral/block/primitives/index.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +1 -0
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +10 -3
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Services.d.ts +6 -0
- package/dist/neutral/config/Services.d.ts.map +1 -0
- package/dist/neutral/config/Telemetry.d.ts +16 -0
- package/dist/neutral/config/Telemetry.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +859 -303
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/summary.d.ts +5 -0
- package/dist/neutral/model/summary.d.ts.map +1 -1
- package/dist/neutral/payloads/index.d.ts +1 -0
- package/dist/neutral/payloads/index.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +4 -0
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -0
- package/dist/neutral/payloads/summary/SchemasStepSummary.d.ts +18 -0
- package/dist/neutral/payloads/summary/SchemasStepSummary.d.ts.map +1 -0
- package/dist/neutral/payloads/summary/index.d.ts +1 -0
- package/dist/neutral/payloads/summary/index.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/index.d.ts +2 -1
- package/dist/neutral/primitives/summary/index.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/schemas/index.d.ts +3 -0
- package/dist/neutral/primitives/summary/schemas/index.d.ts.map +1 -0
- package/dist/neutral/primitives/summary/schemas/schemasStepSummaryFromRange.d.ts +6 -0
- package/dist/neutral/primitives/summary/schemas/schemasStepSummaryFromRange.d.ts.map +1 -0
- package/dist/neutral/primitives/summary/schemas/schemasSummary.d.ts +4 -0
- package/dist/neutral/primitives/summary/schemas/schemasSummary.d.ts.map +1 -0
- package/dist/neutral/primitives/summary/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/transfers/transfersSummary.d.ts +3 -2
- package/dist/neutral/primitives/summary/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/primitives/timeBudget.d.ts +1 -1
- package/dist/neutral/primitives/timeBudget.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +2 -2
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/services/SchemasService.d.ts +9 -0
- package/dist/neutral/services/SchemasService.d.ts.map +1 -0
- package/dist/neutral/services/StakeIntentService/ChainIndexingServiceStateSchema.d.ts +2 -2
- package/dist/neutral/services/StakeIntentService/ChainIndexingServiceStateSchema.d.ts.map +1 -1
- package/dist/neutral/services/index.d.ts +1 -1
- package/dist/neutral/services/index.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +2 -2
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts +2 -2
- package/dist/neutral/validation/block/HydratedBlockStateValidationFunction.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +62 -14
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/zod/ArrayBuffer.d.ts +4 -0
- package/dist/neutral/zod/ArrayBuffer.d.ts.map +1 -0
- package/dist/neutral/zod/BlockBoundWitness.d.ts +44 -0
- package/dist/neutral/zod/BlockBoundWitness.d.ts.map +1 -0
- package/dist/neutral/zod/BoundWitness.d.ts +123 -0
- package/dist/neutral/zod/BoundWitness.d.ts.map +1 -0
- package/dist/neutral/zod/Chain.d.ts +4 -0
- package/dist/neutral/zod/Chain.d.ts.map +1 -0
- package/dist/neutral/zod/HydratedBlock.d.ts +133 -0
- package/dist/neutral/zod/HydratedBlock.d.ts.map +1 -0
- package/dist/neutral/zod/HydratedTransaction.d.ts +210 -0
- package/dist/neutral/zod/HydratedTransaction.d.ts.map +1 -0
- package/dist/neutral/zod/Permission.d.ts +53 -0
- package/dist/neutral/zod/Permission.d.ts.map +1 -0
- package/dist/neutral/zod/RewardsRangeOptions.d.ts +11 -0
- package/dist/neutral/zod/RewardsRangeOptions.d.ts.map +1 -0
- package/dist/neutral/zod/Sequence.d.ts +9 -0
- package/dist/neutral/zod/Sequence.d.ts.map +1 -0
- package/dist/neutral/zod/Stake.d.ts +62 -0
- package/dist/neutral/zod/Stake.d.ts.map +1 -0
- package/dist/neutral/zod/TimeDomain.d.ts +3 -0
- package/dist/neutral/zod/TimeDomain.d.ts.map +1 -0
- package/dist/neutral/zod/TransactionBoundWitness.d.ts +75 -0
- package/dist/neutral/zod/TransactionBoundWitness.d.ts.map +1 -0
- package/dist/neutral/zod/TransactionFees.d.ts +53 -0
- package/dist/neutral/zod/TransactionFees.d.ts.map +1 -0
- package/dist/neutral/zod/TransferPair.d.ts +3 -0
- package/dist/neutral/zod/TransferPair.d.ts.map +1 -0
- package/dist/neutral/zod/index.d.ts +15 -0
- package/dist/neutral/zod/index.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/ChainServiceCollectionV2.ts +3 -3
- package/src/block/primitives/index.ts +0 -1
- package/src/config/Chain.ts +8 -0
- package/src/config/Config.ts +2 -2
- package/src/config/Services.ts +12 -0
- package/src/config/Telemetry.ts +19 -0
- package/src/index.ts +1 -0
- package/src/model/summary.ts +5 -0
- package/src/payloads/index.ts +1 -0
- package/src/payloads/netSchemasForPayloads.ts +22 -0
- package/src/payloads/summary/SchemasStepSummary.ts +26 -0
- package/src/payloads/summary/index.ts +1 -0
- package/src/primitives/summary/balances/balancesSummary.ts +1 -1
- package/src/primitives/summary/index.ts +2 -1
- package/src/primitives/summary/schemas/index.ts +2 -0
- package/src/primitives/summary/schemas/schemasStepSummaryFromRange.ts +83 -0
- package/src/primitives/summary/schemas/schemasSummary.ts +33 -0
- package/src/primitives/summary/transfers/transfersStepSummaryFromRange.ts +8 -6
- package/src/primitives/summary/transfers/transfersSummary.ts +11 -7
- package/src/primitives/timeBudget.ts +21 -2
- package/src/provider/viewer/XyoViewer.ts +2 -1
- package/src/services/SchemasService.ts +9 -0
- package/src/services/index.ts +1 -1
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +5 -5
- package/src/simple/chainStake/SimpleChainStakeViewer.ts +1 -1
- package/src/validation/block/HydratedBlockStateValidationFunction.ts +2 -2
- package/src/viewers/AccountBalance.ts +19 -17
- package/src/zod/ArrayBuffer.ts +42 -0
- package/src/zod/BlockBoundWitness.ts +36 -0
- package/src/zod/BoundWitness.ts +56 -0
- package/src/zod/Chain.ts +5 -0
- package/src/zod/HydratedBlock.ts +32 -0
- package/src/zod/HydratedTransaction.ts +37 -0
- package/src/zod/Permission.ts +23 -0
- package/src/zod/RewardsRangeOptions.ts +10 -0
- package/src/zod/Sequence.ts +15 -0
- package/src/zod/Stake.ts +43 -0
- package/src/zod/TimeDomain.ts +7 -0
- package/src/zod/TransactionBoundWitness.ts +42 -0
- package/src/zod/TransactionFees.ts +45 -0
- package/src/zod/TransferPair.ts +6 -0
- package/src/zod/index.ts +14 -0
- package/dist/neutral/block/primitives/transfers/index.d.ts +0 -3
- package/dist/neutral/block/primitives/transfers/index.d.ts.map +0 -1
- package/dist/neutral/block/primitives/transfers/transfersStepSummaryFromRange.d.ts +0 -6
- package/dist/neutral/block/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +0 -1
- package/dist/neutral/block/primitives/transfers/transfersSummary.d.ts +0 -5
- package/dist/neutral/block/primitives/transfers/transfersSummary.d.ts.map +0 -1
- package/dist/neutral/config/App.d.ts +0 -6
- package/dist/neutral/config/App.d.ts.map +0 -1
- package/dist/neutral/services/AccountBalanceService.d.ts +0 -4
- package/dist/neutral/services/AccountBalanceService.d.ts.map +0 -1
- package/src/block/primitives/transfers/index.ts +0 -2
- package/src/block/primitives/transfers/transfersStepSummaryFromRange.ts +0 -98
- package/src/block/primitives/transfers/transfersSummary.ts +0 -44
- package/src/config/App.ts +0 -13
- package/src/services/AccountBalanceService.ts +0 -4
package/dist/neutral/index.mjs
CHANGED
|
@@ -111,10 +111,10 @@ var tryHydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth =
|
|
|
111
111
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
112
112
|
import { asHash } from "@xylabs/sdk-js";
|
|
113
113
|
import { toSafeJsonString } from "@xylabs/sdk-js";
|
|
114
|
-
import { asBlockBoundWitnessWithStorageMeta as
|
|
114
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol";
|
|
115
115
|
|
|
116
116
|
// src/model/ChainContext/ChainContext.ts
|
|
117
|
-
import { isDefined as
|
|
117
|
+
import { isDefined as isDefined7, isUndefined } from "@xylabs/sdk-js";
|
|
118
118
|
|
|
119
119
|
// src/driver/cache/LruCacheMap.ts
|
|
120
120
|
import { LRUCache } from "lru-cache";
|
|
@@ -322,21 +322,41 @@ var netBalancesForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
|
322
322
|
});
|
|
323
323
|
}, "netBalancesForPayloads");
|
|
324
324
|
|
|
325
|
-
// src/payloads/
|
|
326
|
-
import { hexToBigInt as hexToBigInt2 } from "@xylabs/sdk-js";
|
|
325
|
+
// src/payloads/netSchemasForPayloads.ts
|
|
326
|
+
import { hexToBigInt as hexToBigInt2, toAddress as toAddress4 } from "@xylabs/sdk-js";
|
|
327
327
|
import { span as span2 } from "@xylabs/telemetry";
|
|
328
328
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol";
|
|
329
|
+
var netSchemasForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
330
|
+
return span2("netSchemasForPayloads", () => {
|
|
331
|
+
const balances = {};
|
|
332
|
+
for (const payload of payloads) {
|
|
333
|
+
if (isTransfer2(payload)) {
|
|
334
|
+
const { from } = payload;
|
|
335
|
+
for (let [address, amount] of Object.entries(payload.transfers)) {
|
|
336
|
+
balances[toAddress4(address)] = (balances[toAddress4(address)] ?? 0n) + hexToBigInt2(amount);
|
|
337
|
+
balances[toAddress4(from)] = (balances[toAddress4(from)] ?? 0n) - hexToBigInt2(amount);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
return balances;
|
|
342
|
+
});
|
|
343
|
+
}, "netSchemasForPayloads");
|
|
344
|
+
|
|
345
|
+
// src/payloads/netTransfersForPayloads.ts
|
|
346
|
+
import { hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
347
|
+
import { span as span3 } from "@xylabs/telemetry";
|
|
348
|
+
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol";
|
|
329
349
|
function netTransfersForPayloads(payloads) {
|
|
330
|
-
return
|
|
350
|
+
return span3("netTransfersForPayloads", () => {
|
|
331
351
|
const transfers = {};
|
|
332
352
|
for (const payload of payloads) {
|
|
333
|
-
if (
|
|
353
|
+
if (isTransfer3(payload)) {
|
|
334
354
|
const { from } = payload;
|
|
335
355
|
transfers[from] = transfers[from] ?? {};
|
|
336
356
|
for (let [to, amount] of Object.entries(payload.transfers)) {
|
|
337
357
|
transfers[to] = transfers[to] ?? {};
|
|
338
|
-
transfers[to][from] = (transfers[to][from] ?? 0n) +
|
|
339
|
-
transfers[from][to] = (transfers[from][to] ?? 0n) -
|
|
358
|
+
transfers[to][from] = (transfers[to][from] ?? 0n) + hexToBigInt3(amount);
|
|
359
|
+
transfers[from][to] = (transfers[from][to] ?? 0n) - hexToBigInt3(amount);
|
|
340
360
|
}
|
|
341
361
|
}
|
|
342
362
|
}
|
|
@@ -356,22 +376,33 @@ var isBalancesStepSummaryWithStorageMeta = /* @__PURE__ */ __name((value) => {
|
|
|
356
376
|
}, "isBalancesStepSummaryWithStorageMeta");
|
|
357
377
|
var asBalancesStepSummaryWithStorageMeta = AsObjectFactory2.create(isBalancesStepSummaryWithStorageMeta);
|
|
358
378
|
|
|
379
|
+
// src/payloads/summary/SchemasStepSummary.ts
|
|
380
|
+
import { AsObjectFactory as AsObjectFactory3 } from "@xylabs/sdk-js";
|
|
381
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType3, isStorageMeta as isStorageMeta2 } from "@xyo-network/payload-model";
|
|
382
|
+
var SchemasStepSummarySchema = "network.xyo.step.summary.schemas";
|
|
383
|
+
var isSchemasStepSummary = isPayloadOfSchemaType3(SchemasStepSummarySchema);
|
|
384
|
+
var asSchemasStepSummary = AsObjectFactory3.create(isSchemasStepSummary);
|
|
385
|
+
var isSchemasStepSummaryWithStorageMeta = /* @__PURE__ */ __name((value) => {
|
|
386
|
+
return isSchemasStepSummary(value) && isStorageMeta2(value);
|
|
387
|
+
}, "isSchemasStepSummaryWithStorageMeta");
|
|
388
|
+
var asSchemasStepSummaryWithStorageMeta = AsObjectFactory3.create(isSchemasStepSummaryWithStorageMeta);
|
|
389
|
+
|
|
359
390
|
// src/payloads/summary/StepSummary.ts
|
|
360
391
|
var StepSummarySchema = "network.xyo.step.summary";
|
|
361
392
|
|
|
362
393
|
// src/payloads/summary/TransfersSummary.ts
|
|
363
|
-
import { AsObjectFactory as
|
|
364
|
-
import { isPayloadOfSchemaType as
|
|
394
|
+
import { AsObjectFactory as AsObjectFactory4 } from "@xylabs/sdk-js";
|
|
395
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType4, isStorageMeta as isStorageMeta3 } from "@xyo-network/payload-model";
|
|
365
396
|
var TransfersStepSummarySchema = "network.xyo.step.summary.transfer";
|
|
366
|
-
var isTransfersStepSummary =
|
|
367
|
-
var asTransfersStepSummary =
|
|
397
|
+
var isTransfersStepSummary = isPayloadOfSchemaType4(TransfersStepSummarySchema);
|
|
398
|
+
var asTransfersStepSummary = AsObjectFactory4.create(isTransfersStepSummary);
|
|
368
399
|
var isTransfersStepSummaryWithStorageMeta = /* @__PURE__ */ __name((value) => {
|
|
369
|
-
return isTransfersStepSummary(value) &&
|
|
400
|
+
return isTransfersStepSummary(value) && isStorageMeta3(value);
|
|
370
401
|
}, "isTransfersStepSummaryWithStorageMeta");
|
|
371
|
-
var asTransfersStepSummaryWithStorageMeta =
|
|
402
|
+
var asTransfersStepSummaryWithStorageMeta = AsObjectFactory4.create(isTransfersStepSummaryWithStorageMeta);
|
|
372
403
|
|
|
373
404
|
// src/SignedBigInt.ts
|
|
374
|
-
import { hexToBigInt as
|
|
405
|
+
import { hexToBigInt as hexToBigInt4, toHex } from "@xylabs/sdk-js";
|
|
375
406
|
import { isObject } from "@xylabs/sdk-js";
|
|
376
407
|
var isNegativeBigInt = /* @__PURE__ */ __name((value) => {
|
|
377
408
|
return isObject(value) && "negative" in value && typeof value.negative === "string";
|
|
@@ -381,9 +412,9 @@ var isPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
|
381
412
|
}, "isPositiveBigInt");
|
|
382
413
|
var parseSignedBigInt = /* @__PURE__ */ __name((value) => {
|
|
383
414
|
if (isNegativeBigInt(value)) {
|
|
384
|
-
return -
|
|
415
|
+
return -hexToBigInt4(value.negative);
|
|
385
416
|
} else if (isPositiveBigInt(value)) {
|
|
386
|
-
return
|
|
417
|
+
return hexToBigInt4(value.positive);
|
|
387
418
|
} else {
|
|
388
419
|
throw new Error("Invalid balance type");
|
|
389
420
|
}
|
|
@@ -477,7 +508,7 @@ import { asAddress, isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
|
477
508
|
import { spanRootAsync } from "@xylabs/telemetry";
|
|
478
509
|
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2, asXL1BlockNumber, asXL1BlockRange as asXL1BlockRange2 } from "@xyo-network/xl1-protocol";
|
|
479
510
|
async function balancesSummary(context) {
|
|
480
|
-
return await spanRootAsync("
|
|
511
|
+
return await spanRootAsync("balancesSummary", async () => {
|
|
481
512
|
const [headHash] = await context.head();
|
|
482
513
|
const headResult = await context.store.chainMap.get(headHash);
|
|
483
514
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${headHash}`, {
|
|
@@ -503,14 +534,232 @@ async function balancesSummary(context) {
|
|
|
503
534
|
}
|
|
504
535
|
__name(balancesSummary, "balancesSummary");
|
|
505
536
|
|
|
537
|
+
// src/primitives/summary/schemas/schemasStepSummaryFromRange.ts
|
|
538
|
+
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
539
|
+
import { isBoundWitnessWithStorageMeta } from "@xyo-network/boundwitness-model";
|
|
540
|
+
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
541
|
+
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
542
|
+
import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol";
|
|
543
|
+
async function schemasStepSummaryFromRange(context, range) {
|
|
544
|
+
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
545
|
+
const frameSize = range[1] - range[0] + 1;
|
|
546
|
+
const [headHash] = await context.head();
|
|
547
|
+
let result = void 0;
|
|
548
|
+
if (frameSize === 1) {
|
|
549
|
+
const hash = await hashFromBlockNumber(context, range[0]);
|
|
550
|
+
const [block, payloads] = await hydrateBlock(context.store, hash);
|
|
551
|
+
const boundWitnesses = [
|
|
552
|
+
block,
|
|
553
|
+
...payloads.filter(isBoundWitnessWithStorageMeta)
|
|
554
|
+
];
|
|
555
|
+
const schemas = {};
|
|
556
|
+
for (const bw of boundWitnesses) {
|
|
557
|
+
schemas[bw.schema] = (schemas[bw.schema] ?? 0) + 1;
|
|
558
|
+
for (const schema of bw.payload_schemas) {
|
|
559
|
+
schemas[schema] = (schemas[schema] ?? 0) + 1;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
result = {
|
|
563
|
+
schema: SchemasStepSummarySchema,
|
|
564
|
+
hash: headHash,
|
|
565
|
+
stepSize: -1,
|
|
566
|
+
schemas
|
|
567
|
+
};
|
|
568
|
+
} else {
|
|
569
|
+
const step = StepSizes5.indexOf(frameSize);
|
|
570
|
+
assertEx6(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes5.join(", ")}`);
|
|
571
|
+
const summaryResult = await context.summaryMap.get(`${frameHeadHash}|${frameSize}`);
|
|
572
|
+
if (isAnyPayload2(summaryResult)) {
|
|
573
|
+
result = summaryResult;
|
|
574
|
+
} else {
|
|
575
|
+
await context.stepSemaphores[step].acquire();
|
|
576
|
+
try {
|
|
577
|
+
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
578
|
+
const promises = subRanges.map((subRange) => schemasStepSummaryFromRange(context, subRange));
|
|
579
|
+
const subResults = await Promise.all(promises);
|
|
580
|
+
const schemas = {};
|
|
581
|
+
for (const subResult of subResults) {
|
|
582
|
+
for (const [schema, count] of Object.entries(subResult.schemas)) {
|
|
583
|
+
schemas[schema] = (schemas[schema] ?? 0) + count;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
result = {
|
|
587
|
+
schema: SchemasStepSummarySchema,
|
|
588
|
+
hash: frameHeadHash,
|
|
589
|
+
stepSize: frameSize,
|
|
590
|
+
schemas
|
|
591
|
+
};
|
|
592
|
+
await context.summaryMap.set(`${frameHeadHash}|${frameSize}`, result);
|
|
593
|
+
} finally {
|
|
594
|
+
context.stepSemaphores[step].release();
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const finalResult = await PayloadBuilder2.addStorageMeta(result);
|
|
599
|
+
return finalResult;
|
|
600
|
+
}
|
|
601
|
+
__name(schemasStepSummaryFromRange, "schemasStepSummaryFromRange");
|
|
602
|
+
|
|
603
|
+
// src/primitives/summary/schemas/schemasSummary.ts
|
|
604
|
+
import { isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
605
|
+
import { spanRootAsync as spanRootAsync2 } from "@xylabs/telemetry";
|
|
606
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3, asXL1BlockNumber as asXL1BlockNumber2, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol";
|
|
607
|
+
async function schemasSummary(context) {
|
|
608
|
+
return await spanRootAsync2("schemasSummary", async () => {
|
|
609
|
+
const [headHash] = await context.head();
|
|
610
|
+
const headResult = await context.store.chainMap.get(headHash);
|
|
611
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${headHash}`, {
|
|
612
|
+
required: true
|
|
613
|
+
});
|
|
614
|
+
const rangeStart = asXL1BlockNumber2(isDefined5(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0);
|
|
615
|
+
const ranges = deepCalculateFramesFromRange(asXL1BlockRange3([
|
|
616
|
+
rangeStart,
|
|
617
|
+
headBoundWitness.block
|
|
618
|
+
], {
|
|
619
|
+
name: "schemasSummary"
|
|
620
|
+
}));
|
|
621
|
+
const summaries = await Promise.all(ranges.map((range) => schemasStepSummaryFromRange(context, range)));
|
|
622
|
+
const schemas = {};
|
|
623
|
+
for (let summary of summaries) {
|
|
624
|
+
for (const [schema, count] of Object.entries(summary.schemas)) {
|
|
625
|
+
schemas[schema] = (schemas[schema] ?? 0) + count;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return schemas;
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
__name(schemasSummary, "schemasSummary");
|
|
632
|
+
|
|
633
|
+
// src/primitives/summary/transfers/transfersStepSummaryFromRange.ts
|
|
634
|
+
import { assertEx as assertEx7 } from "@xylabs/sdk-js";
|
|
635
|
+
import { PayloadBuilder as PayloadBuilder3 } from "@xyo-network/payload-builder";
|
|
636
|
+
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
|
|
637
|
+
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol";
|
|
638
|
+
|
|
639
|
+
// src/primitives/summary/transfers/transfersSummary.ts
|
|
640
|
+
import { asAddress as asAddress2, isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
641
|
+
import { spanRootAsync as spanRootAsync3 } from "@xylabs/telemetry";
|
|
642
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4, asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange4 } from "@xyo-network/xl1-protocol";
|
|
643
|
+
async function transfersSummary(transferContext) {
|
|
644
|
+
return await spanRootAsync3("transferSummary", async () => {
|
|
645
|
+
const [headHash] = await transferContext.head();
|
|
646
|
+
const headResult = await transferContext.store.chainMap.get(headHash);
|
|
647
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(headResult, () => `Head block not found for hash: ${transferContext.head}`, {
|
|
648
|
+
required: true
|
|
649
|
+
});
|
|
650
|
+
const rangeStart = asXL1BlockNumber3(isDefined6(transferContext.windowSize) ? Math.max(headBoundWitness.block - transferContext.windowSize + 1, 0) : 0);
|
|
651
|
+
const ranges = deepCalculateFramesFromRange(asXL1BlockRange4([
|
|
652
|
+
rangeStart,
|
|
653
|
+
headBoundWitness.block
|
|
654
|
+
], {
|
|
655
|
+
name: "transfersSummary"
|
|
656
|
+
}));
|
|
657
|
+
const summaries = await Promise.all(ranges.map((range) => transfersStepSummaryFromRange(transferContext, range)));
|
|
658
|
+
const transfers = {};
|
|
659
|
+
for (let summary of summaries) {
|
|
660
|
+
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
661
|
+
const validFrom = asAddress2(from, () => `Invalid address: ${from}`);
|
|
662
|
+
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
663
|
+
for (const [to, transfer] of Object.entries(toMap)) {
|
|
664
|
+
const validTo = asAddress2(to, () => `Invalid address: ${to}`);
|
|
665
|
+
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
return transfers;
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
__name(transfersSummary, "transfersSummary");
|
|
673
|
+
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
674
|
+
return `${frameHeadHash}|${frameSize}`;
|
|
675
|
+
}
|
|
676
|
+
__name(transfersSummaryKey, "transfersSummaryKey");
|
|
677
|
+
|
|
678
|
+
// src/primitives/summary/transfers/transfersStepSummaryFromRange.ts
|
|
679
|
+
async function transfersStepSummaryFromRange(context, range) {
|
|
680
|
+
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
681
|
+
const frameSize = range[1] - range[0] + 1;
|
|
682
|
+
const [headHash] = await context.head();
|
|
683
|
+
let result = void 0;
|
|
684
|
+
if (frameSize === 1) {
|
|
685
|
+
const hash = await hashFromBlockNumber(context, range[0]);
|
|
686
|
+
const [, payloads] = await hydrateBlock(context.store, hash);
|
|
687
|
+
const transfers = {};
|
|
688
|
+
for (const [from, toMap] of Object.entries(netTransfersForPayloads(payloads))) {
|
|
689
|
+
transfers[from] = transfers[from] ?? {};
|
|
690
|
+
for (const [to, amount] of Object.entries(toMap)) {
|
|
691
|
+
transfers[from][to] = toSignedBigInt(amount);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
result = {
|
|
695
|
+
schema: TransfersStepSummarySchema,
|
|
696
|
+
hash: headHash,
|
|
697
|
+
stepSize: -1,
|
|
698
|
+
transfers
|
|
699
|
+
};
|
|
700
|
+
} else {
|
|
701
|
+
const step = StepSizes6.indexOf(frameSize);
|
|
702
|
+
assertEx7(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes6.join(", ")}`);
|
|
703
|
+
const key = transfersSummaryKey(frameHeadHash, frameSize);
|
|
704
|
+
const summaryResult = await context.summaryMap.get(key);
|
|
705
|
+
if (isAnyPayload3(summaryResult)) {
|
|
706
|
+
result = summaryResult;
|
|
707
|
+
} else {
|
|
708
|
+
await context.stepSemaphores[step].acquire();
|
|
709
|
+
try {
|
|
710
|
+
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
711
|
+
const promises = subRanges.map((subRange) => transfersStepSummaryFromRange(context, subRange));
|
|
712
|
+
const subResults = await Promise.all(promises);
|
|
713
|
+
const bigIntBalances = {};
|
|
714
|
+
for (const subResult of subResults) {
|
|
715
|
+
for (const [from, toMap] of Object.entries(subResult.transfers)) {
|
|
716
|
+
bigIntBalances[from] = bigIntBalances[from] ?? {};
|
|
717
|
+
for (const [to, transfer] of Object.entries(toMap)) {
|
|
718
|
+
bigIntBalances[from][to] = (bigIntBalances[from][to] ?? 0n) + parseSignedBigInt(transfer);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
const transfers = {};
|
|
723
|
+
for (const [from, toMap] of Object.entries(bigIntBalances)) {
|
|
724
|
+
transfers[from] = transfers[from] ?? {};
|
|
725
|
+
for (const [to, transfer] of Object.entries(toMap)) {
|
|
726
|
+
transfers[from][to] = toSignedBigInt(transfer);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
result = {
|
|
730
|
+
schema: TransfersStepSummarySchema,
|
|
731
|
+
hash: frameHeadHash,
|
|
732
|
+
stepSize: frameSize,
|
|
733
|
+
transfers
|
|
734
|
+
};
|
|
735
|
+
await context.summaryMap.set(key, result);
|
|
736
|
+
} finally {
|
|
737
|
+
context.stepSemaphores[step].release();
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
const finalResult = await PayloadBuilder3.addStorageMeta(result);
|
|
742
|
+
return finalResult;
|
|
743
|
+
}
|
|
744
|
+
__name(transfersStepSummaryFromRange, "transfersStepSummaryFromRange");
|
|
745
|
+
|
|
506
746
|
// src/primitives/timeBudget.ts
|
|
507
|
-
async function timeBudget(name, logger, func, budget) {
|
|
747
|
+
async function timeBudget(name, logger, func, budget, status = false) {
|
|
508
748
|
const start = Date.now();
|
|
749
|
+
const timer = status ? setInterval(() => {
|
|
750
|
+
const duration2 = Date.now() - start;
|
|
751
|
+
if (budget > 0 && duration2 > budget) {
|
|
752
|
+
logger?.warn(`Function [${name}] execution is exceeding budget: ${duration2}ms > ${budget}ms`);
|
|
753
|
+
}
|
|
754
|
+
}, Math.max(100, budget)) : void 0;
|
|
509
755
|
const result = await func();
|
|
510
756
|
const duration = Date.now() - start;
|
|
511
|
-
if (budget > 0 && duration > budget) {
|
|
757
|
+
if (!timer && budget > 0 && duration > budget) {
|
|
512
758
|
logger?.warn(`Function [${name}] execution exceeded budget: ${duration}ms > ${budget}ms`);
|
|
513
759
|
}
|
|
760
|
+
if (timer) {
|
|
761
|
+
clearInterval(timer);
|
|
762
|
+
}
|
|
514
763
|
return result;
|
|
515
764
|
}
|
|
516
765
|
__name(timeBudget, "timeBudget");
|
|
@@ -553,7 +802,7 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4, t
|
|
|
553
802
|
max
|
|
554
803
|
}));
|
|
555
804
|
const cacheResult = await cache.get(key);
|
|
556
|
-
if (
|
|
805
|
+
if (isDefined7(cacheResult)) {
|
|
557
806
|
return cacheResult;
|
|
558
807
|
}
|
|
559
808
|
const result = timeBudgetMs > 0 ? await timeBudget(name, context.logger, func, timeBudgetMs) : await func();
|
|
@@ -568,7 +817,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
568
817
|
return await withContextCacheResponse(context, "blockFromBlockNumber", cacheKey, async () => {
|
|
569
818
|
const [headHash] = await context.head();
|
|
570
819
|
const result = await context.store.chainMap.get(headHash);
|
|
571
|
-
let currentBlock =
|
|
820
|
+
let currentBlock = asBlockBoundWitnessWithStorageMeta5(result, () => `Head block not found for hash: ${headHash}`, {
|
|
572
821
|
required: true
|
|
573
822
|
});
|
|
574
823
|
if (currentBlock.block < blockNumber) {
|
|
@@ -577,7 +826,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
577
826
|
while (currentBlock.block > blockNumber) {
|
|
578
827
|
let jumpHash = currentBlock.previous;
|
|
579
828
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
580
|
-
for (const [step, stepSize2] of
|
|
829
|
+
for (const [step, stepSize2] of StepSizes7.entries()) {
|
|
581
830
|
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize2 - 1;
|
|
582
831
|
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
583
832
|
jumpBlockNumber = possibleJumpBlockNumber;
|
|
@@ -585,7 +834,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
585
834
|
}
|
|
586
835
|
}
|
|
587
836
|
const newBlock = await context.store.chainMap.get(asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`));
|
|
588
|
-
currentBlock =
|
|
837
|
+
currentBlock = asBlockBoundWitnessWithStorageMeta5(newBlock, () => `Block not found for hash: ${jumpHash}`, {
|
|
589
838
|
required: true
|
|
590
839
|
});
|
|
591
840
|
if (currentBlock.block === blockNumber) {
|
|
@@ -601,7 +850,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
601
850
|
__name(blockFromBlockNumber, "blockFromBlockNumber");
|
|
602
851
|
|
|
603
852
|
// src/block/primitives/frames/calculateFramesFromRange.ts
|
|
604
|
-
import { asXL1BlockNumber as
|
|
853
|
+
import { asXL1BlockNumber as asXL1BlockNumber4, stepSize } from "@xyo-network/xl1-protocol";
|
|
605
854
|
function calculateFramesFromRange(range, step) {
|
|
606
855
|
const size = stepSize(step);
|
|
607
856
|
let start = Math.trunc(range[0] / size) * size;
|
|
@@ -611,22 +860,22 @@ function calculateFramesFromRange(range, step) {
|
|
|
611
860
|
start += size;
|
|
612
861
|
remaining.push([
|
|
613
862
|
range[0],
|
|
614
|
-
|
|
863
|
+
asXL1BlockNumber4(Math.min(start - 1, range[1]), true)
|
|
615
864
|
]);
|
|
616
865
|
}
|
|
617
866
|
for (let i = start; i <= range[1]; i += size) {
|
|
618
867
|
if (i + size - 1 <= range[1]) {
|
|
619
868
|
fitted.push([
|
|
620
|
-
|
|
869
|
+
asXL1BlockNumber4(i, {
|
|
621
870
|
name: "calculateFramesFromRange A"
|
|
622
871
|
}),
|
|
623
|
-
|
|
872
|
+
asXL1BlockNumber4(Math.min(i + size - 1, range[1]), {
|
|
624
873
|
name: "calculateFramesFromRange B"
|
|
625
874
|
})
|
|
626
875
|
]);
|
|
627
876
|
} else {
|
|
628
877
|
remaining.push([
|
|
629
|
-
|
|
878
|
+
asXL1BlockNumber4(i, {
|
|
630
879
|
name: "calculateFramesFromRange C"
|
|
631
880
|
}),
|
|
632
881
|
range[1]
|
|
@@ -641,8 +890,8 @@ function calculateFramesFromRange(range, step) {
|
|
|
641
890
|
__name(calculateFramesFromRange, "calculateFramesFromRange");
|
|
642
891
|
|
|
643
892
|
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
644
|
-
import { StepSizes as
|
|
645
|
-
function deepCalculateFramesFromRange(range, startingStep =
|
|
893
|
+
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol";
|
|
894
|
+
function deepCalculateFramesFromRange(range, startingStep = StepSizes8.length - 1) {
|
|
646
895
|
const fitted = [];
|
|
647
896
|
let remaining = [
|
|
648
897
|
range
|
|
@@ -694,119 +943,6 @@ function toStepIdentityString({ block, step }) {
|
|
|
694
943
|
}
|
|
695
944
|
__name(toStepIdentityString, "toStepIdentityString");
|
|
696
945
|
|
|
697
|
-
// src/block/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
698
|
-
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
699
|
-
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
700
|
-
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
701
|
-
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol";
|
|
702
|
-
|
|
703
|
-
// src/block/primitives/transfers/transfersSummary.ts
|
|
704
|
-
import { asAddress as asAddress2, isDefined as isDefined6 } from "@xylabs/sdk-js";
|
|
705
|
-
import { spanRootAsync as spanRootAsync2 } from "@xylabs/telemetry";
|
|
706
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4, asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol";
|
|
707
|
-
async function transfersSummary(transferContext) {
|
|
708
|
-
return await spanRootAsync2("transferSummary", async () => {
|
|
709
|
-
const [headHash] = await transferContext.head();
|
|
710
|
-
const headResult = await transferContext.store.chainMap.get(headHash);
|
|
711
|
-
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(headResult, () => `Head block not found for hash: ${transferContext.head}`, {
|
|
712
|
-
required: true
|
|
713
|
-
});
|
|
714
|
-
const rangeStart = asXL1BlockNumber3(isDefined6(transferContext.windowSize) ? Math.max(headBoundWitness.block - transferContext.windowSize + 1, 0) : 0);
|
|
715
|
-
const ranges = deepCalculateFramesFromRange(asXL1BlockRange3([
|
|
716
|
-
rangeStart,
|
|
717
|
-
headBoundWitness.block
|
|
718
|
-
], {
|
|
719
|
-
name: "transfersSummary"
|
|
720
|
-
}));
|
|
721
|
-
const summaries = await Promise.all(ranges.map((range) => transfersStepSummaryFromRange(transferContext, range)));
|
|
722
|
-
const transfers = {};
|
|
723
|
-
for (let summary of summaries) {
|
|
724
|
-
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
725
|
-
const validFrom = asAddress2(from, () => `Invalid address: ${from}`);
|
|
726
|
-
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
727
|
-
for (const [to, transfer] of Object.entries(toMap)) {
|
|
728
|
-
const validTo = asAddress2(to, () => `Invalid address: ${to}`);
|
|
729
|
-
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
return transfers;
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
__name(transfersSummary, "transfersSummary");
|
|
737
|
-
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
738
|
-
return `${frameHeadHash}|${frameSize}`;
|
|
739
|
-
}
|
|
740
|
-
__name(transfersSummaryKey, "transfersSummaryKey");
|
|
741
|
-
|
|
742
|
-
// src/block/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
743
|
-
async function transfersStepSummaryFromRange(context, range) {
|
|
744
|
-
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
745
|
-
const frameSize = range[1] - range[0] + 1;
|
|
746
|
-
const [headHash] = await context.head();
|
|
747
|
-
let result = void 0;
|
|
748
|
-
if (frameSize === 1) {
|
|
749
|
-
const hash = await hashFromBlockNumber(context, range[0]);
|
|
750
|
-
const [, payloads] = await hydrateBlock(context.store, hash);
|
|
751
|
-
const transfers = {};
|
|
752
|
-
for (const [from, toMap] of Object.entries(netTransfersForPayloads(payloads))) {
|
|
753
|
-
transfers[from] = transfers[from] ?? {};
|
|
754
|
-
for (const [to, amount] of Object.entries(toMap)) {
|
|
755
|
-
transfers[from][to] = toSignedBigInt(amount);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
result = {
|
|
759
|
-
schema: TransfersStepSummarySchema,
|
|
760
|
-
hash: headHash,
|
|
761
|
-
stepSize: -1,
|
|
762
|
-
transfers
|
|
763
|
-
};
|
|
764
|
-
} else {
|
|
765
|
-
const step = StepSizes7.indexOf(frameSize);
|
|
766
|
-
assertEx6(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes7.join(", ")}`);
|
|
767
|
-
const key = transfersSummaryKey(frameHeadHash, frameSize);
|
|
768
|
-
const summaryResult = await context.summaryMap.get(key);
|
|
769
|
-
if (isAnyPayload2(summaryResult)) {
|
|
770
|
-
result = summaryResult;
|
|
771
|
-
} else {
|
|
772
|
-
await context.stepSemaphores[step].acquire();
|
|
773
|
-
try {
|
|
774
|
-
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
775
|
-
const promises = subRanges.map((subRange) => transfersStepSummaryFromRange(context, subRange));
|
|
776
|
-
const subResults = await Promise.all(promises);
|
|
777
|
-
const bigIntBalances = {};
|
|
778
|
-
for (const subResult of subResults) {
|
|
779
|
-
for (const [from, toMap] of Object.entries(subResult.transfers)) {
|
|
780
|
-
bigIntBalances[from] = bigIntBalances[from] ?? {};
|
|
781
|
-
for (const [to, transfer] of Object.entries(toMap)) {
|
|
782
|
-
bigIntBalances[from][to] = (bigIntBalances[from][to] ?? 0n) + parseSignedBigInt(transfer);
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
const transfers = {};
|
|
787
|
-
for (const [from, toMap] of Object.entries(bigIntBalances)) {
|
|
788
|
-
transfers[from] = transfers[from] ?? {};
|
|
789
|
-
for (const [to, transfer] of Object.entries(toMap)) {
|
|
790
|
-
transfers[from][to] = toSignedBigInt(transfer);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
result = {
|
|
794
|
-
schema: TransfersStepSummarySchema,
|
|
795
|
-
hash: frameHeadHash,
|
|
796
|
-
stepSize: frameSize,
|
|
797
|
-
transfers
|
|
798
|
-
};
|
|
799
|
-
await context.summaryMap.set(key, result);
|
|
800
|
-
} finally {
|
|
801
|
-
context.stepSemaphores[step].release();
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
const finalResult = await PayloadBuilder2.addStorageMeta(result);
|
|
806
|
-
return finalResult;
|
|
807
|
-
}
|
|
808
|
-
__name(transfersStepSummaryFromRange, "transfersStepSummaryFromRange");
|
|
809
|
-
|
|
810
946
|
// src/config/Config.ts
|
|
811
947
|
import * as z15 from "zod";
|
|
812
948
|
|
|
@@ -904,34 +1040,22 @@ var ApiConfigZod = z2.object({
|
|
|
904
1040
|
})
|
|
905
1041
|
});
|
|
906
1042
|
|
|
907
|
-
// src/config/
|
|
1043
|
+
// src/config/Bridge.ts
|
|
908
1044
|
import { globalRegistry as globalRegistry2 } from "zod";
|
|
909
1045
|
import * as z3 from "zod";
|
|
910
|
-
var
|
|
911
|
-
|
|
912
|
-
default: 3e3,
|
|
913
|
-
description: "Port for the application",
|
|
914
|
-
title: "app.port",
|
|
915
|
-
type: "number"
|
|
916
|
-
})
|
|
917
|
-
});
|
|
918
|
-
|
|
919
|
-
// src/config/Bridge.ts
|
|
920
|
-
import { globalRegistry as globalRegistry3 } from "zod";
|
|
921
|
-
import * as z4 from "zod";
|
|
922
|
-
var BridgeConfigZod = z4.object({
|
|
923
|
-
host: z4.string().default("localhost").register(globalRegistry3, {
|
|
1046
|
+
var BridgeConfigZod = z3.object({
|
|
1047
|
+
host: z3.string().default("localhost").register(globalRegistry2, {
|
|
924
1048
|
default: "localhost",
|
|
925
1049
|
description: "Host for the Bridge",
|
|
926
1050
|
title: "api.host",
|
|
927
1051
|
type: "string"
|
|
928
1052
|
}),
|
|
929
|
-
mnemonic: MnemonicStringZod.optional().register(
|
|
1053
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry2, {
|
|
930
1054
|
description: "Mnemonic for the Bridge wallet",
|
|
931
1055
|
title: "api.mnemonic",
|
|
932
1056
|
type: "string"
|
|
933
1057
|
}),
|
|
934
|
-
port:
|
|
1058
|
+
port: z3.coerce.number().default(8081).register(globalRegistry2, {
|
|
935
1059
|
default: 8081,
|
|
936
1060
|
description: "Port for the Bridge",
|
|
937
1061
|
title: "api.port",
|
|
@@ -940,40 +1064,46 @@ var BridgeConfigZod = z4.object({
|
|
|
940
1064
|
});
|
|
941
1065
|
|
|
942
1066
|
// src/config/Chain.ts
|
|
943
|
-
import {
|
|
944
|
-
import
|
|
945
|
-
|
|
946
|
-
|
|
1067
|
+
import { AddressZod } from "@xylabs/sdk-js";
|
|
1068
|
+
import { globalRegistry as globalRegistry3 } from "zod";
|
|
1069
|
+
import * as z4 from "zod";
|
|
1070
|
+
var ChainConfigZod = z4.object({
|
|
1071
|
+
id: z4.string().optional().register(globalRegistry3, {
|
|
947
1072
|
description: "The unique identifier for the chain. Should be the staking contract address for contract-backed chains.",
|
|
948
1073
|
title: "chain.id",
|
|
949
1074
|
type: "string"
|
|
1075
|
+
}),
|
|
1076
|
+
genesisRewardAddress: AddressZod.optional().register(globalRegistry3, {
|
|
1077
|
+
description: "Address to send the initial genesis rewards to, if a new chain is being created.",
|
|
1078
|
+
title: "chain.genesisRewardAddress",
|
|
1079
|
+
type: "Address"
|
|
950
1080
|
})
|
|
951
1081
|
});
|
|
952
1082
|
|
|
953
1083
|
// src/config/Evm.ts
|
|
954
|
-
import { globalRegistry as
|
|
955
|
-
import * as
|
|
956
|
-
var EvmInfuraConfigZod =
|
|
957
|
-
projectId:
|
|
1084
|
+
import { globalRegistry as globalRegistry4 } from "zod";
|
|
1085
|
+
import * as z5 from "zod";
|
|
1086
|
+
var EvmInfuraConfigZod = z5.object({
|
|
1087
|
+
projectId: z5.string().optional().register(globalRegistry4, {
|
|
958
1088
|
description: "Infura project ID",
|
|
959
1089
|
title: "evm.infura.projectId",
|
|
960
1090
|
type: "string"
|
|
961
1091
|
}),
|
|
962
|
-
projectSecret:
|
|
1092
|
+
projectSecret: z5.string().optional().register(globalRegistry4, {
|
|
963
1093
|
description: "Infura project secret",
|
|
964
1094
|
title: "evm.infura.projectSecret",
|
|
965
1095
|
type: "string"
|
|
966
1096
|
})
|
|
967
1097
|
});
|
|
968
|
-
var EvmJsonRpcConfigZod =
|
|
969
|
-
url:
|
|
1098
|
+
var EvmJsonRpcConfigZod = z5.object({
|
|
1099
|
+
url: z5.url().optional().register(globalRegistry4, {
|
|
970
1100
|
description: "JSON-RPC URL",
|
|
971
1101
|
title: "evm.jsonRpc.url",
|
|
972
1102
|
type: "string"
|
|
973
1103
|
})
|
|
974
1104
|
});
|
|
975
|
-
var EvmConfigZod =
|
|
976
|
-
chainId:
|
|
1105
|
+
var EvmConfigZod = z5.object({
|
|
1106
|
+
chainId: z5.string().optional().register(globalRegistry4, {
|
|
977
1107
|
description: "EVM chain ID",
|
|
978
1108
|
title: "evm.chainId",
|
|
979
1109
|
type: "string"
|
|
@@ -984,18 +1114,18 @@ var EvmConfigZod = z6.object({
|
|
|
984
1114
|
|
|
985
1115
|
// src/config/Log.ts
|
|
986
1116
|
import { LogLevel } from "@xylabs/sdk-js";
|
|
987
|
-
import { globalRegistry as
|
|
988
|
-
import * as
|
|
1117
|
+
import { globalRegistry as globalRegistry5 } from "zod";
|
|
1118
|
+
import * as z6 from "zod";
|
|
989
1119
|
var LogLevels = Object.keys(LogLevel);
|
|
990
|
-
var LogConfigZod =
|
|
991
|
-
logLevel:
|
|
1120
|
+
var LogConfigZod = z6.object({
|
|
1121
|
+
logLevel: z6.enum(LogLevels).default("info").register(globalRegistry5, {
|
|
992
1122
|
choices: LogLevels,
|
|
993
1123
|
default: "info",
|
|
994
1124
|
description: "Desired process verbosity",
|
|
995
1125
|
title: "logLevel",
|
|
996
1126
|
type: "string"
|
|
997
1127
|
}),
|
|
998
|
-
silent:
|
|
1128
|
+
silent: z6.boolean().default(false).register(globalRegistry5, {
|
|
999
1129
|
default: false,
|
|
1000
1130
|
description: "Whether to run in silent mode",
|
|
1001
1131
|
title: "silent",
|
|
@@ -1004,10 +1134,10 @@ var LogConfigZod = z7.object({
|
|
|
1004
1134
|
});
|
|
1005
1135
|
|
|
1006
1136
|
// src/config/Mempool.ts
|
|
1007
|
-
import { globalRegistry as
|
|
1008
|
-
import * as
|
|
1009
|
-
var MempoolConfigZod =
|
|
1010
|
-
enabled:
|
|
1137
|
+
import { globalRegistry as globalRegistry6 } from "zod";
|
|
1138
|
+
import * as z7 from "zod";
|
|
1139
|
+
var MempoolConfigZod = z7.object({
|
|
1140
|
+
enabled: z7.string().default("false").transform((val, ctx) => {
|
|
1011
1141
|
const normalized = val.toLowerCase().trim();
|
|
1012
1142
|
if ([
|
|
1013
1143
|
"true",
|
|
@@ -1026,25 +1156,25 @@ var MempoolConfigZod = z8.object({
|
|
|
1026
1156
|
expected: "boolean",
|
|
1027
1157
|
message: `Invalid boolean value: "${val}". Use true/false, 1/0, yes/no.`
|
|
1028
1158
|
});
|
|
1029
|
-
return
|
|
1030
|
-
}).register(
|
|
1159
|
+
return z7.NEVER;
|
|
1160
|
+
}).register(globalRegistry6, {
|
|
1031
1161
|
default: "false",
|
|
1032
1162
|
description: "Enable the Mempool",
|
|
1033
1163
|
title: "mempool.enabled",
|
|
1034
1164
|
type: "boolean"
|
|
1035
1165
|
}),
|
|
1036
|
-
host:
|
|
1166
|
+
host: z7.string().default("localhost").register(globalRegistry6, {
|
|
1037
1167
|
default: "localhost",
|
|
1038
1168
|
description: "Host for the Mempool",
|
|
1039
1169
|
title: "mempool.host",
|
|
1040
1170
|
type: "string"
|
|
1041
1171
|
}),
|
|
1042
|
-
mnemonic: MnemonicStringZod.optional().register(
|
|
1172
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry6, {
|
|
1043
1173
|
description: "Mnemonic for the Mempool wallet",
|
|
1044
1174
|
title: "mempool.mnemonic",
|
|
1045
1175
|
type: "string"
|
|
1046
1176
|
}),
|
|
1047
|
-
port:
|
|
1177
|
+
port: z7.coerce.number().default(8083).register(globalRegistry6, {
|
|
1048
1178
|
default: 8083,
|
|
1049
1179
|
description: "Port for the Mempool",
|
|
1050
1180
|
title: "mempool.port",
|
|
@@ -1053,56 +1183,56 @@ var MempoolConfigZod = z8.object({
|
|
|
1053
1183
|
});
|
|
1054
1184
|
|
|
1055
1185
|
// src/config/Producer.ts
|
|
1056
|
-
import { AddressZod, asAddress as asAddress3 } from "@xylabs/sdk-js";
|
|
1057
|
-
import { globalRegistry as
|
|
1058
|
-
import * as
|
|
1059
|
-
var ProducerConfigZod =
|
|
1060
|
-
allowlist:
|
|
1186
|
+
import { AddressZod as AddressZod2, asAddress as asAddress3 } from "@xylabs/sdk-js";
|
|
1187
|
+
import { globalRegistry as globalRegistry7 } from "zod";
|
|
1188
|
+
import * as z8 from "zod";
|
|
1189
|
+
var ProducerConfigZod = z8.object({
|
|
1190
|
+
allowlist: z8.preprocess((val) => {
|
|
1061
1191
|
if (typeof val === "string") {
|
|
1062
1192
|
return val.split(",").map((s) => asAddress3(s.trim()));
|
|
1063
1193
|
}
|
|
1064
1194
|
return val;
|
|
1065
|
-
},
|
|
1195
|
+
}, z8.array(AddressZod2).optional().register(globalRegistry7, {
|
|
1066
1196
|
description: "List of allowed producer addresses, if undefined anyone can participate",
|
|
1067
1197
|
title: "allowlist",
|
|
1068
1198
|
type: "array"
|
|
1069
1199
|
})),
|
|
1070
|
-
disableIntentRedeclaration:
|
|
1200
|
+
disableIntentRedeclaration: z8.boolean().optional().register(globalRegistry7, {
|
|
1071
1201
|
description: "Should the producer skip redeclaring their intent to continue producing blocks",
|
|
1072
1202
|
title: "producer.disableIntentRedeclaration",
|
|
1073
1203
|
type: "boolean"
|
|
1074
1204
|
}),
|
|
1075
1205
|
// TODO: Port schema
|
|
1076
|
-
healthCheckPort:
|
|
1206
|
+
healthCheckPort: z8.coerce.number().optional().register(globalRegistry7, {
|
|
1077
1207
|
description: "Port for the Producer health checks",
|
|
1078
1208
|
title: "producer.healthCheckPort",
|
|
1079
1209
|
type: "number"
|
|
1080
1210
|
}),
|
|
1081
|
-
heartbeatInterval:
|
|
1211
|
+
heartbeatInterval: z8.coerce.number().default(36e5).register(globalRegistry7, {
|
|
1082
1212
|
description: "The number of milliseconds between heartbeats if no blocks are produced",
|
|
1083
1213
|
title: "producer.heartbeatInterval",
|
|
1084
1214
|
type: "number"
|
|
1085
1215
|
}),
|
|
1086
1216
|
// TODO: BigInt schema
|
|
1087
|
-
minStake:
|
|
1217
|
+
minStake: z8.coerce.number().default(1).register(globalRegistry7, {
|
|
1088
1218
|
description: "Minimum stake required to be a Producer",
|
|
1089
1219
|
title: "producer.minStake",
|
|
1090
1220
|
type: "number"
|
|
1091
1221
|
}),
|
|
1092
|
-
mnemonic: MnemonicStringZod.optional().register(
|
|
1222
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry7, {
|
|
1093
1223
|
description: "Mnemonic for the Producer wallet",
|
|
1094
1224
|
title: "producer.mnemonic",
|
|
1095
1225
|
type: "string"
|
|
1096
1226
|
}),
|
|
1097
1227
|
// TODO: Port schema
|
|
1098
|
-
port:
|
|
1228
|
+
port: z8.coerce.number().default(8081).register(globalRegistry7, {
|
|
1099
1229
|
default: 8081,
|
|
1100
1230
|
description: "Port for the Producer",
|
|
1101
1231
|
title: "producer.port",
|
|
1102
1232
|
type: "number"
|
|
1103
1233
|
}),
|
|
1104
1234
|
// TODO: Address schema
|
|
1105
|
-
rewardAddress:
|
|
1235
|
+
rewardAddress: z8.string().optional().register(globalRegistry7, {
|
|
1106
1236
|
description: "Address to receive block rewards",
|
|
1107
1237
|
title: "producer.rewardAddress",
|
|
1108
1238
|
type: "string"
|
|
@@ -1110,27 +1240,27 @@ var ProducerConfigZod = z9.object({
|
|
|
1110
1240
|
});
|
|
1111
1241
|
|
|
1112
1242
|
// src/config/RewardRedemptionApi.ts
|
|
1113
|
-
import { globalRegistry as
|
|
1114
|
-
import * as
|
|
1115
|
-
var RewardRedemptionApiConfigZod =
|
|
1116
|
-
chainRpcApiUrl:
|
|
1243
|
+
import { globalRegistry as globalRegistry8 } from "zod";
|
|
1244
|
+
import * as z9 from "zod";
|
|
1245
|
+
var RewardRedemptionApiConfigZod = z9.object({
|
|
1246
|
+
chainRpcApiUrl: z9.string().default("http://localhost:8080/rpc").register(globalRegistry8, {
|
|
1117
1247
|
default: "http://localhost:8080/rpc",
|
|
1118
1248
|
description: "URL for the Chain RPC API",
|
|
1119
1249
|
title: "rewardRedemptionApi.chainRpcApiUrl",
|
|
1120
1250
|
type: "string"
|
|
1121
1251
|
}),
|
|
1122
|
-
host:
|
|
1252
|
+
host: z9.string().default("localhost").register(globalRegistry8, {
|
|
1123
1253
|
default: "localhost",
|
|
1124
1254
|
description: "Host for the Redemption API",
|
|
1125
1255
|
title: "rewardRedemptionApi.host",
|
|
1126
1256
|
type: "string"
|
|
1127
1257
|
}),
|
|
1128
|
-
mnemonic: MnemonicStringZod.optional().register(
|
|
1258
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry8, {
|
|
1129
1259
|
description: "Mnemonic for the Redemption API wallet",
|
|
1130
1260
|
title: "rewardRedemptionApi.mnemonic",
|
|
1131
1261
|
type: "string"
|
|
1132
1262
|
}),
|
|
1133
|
-
port:
|
|
1263
|
+
port: z9.coerce.number().default(8082).register(globalRegistry8, {
|
|
1134
1264
|
default: 8082,
|
|
1135
1265
|
description: "Port for the Redemption API",
|
|
1136
1266
|
title: "rewardRedemptionApi.port",
|
|
@@ -1138,13 +1268,24 @@ var RewardRedemptionApiConfigZod = z10.object({
|
|
|
1138
1268
|
})
|
|
1139
1269
|
});
|
|
1140
1270
|
|
|
1271
|
+
// src/config/Services.ts
|
|
1272
|
+
import { globalRegistry as globalRegistry9 } from "zod";
|
|
1273
|
+
import * as z10 from "zod";
|
|
1274
|
+
var ServicesConfigZod = z10.object({
|
|
1275
|
+
accountBalanceViewerEndpoint: z10.string().optional().register(globalRegistry9, {
|
|
1276
|
+
description: "Endpoint of the API to use for instantiating an external AccountBalanceViewer",
|
|
1277
|
+
title: "services.accountBalanceViewerEndpoint",
|
|
1278
|
+
type: "string"
|
|
1279
|
+
})
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1141
1282
|
// src/config/storage/driver/Mongo.ts
|
|
1142
|
-
import { isDefined as
|
|
1283
|
+
import { isDefined as isDefined8, isUndefined as isUndefined2 } from "@xylabs/sdk-js";
|
|
1143
1284
|
import { globalRegistry as globalRegistry10 } from "zod";
|
|
1144
1285
|
import * as z11 from "zod";
|
|
1145
1286
|
var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
1146
1287
|
if (isUndefined2(config)) return false;
|
|
1147
|
-
return
|
|
1288
|
+
return isDefined8(config.connectionString) && isDefined8(config.database) && isDefined8(config.domain) && isDefined8(config.password) && isDefined8(config.username);
|
|
1148
1289
|
}, "hasMongoConfig");
|
|
1149
1290
|
var MongoConfigZod = z11.object({
|
|
1150
1291
|
// TODO: Create from other arguments
|
|
@@ -1190,6 +1331,23 @@ var StorageConfigZod = z12.object({
|
|
|
1190
1331
|
// src/config/Telemetry.ts
|
|
1191
1332
|
import { globalRegistry as globalRegistry12 } from "zod";
|
|
1192
1333
|
import * as z13 from "zod";
|
|
1334
|
+
var MetricsScrapeConfigZod = z13.object({
|
|
1335
|
+
path: z13.string().default("/metrics").register(globalRegistry12, {
|
|
1336
|
+
default: "/metrics",
|
|
1337
|
+
description: "Path for the metrics scrape endpoint",
|
|
1338
|
+
title: "telemetry.metrics.scrape.path",
|
|
1339
|
+
type: "string"
|
|
1340
|
+
}),
|
|
1341
|
+
port: z13.coerce.number().default(9464).register(globalRegistry12, {
|
|
1342
|
+
default: 9464,
|
|
1343
|
+
description: "Port for the metrics scrape endpoint",
|
|
1344
|
+
title: "telemetry.metrics.scrape.port",
|
|
1345
|
+
type: "number"
|
|
1346
|
+
})
|
|
1347
|
+
}).describe("Metrics scrape configuration");
|
|
1348
|
+
var MetricsConfigZod = z13.object({
|
|
1349
|
+
scrape: MetricsScrapeConfigZod
|
|
1350
|
+
}).describe("Metrics configuration options");
|
|
1193
1351
|
var OpenTelemetryConfigZod = z13.object({
|
|
1194
1352
|
// OpenTelemetry options
|
|
1195
1353
|
otlpEndpoint: z13.url().optional().register(globalRegistry12, {
|
|
@@ -1199,12 +1357,14 @@ var OpenTelemetryConfigZod = z13.object({
|
|
|
1199
1357
|
})
|
|
1200
1358
|
});
|
|
1201
1359
|
var TelemetryConfigZod = z13.object({
|
|
1360
|
+
// Metrics configuration
|
|
1361
|
+
metrics: MetricsConfigZod.optional().describe("Metrics configuration"),
|
|
1202
1362
|
// OpenTelemetry configuration
|
|
1203
1363
|
otel: OpenTelemetryConfigZod.optional().describe("OpenTelemetry configuration")
|
|
1204
1364
|
}).describe("Telemetry configuration options");
|
|
1205
1365
|
|
|
1206
1366
|
// src/config/Validation.ts
|
|
1207
|
-
import { AddressZod as
|
|
1367
|
+
import { AddressZod as AddressZod3, asAddress as asAddress4 } from "@xylabs/sdk-js";
|
|
1208
1368
|
import { globalRegistry as globalRegistry13 } from "zod";
|
|
1209
1369
|
import * as z14 from "zod";
|
|
1210
1370
|
var ValidationConfigZod = z14.object({
|
|
@@ -1213,7 +1373,7 @@ var ValidationConfigZod = z14.object({
|
|
|
1213
1373
|
return val.split(",").map((s) => asAddress4(s.trim()));
|
|
1214
1374
|
}
|
|
1215
1375
|
return val;
|
|
1216
|
-
}, z14.array(
|
|
1376
|
+
}, z14.array(AddressZod3).optional().register(globalRegistry13, {
|
|
1217
1377
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
1218
1378
|
title: "allowedRewardRedeemers",
|
|
1219
1379
|
type: "array"
|
|
@@ -1223,7 +1383,7 @@ var ValidationConfigZod = z14.object({
|
|
|
1223
1383
|
return val.split(",").map((s) => asAddress4(s.trim()));
|
|
1224
1384
|
}
|
|
1225
1385
|
return val;
|
|
1226
|
-
}, z14.array(
|
|
1386
|
+
}, z14.array(AddressZod3).optional().register(globalRegistry13, {
|
|
1227
1387
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
1228
1388
|
title: "allowedRewardEscrowAccountSigners",
|
|
1229
1389
|
type: "array"
|
|
@@ -1237,13 +1397,13 @@ var Xl1CommonConfigSchema = z15.object({
|
|
|
1237
1397
|
var ConfigZod = z15.object({
|
|
1238
1398
|
...Xl1CommonConfigSchema.shape,
|
|
1239
1399
|
api: ApiConfigZod.default(ApiConfigZod.parse({})).describe("Configuration for the API node"),
|
|
1240
|
-
app: AppConfigZod.default(AppConfigZod.parse({})).describe("Configuration for the application"),
|
|
1241
1400
|
bridge: BridgeConfigZod.default(BridgeConfigZod.parse({})).describe("Configuration for the Bridge node"),
|
|
1242
1401
|
chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe("Configuration for the chain"),
|
|
1243
1402
|
evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe("Configuration for EVM-backed services"),
|
|
1244
1403
|
mempool: MempoolConfigZod.default(MempoolConfigZod.parse({})).describe("Configuration for the mempool"),
|
|
1245
1404
|
producer: ProducerConfigZod.default(ProducerConfigZod.parse({})).describe("Configuration for the producer"),
|
|
1246
1405
|
rewardRedemptionApi: RewardRedemptionApiConfigZod.default(RewardRedemptionApiConfigZod.parse({})).describe("Configuration for the rewards redemption API"),
|
|
1406
|
+
services: ServicesConfigZod.default(ServicesConfigZod.parse({})).describe("Configuration for the global services"),
|
|
1247
1407
|
storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe("Configuration for the storage"),
|
|
1248
1408
|
telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe("Configuration for telemetry"),
|
|
1249
1409
|
validation: ValidationConfigZod.default(ValidationConfigZod.parse({})).describe("Configuration for validation")
|
|
@@ -1292,7 +1452,7 @@ var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH = 1760572800;
|
|
|
1292
1452
|
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK = 107496;
|
|
1293
1453
|
|
|
1294
1454
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
1295
|
-
import { AsObjectFactory as
|
|
1455
|
+
import { AsObjectFactory as AsObjectFactory5 } from "@xylabs/sdk-js";
|
|
1296
1456
|
import { isPayloadOfZodType } from "@xyo-network/payload-model";
|
|
1297
1457
|
import z18 from "zod";
|
|
1298
1458
|
|
|
@@ -1327,10 +1487,10 @@ var EIP712DataPayloadFieldsZod = z18.object({
|
|
|
1327
1487
|
});
|
|
1328
1488
|
var EIP712DataPayloadSchema = "network.xyo.chains.ethereum.eip712.data";
|
|
1329
1489
|
var isEIP712DataPayload = isPayloadOfZodType(EIP712DataPayloadFieldsZod, EIP712DataPayloadSchema);
|
|
1330
|
-
var asEIP712DataPayload =
|
|
1490
|
+
var asEIP712DataPayload = AsObjectFactory5.create(isEIP712DataPayload);
|
|
1331
1491
|
|
|
1332
1492
|
// src/eip-712/Payloads/EIP712Signature.ts
|
|
1333
|
-
import { AsObjectFactory as
|
|
1493
|
+
import { AsObjectFactory as AsObjectFactory6, HashZod } from "@xylabs/sdk-js";
|
|
1334
1494
|
import { isPayloadOfZodType as isPayloadOfZodType2 } from "@xyo-network/payload-model";
|
|
1335
1495
|
import z19 from "zod";
|
|
1336
1496
|
var EIP712SignaturePayloadFieldsZod = z19.object({
|
|
@@ -1340,14 +1500,14 @@ var EIP712SignaturePayloadFieldsZod = z19.object({
|
|
|
1340
1500
|
});
|
|
1341
1501
|
var EIP712SignaturePayloadSchema = "network.xyo.chains.ethereum.eip712.signature";
|
|
1342
1502
|
var isEIP712SignaturePayload = isPayloadOfZodType2(EIP712SignaturePayloadFieldsZod, EIP712SignaturePayloadSchema);
|
|
1343
|
-
var asEIP712SignaturePayload =
|
|
1503
|
+
var asEIP712SignaturePayload = AsObjectFactory6.create(isEIP712SignaturePayload);
|
|
1344
1504
|
|
|
1345
1505
|
// src/eip-712/sign.ts
|
|
1346
|
-
import { PayloadBuilder as
|
|
1506
|
+
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
1347
1507
|
var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
1348
1508
|
const { domain, types, values } = data;
|
|
1349
1509
|
const signature = await signer.signTypedData(domain, types, values);
|
|
1350
|
-
const hash = await
|
|
1510
|
+
const hash = await PayloadBuilder4.hash(data);
|
|
1351
1511
|
const address = await signer.getAddress();
|
|
1352
1512
|
return {
|
|
1353
1513
|
address,
|
|
@@ -1359,13 +1519,13 @@ var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
|
1359
1519
|
|
|
1360
1520
|
// src/eip-712/verify.ts
|
|
1361
1521
|
import { asHash as asHash2, isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
1362
|
-
import { PayloadBuilder as
|
|
1522
|
+
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
1363
1523
|
import { verifyTypedData } from "ethers/hash";
|
|
1364
1524
|
var verifyEIP712Message = /* @__PURE__ */ __name(async (data, sig) => {
|
|
1365
1525
|
const { address, signature, hash } = sig;
|
|
1366
1526
|
const { schema, ...fields } = data;
|
|
1367
1527
|
const signedHash = asHash2(hash);
|
|
1368
|
-
if (isUndefined3(signedHash) || signedHash !== await
|
|
1528
|
+
if (isUndefined3(signedHash) || signedHash !== await PayloadBuilder5.hash(data)) return false;
|
|
1369
1529
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
1370
1530
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
1371
1531
|
}, "verifyEIP712Message");
|
|
@@ -1383,20 +1543,20 @@ var RewardMultipliers = {
|
|
|
1383
1543
|
};
|
|
1384
1544
|
|
|
1385
1545
|
// src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts
|
|
1386
|
-
import { AsObjectFactory as
|
|
1387
|
-
import { isPayloadOfSchemaType as
|
|
1546
|
+
import { AsObjectFactory as AsObjectFactory7 } from "@xylabs/sdk-js";
|
|
1547
|
+
import { isPayloadOfSchemaType as isPayloadOfSchemaType5, isStorageMeta as isStorageMeta4 } from "@xyo-network/payload-model";
|
|
1388
1548
|
var ChainIndexingServiceStateSchema = "network.xyo.chain.indexing.service.state";
|
|
1389
1549
|
var isChainIndexingServiceState = /* @__PURE__ */ __name((payload) => {
|
|
1390
|
-
return
|
|
1550
|
+
return isPayloadOfSchemaType5(ChainIndexingServiceStateSchema)(payload);
|
|
1391
1551
|
}, "isChainIndexingServiceState");
|
|
1392
|
-
var asChainIndexingServiceState =
|
|
1393
|
-
var isChainIndexingServiceStateWithStorageMeta = /* @__PURE__ */ __name((value) => isChainIndexingServiceState(value) &&
|
|
1394
|
-
var asChainIndexingServiceStateWithStorageMeta =
|
|
1552
|
+
var asChainIndexingServiceState = AsObjectFactory7.create(isChainIndexingServiceState);
|
|
1553
|
+
var isChainIndexingServiceStateWithStorageMeta = /* @__PURE__ */ __name((value) => isChainIndexingServiceState(value) && isStorageMeta4(value), "isChainIndexingServiceStateWithStorageMeta");
|
|
1554
|
+
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.create(isChainIndexingServiceStateWithStorageMeta);
|
|
1395
1555
|
|
|
1396
1556
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
1397
|
-
import { assertEx as
|
|
1398
|
-
import { spanRootAsync as
|
|
1399
|
-
import { asRange, asXL1BlockNumber as
|
|
1557
|
+
import { assertEx as assertEx8, exists, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1558
|
+
import { spanRootAsync as spanRootAsync4 } from "@xylabs/telemetry";
|
|
1559
|
+
import { asRange, asXL1BlockNumber as asXL1BlockNumber5, asXL1BlockRange as asXL1BlockRange5, AttoXL1, StepSizes as StepSizes9, TransferSchema } from "@xyo-network/xl1-protocol";
|
|
1400
1560
|
var SimpleAccountBalanceViewer = class {
|
|
1401
1561
|
static {
|
|
1402
1562
|
__name(this, "SimpleAccountBalanceViewer");
|
|
@@ -1410,14 +1570,14 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1410
1570
|
this.blockViewer = blockViewer;
|
|
1411
1571
|
}
|
|
1412
1572
|
async accountBalance(address, headOrRange) {
|
|
1413
|
-
const balances = await this.
|
|
1573
|
+
const balances = await this.accountsBalances([
|
|
1414
1574
|
address
|
|
1415
1575
|
], headOrRange);
|
|
1416
1576
|
return balances[address] ?? AttoXL1(0n);
|
|
1417
1577
|
}
|
|
1418
1578
|
async accountBalanceHistory(address, headOrRange) {
|
|
1419
1579
|
const range = asRange(headOrRange);
|
|
1420
|
-
const startingRange =
|
|
1580
|
+
const startingRange = asXL1BlockRange5(range ?? [
|
|
1421
1581
|
0,
|
|
1422
1582
|
await this.blockViewer.currentBlockNumber()
|
|
1423
1583
|
], true);
|
|
@@ -1428,8 +1588,8 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1428
1588
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema ? index : void 0).filter(exists);
|
|
1429
1589
|
const transfers = transferIndexes.map((index) => {
|
|
1430
1590
|
const hash = block[0].payload_hashes[index];
|
|
1431
|
-
return
|
|
1432
|
-
}).filter(exists).filter((t) => t.from === address ||
|
|
1591
|
+
return assertEx8(block[1].find((p) => p._hash === hash), () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`);
|
|
1592
|
+
}).filter(exists).filter((t) => t.from === address || isDefined9(t.transfers[address]));
|
|
1433
1593
|
if (transfers.length === 0) {
|
|
1434
1594
|
continue;
|
|
1435
1595
|
}
|
|
@@ -1447,8 +1607,8 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1447
1607
|
}
|
|
1448
1608
|
return result;
|
|
1449
1609
|
}
|
|
1450
|
-
async
|
|
1451
|
-
return await
|
|
1610
|
+
async accountsBalances(address, _headOrRange) {
|
|
1611
|
+
return await spanRootAsync4("balances", async () => {
|
|
1452
1612
|
const summary = await balancesSummary(this.context);
|
|
1453
1613
|
const result = {};
|
|
1454
1614
|
for (const addr of address) {
|
|
@@ -1458,16 +1618,16 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1458
1618
|
return result;
|
|
1459
1619
|
});
|
|
1460
1620
|
}
|
|
1461
|
-
|
|
1621
|
+
accountsBalancesHistory(_addresses, _rangeOrHash) {
|
|
1462
1622
|
throw new Error("Method not implemented.");
|
|
1463
1623
|
}
|
|
1464
1624
|
async distillTransferHistory(address, range, max = 50) {
|
|
1465
|
-
if (range[1] - range[0] <=
|
|
1625
|
+
if (range[1] - range[0] <= StepSizes9[0] || max <= 1) {
|
|
1466
1626
|
return Array.from({
|
|
1467
1627
|
length: range[1] - range[0] + 1
|
|
1468
|
-
}, (_, i) => range[1] - i).slice(0, max).map((n) =>
|
|
1628
|
+
}, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber5(n, true));
|
|
1469
1629
|
}
|
|
1470
|
-
const frames = deepCalculateFramesFromRange(
|
|
1630
|
+
const frames = deepCalculateFramesFromRange(asXL1BlockRange5(range, true));
|
|
1471
1631
|
const transferSummaryPairs = await Promise.all(frames.map(async (frame) => {
|
|
1472
1632
|
return [
|
|
1473
1633
|
frame,
|
|
@@ -1480,8 +1640,8 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1480
1640
|
});
|
|
1481
1641
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
1482
1642
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
1483
|
-
if (frame[1] - frame[0] + 1 >
|
|
1484
|
-
const values = await this.distillTransferHistory(address,
|
|
1643
|
+
if (frame[1] - frame[0] + 1 > StepSizes9[0]) {
|
|
1644
|
+
const values = await this.distillTransferHistory(address, asXL1BlockRange5([
|
|
1485
1645
|
frame[0],
|
|
1486
1646
|
frame[1] - 1
|
|
1487
1647
|
], true), max - resultBlockNumbers.size);
|
|
@@ -1505,12 +1665,12 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1505
1665
|
};
|
|
1506
1666
|
|
|
1507
1667
|
// src/simple/chainStake/SimpleChainStakeViewer.ts
|
|
1508
|
-
import { asAddress as asAddress5, toAddress as
|
|
1509
|
-
import { AbstractCreatable as AbstractCreatable2, assertEx as
|
|
1668
|
+
import { asAddress as asAddress5, toAddress as toAddress5 } from "@xylabs/sdk-js";
|
|
1669
|
+
import { AbstractCreatable as AbstractCreatable2, assertEx as assertEx9, creatable as creatable2 } from "@xylabs/sdk-js";
|
|
1510
1670
|
import { Account } from "@xyo-network/account";
|
|
1511
1671
|
|
|
1512
1672
|
// src/simple/chainStakeEvents/SimpleChainStakeEventsViewer.ts
|
|
1513
|
-
import { AbstractCreatable, creatable, isDefined as
|
|
1673
|
+
import { AbstractCreatable, creatable, isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
1514
1674
|
function _ts_decorate(decorators, target, key, desc) {
|
|
1515
1675
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1516
1676
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1531,7 +1691,7 @@ var SimpleChainStakeEventsViewer = class extends AbstractCreatable {
|
|
|
1531
1691
|
stakeEvents(range, { name } = {}) {
|
|
1532
1692
|
const positions = this.positionsFromRange(range);
|
|
1533
1693
|
const events = this.eventsFromPositions(positions);
|
|
1534
|
-
if (
|
|
1694
|
+
if (isDefined10(name)) {
|
|
1535
1695
|
return events.filter((event) => event.name === name);
|
|
1536
1696
|
}
|
|
1537
1697
|
return events;
|
|
@@ -1609,7 +1769,7 @@ var SimpleChainStakeViewer = class extends AbstractCreatable2 {
|
|
|
1609
1769
|
_chainId;
|
|
1610
1770
|
_chainStakeEventsViewer;
|
|
1611
1771
|
get chainId() {
|
|
1612
|
-
return
|
|
1772
|
+
return assertEx9(this._chainId, () => "Chain ID not set");
|
|
1613
1773
|
}
|
|
1614
1774
|
get chainMap() {
|
|
1615
1775
|
return this.params.chainMap;
|
|
@@ -1618,13 +1778,13 @@ var SimpleChainStakeViewer = class extends AbstractCreatable2 {
|
|
|
1618
1778
|
return this.params.minWithdrawalBlocks ?? 10;
|
|
1619
1779
|
}
|
|
1620
1780
|
get rewardsContract() {
|
|
1621
|
-
return
|
|
1781
|
+
return toAddress5(toAddress5(1n));
|
|
1622
1782
|
}
|
|
1623
1783
|
get stakeEvents() {
|
|
1624
|
-
return
|
|
1784
|
+
return assertEx9(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
1625
1785
|
}
|
|
1626
1786
|
get stakingTokenAddress() {
|
|
1627
|
-
return
|
|
1787
|
+
return toAddress5("0x000000000000000000000000000011");
|
|
1628
1788
|
}
|
|
1629
1789
|
get positions() {
|
|
1630
1790
|
return this.params.positions;
|
|
@@ -1675,7 +1835,7 @@ var SimpleChainStakeViewer = class extends AbstractCreatable2 {
|
|
|
1675
1835
|
return pending;
|
|
1676
1836
|
}
|
|
1677
1837
|
stakeById(id) {
|
|
1678
|
-
return
|
|
1838
|
+
return assertEx9(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
1679
1839
|
}
|
|
1680
1840
|
stakeByStaker(staker, slot) {
|
|
1681
1841
|
return this.positions.filter((s) => asAddress5(s.staker) === asAddress5(staker))[slot];
|
|
@@ -1738,7 +1898,7 @@ var SimpleXyoClient = class {
|
|
|
1738
1898
|
};
|
|
1739
1899
|
|
|
1740
1900
|
// src/simple/datalake/SimpleDataLakeViewer.ts
|
|
1741
|
-
import { isAnyPayload as
|
|
1901
|
+
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/payload-model";
|
|
1742
1902
|
var SimpleDataLakeViewer = class {
|
|
1743
1903
|
static {
|
|
1744
1904
|
__name(this, "SimpleDataLakeViewer");
|
|
@@ -1769,13 +1929,13 @@ var SimpleDataLakeViewer = class {
|
|
|
1769
1929
|
}
|
|
1770
1930
|
async has(hash) {
|
|
1771
1931
|
const value = await this.get(hash);
|
|
1772
|
-
if (
|
|
1932
|
+
if (isAnyPayload4(value)) {
|
|
1773
1933
|
return this.isAllowed(value);
|
|
1774
1934
|
}
|
|
1775
1935
|
return value !== void 0;
|
|
1776
1936
|
}
|
|
1777
1937
|
isAllowed(value) {
|
|
1778
|
-
if (
|
|
1938
|
+
if (isAnyPayload4(value)) {
|
|
1779
1939
|
return this.isAllowedSchema(value.schema);
|
|
1780
1940
|
}
|
|
1781
1941
|
return true;
|
|
@@ -1842,14 +2002,14 @@ var SimpleXyoGateway = class {
|
|
|
1842
2002
|
};
|
|
1843
2003
|
|
|
1844
2004
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
1845
|
-
import { assertEx as
|
|
1846
|
-
import { PayloadBuilder as
|
|
2005
|
+
import { assertEx as assertEx14, BigIntToJsonZod, isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
2006
|
+
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
1847
2007
|
import { TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
1848
2008
|
|
|
1849
2009
|
// src/transaction/buildTransaction.ts
|
|
1850
|
-
import { assertEx as
|
|
2010
|
+
import { assertEx as assertEx10, toHex as toHex2 } from "@xylabs/sdk-js";
|
|
1851
2011
|
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
1852
|
-
import { PayloadBuilder as
|
|
2012
|
+
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
1853
2013
|
import { defaultTransactionFees } from "@xyo-network/xl1-protocol";
|
|
1854
2014
|
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
1855
2015
|
if (from === void 0 && Array.isArray(signer)) {
|
|
@@ -1866,14 +2026,14 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
1866
2026
|
nbf,
|
|
1867
2027
|
exp
|
|
1868
2028
|
};
|
|
1869
|
-
const elevatedHashes = await
|
|
2029
|
+
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
1870
2030
|
const script = [];
|
|
1871
2031
|
for (const elevatedHash of elevatedHashes) {
|
|
1872
2032
|
script.push(`elevate|${elevatedHash}`);
|
|
1873
2033
|
}
|
|
1874
2034
|
const fields = {
|
|
1875
2035
|
...txBoundWitnessFields,
|
|
1876
|
-
from: from ?? (Array.isArray(signer) ?
|
|
2036
|
+
from: from ?? (Array.isArray(signer) ? assertEx10(signer.at(0)?.address) : signer.address)
|
|
1877
2037
|
};
|
|
1878
2038
|
if (script.length > 0) {
|
|
1879
2039
|
fields.script = script;
|
|
@@ -1887,8 +2047,8 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
1887
2047
|
signer
|
|
1888
2048
|
]).build();
|
|
1889
2049
|
return [
|
|
1890
|
-
await
|
|
1891
|
-
await
|
|
2050
|
+
await PayloadBuilder6.addStorageMeta(tx),
|
|
2051
|
+
await PayloadBuilder6.addStorageMeta(txPayloads)
|
|
1892
2052
|
];
|
|
1893
2053
|
}
|
|
1894
2054
|
__name(buildTransaction, "buildTransaction");
|
|
@@ -1896,7 +2056,7 @@ __name(buildTransaction, "buildTransaction");
|
|
|
1896
2056
|
// src/transaction/buildUnsignedTransaction.ts
|
|
1897
2057
|
import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
1898
2058
|
import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundwitness-builder";
|
|
1899
|
-
import { PayloadBuilder as
|
|
2059
|
+
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1900
2060
|
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol";
|
|
1901
2061
|
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
1902
2062
|
const txBoundWitnessFields = {
|
|
@@ -1910,7 +2070,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
1910
2070
|
nbf,
|
|
1911
2071
|
exp
|
|
1912
2072
|
};
|
|
1913
|
-
const elevatedHashes = await
|
|
2073
|
+
const elevatedHashes = await PayloadBuilder7.hashes(onChainPayloads);
|
|
1914
2074
|
const script = [];
|
|
1915
2075
|
for (const elevatedHash of elevatedHashes) {
|
|
1916
2076
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -1936,7 +2096,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
1936
2096
|
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
1937
2097
|
|
|
1938
2098
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
1939
|
-
import { delay, isDefined as
|
|
2099
|
+
import { delay, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1940
2100
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
1941
2101
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
1942
2102
|
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash, options) => {
|
|
@@ -1945,7 +2105,7 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash,
|
|
|
1945
2105
|
let attempts = 0;
|
|
1946
2106
|
while (true) {
|
|
1947
2107
|
const tx = await viewer.transactionByHash(txHash) ?? void 0;
|
|
1948
|
-
if (
|
|
2108
|
+
if (isDefined11(tx)) {
|
|
1949
2109
|
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
1950
2110
|
return tx;
|
|
1951
2111
|
} else {
|
|
@@ -1962,7 +2122,7 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash,
|
|
|
1962
2122
|
}, "confirmSubmittedTransaction");
|
|
1963
2123
|
|
|
1964
2124
|
// src/transaction/hydrateTransaction.ts
|
|
1965
|
-
import { assertEx as
|
|
2125
|
+
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
1966
2126
|
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
1967
2127
|
import { isAllowedBlockPayload as isAllowedBlockPayload2, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
1968
2128
|
var tryHydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
@@ -2021,15 +2181,15 @@ var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap },
|
|
|
2021
2181
|
return void 0;
|
|
2022
2182
|
}, "tryHydrateElevatedTransaction");
|
|
2023
2183
|
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) => {
|
|
2024
|
-
return
|
|
2184
|
+
return assertEx11(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
2025
2185
|
}, "hydrateElevatedTransaction");
|
|
2026
2186
|
|
|
2027
2187
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
2028
|
-
import { PayloadBuilder as
|
|
2188
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
2029
2189
|
function transactionBlockByteCount([transaction, payloads]) {
|
|
2030
|
-
const cleanTransaction =
|
|
2190
|
+
const cleanTransaction = PayloadBuilder8.omitStorageMeta(transaction);
|
|
2031
2191
|
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
2032
|
-
const cleanPayloads =
|
|
2192
|
+
const cleanPayloads = PayloadBuilder8.omitStorageMeta(payloads);
|
|
2033
2193
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
2034
2194
|
}
|
|
2035
2195
|
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
@@ -2087,7 +2247,7 @@ __name(transactionRequiredGas, "transactionRequiredGas");
|
|
|
2087
2247
|
|
|
2088
2248
|
// src/transaction/script.ts
|
|
2089
2249
|
import { asHash as asHash4 } from "@xylabs/sdk-js";
|
|
2090
|
-
import { assertEx as
|
|
2250
|
+
import { assertEx as assertEx12, filterAs as filterAs2 } from "@xylabs/sdk-js";
|
|
2091
2251
|
import { isAllowedBlockPayloadWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
2092
2252
|
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
2093
2253
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
@@ -2096,7 +2256,7 @@ var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
|
2096
2256
|
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
2097
2257
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
2098
2258
|
const filtered = filterAs2(hashes, (h) => asHash4(h));
|
|
2099
|
-
|
|
2259
|
+
assertEx12(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2100
2260
|
return filtered;
|
|
2101
2261
|
}, "extractElevatedHashesFromScript");
|
|
2102
2262
|
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
@@ -2110,15 +2270,15 @@ var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
|
2110
2270
|
const { script } = bw;
|
|
2111
2271
|
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
2112
2272
|
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
2113
|
-
|
|
2273
|
+
assertEx12(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2114
2274
|
return filtered;
|
|
2115
2275
|
}, "extractElevatedHashes");
|
|
2116
2276
|
|
|
2117
2277
|
// src/transaction/signTransaction.ts
|
|
2118
|
-
import { assertEx as
|
|
2119
|
-
import { PayloadBuilder as
|
|
2278
|
+
import { assertEx as assertEx13, hexFromArrayBuffer, toArrayBuffer } from "@xylabs/sdk-js";
|
|
2279
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
2120
2280
|
async function signTransaction(tx, account) {
|
|
2121
|
-
|
|
2281
|
+
assertEx13(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2122
2282
|
const signedTx = structuredClone(tx);
|
|
2123
2283
|
signedTx.addresses = [
|
|
2124
2284
|
account.address
|
|
@@ -2126,7 +2286,7 @@ async function signTransaction(tx, account) {
|
|
|
2126
2286
|
signedTx.previous_hashes = [
|
|
2127
2287
|
account.previousHash ?? null
|
|
2128
2288
|
];
|
|
2129
|
-
const hash = await
|
|
2289
|
+
const hash = await PayloadBuilder9.dataHash(signedTx);
|
|
2130
2290
|
const hashBytes = toArrayBuffer(hash);
|
|
2131
2291
|
const [signature] = await account.sign(hashBytes);
|
|
2132
2292
|
signedTx.$signatures = [
|
|
@@ -2165,18 +2325,18 @@ var SimpleXyoGatewayRunner = class {
|
|
|
2165
2325
|
return this._dataLakes.length - 1;
|
|
2166
2326
|
}
|
|
2167
2327
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
2168
|
-
const viewer =
|
|
2328
|
+
const viewer = assertEx14(this.connectionInstance.viewer, () => "No viewer available on connection");
|
|
2169
2329
|
const { nbf, exp, chain, fees } = options ?? {};
|
|
2170
|
-
const resolvedChainId =
|
|
2171
|
-
const resolvedNbf =
|
|
2172
|
-
const resolvedExp =
|
|
2330
|
+
const resolvedChainId = isDefined12(chain) ? chain : await viewer.chainId();
|
|
2331
|
+
const resolvedNbf = isDefined12(nbf) ? nbf : await viewer?.currentBlockNumber();
|
|
2332
|
+
const resolvedExp = isDefined12(exp) ? exp : resolvedNbf + 10;
|
|
2173
2333
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await (await this.signer()).address(), fees);
|
|
2174
2334
|
return await this.addTransactionToChain(tx);
|
|
2175
2335
|
}
|
|
2176
2336
|
async addTransactionToChain(tx) {
|
|
2177
2337
|
const connection = this.connectionInstance;
|
|
2178
2338
|
const signer = this.signerInstance;
|
|
2179
|
-
const runner =
|
|
2339
|
+
const runner = assertEx14(connection.runner, () => "No runner available on connection");
|
|
2180
2340
|
const signedTx = await signer.signTransaction(tx);
|
|
2181
2341
|
await this.addPayloadsToDataLakes(signedTx[1]);
|
|
2182
2342
|
return [
|
|
@@ -2188,7 +2348,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
2188
2348
|
];
|
|
2189
2349
|
}
|
|
2190
2350
|
async confirmSubmittedTransaction(txHash, options) {
|
|
2191
|
-
return await confirmSubmittedTransaction(
|
|
2351
|
+
return await confirmSubmittedTransaction(assertEx14(this.connectionInstance.viewer, () => "Connection viewer is undefined"), txHash, options);
|
|
2192
2352
|
}
|
|
2193
2353
|
/** @deprecated use connectionInstance instead */
|
|
2194
2354
|
connection() {
|
|
@@ -2208,7 +2368,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
2208
2368
|
address,
|
|
2209
2369
|
BigIntToJsonZod.parse(amount)
|
|
2210
2370
|
]));
|
|
2211
|
-
const transfer = new
|
|
2371
|
+
const transfer = new PayloadBuilder10({
|
|
2212
2372
|
schema: TransferSchema2
|
|
2213
2373
|
}).fields({
|
|
2214
2374
|
from,
|
|
@@ -2306,7 +2466,7 @@ var SimpleXyoNetwork = class {
|
|
|
2306
2466
|
};
|
|
2307
2467
|
|
|
2308
2468
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
2309
|
-
import { assertEx as
|
|
2469
|
+
import { assertEx as assertEx15 } from "@xylabs/sdk-js";
|
|
2310
2470
|
var SimpleXyoPermissions = class {
|
|
2311
2471
|
static {
|
|
2312
2472
|
__name(this, "SimpleXyoPermissions");
|
|
@@ -2318,7 +2478,7 @@ var SimpleXyoPermissions = class {
|
|
|
2318
2478
|
this.invoker = store.invoker;
|
|
2319
2479
|
}
|
|
2320
2480
|
get store() {
|
|
2321
|
-
return
|
|
2481
|
+
return assertEx15(this._store, () => "Store must be defined to get permissions");
|
|
2322
2482
|
}
|
|
2323
2483
|
async getPermissions() {
|
|
2324
2484
|
return await this.store.getPermissions();
|
|
@@ -2376,7 +2536,7 @@ var SimpleXyoPermissions = class {
|
|
|
2376
2536
|
};
|
|
2377
2537
|
|
|
2378
2538
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
2379
|
-
import { assertEx as
|
|
2539
|
+
import { assertEx as assertEx16 } from "@xylabs/sdk-js";
|
|
2380
2540
|
var MemoryPermissionsStore = class {
|
|
2381
2541
|
static {
|
|
2382
2542
|
__name(this, "MemoryPermissionsStore");
|
|
@@ -2387,7 +2547,7 @@ var MemoryPermissionsStore = class {
|
|
|
2387
2547
|
this._invoker = invoker;
|
|
2388
2548
|
}
|
|
2389
2549
|
get invoker() {
|
|
2390
|
-
return
|
|
2550
|
+
return assertEx16(this._invoker, () => "Invoker must be defined to get permissions");
|
|
2391
2551
|
}
|
|
2392
2552
|
async getPermissions() {
|
|
2393
2553
|
await Promise.resolve();
|
|
@@ -2401,7 +2561,7 @@ var MemoryPermissionsStore = class {
|
|
|
2401
2561
|
|
|
2402
2562
|
// src/simple/runner/SimpleXyoRunner.ts
|
|
2403
2563
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
2404
|
-
import { PayloadBuilder as
|
|
2564
|
+
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/payload-builder";
|
|
2405
2565
|
var SimpleXyoRunner = class {
|
|
2406
2566
|
static {
|
|
2407
2567
|
__name(this, "SimpleXyoRunner");
|
|
@@ -2413,7 +2573,7 @@ var SimpleXyoRunner = class {
|
|
|
2413
2573
|
async broadcastTransaction(transaction) {
|
|
2414
2574
|
const archivist = await this.getMempoolArchivist();
|
|
2415
2575
|
await archivist.insert(flattenHydratedTransaction(transaction));
|
|
2416
|
-
return await
|
|
2576
|
+
return await PayloadBuilder11.hash(transaction[0]);
|
|
2417
2577
|
}
|
|
2418
2578
|
async getMempoolArchivist() {
|
|
2419
2579
|
if (!this._mempoolArchivist) {
|
|
@@ -2426,7 +2586,7 @@ var SimpleXyoRunner = class {
|
|
|
2426
2586
|
};
|
|
2427
2587
|
|
|
2428
2588
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
2429
|
-
import { PayloadBuilder as
|
|
2589
|
+
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/payload-builder";
|
|
2430
2590
|
var SimpleXyoSigner = class {
|
|
2431
2591
|
static {
|
|
2432
2592
|
__name(this, "SimpleXyoSigner");
|
|
@@ -2446,15 +2606,15 @@ var SimpleXyoSigner = class {
|
|
|
2446
2606
|
async signTransaction(tx) {
|
|
2447
2607
|
const txBW = await signTransaction(tx[0], this._account);
|
|
2448
2608
|
return [
|
|
2449
|
-
await
|
|
2450
|
-
await
|
|
2609
|
+
await PayloadBuilder12.addStorageMeta(txBW),
|
|
2610
|
+
await PayloadBuilder12.addStorageMeta(tx[1])
|
|
2451
2611
|
];
|
|
2452
2612
|
}
|
|
2453
2613
|
};
|
|
2454
2614
|
|
|
2455
2615
|
// src/simple/timesync/SimpleTimeSyncViewer.ts
|
|
2456
|
-
import { asHash as asHash5, assertEx as
|
|
2457
|
-
import { asTimePayload, asXL1BlockNumber as
|
|
2616
|
+
import { asHash as asHash5, assertEx as assertEx17, isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
2617
|
+
import { asTimePayload, asXL1BlockNumber as asXL1BlockNumber6, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
2458
2618
|
var SimpleTimeSyncViewer = class {
|
|
2459
2619
|
static {
|
|
2460
2620
|
__name(this, "SimpleTimeSyncViewer");
|
|
@@ -2468,10 +2628,10 @@ var SimpleTimeSyncViewer = class {
|
|
|
2468
2628
|
async convertTime(fromDomain, toDomain, from) {
|
|
2469
2629
|
switch (fromDomain) {
|
|
2470
2630
|
case "xl1": {
|
|
2471
|
-
const [block, payloads] =
|
|
2631
|
+
const [block, payloads] = assertEx17(await this.blockViewer.blockByNumber(asXL1BlockNumber6(from, true)), () => "Block not found");
|
|
2472
2632
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
2473
2633
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
2474
|
-
const timePayload = asTimePayload(
|
|
2634
|
+
const timePayload = asTimePayload(isDefined13(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
2475
2635
|
if (timePayload === void 0) return 0;
|
|
2476
2636
|
switch (toDomain) {
|
|
2477
2637
|
case "xl1": {
|
|
@@ -2534,10 +2694,10 @@ var SimpleTimeSyncViewer = class {
|
|
|
2534
2694
|
];
|
|
2535
2695
|
}
|
|
2536
2696
|
case "ethereum": {
|
|
2537
|
-
const provider =
|
|
2697
|
+
const provider = assertEx17(this.ethProvider, () => "Ethereum provider not configured");
|
|
2538
2698
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
2539
2699
|
const block = await provider.getBlock(blockNumber);
|
|
2540
|
-
const blockHash = asHash5(
|
|
2700
|
+
const blockHash = asHash5(assertEx17(block?.hash, () => "Block hash not found"), true);
|
|
2541
2701
|
return [
|
|
2542
2702
|
blockNumber,
|
|
2543
2703
|
blockHash
|
|
@@ -2554,7 +2714,7 @@ var SimpleTimeSyncViewer = class {
|
|
|
2554
2714
|
};
|
|
2555
2715
|
|
|
2556
2716
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
2557
|
-
import { assertEx as
|
|
2717
|
+
import { assertEx as assertEx18 } from "@xylabs/sdk-js";
|
|
2558
2718
|
import { asTimePayload as asTimePayload2, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol";
|
|
2559
2719
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
2560
2720
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
@@ -2562,7 +2722,7 @@ async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
|
2562
2722
|
const timePayload = asTimePayload2(hydratedBlock[1].find((p) => p.schema === TimeSchema2), {
|
|
2563
2723
|
required: true
|
|
2564
2724
|
});
|
|
2565
|
-
return
|
|
2725
|
+
return assertEx18(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
2566
2726
|
}
|
|
2567
2727
|
__name(xl1BlockNumberToEthBlockNumber, "xl1BlockNumberToEthBlockNumber");
|
|
2568
2728
|
|
|
@@ -2575,6 +2735,337 @@ var prettifyZodError = /* @__PURE__ */ __name((error) => {
|
|
|
2575
2735
|
return z20.prettifyError(error);
|
|
2576
2736
|
}, "prettifyZodError");
|
|
2577
2737
|
|
|
2738
|
+
// src/viewers/AccountBalance.ts
|
|
2739
|
+
import { WithHashMetaZod } from "@xyo-network/payload-model";
|
|
2740
|
+
import { TransferZod } from "@xyo-network/xl1-protocol";
|
|
2741
|
+
import z35 from "zod";
|
|
2742
|
+
|
|
2743
|
+
// src/zod/ArrayBuffer.ts
|
|
2744
|
+
import * as z21 from "zod";
|
|
2745
|
+
function base64Encode(u8) {
|
|
2746
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
|
|
2747
|
+
return Buffer.from(u8).toString("base64");
|
|
2748
|
+
}
|
|
2749
|
+
let binary = "";
|
|
2750
|
+
const chunk = 32768;
|
|
2751
|
+
for (let i = 0; i < u8.length; i += chunk) {
|
|
2752
|
+
binary += String.fromCharCode(...u8.subarray(i, i + chunk));
|
|
2753
|
+
}
|
|
2754
|
+
return btoa(binary);
|
|
2755
|
+
}
|
|
2756
|
+
__name(base64Encode, "base64Encode");
|
|
2757
|
+
function base64Decode(b64) {
|
|
2758
|
+
if (typeof Buffer !== "undefined" && typeof Buffer.from === "function") {
|
|
2759
|
+
return new Uint8Array(Buffer.from(b64, "base64"));
|
|
2760
|
+
}
|
|
2761
|
+
const binary = atob(b64);
|
|
2762
|
+
const u8 = new Uint8Array(binary.length);
|
|
2763
|
+
for (let i = 0; i < binary.length; i++) u8[i] = binary.charCodeAt(i);
|
|
2764
|
+
return u8;
|
|
2765
|
+
}
|
|
2766
|
+
__name(base64Decode, "base64Decode");
|
|
2767
|
+
var ArrayBufferToJsonZod = z21.instanceof(ArrayBuffer).transform((x) => {
|
|
2768
|
+
const u8 = new Uint8Array(x);
|
|
2769
|
+
return base64Encode(u8);
|
|
2770
|
+
});
|
|
2771
|
+
var JsonToArrayBufferZod = z21.string().transform((x) => {
|
|
2772
|
+
const u8 = base64Decode(x);
|
|
2773
|
+
return u8.buffer;
|
|
2774
|
+
});
|
|
2775
|
+
|
|
2776
|
+
// src/zod/BlockBoundWitness.ts
|
|
2777
|
+
import { HashZod as HashZod3 } from "@xylabs/sdk-js";
|
|
2778
|
+
import { StorageMetaZod as StorageMetaZod2 } from "@xyo-network/payload-model";
|
|
2779
|
+
import { XL1BlockNumberZod } from "@xyo-network/xl1-protocol";
|
|
2780
|
+
import * as z24 from "zod";
|
|
2781
|
+
|
|
2782
|
+
// src/zod/BoundWitness.ts
|
|
2783
|
+
import { AddressZod as AddressZod4, HashZod as HashZod2, HexZod } from "@xylabs/sdk-js";
|
|
2784
|
+
import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
|
|
2785
|
+
import { PayloadZod, SchemaZod, StorageMetaZod } from "@xyo-network/payload-model";
|
|
2786
|
+
import * as z22 from "zod";
|
|
2787
|
+
var BoundWitnessRequiredFieldsZod = z22.object({
|
|
2788
|
+
addresses: z22.array(AddressZod4),
|
|
2789
|
+
payload_hashes: z22.array(HashZod2),
|
|
2790
|
+
payload_schemas: z22.array(SchemaZod),
|
|
2791
|
+
previous_hashes: z22.array(HashZod2.nullable())
|
|
2792
|
+
});
|
|
2793
|
+
var BoundWitnessMetaZod = z22.object({
|
|
2794
|
+
$destination: AddressZod4.optional(),
|
|
2795
|
+
$sourceQuery: HashZod2.optional(),
|
|
2796
|
+
$signatures: z22.array(z22.union([
|
|
2797
|
+
HexZod,
|
|
2798
|
+
z22.null()
|
|
2799
|
+
]))
|
|
2800
|
+
});
|
|
2801
|
+
var BoundWitnessZod = PayloadZod.extend({
|
|
2802
|
+
schema: z22.literal(BoundWitnessSchema)
|
|
2803
|
+
}).extend(BoundWitnessRequiredFieldsZod.shape).extend(BoundWitnessMetaZod.shape).refine((data) => data.$signatures.length === data.addresses.length, {
|
|
2804
|
+
message: "$signatures length must equal addresses length"
|
|
2805
|
+
});
|
|
2806
|
+
var AnyBoundWitnessZod = BoundWitnessZod.catchall(z22.any());
|
|
2807
|
+
var UnsignedBoundWitnessZod = BoundWitnessZod.refine((data) => data.$signatures.includes(null), {
|
|
2808
|
+
message: "all $signatures must be null"
|
|
2809
|
+
});
|
|
2810
|
+
var AnyUnsignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z22.any());
|
|
2811
|
+
var UnsignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessZod.safeExtend(BoundWitnessRequiredFieldsZod.shape).safeExtend(BoundWitnessMetaZod.shape).safeExtend(StorageMetaZod.shape);
|
|
2812
|
+
var SignedBoundWitnessZod = BoundWitnessZod.refine((data) => !data.$signatures.includes(null), {
|
|
2813
|
+
message: "all $signatures must not be null"
|
|
2814
|
+
});
|
|
2815
|
+
var SignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod;
|
|
2816
|
+
var AnySignedBoundWitnessZod = UnsignedBoundWitnessZod.catchall(z22.any());
|
|
2817
|
+
var AnySignedBoundWitnessWithStorageMetaZod = UnsignedBoundWitnessWithStorageMetaZod.catchall(z22.any());
|
|
2818
|
+
|
|
2819
|
+
// src/zod/Chain.ts
|
|
2820
|
+
import { AddressRegEx, toAddress as toAddress6 } from "@xylabs/sdk-js";
|
|
2821
|
+
import * as z23 from "zod";
|
|
2822
|
+
var ChainZod = z23.string().toLowerCase().regex(AddressRegEx).transform((v) => toAddress6(v));
|
|
2823
|
+
|
|
2824
|
+
// src/zod/BlockBoundWitness.ts
|
|
2825
|
+
var BlockBoundWitnessFieldsZod = z24.object({
|
|
2826
|
+
block: XL1BlockNumberZod,
|
|
2827
|
+
chain: ChainZod,
|
|
2828
|
+
previous: HashZod3.nullable(),
|
|
2829
|
+
protocol: z24.number(),
|
|
2830
|
+
step_hashes: z24.array(HashZod3).optional()
|
|
2831
|
+
});
|
|
2832
|
+
var BlockBoundWitnessMetaZod = z24.object({
|
|
2833
|
+
$epoch: z24.number()
|
|
2834
|
+
});
|
|
2835
|
+
var BlockBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod2.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
2836
|
+
var SignedBlockBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod2.partial()).merge(BlockBoundWitnessFieldsZod).merge(BlockBoundWitnessMetaZod);
|
|
2837
|
+
|
|
2838
|
+
// src/zod/HydratedBlock.ts
|
|
2839
|
+
import { PayloadZodLoose, WithStorageMetaZod } from "@xyo-network/payload-model";
|
|
2840
|
+
import * as z25 from "zod";
|
|
2841
|
+
var HydratedBlockZod = z25.tuple([
|
|
2842
|
+
BlockBoundWitnessZod,
|
|
2843
|
+
z25.array(PayloadZodLoose)
|
|
2844
|
+
]);
|
|
2845
|
+
var HydratedBlockWithStorageMetaZod = z25.tuple([
|
|
2846
|
+
WithStorageMetaZod(BlockBoundWitnessZod),
|
|
2847
|
+
z25.array(WithStorageMetaZod(PayloadZodLoose))
|
|
2848
|
+
]);
|
|
2849
|
+
var SignedHydratedBlockZod = z25.tuple([
|
|
2850
|
+
SignedBlockBoundWitnessZod,
|
|
2851
|
+
z25.array(PayloadZodLoose)
|
|
2852
|
+
]);
|
|
2853
|
+
var SignedHydratedBlockToJsonZod = z25.tuple([
|
|
2854
|
+
SignedBlockBoundWitnessZod,
|
|
2855
|
+
z25.array(PayloadZodLoose)
|
|
2856
|
+
]);
|
|
2857
|
+
var SignedHydratedBlockWithStorageMetaZod = z25.tuple([
|
|
2858
|
+
WithStorageMetaZod(SignedBlockBoundWitnessZod),
|
|
2859
|
+
z25.array(WithStorageMetaZod(PayloadZodLoose))
|
|
2860
|
+
]);
|
|
2861
|
+
|
|
2862
|
+
// src/zod/HydratedTransaction.ts
|
|
2863
|
+
import { asAnyPayload, PayloadZodLoose as PayloadZodLoose2 } from "@xyo-network/payload-model";
|
|
2864
|
+
import { asSignedHydratedTransaction } from "@xyo-network/xl1-protocol";
|
|
2865
|
+
import * as z28 from "zod";
|
|
2866
|
+
|
|
2867
|
+
// src/zod/TransactionBoundWitness.ts
|
|
2868
|
+
import { StorageMetaZod as StorageMetaZod3 } from "@xyo-network/payload-model";
|
|
2869
|
+
import { BlockNumberZod } from "@xyo-network/xl1-protocol";
|
|
2870
|
+
import * as z27 from "zod";
|
|
2871
|
+
|
|
2872
|
+
// src/zod/TransactionFees.ts
|
|
2873
|
+
import { BigIntToJsonZod as BigIntToJsonZod2, HexZod as HexZod2, JsonToBigIntZod } from "@xylabs/sdk-js";
|
|
2874
|
+
import { asAttoXL1 as asAttoXL12 } from "@xyo-network/xl1-protocol";
|
|
2875
|
+
import * as z26 from "zod";
|
|
2876
|
+
var AttoZod = z26.bigint();
|
|
2877
|
+
var JsonToAttoZod = JsonToBigIntZod.transform((v) => asAttoXL12(v));
|
|
2878
|
+
var AttoToJsonZod = BigIntToJsonZod2;
|
|
2879
|
+
var TransactionFeesHexZod = z26.object({
|
|
2880
|
+
base: HexZod2,
|
|
2881
|
+
gasLimit: HexZod2,
|
|
2882
|
+
gasPrice: HexZod2,
|
|
2883
|
+
priority: HexZod2
|
|
2884
|
+
});
|
|
2885
|
+
var TransactionFeesBigIntZod = z26.object({
|
|
2886
|
+
base: AttoZod,
|
|
2887
|
+
gasLimit: AttoZod,
|
|
2888
|
+
gasPrice: AttoZod,
|
|
2889
|
+
priority: AttoZod
|
|
2890
|
+
});
|
|
2891
|
+
var TransactionFeesJsonToBigIntZod = TransactionFeesHexZod.transform((val) => ({
|
|
2892
|
+
base: JsonToBigIntZod.parse(val.base),
|
|
2893
|
+
gasLimit: JsonToBigIntZod.parse(val.gasLimit),
|
|
2894
|
+
gasPrice: JsonToBigIntZod.parse(val.gasPrice),
|
|
2895
|
+
priority: JsonToBigIntZod.parse(val.priority)
|
|
2896
|
+
}));
|
|
2897
|
+
var TransactionFeesBigIntToJsonZod = TransactionFeesBigIntZod.transform((val) => ({
|
|
2898
|
+
base: BigIntToJsonZod2.parse(val.base),
|
|
2899
|
+
gasLimit: BigIntToJsonZod2.parse(val.gasLimit),
|
|
2900
|
+
gasPrice: BigIntToJsonZod2.parse(val.gasPrice),
|
|
2901
|
+
priority: BigIntToJsonZod2.parse(val.priority)
|
|
2902
|
+
}));
|
|
2903
|
+
|
|
2904
|
+
// src/zod/TransactionBoundWitness.ts
|
|
2905
|
+
var BlockStartZod = z27.object({
|
|
2906
|
+
nbf: BlockNumberZod
|
|
2907
|
+
});
|
|
2908
|
+
var BlockEndZod = z27.object({
|
|
2909
|
+
exp: BlockNumberZod
|
|
2910
|
+
});
|
|
2911
|
+
var BlockDurationZod = z27.object({
|
|
2912
|
+
nbf: BlockNumberZod,
|
|
2913
|
+
exp: BlockNumberZod
|
|
2914
|
+
});
|
|
2915
|
+
var BlockScriptsZod = z27.object({
|
|
2916
|
+
script: z27.array(z27.string()).optional()
|
|
2917
|
+
});
|
|
2918
|
+
var WithTransactionFeesZod = z27.object({
|
|
2919
|
+
fees: TransactionFeesHexZod
|
|
2920
|
+
});
|
|
2921
|
+
var TransactionBoundWitnessFields = z27.object({
|
|
2922
|
+
chain: ChainZod,
|
|
2923
|
+
from: ChainZod
|
|
2924
|
+
});
|
|
2925
|
+
var TransactionBoundWitnessZod = UnsignedBoundWitnessZod.merge(StorageMetaZod3.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod);
|
|
2926
|
+
var SignedTransactionBoundWitnessZod = SignedBoundWitnessZod.merge(StorageMetaZod3.partial()).merge(BlockDurationZod).merge(WithTransactionFeesZod).merge(TransactionBoundWitnessFields).merge(BlockScriptsZod.partial());
|
|
2927
|
+
|
|
2928
|
+
// src/zod/HydratedTransaction.ts
|
|
2929
|
+
var HydratedTransactionZod = z28.tuple([
|
|
2930
|
+
TransactionBoundWitnessZod,
|
|
2931
|
+
z28.array(PayloadZodLoose2)
|
|
2932
|
+
]);
|
|
2933
|
+
var UnsignedHydratedTransactionZod = z28.tuple([
|
|
2934
|
+
TransactionBoundWitnessZod,
|
|
2935
|
+
z28.array(PayloadZodLoose2)
|
|
2936
|
+
]);
|
|
2937
|
+
var SignedHydratedTransactionZod = z28.tuple([
|
|
2938
|
+
SignedTransactionBoundWitnessZod,
|
|
2939
|
+
z28.array(PayloadZodLoose2)
|
|
2940
|
+
]);
|
|
2941
|
+
var SignedHydratedTransactionToJsonZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => asSignedHydratedTransaction([
|
|
2942
|
+
tx,
|
|
2943
|
+
payloads.map((payload) => payload)
|
|
2944
|
+
]));
|
|
2945
|
+
var JsonToSignedHydratedTransactionZod = SignedHydratedTransactionZod.transform(([tx, payloads]) => [
|
|
2946
|
+
asSignedHydratedTransaction(tx),
|
|
2947
|
+
payloads.map((p) => asAnyPayload(p))
|
|
2948
|
+
]);
|
|
2949
|
+
|
|
2950
|
+
// src/zod/Permission.ts
|
|
2951
|
+
import { z as z29 } from "zod";
|
|
2952
|
+
var CaveatTypesZod = z29.enum([
|
|
2953
|
+
"chain",
|
|
2954
|
+
"expiration",
|
|
2955
|
+
"filteredResponse",
|
|
2956
|
+
"rateLimit",
|
|
2957
|
+
"restrictReturnedAccounts"
|
|
2958
|
+
]);
|
|
2959
|
+
var CaveatsZod = z29.object({
|
|
2960
|
+
type: CaveatTypesZod,
|
|
2961
|
+
value: z29.json()
|
|
2962
|
+
});
|
|
2963
|
+
var PermissionZod = z29.object({
|
|
2964
|
+
parentCapability: z29.string(),
|
|
2965
|
+
caveats: CaveatsZod.array().optional(),
|
|
2966
|
+
invoker: z29.string()
|
|
2967
|
+
});
|
|
2968
|
+
var InvokerPermissionZod = PermissionZod.extend({
|
|
2969
|
+
date: z29.number().optional()
|
|
2970
|
+
});
|
|
2971
|
+
var PermissionRequestZod = z29.record(z29.string(), z29.record(z29.string(), z29.any()));
|
|
2972
|
+
var RequestedPermissionZod = z29.object({
|
|
2973
|
+
parentCapability: z29.string(),
|
|
2974
|
+
date: z29.number().optional()
|
|
2975
|
+
});
|
|
2976
|
+
|
|
2977
|
+
// src/zod/RewardsRangeOptions.ts
|
|
2978
|
+
import { AddressZod as AddressZod5 } from "@xylabs/sdk-js";
|
|
2979
|
+
import { BlockRangeZod, StepIdentityZod } from "@xyo-network/xl1-protocol";
|
|
2980
|
+
import { z as z30 } from "zod";
|
|
2981
|
+
var RewardsRangeOptionsZod = z30.object({
|
|
2982
|
+
positions: z30.array(z30.number()).optional(),
|
|
2983
|
+
range: BlockRangeZod.optional(),
|
|
2984
|
+
steps: z30.array(StepIdentityZod).optional(),
|
|
2985
|
+
stakers: z30.array(AddressZod5).optional()
|
|
2986
|
+
});
|
|
2987
|
+
|
|
2988
|
+
// src/zod/Sequence.ts
|
|
2989
|
+
import { HexRegExMinMax, toHex as toHex4 } from "@xylabs/sdk-js";
|
|
2990
|
+
import { SequenceConstants } from "@xyo-network/payload-model";
|
|
2991
|
+
import * as z31 from "zod";
|
|
2992
|
+
var LocalSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.localSequenceBytes, SequenceConstants.localSequenceBytes));
|
|
2993
|
+
var LocalSequenceToStringZod = z31.string().regex(LocalSequenceRegex);
|
|
2994
|
+
var LocalSequenceFromStringZod = z31.string().regex(LocalSequenceRegex).transform((v) => toHex4(v));
|
|
2995
|
+
var QualifiedSequenceRegex = new RegExp(HexRegExMinMax(SequenceConstants.qualifiedSequenceBytes, SequenceConstants.qualifiedSequenceBytes));
|
|
2996
|
+
var QualifiedSequenceToStringZod = z31.string().regex(QualifiedSequenceRegex);
|
|
2997
|
+
var QualifiedSequenceFromStringZod = z31.string().regex(QualifiedSequenceRegex).transform((v) => toHex4(v));
|
|
2998
|
+
var SequenceToStringZod = z31.union([
|
|
2999
|
+
LocalSequenceToStringZod,
|
|
3000
|
+
QualifiedSequenceToStringZod
|
|
3001
|
+
]);
|
|
3002
|
+
var SequenceFromStringZod = z31.union([
|
|
3003
|
+
LocalSequenceFromStringZod,
|
|
3004
|
+
QualifiedSequenceFromStringZod
|
|
3005
|
+
]);
|
|
3006
|
+
|
|
3007
|
+
// src/zod/Stake.ts
|
|
3008
|
+
import { AddressZod as AddressZod6, HexZod as HexZod3 } from "@xylabs/sdk-js";
|
|
3009
|
+
import * as z32 from "zod";
|
|
3010
|
+
var StakeZod = z32.object({
|
|
3011
|
+
amount: AttoZod,
|
|
3012
|
+
// the block number when the stake was added
|
|
3013
|
+
addBlock: z32.number(),
|
|
3014
|
+
// the unique id for the stake item
|
|
3015
|
+
id: z32.number(),
|
|
3016
|
+
// the block number when the stake was removed (set to 0 if not removed)
|
|
3017
|
+
removeBlock: z32.number(),
|
|
3018
|
+
// the address that is being staked
|
|
3019
|
+
staked: AddressZod6,
|
|
3020
|
+
// the address that owns the stake
|
|
3021
|
+
staker: AddressZod6,
|
|
3022
|
+
// the block number when the stake was withdrawn (set to 0 if not withdrawn)
|
|
3023
|
+
withdrawBlock: z32.number()
|
|
3024
|
+
});
|
|
3025
|
+
var StakeToJsonZod = StakeZod.transform((val) => ({
|
|
3026
|
+
addBlock: val.addBlock,
|
|
3027
|
+
amount: AttoToJsonZod.parse(val.amount),
|
|
3028
|
+
id: val.id,
|
|
3029
|
+
removeBlock: val.removeBlock,
|
|
3030
|
+
staked: AddressZod6.parse(val.staked),
|
|
3031
|
+
staker: AddressZod6.parse(val.staker),
|
|
3032
|
+
withdrawBlock: val.withdrawBlock
|
|
3033
|
+
}));
|
|
3034
|
+
var JsonToStakeZod = StakeZod.extend({
|
|
3035
|
+
amount: HexZod3
|
|
3036
|
+
}).transform((val) => ({
|
|
3037
|
+
addBlock: val.addBlock,
|
|
3038
|
+
amount: JsonToAttoZod.parse(val.amount),
|
|
3039
|
+
id: val.id,
|
|
3040
|
+
removeBlock: val.removeBlock,
|
|
3041
|
+
staked: val.staked,
|
|
3042
|
+
staker: val.staker,
|
|
3043
|
+
withdrawBlock: val.withdrawBlock
|
|
3044
|
+
}));
|
|
3045
|
+
|
|
3046
|
+
// src/zod/TimeDomain.ts
|
|
3047
|
+
import * as z33 from "zod";
|
|
3048
|
+
var TimeDomainZod = z33.union([
|
|
3049
|
+
z33.literal("xl1"),
|
|
3050
|
+
z33.literal("epoch"),
|
|
3051
|
+
z33.literal("ethereum")
|
|
3052
|
+
]);
|
|
3053
|
+
|
|
3054
|
+
// src/zod/TransferPair.ts
|
|
3055
|
+
import { AddressZod as AddressZod7 } from "@xylabs/sdk-js";
|
|
3056
|
+
import z34 from "zod";
|
|
3057
|
+
var TransferPairZod = z34.tuple([
|
|
3058
|
+
AddressZod7,
|
|
3059
|
+
AddressZod7
|
|
3060
|
+
]);
|
|
3061
|
+
|
|
3062
|
+
// src/viewers/AccountBalance.ts
|
|
3063
|
+
var AccountBalanceHistoryItemZod = z35.tuple([
|
|
3064
|
+
WithHashMetaZod(BlockBoundWitnessZod),
|
|
3065
|
+
WithHashMetaZod(TransactionBoundWitnessZod).nullable(),
|
|
3066
|
+
WithHashMetaZod(TransferZod)
|
|
3067
|
+
]);
|
|
3068
|
+
|
|
2578
3069
|
// src/viewers/StakeEvents.ts
|
|
2579
3070
|
var StakeEventNames = [
|
|
2580
3071
|
"StakeAdded",
|
|
@@ -2612,12 +3103,29 @@ var generateXyoBaseWalletFromPhrase = /* @__PURE__ */ __name((walletPhrase) => {
|
|
|
2612
3103
|
export {
|
|
2613
3104
|
ACCOUNT_TYPE,
|
|
2614
3105
|
ADDRESS_INDEX,
|
|
3106
|
+
AccountBalanceHistoryItemZod,
|
|
2615
3107
|
AddressPairSchema,
|
|
3108
|
+
AnyBoundWitnessZod,
|
|
3109
|
+
AnySignedBoundWitnessWithStorageMetaZod,
|
|
3110
|
+
AnySignedBoundWitnessZod,
|
|
3111
|
+
AnyUnsignedBoundWitnessZod,
|
|
3112
|
+
ArrayBufferToJsonZod,
|
|
3113
|
+
AttoToJsonZod,
|
|
3114
|
+
AttoZod,
|
|
2616
3115
|
BalancesStepSummarySchema,
|
|
3116
|
+
BlockBoundWitnessZod,
|
|
3117
|
+
BlockDurationZod,
|
|
3118
|
+
BlockEndZod,
|
|
3119
|
+
BlockScriptsZod,
|
|
3120
|
+
BlockStartZod,
|
|
2617
3121
|
BlockValidationError,
|
|
3122
|
+
BoundWitnessZod,
|
|
2618
3123
|
CHANGE_ADDRESS,
|
|
2619
3124
|
COIN_TYPES,
|
|
3125
|
+
CaveatTypesZod,
|
|
3126
|
+
CaveatsZod,
|
|
2620
3127
|
ChainIndexingServiceStateSchema,
|
|
3128
|
+
ChainZod,
|
|
2621
3129
|
ConfigZod,
|
|
2622
3130
|
DEFAULT_WALLET_PATH,
|
|
2623
3131
|
EIP712DataPayloadFieldsZod,
|
|
@@ -2627,12 +3135,40 @@ export {
|
|
|
2627
3135
|
GlobalMetaSchema,
|
|
2628
3136
|
HydratedBlockStateValidationError,
|
|
2629
3137
|
HydratedBlockValidationError,
|
|
3138
|
+
HydratedBlockWithStorageMetaZod,
|
|
3139
|
+
HydratedBlockZod,
|
|
3140
|
+
HydratedTransactionZod,
|
|
3141
|
+
InvokerPermissionZod,
|
|
2630
3142
|
JSONSchemaMetaSchema,
|
|
3143
|
+
JsonToArrayBufferZod,
|
|
3144
|
+
JsonToAttoZod,
|
|
3145
|
+
JsonToSignedHydratedTransactionZod,
|
|
3146
|
+
JsonToStakeZod,
|
|
3147
|
+
LocalSequenceFromStringZod,
|
|
3148
|
+
LocalSequenceToStringZod,
|
|
2631
3149
|
LruCacheMap,
|
|
2632
3150
|
MemoryMap,
|
|
2633
3151
|
MemoryPermissionsStore,
|
|
2634
3152
|
MnemonicStringZod,
|
|
3153
|
+
PermissionRequestZod,
|
|
3154
|
+
PermissionZod,
|
|
3155
|
+
QualifiedSequenceFromStringZod,
|
|
3156
|
+
QualifiedSequenceToStringZod,
|
|
3157
|
+
RequestedPermissionZod,
|
|
2635
3158
|
RewardMultipliers,
|
|
3159
|
+
RewardsRangeOptionsZod,
|
|
3160
|
+
SchemasStepSummarySchema,
|
|
3161
|
+
SequenceFromStringZod,
|
|
3162
|
+
SequenceToStringZod,
|
|
3163
|
+
SignedBlockBoundWitnessZod,
|
|
3164
|
+
SignedBoundWitnessWithStorageMetaZod,
|
|
3165
|
+
SignedBoundWitnessZod,
|
|
3166
|
+
SignedHydratedBlockToJsonZod,
|
|
3167
|
+
SignedHydratedBlockWithStorageMetaZod,
|
|
3168
|
+
SignedHydratedBlockZod,
|
|
3169
|
+
SignedHydratedTransactionToJsonZod,
|
|
3170
|
+
SignedHydratedTransactionZod,
|
|
3171
|
+
SignedTransactionBoundWitnessZod,
|
|
2636
3172
|
SimpleAccountBalanceViewer,
|
|
2637
3173
|
SimpleChainStakeViewer,
|
|
2638
3174
|
SimpleDataLakeRunner,
|
|
@@ -2646,15 +3182,28 @@ export {
|
|
|
2646
3182
|
SimpleXyoRunner,
|
|
2647
3183
|
SimpleXyoSigner,
|
|
2648
3184
|
StakeEventNames,
|
|
3185
|
+
StakeToJsonZod,
|
|
3186
|
+
StakeZod,
|
|
2649
3187
|
StepSummarySchema,
|
|
2650
3188
|
TODO,
|
|
3189
|
+
TimeDomainZod,
|
|
3190
|
+
TransactionBoundWitnessZod,
|
|
3191
|
+
TransactionFeesBigIntToJsonZod,
|
|
3192
|
+
TransactionFeesBigIntZod,
|
|
3193
|
+
TransactionFeesHexZod,
|
|
3194
|
+
TransactionFeesJsonToBigIntZod,
|
|
3195
|
+
TransferPairZod,
|
|
2651
3196
|
TransfersStepSummarySchema,
|
|
2652
3197
|
TypedDataDomainZod,
|
|
2653
3198
|
TypedDataFieldZod,
|
|
2654
3199
|
TypedDataTypesZod,
|
|
2655
3200
|
TypedDataValueZod,
|
|
3201
|
+
UnsignedBoundWitnessWithStorageMetaZod,
|
|
3202
|
+
UnsignedBoundWitnessZod,
|
|
3203
|
+
UnsignedHydratedTransactionZod,
|
|
2656
3204
|
UsageMetaSchema,
|
|
2657
3205
|
WALLET_COMPLIANCE,
|
|
3206
|
+
WithTransactionFeesZod,
|
|
2658
3207
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH,
|
|
2659
3208
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK,
|
|
2660
3209
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS,
|
|
@@ -2670,6 +3219,8 @@ export {
|
|
|
2670
3219
|
asEIP712DataPayload,
|
|
2671
3220
|
asEIP712SignaturePayload,
|
|
2672
3221
|
asOptionalAddressPairPayload,
|
|
3222
|
+
asSchemasStepSummary,
|
|
3223
|
+
asSchemasStepSummaryWithStorageMeta,
|
|
2673
3224
|
asTransfersStepSummary,
|
|
2674
3225
|
asTransfersStepSummaryWithStorageMeta,
|
|
2675
3226
|
balancesStepSummaryFromRange,
|
|
@@ -2716,16 +3267,21 @@ export {
|
|
|
2716
3267
|
isPositiveBigInt,
|
|
2717
3268
|
isReadArchivist,
|
|
2718
3269
|
isReadWriteArchivist,
|
|
3270
|
+
isSchemasStepSummary,
|
|
3271
|
+
isSchemasStepSummaryWithStorageMeta,
|
|
2719
3272
|
isTransfersStepSummary,
|
|
2720
3273
|
isTransfersStepSummaryWithStorageMeta,
|
|
2721
3274
|
isUsageMeta,
|
|
2722
3275
|
isWriteArchivist,
|
|
2723
3276
|
isZodError,
|
|
2724
3277
|
netBalancesForPayloads,
|
|
3278
|
+
netSchemasForPayloads,
|
|
2725
3279
|
netTransfersForPayloads,
|
|
2726
3280
|
parseSignedBigInt,
|
|
2727
3281
|
prettifyZodError,
|
|
2728
3282
|
readPayloadMapFromStore,
|
|
3283
|
+
schemasStepSummaryFromRange,
|
|
3284
|
+
schemasSummary,
|
|
2729
3285
|
signEIP712Message,
|
|
2730
3286
|
signTransaction,
|
|
2731
3287
|
stepBlockRange,
|