@xyo-network/xl1-protocol-sdk 1.16.24 → 1.16.26
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/block/hydrate/blockPayloadsFromHydratedBlock.d.ts +3 -3
- package/dist/neutral/block/hydrate/blockPayloadsFromHydratedBlock.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/flattenHydratedBlock.d.ts +3 -3
- package/dist/neutral/block/hydrate/flattenHydratedBlock.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/flattenHydratedBlocks.d.ts +3 -3
- package/dist/neutral/block/hydrate/flattenHydratedBlocks.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts +2 -2
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/transactionsFromHydratedBlock.d.ts +2 -3
- package/dist/neutral/block/hydrate/transactionsFromHydratedBlock.d.ts.map +1 -1
- package/dist/neutral/block/primitives/blockFromBlockNumber.d.ts +3 -2
- package/dist/neutral/block/primitives/blockFromBlockNumber.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +1 -0
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Services.d.ts +1 -0
- package/dist/neutral/config/Services.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +0 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +534 -851
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/instances/transaction/HydratedTransaction.d.ts +2 -3
- package/dist/neutral/instances/transaction/HydratedTransaction.d.ts.map +1 -1
- package/dist/neutral/instances/transaction/TransactionFields.d.ts +3 -2
- package/dist/neutral/instances/transaction/TransactionFields.d.ts.map +1 -1
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts +4 -0
- package/dist/neutral/model/PayloadBundle/bundledPayloadToHydratedTransaction.d.ts.map +1 -0
- package/dist/neutral/model/PayloadBundle/hydratedTransactionToPayloadBundle.d.ts +4 -0
- package/dist/neutral/model/PayloadBundle/hydratedTransactionToPayloadBundle.d.ts.map +1 -0
- package/dist/neutral/model/PayloadBundle/index.d.ts +3 -0
- package/dist/neutral/model/PayloadBundle/index.d.ts.map +1 -0
- package/dist/neutral/model/index.d.ts +1 -0
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/schemas/schemasStepSummaryFromRange.d.ts +2 -2
- package/dist/neutral/primitives/summary/schemas/schemasStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/primitives/transaction/elevatedPayloads.d.ts +3 -3
- package/dist/neutral/primitives/transaction/elevatedPayloads.d.ts.map +1 -1
- package/dist/neutral/provider/TransactionSubmitter.d.ts +3 -3
- package/dist/neutral/provider/TransactionSubmitter.d.ts.map +1 -1
- package/dist/neutral/provider/XyoGatewayRunner.d.ts +3 -3
- package/dist/neutral/provider/XyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/provider/signer/XyoSigner.d.ts +2 -2
- package/dist/neutral/provider/signer/XyoSigner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +3 -0
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/services/BlockProducerService.d.ts +2 -2
- package/dist/neutral/services/BlockProducerService.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +18 -6
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts +2 -2
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +9 -0
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -0
- package/dist/neutral/simple/mempool/index.d.ts +2 -0
- package/dist/neutral/simple/mempool/index.d.ts.map +1 -0
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +3 -4
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/transaction/buildTransaction.d.ts +2 -2
- package/dist/neutral/transaction/buildTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts +2 -2
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/hydrateTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionBlockByteCount.d.ts +2 -2
- package/dist/neutral/transaction/primitives/transactionBlockByteCount.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts +2 -2
- package/dist/neutral/transaction/primitives/transactionElevatedPayloads.d.ts.map +1 -1
- package/dist/neutral/transaction/primitives/transactionRequiredGas.d.ts +3 -3
- package/dist/neutral/transaction/primitives/transactionRequiredGas.d.ts.map +1 -1
- package/dist/neutral/transaction/script.d.ts +3 -3
- package/dist/neutral/transaction/script.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +23 -3
- package/dist/neutral/transaction/signTransaction.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/validation/block/HydratedBlockValidationFunction.d.ts +2 -2
- package/dist/neutral/validation/block/HydratedBlockValidationFunction.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +20 -26
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +5 -5
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/Mempool.d.ts +14 -0
- package/dist/neutral/viewers/Mempool.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +1 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/block/hydrate/blockPayloadsFromHydratedBlock.ts +5 -5
- package/src/block/hydrate/flattenHydratedBlock.ts +3 -3
- package/src/block/hydrate/flattenHydratedBlocks.ts +3 -3
- package/src/block/hydrate/hydrateBlock.ts +2 -2
- package/src/block/hydrate/transactionsFromHydratedBlock.ts +4 -6
- package/src/block/primitives/blockFromBlockNumber.ts +27 -7
- package/src/config/Services.ts +5 -0
- package/src/index.ts +1 -1
- package/src/instances/transaction/HydratedTransaction.ts +3 -5
- package/src/instances/transaction/TransactionFields.ts +4 -4
- package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +14 -0
- package/src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts +18 -0
- package/src/model/PayloadBundle/index.ts +2 -0
- package/src/model/index.ts +1 -0
- package/src/primitives/summary/balances/balancesSummary.ts +1 -1
- package/src/primitives/summary/schemas/schemasStepSummaryFromRange.ts +8 -8
- package/src/primitives/summary/schemas/schemasSummary.ts +1 -1
- package/src/primitives/summary/transfers/transfersSummary.ts +1 -1
- package/src/primitives/transaction/elevatedPayloads.ts +4 -4
- package/src/provider/TransactionSubmitter.ts +3 -2
- package/src/provider/XyoGatewayRunner.ts +3 -2
- package/src/provider/signer/XyoSigner.ts +4 -3
- package/src/provider/viewer/XyoViewer.ts +3 -0
- package/src/services/BlockProducerService.ts +2 -2
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +31 -13
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +11 -8
- package/src/simple/mempool/SimpleMempoolViewer.ts +37 -0
- package/src/simple/mempool/index.ts +1 -0
- package/src/simple/signer/SimpleXyoSigner.ts +10 -7
- package/src/transaction/buildTransaction.ts +8 -6
- package/src/transaction/buildUnsignedTransaction.ts +5 -4
- package/src/transaction/hydrateTransaction.ts +2 -2
- package/src/transaction/primitives/transactionBlockByteCount.ts +2 -2
- package/src/transaction/primitives/transactionElevatedPayloads.ts +2 -2
- package/src/transaction/primitives/transactionRequiredGas.ts +3 -3
- package/src/transaction/script.ts +3 -3
- package/src/transaction/signTransaction.ts +12 -9
- package/src/validation/block/HydratedBlockStateValidationFunction.ts +2 -2
- package/src/validation/block/HydratedBlockValidationFunction.ts +2 -2
- package/src/viewers/AccountBalance.ts +1 -2
- package/src/viewers/Block.ts +5 -5
- package/src/viewers/Mempool.ts +18 -0
- package/src/viewers/index.ts +1 -0
- package/dist/neutral/zod/ArrayBuffer.d.ts +0 -4
- package/dist/neutral/zod/ArrayBuffer.d.ts.map +0 -1
- package/dist/neutral/zod/BlockBoundWitness.d.ts +0 -44
- package/dist/neutral/zod/BlockBoundWitness.d.ts.map +0 -1
- package/dist/neutral/zod/BoundWitness.d.ts +0 -123
- package/dist/neutral/zod/BoundWitness.d.ts.map +0 -1
- package/dist/neutral/zod/Chain.d.ts +0 -4
- package/dist/neutral/zod/Chain.d.ts.map +0 -1
- package/dist/neutral/zod/HydratedBlock.d.ts +0 -133
- package/dist/neutral/zod/HydratedBlock.d.ts.map +0 -1
- package/dist/neutral/zod/HydratedTransaction.d.ts +0 -210
- package/dist/neutral/zod/HydratedTransaction.d.ts.map +0 -1
- package/dist/neutral/zod/Permission.d.ts +0 -53
- package/dist/neutral/zod/Permission.d.ts.map +0 -1
- package/dist/neutral/zod/RewardsRangeOptions.d.ts +0 -11
- package/dist/neutral/zod/RewardsRangeOptions.d.ts.map +0 -1
- package/dist/neutral/zod/Sequence.d.ts +0 -9
- package/dist/neutral/zod/Sequence.d.ts.map +0 -1
- package/dist/neutral/zod/Stake.d.ts +0 -62
- package/dist/neutral/zod/Stake.d.ts.map +0 -1
- package/dist/neutral/zod/TimeDomain.d.ts +0 -3
- package/dist/neutral/zod/TimeDomain.d.ts.map +0 -1
- package/dist/neutral/zod/TransactionBoundWitness.d.ts +0 -75
- package/dist/neutral/zod/TransactionBoundWitness.d.ts.map +0 -1
- package/dist/neutral/zod/TransactionFees.d.ts +0 -53
- package/dist/neutral/zod/TransactionFees.d.ts.map +0 -1
- package/dist/neutral/zod/TransferPair.d.ts +0 -3
- package/dist/neutral/zod/TransferPair.d.ts.map +0 -1
- package/dist/neutral/zod/index.d.ts +0 -15
- package/dist/neutral/zod/index.d.ts.map +0 -1
- package/src/zod/ArrayBuffer.ts +0 -42
- package/src/zod/BlockBoundWitness.ts +0 -36
- package/src/zod/BoundWitness.ts +0 -56
- package/src/zod/Chain.ts +0 -5
- package/src/zod/HydratedBlock.ts +0 -32
- package/src/zod/HydratedTransaction.ts +0 -37
- package/src/zod/Permission.ts +0 -23
- package/src/zod/RewardsRangeOptions.ts +0 -10
- package/src/zod/Sequence.ts +0 -15
- package/src/zod/Stake.ts +0 -43
- package/src/zod/TimeDomain.ts +0 -7
- package/src/zod/TransactionBoundWitness.ts +0 -42
- package/src/zod/TransactionFees.ts +0 -45
- package/src/zod/TransferPair.ts +0 -6
- package/src/zod/index.ts +0 -14
package/dist/neutral/index.mjs
CHANGED
|
@@ -10,9 +10,9 @@ __name(allHashesPresent, "allHashesPresent");
|
|
|
10
10
|
|
|
11
11
|
// src/block/hydrate/blockPayloadsFromHydratedBlock.ts
|
|
12
12
|
import { assertEx } from "@xylabs/sdk-js";
|
|
13
|
-
import {
|
|
13
|
+
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
14
14
|
var blockPayloadsFromHydratedBlock = /* @__PURE__ */ __name((block) => {
|
|
15
|
-
return block[0].payload_hashes.map((hash) => assertEx(block[1].find((p) => p._hash === hash), () => `missing payload ${hash}`)).filter((x) => !
|
|
15
|
+
return block[0].payload_hashes.map((hash) => assertEx(block[1].find((p) => p._hash === hash), () => `missing payload ${hash}`)).filter((x) => !isTransactionBoundWitness(x));
|
|
16
16
|
}, "blockPayloadsFromHydratedBlock");
|
|
17
17
|
|
|
18
18
|
// src/block/hydrate/flattenHydratedBlock.ts
|
|
@@ -29,7 +29,7 @@ var flattenHydratedBlocks = /* @__PURE__ */ __name((hydratedBlocks) => hydratedB
|
|
|
29
29
|
|
|
30
30
|
// src/block/hydrate/hydrateBlock.ts
|
|
31
31
|
import { assertEx as assertEx2 } from "@xylabs/sdk-js";
|
|
32
|
-
import { asBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta
|
|
32
|
+
import { asBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
33
33
|
var hydrateBlock = /* @__PURE__ */ __name(async ({ chainMap }, hash, maxDepth = 1, minDepth = maxDepth) => {
|
|
34
34
|
assertEx2(maxDepth >= 0, () => "maxDepth must be greater than or equal to 0");
|
|
35
35
|
assertEx2(minDepth >= 0, () => "minDepth must be greater than or equal to 0");
|
|
@@ -45,7 +45,7 @@ var hydrateBlock = /* @__PURE__ */ __name(async ({ chainMap }, hash, maxDepth =
|
|
|
45
45
|
bw,
|
|
46
46
|
blkPayloads
|
|
47
47
|
];
|
|
48
|
-
const transactions = blkPayloads.filter(
|
|
48
|
+
const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta);
|
|
49
49
|
const transactionsPayloadHashes = transactions.flatMap((tx) => tx.payload_hashes);
|
|
50
50
|
const transactionsPayloads = await chainMap.getMany(transactionsPayloadHashes);
|
|
51
51
|
assertEx2(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`);
|
|
@@ -67,10 +67,9 @@ var hydrateBlock = /* @__PURE__ */ __name(async ({ chainMap }, hash, maxDepth =
|
|
|
67
67
|
}, "hydrateBlock");
|
|
68
68
|
|
|
69
69
|
// src/block/hydrate/transactionsFromHydratedBlock.ts
|
|
70
|
-
import {
|
|
71
|
-
import { asTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
70
|
+
import { isTransactionBoundWitnessWithStorageMeta as isTransactionBoundWitnessWithStorageMeta2 } from "@xyo-network/xl1-protocol";
|
|
72
71
|
var transactionsFromHydratedBlock = /* @__PURE__ */ __name((block) => {
|
|
73
|
-
return
|
|
72
|
+
return block[1].filter(isTransactionBoundWitnessWithStorageMeta2);
|
|
74
73
|
}, "transactionsFromHydratedBlock");
|
|
75
74
|
|
|
76
75
|
// src/block/hydrate/tryHydrateBlock.ts
|
|
@@ -109,9 +108,9 @@ var tryHydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth =
|
|
|
109
108
|
}, "tryHydrateBlock");
|
|
110
109
|
|
|
111
110
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
112
|
-
import { asHash } from "@xylabs/sdk-js";
|
|
111
|
+
import { asHash as asHash3, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
113
112
|
import { toSafeJsonString } from "@xylabs/sdk-js";
|
|
114
|
-
import {
|
|
113
|
+
import { asSignedBlockBoundWitnessWithStorageMeta, SignedBlockBoundWitnessWithHashMetaZod, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol";
|
|
115
114
|
|
|
116
115
|
// src/model/ChainContext/ChainContext.ts
|
|
117
116
|
import { isDefined as isDefined7, isUndefined } from "@xylabs/sdk-js";
|
|
@@ -511,9 +510,7 @@ async function balancesSummary(context) {
|
|
|
511
510
|
return await spanRootAsync("balancesSummary", async () => {
|
|
512
511
|
const [headHash] = await context.head();
|
|
513
512
|
const headResult = await context.store.chainMap.get(headHash);
|
|
514
|
-
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${headHash}
|
|
515
|
-
required: true
|
|
516
|
-
});
|
|
513
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${headHash}`);
|
|
517
514
|
const rangeStart = asXL1BlockNumber(isDefined4(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0);
|
|
518
515
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange2([
|
|
519
516
|
rangeStart,
|
|
@@ -536,9 +533,9 @@ __name(balancesSummary, "balancesSummary");
|
|
|
536
533
|
|
|
537
534
|
// src/primitives/summary/schemas/schemasStepSummaryFromRange.ts
|
|
538
535
|
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
539
|
-
import {
|
|
536
|
+
import { isBoundWitness } from "@xyo-network/boundwitness-model";
|
|
540
537
|
import { PayloadBuilder as PayloadBuilder2 } from "@xyo-network/payload-builder";
|
|
541
|
-
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/payload-model";
|
|
538
|
+
import { isAnyPayload as isAnyPayload2, isHashMeta } from "@xyo-network/payload-model";
|
|
542
539
|
import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol";
|
|
543
540
|
async function schemasStepSummaryFromRange(context, range) {
|
|
544
541
|
const frameHeadHash = await hashFromBlockNumber(context, range[1]);
|
|
@@ -550,7 +547,7 @@ async function schemasStepSummaryFromRange(context, range) {
|
|
|
550
547
|
const [block, payloads] = await hydrateBlock(context.store, hash);
|
|
551
548
|
const boundWitnesses = [
|
|
552
549
|
block,
|
|
553
|
-
...payloads.filter(
|
|
550
|
+
...payloads.filter((x) => isBoundWitness(x) && isHashMeta(x))
|
|
554
551
|
];
|
|
555
552
|
const schemas = {};
|
|
556
553
|
for (const bw of boundWitnesses) {
|
|
@@ -595,8 +592,7 @@ async function schemasStepSummaryFromRange(context, range) {
|
|
|
595
592
|
}
|
|
596
593
|
}
|
|
597
594
|
}
|
|
598
|
-
|
|
599
|
-
return finalResult;
|
|
595
|
+
return await PayloadBuilder2.addHashMeta(result);
|
|
600
596
|
}
|
|
601
597
|
__name(schemasStepSummaryFromRange, "schemasStepSummaryFromRange");
|
|
602
598
|
|
|
@@ -608,9 +604,7 @@ async function schemasSummary(context) {
|
|
|
608
604
|
return await spanRootAsync2("schemasSummary", async () => {
|
|
609
605
|
const [headHash] = await context.head();
|
|
610
606
|
const headResult = await context.store.chainMap.get(headHash);
|
|
611
|
-
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${headHash}
|
|
612
|
-
required: true
|
|
613
|
-
});
|
|
607
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${headHash}`);
|
|
614
608
|
const rangeStart = asXL1BlockNumber2(isDefined5(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0);
|
|
615
609
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange3([
|
|
616
610
|
rangeStart,
|
|
@@ -644,9 +638,7 @@ async function transfersSummary(transferContext) {
|
|
|
644
638
|
return await spanRootAsync3("transferSummary", async () => {
|
|
645
639
|
const [headHash] = await transferContext.head();
|
|
646
640
|
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
|
-
});
|
|
641
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(headResult, () => `Head block not found for hash: ${transferContext.head}`);
|
|
650
642
|
const rangeStart = asXL1BlockNumber3(isDefined6(transferContext.windowSize) ? Math.max(headBoundWitness.block - transferContext.windowSize + 1, 0) : 0);
|
|
651
643
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange4([
|
|
652
644
|
rangeStart,
|
|
@@ -811,114 +803,445 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4, t
|
|
|
811
803
|
}
|
|
812
804
|
__name(withContextCacheResponse, "withContextCacheResponse");
|
|
813
805
|
|
|
814
|
-
// src/
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
let jumpHash = currentBlock.previous;
|
|
828
|
-
let jumpBlockNumber = currentBlock.block - 1;
|
|
829
|
-
for (const [step, stepSize2] of StepSizes7.entries()) {
|
|
830
|
-
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize2 - 1;
|
|
831
|
-
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
832
|
-
jumpBlockNumber = possibleJumpBlockNumber;
|
|
833
|
-
jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`);
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
const newBlock = await context.store.chainMap.get(asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`));
|
|
837
|
-
currentBlock = asBlockBoundWitnessWithStorageMeta5(newBlock, () => `Block not found for hash: ${jumpHash}`, {
|
|
838
|
-
required: true
|
|
839
|
-
});
|
|
840
|
-
if (currentBlock.block === blockNumber) {
|
|
841
|
-
break;
|
|
842
|
-
}
|
|
843
|
-
if (currentBlock.block < blockNumber) {
|
|
844
|
-
throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${headHash}.`);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
return currentBlock;
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
__name(blockFromBlockNumber, "blockFromBlockNumber");
|
|
806
|
+
// src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts
|
|
807
|
+
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
808
|
+
import { asSignedTransactionBoundWitnessWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
809
|
+
var bundledPayloadToHydratedTransaction = /* @__PURE__ */ __name(async (payload) => {
|
|
810
|
+
const withHashMeta = await PayloadBuilder4.addHashMeta(payload.payloads);
|
|
811
|
+
const tx = asSignedTransactionBoundWitnessWithHashMeta(withHashMeta.find((p) => p._hash === payload.root));
|
|
812
|
+
if (tx) {
|
|
813
|
+
return [
|
|
814
|
+
tx,
|
|
815
|
+
withHashMeta.filter((p) => p._hash !== payload.root)
|
|
816
|
+
];
|
|
817
|
+
}
|
|
818
|
+
}, "bundledPayloadToHydratedTransaction");
|
|
851
819
|
|
|
852
|
-
// src/
|
|
853
|
-
import {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
]);
|
|
820
|
+
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
821
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
822
|
+
import { PayloadBundleSchema } from "@xyo-network/payload-model";
|
|
823
|
+
|
|
824
|
+
// src/transaction/buildTransaction.ts
|
|
825
|
+
import { assertEx as assertEx8, toHex as toHex2 } from "@xylabs/sdk-js";
|
|
826
|
+
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
827
|
+
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
828
|
+
import { defaultTransactionFees } from "@xyo-network/xl1-protocol";
|
|
829
|
+
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
830
|
+
if (from === void 0 && Array.isArray(signer)) {
|
|
831
|
+
throw new Error("from is required when signer is an array");
|
|
865
832
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
833
|
+
const txBoundWitnessFields = {
|
|
834
|
+
chain,
|
|
835
|
+
fees: {
|
|
836
|
+
base: toHex2(fees.base),
|
|
837
|
+
gasLimit: toHex2(fees.gasLimit),
|
|
838
|
+
gasPrice: toHex2(fees.gasPrice),
|
|
839
|
+
priority: toHex2(fees.priority)
|
|
840
|
+
},
|
|
841
|
+
nbf,
|
|
842
|
+
exp
|
|
843
|
+
};
|
|
844
|
+
const elevatedHashes = await PayloadBuilder5.hashes(onChainPayloads);
|
|
845
|
+
const script = [];
|
|
846
|
+
for (const elevatedHash of elevatedHashes) {
|
|
847
|
+
script.push(`elevate|${elevatedHash}`);
|
|
848
|
+
}
|
|
849
|
+
const fields = {
|
|
850
|
+
...txBoundWitnessFields,
|
|
851
|
+
from: from ?? (Array.isArray(signer) ? assertEx8(signer.at(0)?.address) : signer.address)
|
|
852
|
+
};
|
|
853
|
+
if (script.length > 0) {
|
|
854
|
+
fields.script = script;
|
|
884
855
|
}
|
|
856
|
+
const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({
|
|
857
|
+
$signatures: []
|
|
858
|
+
}).payloads([
|
|
859
|
+
...onChainPayloads,
|
|
860
|
+
...offChainPayloads
|
|
861
|
+
]).signers(Array.isArray(signer) ? signer : [
|
|
862
|
+
signer
|
|
863
|
+
]).build();
|
|
885
864
|
return [
|
|
886
|
-
|
|
887
|
-
|
|
865
|
+
await PayloadBuilder5.addHashMeta(tx),
|
|
866
|
+
await PayloadBuilder5.addHashMeta(txPayloads)
|
|
888
867
|
];
|
|
889
868
|
}
|
|
890
|
-
__name(
|
|
869
|
+
__name(buildTransaction, "buildTransaction");
|
|
891
870
|
|
|
892
|
-
// src/
|
|
893
|
-
import {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
871
|
+
// src/transaction/buildUnsignedTransaction.ts
|
|
872
|
+
import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
873
|
+
import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundwitness-builder";
|
|
874
|
+
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
875
|
+
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol";
|
|
876
|
+
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
877
|
+
const txBoundWitnessFields = {
|
|
878
|
+
chain,
|
|
879
|
+
fees: {
|
|
880
|
+
base: toHex3(fees.base),
|
|
881
|
+
gasLimit: toHex3(fees.gasLimit),
|
|
882
|
+
gasPrice: toHex3(fees.gasPrice),
|
|
883
|
+
priority: toHex3(fees.priority)
|
|
884
|
+
},
|
|
885
|
+
nbf,
|
|
886
|
+
exp
|
|
887
|
+
};
|
|
888
|
+
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
889
|
+
const script = [];
|
|
890
|
+
for (const elevatedHash of elevatedHashes) {
|
|
891
|
+
script.push(`elevate|${elevatedHash}`);
|
|
892
|
+
}
|
|
893
|
+
const fields = {
|
|
894
|
+
...txBoundWitnessFields,
|
|
895
|
+
from
|
|
896
|
+
};
|
|
897
|
+
if (script.length > 0) {
|
|
898
|
+
fields.script = script;
|
|
899
|
+
}
|
|
900
|
+
const [tx, txPayloads] = await new BoundWitnessBuilder2().fields(fields).meta({
|
|
901
|
+
$signatures: []
|
|
902
|
+
}).payloads([
|
|
903
|
+
...onChainPayloads,
|
|
904
|
+
...offChainPayloads
|
|
905
|
+
]).build(false);
|
|
906
|
+
return [
|
|
907
|
+
tx,
|
|
908
|
+
txPayloads
|
|
898
909
|
];
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
910
|
+
}
|
|
911
|
+
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
912
|
+
|
|
913
|
+
// src/transaction/confirmSubmittedTransaction.ts
|
|
914
|
+
import { delay, isDefined as isDefined8 } from "@xylabs/sdk-js";
|
|
915
|
+
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
916
|
+
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
917
|
+
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash, options) => {
|
|
918
|
+
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options ?? {};
|
|
919
|
+
options?.logger?.log("\u{1F680} confirming transaction:", txHash, "\n");
|
|
920
|
+
let attempts = 0;
|
|
921
|
+
while (true) {
|
|
922
|
+
const tx = await viewer.transactionByHash(txHash) ?? void 0;
|
|
923
|
+
if (isDefined8(tx)) {
|
|
924
|
+
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
925
|
+
return tx;
|
|
926
|
+
} else {
|
|
927
|
+
attempts++;
|
|
928
|
+
if (attempts > maxAttempts) {
|
|
929
|
+
options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
|
|
930
|
+
throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
|
|
931
|
+
} else {
|
|
932
|
+
options?.logger?.log(`\u{1F504} Transaction not confirmed yet, attempt ${attempts}. Retrying...`, "\n");
|
|
933
|
+
await delay(attemptDelay);
|
|
934
|
+
}
|
|
905
935
|
}
|
|
906
|
-
remaining = newRemaining;
|
|
907
936
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
937
|
+
}, "confirmSubmittedTransaction");
|
|
938
|
+
|
|
939
|
+
// src/transaction/hydrateTransaction.ts
|
|
940
|
+
import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
941
|
+
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
942
|
+
import { isAllowedBlockPayload as isAllowedBlockPayload2, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
943
|
+
var tryHydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
944
|
+
return await tryHydrateTypedBoundWitness({
|
|
945
|
+
get(hashes) {
|
|
946
|
+
return chainMap.getMany(hashes);
|
|
947
|
+
},
|
|
948
|
+
next() {
|
|
949
|
+
throw new Error("Not implemented");
|
|
950
|
+
}
|
|
951
|
+
}, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
952
|
+
}, "tryHydrateTransaction");
|
|
953
|
+
var hydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
954
|
+
return await hydrateTypedBoundWitness({
|
|
955
|
+
get(hashes) {
|
|
956
|
+
return chainMap.getMany(hashes);
|
|
957
|
+
},
|
|
958
|
+
next() {
|
|
959
|
+
throw new Error("Not implemented");
|
|
960
|
+
}
|
|
961
|
+
}, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
962
|
+
}, "hydrateTransaction");
|
|
963
|
+
var flattenHydratedTransaction = /* @__PURE__ */ __name((hydratedTransaction) => {
|
|
964
|
+
const [tx, txPayloads] = hydratedTransaction;
|
|
965
|
+
return [
|
|
966
|
+
...txPayloads,
|
|
967
|
+
tx
|
|
968
|
+
];
|
|
969
|
+
}, "flattenHydratedTransaction");
|
|
970
|
+
var flattenHydratedTransactions = /* @__PURE__ */ __name((hydratedTransactions) => hydratedTransactions.flatMap((tx) => flattenHydratedTransaction(tx)), "flattenHydratedTransactions");
|
|
971
|
+
var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
972
|
+
const hydratedTransaction = await tryHydrateTransaction({
|
|
973
|
+
chainMap
|
|
974
|
+
}, hash);
|
|
975
|
+
if (!hydratedTransaction) {
|
|
976
|
+
return void 0;
|
|
977
|
+
}
|
|
978
|
+
const [transaction, payloads] = hydratedTransaction;
|
|
979
|
+
const opCodes = (transaction.script ?? []).filter((operation) => operation.startsWith("elevate|"));
|
|
980
|
+
const elevatedPayloads2 = [];
|
|
981
|
+
for (const opCode of opCodes) {
|
|
982
|
+
const [code, hash2] = opCode.split("|");
|
|
983
|
+
if (code === "elevated") {
|
|
984
|
+
const elevatedPayload = payloads.find((payload) => payload._hash === hash2);
|
|
985
|
+
if (isAllowedBlockPayload2(elevatedPayload)) {
|
|
986
|
+
elevatedPayloads2.push(elevatedPayload);
|
|
987
|
+
}
|
|
914
988
|
}
|
|
915
989
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
990
|
+
if (opCodes.length === elevatedPayloads2.length) {
|
|
991
|
+
return [
|
|
992
|
+
transaction,
|
|
993
|
+
elevatedPayloads2
|
|
994
|
+
];
|
|
995
|
+
}
|
|
996
|
+
return void 0;
|
|
997
|
+
}, "tryHydrateElevatedTransaction");
|
|
998
|
+
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) => {
|
|
999
|
+
return assertEx9(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
1000
|
+
}, "hydrateElevatedTransaction");
|
|
919
1001
|
|
|
920
|
-
// src/
|
|
921
|
-
|
|
1002
|
+
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
1003
|
+
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1004
|
+
function transactionBlockByteCount([transaction, payloads]) {
|
|
1005
|
+
const cleanTransaction = PayloadBuilder7.omitStorageMeta(transaction);
|
|
1006
|
+
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
1007
|
+
const cleanPayloads = PayloadBuilder7.omitStorageMeta(payloads);
|
|
1008
|
+
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
1009
|
+
}
|
|
1010
|
+
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
1011
|
+
|
|
1012
|
+
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
1013
|
+
import { asHash } from "@xylabs/sdk-js";
|
|
1014
|
+
|
|
1015
|
+
// src/transaction/primitives/transactionOperations.ts
|
|
1016
|
+
function crackOperation(operation) {
|
|
1017
|
+
const parts = operation.split("|");
|
|
1018
|
+
if (parts.length < 2) {
|
|
1019
|
+
throw new Error(`Invalid operation format: ${operation}`);
|
|
1020
|
+
}
|
|
1021
|
+
return [
|
|
1022
|
+
parts[0],
|
|
1023
|
+
parts.slice(1)
|
|
1024
|
+
];
|
|
1025
|
+
}
|
|
1026
|
+
__name(crackOperation, "crackOperation");
|
|
1027
|
+
function crackOperations(operations) {
|
|
1028
|
+
return operations.map((op) => crackOperation(op));
|
|
1029
|
+
}
|
|
1030
|
+
__name(crackOperations, "crackOperations");
|
|
1031
|
+
|
|
1032
|
+
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
1033
|
+
function transactionElevatedPayloadHashes(transaction) {
|
|
1034
|
+
const elevateOperations = crackOperations(transaction.script ?? []).filter((op) => op[0] === "elevate");
|
|
1035
|
+
return elevateOperations.map((op) => asHash(op[1][0], true));
|
|
1036
|
+
}
|
|
1037
|
+
__name(transactionElevatedPayloadHashes, "transactionElevatedPayloadHashes");
|
|
1038
|
+
function transactionElevatedPayloads([transaction, payloads]) {
|
|
1039
|
+
const hashes = transactionElevatedPayloadHashes(transaction);
|
|
1040
|
+
const elevatedPayloads2 = payloads.filter((payload) => hashes.includes(payload._hash));
|
|
1041
|
+
return elevatedPayloads2;
|
|
1042
|
+
}
|
|
1043
|
+
__name(transactionElevatedPayloads, "transactionElevatedPayloads");
|
|
1044
|
+
|
|
1045
|
+
// src/transaction/primitives/transactionRequiredGas.ts
|
|
1046
|
+
import { AttoXL1, TransactionGasCosts } from "@xyo-network/xl1-protocol";
|
|
1047
|
+
function transactionBytesRequiredGas([transaction, payloads]) {
|
|
1048
|
+
const transactionBlockBytes = transactionBlockByteCount([
|
|
1049
|
+
transaction,
|
|
1050
|
+
payloads
|
|
1051
|
+
]);
|
|
1052
|
+
return AttoXL1(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes));
|
|
1053
|
+
}
|
|
1054
|
+
__name(transactionBytesRequiredGas, "transactionBytesRequiredGas");
|
|
1055
|
+
function transactionRequiredGas(hydratedTransaction) {
|
|
1056
|
+
const elevatedPayloads2 = transactionElevatedPayloads(hydratedTransaction);
|
|
1057
|
+
const hashes = elevatedPayloads2.length + 1;
|
|
1058
|
+
const signatures = hydratedTransaction[0].addresses.length;
|
|
1059
|
+
return AttoXL1(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads2.length));
|
|
1060
|
+
}
|
|
1061
|
+
__name(transactionRequiredGas, "transactionRequiredGas");
|
|
1062
|
+
|
|
1063
|
+
// src/transaction/script.ts
|
|
1064
|
+
import { asHash as asHash2 } from "@xylabs/sdk-js";
|
|
1065
|
+
import { assertEx as assertEx10, filterAs } from "@xylabs/sdk-js";
|
|
1066
|
+
import { isAllowedBlockPayloadWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
1067
|
+
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
1068
|
+
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
1069
|
+
return filterAs(hashes, (h) => asHash2(h));
|
|
1070
|
+
}, "tryExtractElevatedHashesFromScript");
|
|
1071
|
+
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
1072
|
+
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
1073
|
+
const filtered = filterAs(hashes, (h) => asHash2(h));
|
|
1074
|
+
assertEx10(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
1075
|
+
return filtered;
|
|
1076
|
+
}, "extractElevatedHashesFromScript");
|
|
1077
|
+
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
1078
|
+
const [bw, payloads] = tx;
|
|
1079
|
+
const { script } = bw;
|
|
1080
|
+
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
1081
|
+
return payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
1082
|
+
}, "tryExtractElevatedHashes");
|
|
1083
|
+
var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
1084
|
+
const [bw, payloads] = tx;
|
|
1085
|
+
const { script } = bw;
|
|
1086
|
+
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
1087
|
+
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
1088
|
+
assertEx10(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
1089
|
+
return filtered;
|
|
1090
|
+
}, "extractElevatedHashes");
|
|
1091
|
+
|
|
1092
|
+
// src/transaction/signTransaction.ts
|
|
1093
|
+
import { assertEx as assertEx11, hexFromArrayBuffer, toArrayBuffer } from "@xylabs/sdk-js";
|
|
1094
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
1095
|
+
async function signTransaction(tx, account) {
|
|
1096
|
+
assertEx11(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
1097
|
+
const unsignedTx = structuredClone(tx);
|
|
1098
|
+
unsignedTx.addresses = [
|
|
1099
|
+
account.address
|
|
1100
|
+
];
|
|
1101
|
+
unsignedTx.previous_hashes = [
|
|
1102
|
+
account.previousHash ?? null
|
|
1103
|
+
];
|
|
1104
|
+
const hash = await PayloadBuilder8.dataHash(unsignedTx);
|
|
1105
|
+
const hashBytes = toArrayBuffer(hash);
|
|
1106
|
+
const [signature] = await account.sign(hashBytes);
|
|
1107
|
+
const result = {
|
|
1108
|
+
...unsignedTx,
|
|
1109
|
+
$signatures: [
|
|
1110
|
+
hexFromArrayBuffer(signature)
|
|
1111
|
+
]
|
|
1112
|
+
};
|
|
1113
|
+
return result;
|
|
1114
|
+
}
|
|
1115
|
+
__name(signTransaction, "signTransaction");
|
|
1116
|
+
|
|
1117
|
+
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
1118
|
+
var hydratedTransactionToPayloadBundle = /* @__PURE__ */ __name((transaction) => {
|
|
1119
|
+
const root = transaction[0]._hash;
|
|
1120
|
+
return bundle(root, transaction);
|
|
1121
|
+
}, "hydratedTransactionToPayloadBundle");
|
|
1122
|
+
var bundle = /* @__PURE__ */ __name((root, transaction) => {
|
|
1123
|
+
const payloads = flattenHydratedTransaction(transaction).flatMap((p) => PayloadBuilder9.omitStorageMeta(p));
|
|
1124
|
+
return new PayloadBuilder9({
|
|
1125
|
+
schema: PayloadBundleSchema
|
|
1126
|
+
}).fields({
|
|
1127
|
+
payloads,
|
|
1128
|
+
root
|
|
1129
|
+
}).build();
|
|
1130
|
+
}, "bundle");
|
|
1131
|
+
|
|
1132
|
+
// src/block/primitives/blockFromBlockNumber.ts
|
|
1133
|
+
async function blockFromBlockNumber(context, blockNumber) {
|
|
1134
|
+
const cacheKey = `${blockNumber}`;
|
|
1135
|
+
return await withContextCacheResponse(context, "blockFromBlockNumber", cacheKey, async () => {
|
|
1136
|
+
const [headHash] = await context.head();
|
|
1137
|
+
const result = await context.store.chainMap.get(headHash);
|
|
1138
|
+
if (!isDefined9(result)) {
|
|
1139
|
+
throw new Error(`Head block not found for hash: ${headHash}`);
|
|
1140
|
+
}
|
|
1141
|
+
let currentBlock = asSignedBlockBoundWitnessWithStorageMeta(result, () => `Found Payload is not a Signed<BlockBoundWitness>: ${JSON.stringify(result, null, 2)}`);
|
|
1142
|
+
if (currentBlock.block < blockNumber) {
|
|
1143
|
+
throw new Error(`Block number ${blockNumber} is greater than head ${currentBlock.block}.`);
|
|
1144
|
+
}
|
|
1145
|
+
while (currentBlock.block > blockNumber) {
|
|
1146
|
+
let jumpHash = currentBlock.previous;
|
|
1147
|
+
let jumpBlockNumber = currentBlock.block - 1;
|
|
1148
|
+
for (const [step, stepSize2] of StepSizes7.entries()) {
|
|
1149
|
+
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize2 - 1;
|
|
1150
|
+
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
1151
|
+
jumpBlockNumber = possibleJumpBlockNumber;
|
|
1152
|
+
jumpHash = asHash3(currentBlock.step_hashes?.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
const newBlock = await context.store.chainMap.get(asHash3(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`));
|
|
1156
|
+
if (!isDefined9(newBlock)) {
|
|
1157
|
+
throw new Error(`Block not found for jump hash: ${jumpHash}`);
|
|
1158
|
+
}
|
|
1159
|
+
currentBlock = asSignedBlockBoundWitnessWithStorageMeta(newBlock, () => {
|
|
1160
|
+
const result2 = SignedBlockBoundWitnessWithHashMetaZod.safeParse(newBlock);
|
|
1161
|
+
return `Found Payload [jump hash] is not a Signed<BlockBoundWitness>: ${result2.error}`;
|
|
1162
|
+
});
|
|
1163
|
+
if (currentBlock.block === blockNumber) {
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
if (currentBlock.block < blockNumber) {
|
|
1167
|
+
throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${headHash}.`);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return currentBlock;
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
__name(blockFromBlockNumber, "blockFromBlockNumber");
|
|
1174
|
+
|
|
1175
|
+
// src/block/primitives/frames/calculateFramesFromRange.ts
|
|
1176
|
+
import { asXL1BlockNumber as asXL1BlockNumber4, stepSize } from "@xyo-network/xl1-protocol";
|
|
1177
|
+
function calculateFramesFromRange(range, step) {
|
|
1178
|
+
const size = stepSize(step);
|
|
1179
|
+
let start = Math.trunc(range[0] / size) * size;
|
|
1180
|
+
const fitted = [];
|
|
1181
|
+
const remaining = [];
|
|
1182
|
+
if (start !== range[0]) {
|
|
1183
|
+
start += size;
|
|
1184
|
+
remaining.push([
|
|
1185
|
+
range[0],
|
|
1186
|
+
asXL1BlockNumber4(Math.min(start - 1, range[1]), true)
|
|
1187
|
+
]);
|
|
1188
|
+
}
|
|
1189
|
+
for (let i = start; i <= range[1]; i += size) {
|
|
1190
|
+
if (i + size - 1 <= range[1]) {
|
|
1191
|
+
fitted.push([
|
|
1192
|
+
asXL1BlockNumber4(i, {
|
|
1193
|
+
name: "calculateFramesFromRange A"
|
|
1194
|
+
}),
|
|
1195
|
+
asXL1BlockNumber4(Math.min(i + size - 1, range[1]), {
|
|
1196
|
+
name: "calculateFramesFromRange B"
|
|
1197
|
+
})
|
|
1198
|
+
]);
|
|
1199
|
+
} else {
|
|
1200
|
+
remaining.push([
|
|
1201
|
+
asXL1BlockNumber4(i, {
|
|
1202
|
+
name: "calculateFramesFromRange C"
|
|
1203
|
+
}),
|
|
1204
|
+
range[1]
|
|
1205
|
+
]);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
return [
|
|
1209
|
+
fitted,
|
|
1210
|
+
remaining
|
|
1211
|
+
];
|
|
1212
|
+
}
|
|
1213
|
+
__name(calculateFramesFromRange, "calculateFramesFromRange");
|
|
1214
|
+
|
|
1215
|
+
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
1216
|
+
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol";
|
|
1217
|
+
function deepCalculateFramesFromRange(range, startingStep = StepSizes8.length - 1) {
|
|
1218
|
+
const fitted = [];
|
|
1219
|
+
let remaining = [
|
|
1220
|
+
range
|
|
1221
|
+
];
|
|
1222
|
+
for (let step = startingStep; step >= 0; step--) {
|
|
1223
|
+
const newRemaining = [];
|
|
1224
|
+
for (const range2 of remaining) {
|
|
1225
|
+
const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range2, step);
|
|
1226
|
+
fitted.push(...newFittedFrames);
|
|
1227
|
+
newRemaining.push(...newRemainingFrames);
|
|
1228
|
+
}
|
|
1229
|
+
remaining = newRemaining;
|
|
1230
|
+
}
|
|
1231
|
+
for (const range2 of remaining) {
|
|
1232
|
+
for (let i = range2[0]; i <= range2[1]; i++) {
|
|
1233
|
+
fitted.push([
|
|
1234
|
+
i,
|
|
1235
|
+
i
|
|
1236
|
+
]);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
return fitted.toSorted((a, b) => a[0] - b[0]);
|
|
1240
|
+
}
|
|
1241
|
+
__name(deepCalculateFramesFromRange, "deepCalculateFramesFromRange");
|
|
1242
|
+
|
|
1243
|
+
// src/block/primitives/hashFromBlockNumber.ts
|
|
1244
|
+
async function hashFromBlockNumber(context, blockNumber) {
|
|
922
1245
|
return (await blockFromBlockNumber(context, blockNumber))._hash;
|
|
923
1246
|
}
|
|
924
1247
|
__name(hashFromBlockNumber, "hashFromBlockNumber");
|
|
@@ -1276,16 +1599,21 @@ var ServicesConfigZod = z10.object({
|
|
|
1276
1599
|
description: "Endpoint of the API to use for instantiating an external AccountBalanceViewer",
|
|
1277
1600
|
title: "services.accountBalanceViewerEndpoint",
|
|
1278
1601
|
type: "string"
|
|
1602
|
+
}),
|
|
1603
|
+
apiEndpoint: z10.string().optional().register(globalRegistry9, {
|
|
1604
|
+
description: "Endpoint of the API to use for instantiating an external Viewers",
|
|
1605
|
+
title: "services.apiEndpoint",
|
|
1606
|
+
type: "string"
|
|
1279
1607
|
})
|
|
1280
1608
|
});
|
|
1281
1609
|
|
|
1282
1610
|
// src/config/storage/driver/Mongo.ts
|
|
1283
|
-
import { isDefined as
|
|
1611
|
+
import { isDefined as isDefined10, isUndefined as isUndefined2 } from "@xylabs/sdk-js";
|
|
1284
1612
|
import { globalRegistry as globalRegistry10 } from "zod";
|
|
1285
1613
|
import * as z11 from "zod";
|
|
1286
1614
|
var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
1287
1615
|
if (isUndefined2(config)) return false;
|
|
1288
|
-
return
|
|
1616
|
+
return isDefined10(config.connectionString) && isDefined10(config.database) && isDefined10(config.domain) && isDefined10(config.password) && isDefined10(config.username);
|
|
1289
1617
|
}, "hasMongoConfig");
|
|
1290
1618
|
var MongoConfigZod = z11.object({
|
|
1291
1619
|
// TODO: Create from other arguments
|
|
@@ -1503,11 +1831,11 @@ var isEIP712SignaturePayload = isPayloadOfZodType2(EIP712SignaturePayloadFieldsZ
|
|
|
1503
1831
|
var asEIP712SignaturePayload = AsObjectFactory6.create(isEIP712SignaturePayload);
|
|
1504
1832
|
|
|
1505
1833
|
// src/eip-712/sign.ts
|
|
1506
|
-
import { PayloadBuilder as
|
|
1834
|
+
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
1507
1835
|
var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
1508
1836
|
const { domain, types, values } = data;
|
|
1509
1837
|
const signature = await signer.signTypedData(domain, types, values);
|
|
1510
|
-
const hash = await
|
|
1838
|
+
const hash = await PayloadBuilder10.hash(data);
|
|
1511
1839
|
const address = await signer.getAddress();
|
|
1512
1840
|
return {
|
|
1513
1841
|
address,
|
|
@@ -1518,14 +1846,14 @@ var signEIP712Message = /* @__PURE__ */ __name(async (signer, data) => {
|
|
|
1518
1846
|
}, "signEIP712Message");
|
|
1519
1847
|
|
|
1520
1848
|
// src/eip-712/verify.ts
|
|
1521
|
-
import { asHash as
|
|
1522
|
-
import { PayloadBuilder as
|
|
1849
|
+
import { asHash as asHash4, isUndefined as isUndefined3 } from "@xylabs/sdk-js";
|
|
1850
|
+
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/payload-builder";
|
|
1523
1851
|
import { verifyTypedData } from "ethers/hash";
|
|
1524
1852
|
var verifyEIP712Message = /* @__PURE__ */ __name(async (data, sig) => {
|
|
1525
1853
|
const { address, signature, hash } = sig;
|
|
1526
1854
|
const { schema, ...fields } = data;
|
|
1527
|
-
const signedHash =
|
|
1528
|
-
if (isUndefined3(signedHash) || signedHash !== await
|
|
1855
|
+
const signedHash = asHash4(hash);
|
|
1856
|
+
if (isUndefined3(signedHash) || signedHash !== await PayloadBuilder11.hash(data)) return false;
|
|
1529
1857
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
1530
1858
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
1531
1859
|
}, "verifyEIP712Message");
|
|
@@ -1554,26 +1882,35 @@ var isChainIndexingServiceStateWithStorageMeta = /* @__PURE__ */ __name((value)
|
|
|
1554
1882
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory7.create(isChainIndexingServiceStateWithStorageMeta);
|
|
1555
1883
|
|
|
1556
1884
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
1557
|
-
import { assertEx as
|
|
1885
|
+
import { AbstractCreatable, assertEx as assertEx12, exists, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1558
1886
|
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";
|
|
1560
|
-
var SimpleAccountBalanceViewer = class {
|
|
1887
|
+
import { asRange, asXL1BlockNumber as asXL1BlockNumber5, asXL1BlockRange as asXL1BlockRange5, AttoXL1 as AttoXL12, StepSizes as StepSizes9, TransferSchema } from "@xyo-network/xl1-protocol";
|
|
1888
|
+
var SimpleAccountBalanceViewer = class extends AbstractCreatable {
|
|
1561
1889
|
static {
|
|
1562
1890
|
__name(this, "SimpleAccountBalanceViewer");
|
|
1563
1891
|
}
|
|
1564
|
-
blockViewer
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
this.context
|
|
1569
|
-
|
|
1570
|
-
|
|
1892
|
+
get blockViewer() {
|
|
1893
|
+
return this.params.blockViewer;
|
|
1894
|
+
}
|
|
1895
|
+
get context() {
|
|
1896
|
+
return this.params.context;
|
|
1897
|
+
}
|
|
1898
|
+
get transferContext() {
|
|
1899
|
+
return this.params.transferContext;
|
|
1900
|
+
}
|
|
1901
|
+
static async paramsHandler(params) {
|
|
1902
|
+
assertEx12(params.blockViewer, () => "blockViewer is required");
|
|
1903
|
+
assertEx12(params.context, () => "context is required");
|
|
1904
|
+
assertEx12(params.transferContext, () => "transferContext is required");
|
|
1905
|
+
return {
|
|
1906
|
+
...await super.paramsHandler(params)
|
|
1907
|
+
};
|
|
1571
1908
|
}
|
|
1572
1909
|
async accountBalance(address, headOrRange) {
|
|
1573
1910
|
const balances = await this.accountsBalances([
|
|
1574
1911
|
address
|
|
1575
1912
|
], headOrRange);
|
|
1576
|
-
return balances[address] ??
|
|
1913
|
+
return balances[address] ?? AttoXL12(0n);
|
|
1577
1914
|
}
|
|
1578
1915
|
async accountBalanceHistory(address, headOrRange) {
|
|
1579
1916
|
const range = asRange(headOrRange);
|
|
@@ -1588,8 +1925,8 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1588
1925
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema ? index : void 0).filter(exists);
|
|
1589
1926
|
const transfers = transferIndexes.map((index) => {
|
|
1590
1927
|
const hash = block[0].payload_hashes[index];
|
|
1591
|
-
return
|
|
1592
|
-
}).filter(exists).filter((t) => t.from === address ||
|
|
1928
|
+
return assertEx12(block[1].find((p) => p._hash === hash), () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`);
|
|
1929
|
+
}).filter(exists).filter((t) => t.from === address || isDefined11(t.transfers[address]));
|
|
1593
1930
|
if (transfers.length === 0) {
|
|
1594
1931
|
continue;
|
|
1595
1932
|
}
|
|
@@ -1613,7 +1950,7 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1613
1950
|
const result = {};
|
|
1614
1951
|
for (const addr of address) {
|
|
1615
1952
|
const summaryBalance = summary[addr] ?? 0n;
|
|
1616
|
-
result[addr] =
|
|
1953
|
+
result[addr] = AttoXL12(summaryBalance < 0n ? 0n : summaryBalance);
|
|
1617
1954
|
}
|
|
1618
1955
|
return result;
|
|
1619
1956
|
});
|
|
@@ -1666,11 +2003,11 @@ var SimpleAccountBalanceViewer = class {
|
|
|
1666
2003
|
|
|
1667
2004
|
// src/simple/chainStake/SimpleChainStakeViewer.ts
|
|
1668
2005
|
import { asAddress as asAddress5, toAddress as toAddress5 } from "@xylabs/sdk-js";
|
|
1669
|
-
import { AbstractCreatable as
|
|
2006
|
+
import { AbstractCreatable as AbstractCreatable3, assertEx as assertEx13, creatable as creatable2 } from "@xylabs/sdk-js";
|
|
1670
2007
|
import { Account } from "@xyo-network/account";
|
|
1671
2008
|
|
|
1672
2009
|
// src/simple/chainStakeEvents/SimpleChainStakeEventsViewer.ts
|
|
1673
|
-
import { AbstractCreatable, creatable, isDefined as
|
|
2010
|
+
import { AbstractCreatable as AbstractCreatable2, creatable, isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
1674
2011
|
function _ts_decorate(decorators, target, key, desc) {
|
|
1675
2012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1676
2013
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1678,7 +2015,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
1678
2015
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1679
2016
|
}
|
|
1680
2017
|
__name(_ts_decorate, "_ts_decorate");
|
|
1681
|
-
var SimpleChainStakeEventsViewer = class extends
|
|
2018
|
+
var SimpleChainStakeEventsViewer = class extends AbstractCreatable2 {
|
|
1682
2019
|
static {
|
|
1683
2020
|
__name(this, "SimpleChainStakeEventsViewer");
|
|
1684
2021
|
}
|
|
@@ -1691,7 +2028,7 @@ var SimpleChainStakeEventsViewer = class extends AbstractCreatable {
|
|
|
1691
2028
|
stakeEvents(range, { name } = {}) {
|
|
1692
2029
|
const positions = this.positionsFromRange(range);
|
|
1693
2030
|
const events = this.eventsFromPositions(positions);
|
|
1694
|
-
if (
|
|
2031
|
+
if (isDefined12(name)) {
|
|
1695
2032
|
return events.filter((event) => event.name === name);
|
|
1696
2033
|
}
|
|
1697
2034
|
return events;
|
|
@@ -1762,14 +2099,14 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
1762
2099
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1763
2100
|
}
|
|
1764
2101
|
__name(_ts_decorate2, "_ts_decorate");
|
|
1765
|
-
var SimpleChainStakeViewer = class extends
|
|
2102
|
+
var SimpleChainStakeViewer = class extends AbstractCreatable3 {
|
|
1766
2103
|
static {
|
|
1767
2104
|
__name(this, "SimpleChainStakeViewer");
|
|
1768
2105
|
}
|
|
1769
2106
|
_chainId;
|
|
1770
2107
|
_chainStakeEventsViewer;
|
|
1771
2108
|
get chainId() {
|
|
1772
|
-
return
|
|
2109
|
+
return assertEx13(this._chainId, () => "Chain ID not set");
|
|
1773
2110
|
}
|
|
1774
2111
|
get chainMap() {
|
|
1775
2112
|
return this.params.chainMap;
|
|
@@ -1781,7 +2118,7 @@ var SimpleChainStakeViewer = class extends AbstractCreatable2 {
|
|
|
1781
2118
|
return toAddress5(toAddress5(1n));
|
|
1782
2119
|
}
|
|
1783
2120
|
get stakeEvents() {
|
|
1784
|
-
return
|
|
2121
|
+
return assertEx13(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
1785
2122
|
}
|
|
1786
2123
|
get stakingTokenAddress() {
|
|
1787
2124
|
return toAddress5("0x000000000000000000000000000011");
|
|
@@ -1835,7 +2172,7 @@ var SimpleChainStakeViewer = class extends AbstractCreatable2 {
|
|
|
1835
2172
|
return pending;
|
|
1836
2173
|
}
|
|
1837
2174
|
stakeById(id) {
|
|
1838
|
-
return
|
|
2175
|
+
return assertEx13(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
1839
2176
|
}
|
|
1840
2177
|
stakeByStaker(staker, slot) {
|
|
1841
2178
|
return this.positions.filter((s) => asAddress5(s.staker) === asAddress5(staker))[slot];
|
|
@@ -2002,317 +2339,25 @@ var SimpleXyoGateway = class {
|
|
|
2002
2339
|
};
|
|
2003
2340
|
|
|
2004
2341
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
2005
|
-
import { assertEx as assertEx14, BigIntToJsonZod, isDefined as
|
|
2006
|
-
import { PayloadBuilder as
|
|
2007
|
-
import { TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
2012
|
-
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder";
|
|
2013
|
-
import { defaultTransactionFees } from "@xyo-network/xl1-protocol";
|
|
2014
|
-
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
2015
|
-
if (from === void 0 && Array.isArray(signer)) {
|
|
2016
|
-
throw new Error("from is required when signer is an array");
|
|
2342
|
+
import { assertEx as assertEx14, BigIntToJsonZod, isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
2343
|
+
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/payload-builder";
|
|
2344
|
+
import { asXL1BlockNumber as asXL1BlockNumber6, TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
2345
|
+
var SimpleXyoGatewayRunner = class {
|
|
2346
|
+
static {
|
|
2347
|
+
__name(this, "SimpleXyoGatewayRunner");
|
|
2017
2348
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
exp
|
|
2028
|
-
};
|
|
2029
|
-
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
2030
|
-
const script = [];
|
|
2031
|
-
for (const elevatedHash of elevatedHashes) {
|
|
2032
|
-
script.push(`elevate|${elevatedHash}`);
|
|
2349
|
+
_connection;
|
|
2350
|
+
_dataLakes;
|
|
2351
|
+
_signer;
|
|
2352
|
+
constructor(connection, signer, dataLakes = []) {
|
|
2353
|
+
this._connection = connection;
|
|
2354
|
+
this._dataLakes = [
|
|
2355
|
+
...dataLakes
|
|
2356
|
+
];
|
|
2357
|
+
this._signer = signer;
|
|
2033
2358
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
from: from ?? (Array.isArray(signer) ? assertEx10(signer.at(0)?.address) : signer.address)
|
|
2037
|
-
};
|
|
2038
|
-
if (script.length > 0) {
|
|
2039
|
-
fields.script = script;
|
|
2040
|
-
}
|
|
2041
|
-
const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({
|
|
2042
|
-
$signatures: []
|
|
2043
|
-
}).payloads([
|
|
2044
|
-
...onChainPayloads,
|
|
2045
|
-
...offChainPayloads
|
|
2046
|
-
]).signers(Array.isArray(signer) ? signer : [
|
|
2047
|
-
signer
|
|
2048
|
-
]).build();
|
|
2049
|
-
return [
|
|
2050
|
-
await PayloadBuilder6.addStorageMeta(tx),
|
|
2051
|
-
await PayloadBuilder6.addStorageMeta(txPayloads)
|
|
2052
|
-
];
|
|
2053
|
-
}
|
|
2054
|
-
__name(buildTransaction, "buildTransaction");
|
|
2055
|
-
|
|
2056
|
-
// src/transaction/buildUnsignedTransaction.ts
|
|
2057
|
-
import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
2058
|
-
import { BoundWitnessBuilder as BoundWitnessBuilder2 } from "@xyo-network/boundwitness-builder";
|
|
2059
|
-
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
2060
|
-
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol";
|
|
2061
|
-
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
2062
|
-
const txBoundWitnessFields = {
|
|
2063
|
-
chain,
|
|
2064
|
-
fees: {
|
|
2065
|
-
base: toHex3(fees.base),
|
|
2066
|
-
gasLimit: toHex3(fees.gasLimit),
|
|
2067
|
-
gasPrice: toHex3(fees.gasPrice),
|
|
2068
|
-
priority: toHex3(fees.priority)
|
|
2069
|
-
},
|
|
2070
|
-
nbf,
|
|
2071
|
-
exp
|
|
2072
|
-
};
|
|
2073
|
-
const elevatedHashes = await PayloadBuilder7.hashes(onChainPayloads);
|
|
2074
|
-
const script = [];
|
|
2075
|
-
for (const elevatedHash of elevatedHashes) {
|
|
2076
|
-
script.push(`elevate|${elevatedHash}`);
|
|
2077
|
-
}
|
|
2078
|
-
const fields = {
|
|
2079
|
-
...txBoundWitnessFields,
|
|
2080
|
-
from
|
|
2081
|
-
};
|
|
2082
|
-
if (script.length > 0) {
|
|
2083
|
-
fields.script = script;
|
|
2084
|
-
}
|
|
2085
|
-
const [tx, txPayloads] = await new BoundWitnessBuilder2().fields(fields).meta({
|
|
2086
|
-
$signatures: []
|
|
2087
|
-
}).payloads([
|
|
2088
|
-
...onChainPayloads,
|
|
2089
|
-
...offChainPayloads
|
|
2090
|
-
]).build();
|
|
2091
|
-
return [
|
|
2092
|
-
tx,
|
|
2093
|
-
txPayloads
|
|
2094
|
-
];
|
|
2095
|
-
}
|
|
2096
|
-
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
2097
|
-
|
|
2098
|
-
// src/transaction/confirmSubmittedTransaction.ts
|
|
2099
|
-
import { delay, isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
2100
|
-
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
2101
|
-
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
2102
|
-
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, txHash, options) => {
|
|
2103
|
-
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options ?? {};
|
|
2104
|
-
options?.logger?.log("\u{1F680} confirming transaction:", txHash, "\n");
|
|
2105
|
-
let attempts = 0;
|
|
2106
|
-
while (true) {
|
|
2107
|
-
const tx = await viewer.transactionByHash(txHash) ?? void 0;
|
|
2108
|
-
if (isDefined11(tx)) {
|
|
2109
|
-
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
2110
|
-
return tx;
|
|
2111
|
-
} else {
|
|
2112
|
-
attempts++;
|
|
2113
|
-
if (attempts > maxAttempts) {
|
|
2114
|
-
options?.logger?.error(`\u26A0\uFE0F Transaction not confirmed after ${maxAttempts} attempts`);
|
|
2115
|
-
throw new Error(`Transaction ${txHash} not confirmed after ${maxAttempts} attempts`);
|
|
2116
|
-
} else {
|
|
2117
|
-
options?.logger?.log(`\u{1F504} Transaction not confirmed yet, attempt ${attempts}. Retrying...`, "\n");
|
|
2118
|
-
await delay(attemptDelay);
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
}, "confirmSubmittedTransaction");
|
|
2123
|
-
|
|
2124
|
-
// src/transaction/hydrateTransaction.ts
|
|
2125
|
-
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
2126
|
-
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
2127
|
-
import { isAllowedBlockPayload as isAllowedBlockPayload2, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
2128
|
-
var tryHydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
2129
|
-
return await tryHydrateTypedBoundWitness({
|
|
2130
|
-
get(hashes) {
|
|
2131
|
-
return chainMap.getMany(hashes);
|
|
2132
|
-
},
|
|
2133
|
-
next() {
|
|
2134
|
-
throw new Error("Not implemented");
|
|
2135
|
-
}
|
|
2136
|
-
}, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
2137
|
-
}, "tryHydrateTransaction");
|
|
2138
|
-
var hydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
2139
|
-
return await hydrateTypedBoundWitness({
|
|
2140
|
-
get(hashes) {
|
|
2141
|
-
return chainMap.getMany(hashes);
|
|
2142
|
-
},
|
|
2143
|
-
next() {
|
|
2144
|
-
throw new Error("Not implemented");
|
|
2145
|
-
}
|
|
2146
|
-
}, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
2147
|
-
}, "hydrateTransaction");
|
|
2148
|
-
var flattenHydratedTransaction = /* @__PURE__ */ __name((hydratedTransaction) => {
|
|
2149
|
-
const [tx, txPayloads] = hydratedTransaction;
|
|
2150
|
-
return [
|
|
2151
|
-
...txPayloads,
|
|
2152
|
-
tx
|
|
2153
|
-
];
|
|
2154
|
-
}, "flattenHydratedTransaction");
|
|
2155
|
-
var flattenHydratedTransactions = /* @__PURE__ */ __name((hydratedTransactions) => hydratedTransactions.flatMap((tx) => flattenHydratedTransaction(tx)), "flattenHydratedTransactions");
|
|
2156
|
-
var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
2157
|
-
const hydratedTransaction = await tryHydrateTransaction({
|
|
2158
|
-
chainMap
|
|
2159
|
-
}, hash);
|
|
2160
|
-
if (!hydratedTransaction) {
|
|
2161
|
-
return void 0;
|
|
2162
|
-
}
|
|
2163
|
-
const [transaction, payloads] = hydratedTransaction;
|
|
2164
|
-
const opCodes = (transaction.script ?? []).filter((operation) => operation.startsWith("elevate|"));
|
|
2165
|
-
const elevatedPayloads2 = [];
|
|
2166
|
-
for (const opCode of opCodes) {
|
|
2167
|
-
const [code, hash2] = opCode.split("|");
|
|
2168
|
-
if (code === "elevated") {
|
|
2169
|
-
const elevatedPayload = payloads.find((payload) => payload._hash === hash2);
|
|
2170
|
-
if (isAllowedBlockPayload2(elevatedPayload)) {
|
|
2171
|
-
elevatedPayloads2.push(elevatedPayload);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
}
|
|
2175
|
-
if (opCodes.length === elevatedPayloads2.length) {
|
|
2176
|
-
return [
|
|
2177
|
-
transaction,
|
|
2178
|
-
elevatedPayloads2
|
|
2179
|
-
];
|
|
2180
|
-
}
|
|
2181
|
-
return void 0;
|
|
2182
|
-
}, "tryHydrateElevatedTransaction");
|
|
2183
|
-
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) => {
|
|
2184
|
-
return assertEx11(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
2185
|
-
}, "hydrateElevatedTransaction");
|
|
2186
|
-
|
|
2187
|
-
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
2188
|
-
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/payload-builder";
|
|
2189
|
-
function transactionBlockByteCount([transaction, payloads]) {
|
|
2190
|
-
const cleanTransaction = PayloadBuilder8.omitStorageMeta(transaction);
|
|
2191
|
-
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
2192
|
-
const cleanPayloads = PayloadBuilder8.omitStorageMeta(payloads);
|
|
2193
|
-
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
2194
|
-
}
|
|
2195
|
-
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
2196
|
-
|
|
2197
|
-
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
2198
|
-
import { asHash as asHash3 } from "@xylabs/sdk-js";
|
|
2199
|
-
|
|
2200
|
-
// src/transaction/primitives/transactionOperations.ts
|
|
2201
|
-
function crackOperation(operation) {
|
|
2202
|
-
const parts = operation.split("|");
|
|
2203
|
-
if (parts.length < 2) {
|
|
2204
|
-
throw new Error(`Invalid operation format: ${operation}`);
|
|
2205
|
-
}
|
|
2206
|
-
return [
|
|
2207
|
-
parts[0],
|
|
2208
|
-
parts.slice(1)
|
|
2209
|
-
];
|
|
2210
|
-
}
|
|
2211
|
-
__name(crackOperation, "crackOperation");
|
|
2212
|
-
function crackOperations(operations) {
|
|
2213
|
-
return operations.map((op) => crackOperation(op));
|
|
2214
|
-
}
|
|
2215
|
-
__name(crackOperations, "crackOperations");
|
|
2216
|
-
|
|
2217
|
-
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
2218
|
-
function transactionElevatedPayloadHashes(transaction) {
|
|
2219
|
-
const elevateOperations = crackOperations(transaction.script ?? []).filter((op) => op[0] === "elevate");
|
|
2220
|
-
return elevateOperations.map((op) => asHash3(op[1][0], true));
|
|
2221
|
-
}
|
|
2222
|
-
__name(transactionElevatedPayloadHashes, "transactionElevatedPayloadHashes");
|
|
2223
|
-
function transactionElevatedPayloads([transaction, payloads]) {
|
|
2224
|
-
const hashes = transactionElevatedPayloadHashes(transaction);
|
|
2225
|
-
const elevatedPayloads2 = payloads.filter((payload) => hashes.includes(payload._hash));
|
|
2226
|
-
return elevatedPayloads2;
|
|
2227
|
-
}
|
|
2228
|
-
__name(transactionElevatedPayloads, "transactionElevatedPayloads");
|
|
2229
|
-
|
|
2230
|
-
// src/transaction/primitives/transactionRequiredGas.ts
|
|
2231
|
-
import { AttoXL1 as AttoXL12, TransactionGasCosts } from "@xyo-network/xl1-protocol";
|
|
2232
|
-
function transactionBytesRequiredGas([transaction, payloads]) {
|
|
2233
|
-
const transactionBlockBytes = transactionBlockByteCount([
|
|
2234
|
-
transaction,
|
|
2235
|
-
payloads
|
|
2236
|
-
]);
|
|
2237
|
-
return AttoXL12(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes));
|
|
2238
|
-
}
|
|
2239
|
-
__name(transactionBytesRequiredGas, "transactionBytesRequiredGas");
|
|
2240
|
-
function transactionRequiredGas(hydratedTransaction) {
|
|
2241
|
-
const elevatedPayloads2 = transactionElevatedPayloads(hydratedTransaction);
|
|
2242
|
-
const hashes = elevatedPayloads2.length + 1;
|
|
2243
|
-
const signatures = hydratedTransaction[0].addresses.length;
|
|
2244
|
-
return AttoXL12(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads2.length));
|
|
2245
|
-
}
|
|
2246
|
-
__name(transactionRequiredGas, "transactionRequiredGas");
|
|
2247
|
-
|
|
2248
|
-
// src/transaction/script.ts
|
|
2249
|
-
import { asHash as asHash4 } from "@xylabs/sdk-js";
|
|
2250
|
-
import { assertEx as assertEx12, filterAs as filterAs2 } from "@xylabs/sdk-js";
|
|
2251
|
-
import { isAllowedBlockPayloadWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
2252
|
-
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
2253
|
-
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
2254
|
-
return filterAs2(hashes, (h) => asHash4(h));
|
|
2255
|
-
}, "tryExtractElevatedHashesFromScript");
|
|
2256
|
-
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
2257
|
-
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
2258
|
-
const filtered = filterAs2(hashes, (h) => asHash4(h));
|
|
2259
|
-
assertEx12(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2260
|
-
return filtered;
|
|
2261
|
-
}, "extractElevatedHashesFromScript");
|
|
2262
|
-
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
2263
|
-
const [bw, payloads] = tx;
|
|
2264
|
-
const { script } = bw;
|
|
2265
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
2266
|
-
return payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
2267
|
-
}, "tryExtractElevatedHashes");
|
|
2268
|
-
var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
2269
|
-
const [bw, payloads] = tx;
|
|
2270
|
-
const { script } = bw;
|
|
2271
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
2272
|
-
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
2273
|
-
assertEx12(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2274
|
-
return filtered;
|
|
2275
|
-
}, "extractElevatedHashes");
|
|
2276
|
-
|
|
2277
|
-
// src/transaction/signTransaction.ts
|
|
2278
|
-
import { assertEx as assertEx13, hexFromArrayBuffer, toArrayBuffer } from "@xylabs/sdk-js";
|
|
2279
|
-
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
2280
|
-
async function signTransaction(tx, account) {
|
|
2281
|
-
assertEx13(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2282
|
-
const signedTx = structuredClone(tx);
|
|
2283
|
-
signedTx.addresses = [
|
|
2284
|
-
account.address
|
|
2285
|
-
];
|
|
2286
|
-
signedTx.previous_hashes = [
|
|
2287
|
-
account.previousHash ?? null
|
|
2288
|
-
];
|
|
2289
|
-
const hash = await PayloadBuilder9.dataHash(signedTx);
|
|
2290
|
-
const hashBytes = toArrayBuffer(hash);
|
|
2291
|
-
const [signature] = await account.sign(hashBytes);
|
|
2292
|
-
signedTx.$signatures = [
|
|
2293
|
-
hexFromArrayBuffer(signature)
|
|
2294
|
-
];
|
|
2295
|
-
return signedTx;
|
|
2296
|
-
}
|
|
2297
|
-
__name(signTransaction, "signTransaction");
|
|
2298
|
-
|
|
2299
|
-
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
2300
|
-
var SimpleXyoGatewayRunner = class {
|
|
2301
|
-
static {
|
|
2302
|
-
__name(this, "SimpleXyoGatewayRunner");
|
|
2303
|
-
}
|
|
2304
|
-
_connection;
|
|
2305
|
-
_dataLakes;
|
|
2306
|
-
_signer;
|
|
2307
|
-
constructor(connection, signer, dataLakes = []) {
|
|
2308
|
-
this._connection = connection;
|
|
2309
|
-
this._dataLakes = [
|
|
2310
|
-
...dataLakes
|
|
2311
|
-
];
|
|
2312
|
-
this._signer = signer;
|
|
2313
|
-
}
|
|
2314
|
-
get connectionInstance() {
|
|
2315
|
-
return this._connection;
|
|
2359
|
+
get connectionInstance() {
|
|
2360
|
+
return this._connection;
|
|
2316
2361
|
}
|
|
2317
2362
|
get dataLakes() {
|
|
2318
2363
|
throw new Error("Method not implemented.");
|
|
@@ -2327,9 +2372,9 @@ var SimpleXyoGatewayRunner = class {
|
|
|
2327
2372
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
2328
2373
|
const viewer = assertEx14(this.connectionInstance.viewer, () => "No viewer available on connection");
|
|
2329
2374
|
const { nbf, exp, chain, fees } = options ?? {};
|
|
2330
|
-
const resolvedChainId =
|
|
2331
|
-
const resolvedNbf =
|
|
2332
|
-
const resolvedExp =
|
|
2375
|
+
const resolvedChainId = isDefined13(chain) ? chain : await viewer.chainId();
|
|
2376
|
+
const resolvedNbf = asXL1BlockNumber6(isDefined13(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
2377
|
+
const resolvedExp = asXL1BlockNumber6(isDefined13(exp) ? exp : resolvedNbf + 10, true);
|
|
2333
2378
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await (await this.signer()).address(), fees);
|
|
2334
2379
|
return await this.addTransactionToChain(tx);
|
|
2335
2380
|
}
|
|
@@ -2368,7 +2413,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
2368
2413
|
address,
|
|
2369
2414
|
BigIntToJsonZod.parse(amount)
|
|
2370
2415
|
]));
|
|
2371
|
-
const transfer = new
|
|
2416
|
+
const transfer = new PayloadBuilder12({
|
|
2372
2417
|
schema: TransferSchema2
|
|
2373
2418
|
}).fields({
|
|
2374
2419
|
from,
|
|
@@ -2561,7 +2606,7 @@ var MemoryPermissionsStore = class {
|
|
|
2561
2606
|
|
|
2562
2607
|
// src/simple/runner/SimpleXyoRunner.ts
|
|
2563
2608
|
import { MemoryArchivist } from "@xyo-network/archivist-memory";
|
|
2564
|
-
import { PayloadBuilder as
|
|
2609
|
+
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/payload-builder";
|
|
2565
2610
|
var SimpleXyoRunner = class {
|
|
2566
2611
|
static {
|
|
2567
2612
|
__name(this, "SimpleXyoRunner");
|
|
@@ -2573,7 +2618,7 @@ var SimpleXyoRunner = class {
|
|
|
2573
2618
|
async broadcastTransaction(transaction) {
|
|
2574
2619
|
const archivist = await this.getMempoolArchivist();
|
|
2575
2620
|
await archivist.insert(flattenHydratedTransaction(transaction));
|
|
2576
|
-
return await
|
|
2621
|
+
return await PayloadBuilder13.hash(transaction[0]);
|
|
2577
2622
|
}
|
|
2578
2623
|
async getMempoolArchivist() {
|
|
2579
2624
|
if (!this._mempoolArchivist) {
|
|
@@ -2586,7 +2631,8 @@ var SimpleXyoRunner = class {
|
|
|
2586
2631
|
};
|
|
2587
2632
|
|
|
2588
2633
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
2589
|
-
import { PayloadBuilder as
|
|
2634
|
+
import { PayloadBuilder as PayloadBuilder14 } from "@xyo-network/payload-builder";
|
|
2635
|
+
import { SignedHydratedTransactionWithHashMetaZod } from "@xyo-network/xl1-protocol";
|
|
2590
2636
|
var SimpleXyoSigner = class {
|
|
2591
2637
|
static {
|
|
2592
2638
|
__name(this, "SimpleXyoSigner");
|
|
@@ -2605,16 +2651,16 @@ var SimpleXyoSigner = class {
|
|
|
2605
2651
|
}
|
|
2606
2652
|
async signTransaction(tx) {
|
|
2607
2653
|
const txBW = await signTransaction(tx[0], this._account);
|
|
2608
|
-
return [
|
|
2609
|
-
await
|
|
2610
|
-
await
|
|
2611
|
-
];
|
|
2654
|
+
return SignedHydratedTransactionWithHashMetaZod.parse([
|
|
2655
|
+
await PayloadBuilder14.addStorageMeta(txBW),
|
|
2656
|
+
await PayloadBuilder14.addStorageMeta(tx[1])
|
|
2657
|
+
]);
|
|
2612
2658
|
}
|
|
2613
2659
|
};
|
|
2614
2660
|
|
|
2615
2661
|
// src/simple/timesync/SimpleTimeSyncViewer.ts
|
|
2616
|
-
import { asHash as asHash5, assertEx as assertEx17, isDefined as
|
|
2617
|
-
import { asTimePayload, asXL1BlockNumber as
|
|
2662
|
+
import { asHash as asHash5, assertEx as assertEx17, isDefined as isDefined14 } from "@xylabs/sdk-js";
|
|
2663
|
+
import { asTimePayload, asXL1BlockNumber as asXL1BlockNumber7, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
2618
2664
|
var SimpleTimeSyncViewer = class {
|
|
2619
2665
|
static {
|
|
2620
2666
|
__name(this, "SimpleTimeSyncViewer");
|
|
@@ -2628,10 +2674,10 @@ var SimpleTimeSyncViewer = class {
|
|
|
2628
2674
|
async convertTime(fromDomain, toDomain, from) {
|
|
2629
2675
|
switch (fromDomain) {
|
|
2630
2676
|
case "xl1": {
|
|
2631
|
-
const [block, payloads] = assertEx17(await this.blockViewer.blockByNumber(
|
|
2677
|
+
const [block, payloads] = assertEx17(await this.blockViewer.blockByNumber(asXL1BlockNumber7(from, true)), () => "Block not found");
|
|
2632
2678
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
2633
2679
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
2634
|
-
const timePayload = asTimePayload(
|
|
2680
|
+
const timePayload = asTimePayload(isDefined14(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
2635
2681
|
if (timePayload === void 0) return 0;
|
|
2636
2682
|
switch (toDomain) {
|
|
2637
2683
|
case "xl1": {
|
|
@@ -2738,334 +2784,24 @@ var prettifyZodError = /* @__PURE__ */ __name((error) => {
|
|
|
2738
2784
|
// src/viewers/AccountBalance.ts
|
|
2739
2785
|
import { WithHashMetaZod } from "@xyo-network/payload-model";
|
|
2740
2786
|
import { TransferZod } from "@xyo-network/xl1-protocol";
|
|
2741
|
-
import
|
|
2742
|
-
|
|
2743
|
-
|
|
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([
|
|
2787
|
+
import { BlockBoundWitnessZod, TransactionBoundWitnessZod } from "@xyo-network/xl1-protocol";
|
|
2788
|
+
import z21 from "zod";
|
|
2789
|
+
var AccountBalanceHistoryItemZod = z21.tuple([
|
|
3064
2790
|
WithHashMetaZod(BlockBoundWitnessZod),
|
|
3065
2791
|
WithHashMetaZod(TransactionBoundWitnessZod).nullable(),
|
|
3066
2792
|
WithHashMetaZod(TransferZod)
|
|
3067
2793
|
]);
|
|
3068
2794
|
|
|
2795
|
+
// src/viewers/Mempool.ts
|
|
2796
|
+
import { HashZod as HashZod2 } from "@xylabs/sdk-js";
|
|
2797
|
+
import { XL1BlockRangeZod } from "@xyo-network/xl1-protocol";
|
|
2798
|
+
import z22 from "zod";
|
|
2799
|
+
var PendingTransactionsOptionsZod = z22.object({
|
|
2800
|
+
cursor: HashZod2.optional(),
|
|
2801
|
+
limit: z22.number().int().positive().optional(),
|
|
2802
|
+
window: XL1BlockRangeZod.optional()
|
|
2803
|
+
});
|
|
2804
|
+
|
|
3069
2805
|
// src/viewers/StakeEvents.ts
|
|
3070
2806
|
var StakeEventNames = [
|
|
3071
2807
|
"StakeAdded",
|
|
@@ -3105,27 +2841,11 @@ export {
|
|
|
3105
2841
|
ADDRESS_INDEX,
|
|
3106
2842
|
AccountBalanceHistoryItemZod,
|
|
3107
2843
|
AddressPairSchema,
|
|
3108
|
-
AnyBoundWitnessZod,
|
|
3109
|
-
AnySignedBoundWitnessWithStorageMetaZod,
|
|
3110
|
-
AnySignedBoundWitnessZod,
|
|
3111
|
-
AnyUnsignedBoundWitnessZod,
|
|
3112
|
-
ArrayBufferToJsonZod,
|
|
3113
|
-
AttoToJsonZod,
|
|
3114
|
-
AttoZod,
|
|
3115
2844
|
BalancesStepSummarySchema,
|
|
3116
|
-
BlockBoundWitnessZod,
|
|
3117
|
-
BlockDurationZod,
|
|
3118
|
-
BlockEndZod,
|
|
3119
|
-
BlockScriptsZod,
|
|
3120
|
-
BlockStartZod,
|
|
3121
2845
|
BlockValidationError,
|
|
3122
|
-
BoundWitnessZod,
|
|
3123
2846
|
CHANGE_ADDRESS,
|
|
3124
2847
|
COIN_TYPES,
|
|
3125
|
-
CaveatTypesZod,
|
|
3126
|
-
CaveatsZod,
|
|
3127
2848
|
ChainIndexingServiceStateSchema,
|
|
3128
|
-
ChainZod,
|
|
3129
2849
|
ConfigZod,
|
|
3130
2850
|
DEFAULT_WALLET_PATH,
|
|
3131
2851
|
EIP712DataPayloadFieldsZod,
|
|
@@ -3135,40 +2855,14 @@ export {
|
|
|
3135
2855
|
GlobalMetaSchema,
|
|
3136
2856
|
HydratedBlockStateValidationError,
|
|
3137
2857
|
HydratedBlockValidationError,
|
|
3138
|
-
HydratedBlockWithStorageMetaZod,
|
|
3139
|
-
HydratedBlockZod,
|
|
3140
|
-
HydratedTransactionZod,
|
|
3141
|
-
InvokerPermissionZod,
|
|
3142
2858
|
JSONSchemaMetaSchema,
|
|
3143
|
-
JsonToArrayBufferZod,
|
|
3144
|
-
JsonToAttoZod,
|
|
3145
|
-
JsonToSignedHydratedTransactionZod,
|
|
3146
|
-
JsonToStakeZod,
|
|
3147
|
-
LocalSequenceFromStringZod,
|
|
3148
|
-
LocalSequenceToStringZod,
|
|
3149
2859
|
LruCacheMap,
|
|
3150
2860
|
MemoryMap,
|
|
3151
2861
|
MemoryPermissionsStore,
|
|
3152
2862
|
MnemonicStringZod,
|
|
3153
|
-
|
|
3154
|
-
PermissionZod,
|
|
3155
|
-
QualifiedSequenceFromStringZod,
|
|
3156
|
-
QualifiedSequenceToStringZod,
|
|
3157
|
-
RequestedPermissionZod,
|
|
2863
|
+
PendingTransactionsOptionsZod,
|
|
3158
2864
|
RewardMultipliers,
|
|
3159
|
-
RewardsRangeOptionsZod,
|
|
3160
2865
|
SchemasStepSummarySchema,
|
|
3161
|
-
SequenceFromStringZod,
|
|
3162
|
-
SequenceToStringZod,
|
|
3163
|
-
SignedBlockBoundWitnessZod,
|
|
3164
|
-
SignedBoundWitnessWithStorageMetaZod,
|
|
3165
|
-
SignedBoundWitnessZod,
|
|
3166
|
-
SignedHydratedBlockToJsonZod,
|
|
3167
|
-
SignedHydratedBlockWithStorageMetaZod,
|
|
3168
|
-
SignedHydratedBlockZod,
|
|
3169
|
-
SignedHydratedTransactionToJsonZod,
|
|
3170
|
-
SignedHydratedTransactionZod,
|
|
3171
|
-
SignedTransactionBoundWitnessZod,
|
|
3172
2866
|
SimpleAccountBalanceViewer,
|
|
3173
2867
|
SimpleChainStakeViewer,
|
|
3174
2868
|
SimpleDataLakeRunner,
|
|
@@ -3182,28 +2876,15 @@ export {
|
|
|
3182
2876
|
SimpleXyoRunner,
|
|
3183
2877
|
SimpleXyoSigner,
|
|
3184
2878
|
StakeEventNames,
|
|
3185
|
-
StakeToJsonZod,
|
|
3186
|
-
StakeZod,
|
|
3187
2879
|
StepSummarySchema,
|
|
3188
2880
|
TODO,
|
|
3189
|
-
TimeDomainZod,
|
|
3190
|
-
TransactionBoundWitnessZod,
|
|
3191
|
-
TransactionFeesBigIntToJsonZod,
|
|
3192
|
-
TransactionFeesBigIntZod,
|
|
3193
|
-
TransactionFeesHexZod,
|
|
3194
|
-
TransactionFeesJsonToBigIntZod,
|
|
3195
|
-
TransferPairZod,
|
|
3196
2881
|
TransfersStepSummarySchema,
|
|
3197
2882
|
TypedDataDomainZod,
|
|
3198
2883
|
TypedDataFieldZod,
|
|
3199
2884
|
TypedDataTypesZod,
|
|
3200
2885
|
TypedDataValueZod,
|
|
3201
|
-
UnsignedBoundWitnessWithStorageMetaZod,
|
|
3202
|
-
UnsignedBoundWitnessZod,
|
|
3203
|
-
UnsignedHydratedTransactionZod,
|
|
3204
2886
|
UsageMetaSchema,
|
|
3205
2887
|
WALLET_COMPLIANCE,
|
|
3206
|
-
WithTransactionFeesZod,
|
|
3207
2888
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH,
|
|
3208
2889
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK,
|
|
3209
2890
|
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS,
|
|
@@ -3229,6 +2910,7 @@ export {
|
|
|
3229
2910
|
blockPayloadsFromHydratedBlock,
|
|
3230
2911
|
buildTransaction,
|
|
3231
2912
|
buildUnsignedTransaction,
|
|
2913
|
+
bundledPayloadToHydratedTransaction,
|
|
3232
2914
|
calculateFramesFromRange,
|
|
3233
2915
|
completedStepRewardAddress,
|
|
3234
2916
|
confirmSubmittedTransaction,
|
|
@@ -3252,6 +2934,7 @@ export {
|
|
|
3252
2934
|
hydrateBlock,
|
|
3253
2935
|
hydrateElevatedTransaction,
|
|
3254
2936
|
hydrateTransaction,
|
|
2937
|
+
hydratedTransactionToPayloadBundle,
|
|
3255
2938
|
isAddressPairPayload,
|
|
3256
2939
|
isBalancesStepSummary,
|
|
3257
2940
|
isBalancesStepSummaryWithStorageMeta,
|