@xyo-network/xl1-protocol-sdk 1.26.4 → 1.26.7
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/index.mjs +166 -35
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +2 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +2 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts +2 -1
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +1 -0
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/index.d.ts +2 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +4 -2
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +14 -7
- package/dist/neutral/test/index.mjs.map +1 -1
- package/package.json +11 -10
- package/src/payloads/netBalancesForPayloads.ts +3 -2
- package/src/payloads/netSchemasForPayloads.ts +3 -2
- package/src/payloads/netTransfersForPayloads.ts +3 -2
- package/src/primitives/chain/step/stepRewardTotal.ts +1 -1
- package/src/simple/block/SimpleBlockViewer.ts +18 -7
- package/src/simple/index.ts +2 -0
- package/src/simple/mempool/SimpleMempoolRunner.ts +11 -3
- package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +1 -1
- package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +1 -1
package/dist/neutral/index.mjs
CHANGED
|
@@ -2167,7 +2167,7 @@ import {
|
|
|
2167
2167
|
} from "@xylabs/sdk-js";
|
|
2168
2168
|
import { span } from "@xylabs/sdk-js";
|
|
2169
2169
|
import { isTransfer } from "@xyo-network/xl1-protocol-lib";
|
|
2170
|
-
var netBalancesForPayloads = (payloads) => {
|
|
2170
|
+
var netBalancesForPayloads = (context, payloads) => {
|
|
2171
2171
|
return span("netBalancesForPayloads", () => {
|
|
2172
2172
|
const balances = {};
|
|
2173
2173
|
for (const payload of payloads) {
|
|
@@ -2180,7 +2180,7 @@ var netBalancesForPayloads = (payloads) => {
|
|
|
2180
2180
|
}
|
|
2181
2181
|
}
|
|
2182
2182
|
return balances;
|
|
2183
|
-
});
|
|
2183
|
+
}, context.traceProvider);
|
|
2184
2184
|
};
|
|
2185
2185
|
|
|
2186
2186
|
// src/payloads/netSchemasForPayloads.ts
|
|
@@ -2190,7 +2190,7 @@ import {
|
|
|
2190
2190
|
} from "@xylabs/sdk-js";
|
|
2191
2191
|
import { span as span2 } from "@xylabs/sdk-js";
|
|
2192
2192
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
2193
|
-
var netSchemasForPayloads = (payloads) => {
|
|
2193
|
+
var netSchemasForPayloads = (context, payloads) => {
|
|
2194
2194
|
return span2("netSchemasForPayloads", () => {
|
|
2195
2195
|
const balances = {};
|
|
2196
2196
|
for (const payload of payloads) {
|
|
@@ -2203,7 +2203,7 @@ var netSchemasForPayloads = (payloads) => {
|
|
|
2203
2203
|
}
|
|
2204
2204
|
}
|
|
2205
2205
|
return balances;
|
|
2206
|
-
});
|
|
2206
|
+
}, context.traceProvider);
|
|
2207
2207
|
};
|
|
2208
2208
|
|
|
2209
2209
|
// src/payloads/netTransfersForPayloads.ts
|
|
@@ -2212,7 +2212,7 @@ import {
|
|
|
2212
2212
|
} from "@xylabs/sdk-js";
|
|
2213
2213
|
import { span as span3 } from "@xylabs/sdk-js";
|
|
2214
2214
|
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol-lib";
|
|
2215
|
-
function netTransfersForPayloads(payloads) {
|
|
2215
|
+
function netTransfersForPayloads(context, payloads) {
|
|
2216
2216
|
return span3("netTransfersForPayloads", () => {
|
|
2217
2217
|
const transfers = {};
|
|
2218
2218
|
for (const payload of payloads) {
|
|
@@ -2227,7 +2227,7 @@ function netTransfersForPayloads(payloads) {
|
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
2229
2229
|
return transfers;
|
|
2230
|
-
});
|
|
2230
|
+
}, context.traceProvider);
|
|
2231
2231
|
}
|
|
2232
2232
|
|
|
2233
2233
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
@@ -2586,7 +2586,7 @@ async function stepRewardTotal(context, blockViewer, { block, step }, multiplier
|
|
|
2586
2586
|
() => `No step transfer found for step ${step} at block ${block} (${blockBw._hash})`
|
|
2587
2587
|
);
|
|
2588
2588
|
const rewards = assertEx22(
|
|
2589
|
-
netTransfersForPayloads([stepTransfer])[XYO_STEP_REWARD_ADDRESS2],
|
|
2589
|
+
netTransfersForPayloads(context, [stepTransfer])[XYO_STEP_REWARD_ADDRESS2],
|
|
2590
2590
|
() => `No rewards found for step reward address ${XYO_STEP_REWARD_ADDRESS2} at block ${block} (${blockBw._hash})`
|
|
2591
2591
|
);
|
|
2592
2592
|
const sortedTransfers = Object.entries(rewards).toSorted(([, a], [, b]) => a > b ? -1 : a < b ? 1 : 0);
|
|
@@ -3218,7 +3218,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3218
3218
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3219
3219
|
const [, payloads] = assertEx26(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3220
3220
|
const balances = {};
|
|
3221
|
-
for (const [address, balance] of Object.entries(netBalancesForPayloads(payloads))) {
|
|
3221
|
+
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3222
3222
|
balances[address] = toSignedBigInt(balance);
|
|
3223
3223
|
}
|
|
3224
3224
|
return {
|
|
@@ -3422,7 +3422,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3422
3422
|
if (frameSize === 1) {
|
|
3423
3423
|
const [, payloads] = assertEx30(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3424
3424
|
const transfers = {};
|
|
3425
|
-
for (const [from, toMap] of Object.entries(netTransfersForPayloads(payloads))) {
|
|
3425
|
+
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3426
3426
|
transfers[from] = transfers[from] ?? {};
|
|
3427
3427
|
for (const [to, amount] of Object.entries(toMap)) {
|
|
3428
3428
|
transfers[from][to] = toSignedBigInt(amount);
|
|
@@ -3818,13 +3818,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3818
3818
|
}
|
|
3819
3819
|
async blockByNumber(blockNumber) {
|
|
3820
3820
|
return await this.spanAsync("blockByNumber", async () => {
|
|
3821
|
-
const
|
|
3822
|
-
if (isUndefined6(head)) {
|
|
3821
|
+
const chainContext = await this.getChainContextRead();
|
|
3822
|
+
if (isUndefined6(chainContext.head)) {
|
|
3823
3823
|
return null;
|
|
3824
3824
|
}
|
|
3825
|
-
|
|
3826
|
-
const [result] = block ? await addDataLakePayloads(block, this.dataLakeViewer) : [null, []];
|
|
3827
|
-
return result;
|
|
3825
|
+
return await this.blockByNumberWithContext(chainContext, blockNumber);
|
|
3828
3826
|
}, { ...this.context, timeBudgetLimit: 100 });
|
|
3829
3827
|
}
|
|
3830
3828
|
async blocksByHash(hash, limit = 50) {
|
|
@@ -3846,13 +3844,17 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3846
3844
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
3847
3845
|
assertEx33(limit > 0, () => "limit must be greater than 0");
|
|
3848
3846
|
assertEx33(limit <= 100, () => "limit must be less than 100");
|
|
3847
|
+
const chainContext = await this.getChainContextRead();
|
|
3848
|
+
if (isUndefined6(chainContext.head)) {
|
|
3849
|
+
return [];
|
|
3850
|
+
}
|
|
3849
3851
|
const blocks = [];
|
|
3850
|
-
let current = await this.
|
|
3852
|
+
let current = await this.blockByNumberWithContext(chainContext, blockNumber);
|
|
3851
3853
|
while (current && blocks.length < limit) {
|
|
3852
3854
|
blocks.push(current);
|
|
3853
3855
|
if (current[0].block === 0) break;
|
|
3854
3856
|
const previousNumber = asXL1BlockNumber9(current[0].block - 1, true);
|
|
3855
|
-
current = await this.
|
|
3857
|
+
current = await this.blockByNumberWithContext(chainContext, previousNumber);
|
|
3856
3858
|
}
|
|
3857
3859
|
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true));
|
|
3858
3860
|
}, this.context);
|
|
@@ -3915,6 +3917,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3915
3917
|
head: (await this.finalizationViewer.head())[0]
|
|
3916
3918
|
};
|
|
3917
3919
|
}
|
|
3920
|
+
async blockByNumberWithContext(chainContext, blockNumber) {
|
|
3921
|
+
const block = asSignedHydratedBlockWithHashMeta(await hydratedBlockByNumber(chainContext, blockNumber)) ?? null;
|
|
3922
|
+
const [result] = block ? await addDataLakePayloads(block, this.dataLakeViewer) : [null, []];
|
|
3923
|
+
return result;
|
|
3924
|
+
}
|
|
3918
3925
|
};
|
|
3919
3926
|
__publicField(SimpleBlockViewer, "defaultMoniker", BlockViewerMoniker2);
|
|
3920
3927
|
__publicField(SimpleBlockViewer, "dependencies", [FinalizationViewerMoniker]);
|
|
@@ -4586,7 +4593,8 @@ import {
|
|
|
4586
4593
|
isHydratedTransactionWithHashMeta,
|
|
4587
4594
|
isSignedHydratedBlockWithHashMeta,
|
|
4588
4595
|
isSignedHydratedTransactionWithHashMeta,
|
|
4589
|
-
MempoolRunnerMoniker
|
|
4596
|
+
MempoolRunnerMoniker,
|
|
4597
|
+
TransactionValidationViewerMoniker
|
|
4590
4598
|
} from "@xyo-network/xl1-protocol-lib";
|
|
4591
4599
|
import { Mutex } from "async-mutex";
|
|
4592
4600
|
var DEFAULT_SYNC_INTERVAL = 3e4;
|
|
@@ -4596,6 +4604,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4596
4604
|
_blockValidationViewer;
|
|
4597
4605
|
_chainContractViewer;
|
|
4598
4606
|
_finalizationViewer;
|
|
4607
|
+
_transactionValidationViewer;
|
|
4599
4608
|
_syncMutex = new Mutex();
|
|
4600
4609
|
_syncTimerId = null;
|
|
4601
4610
|
get blockValidationViewer() {
|
|
@@ -4625,6 +4634,9 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4625
4634
|
get syncLimit() {
|
|
4626
4635
|
return this.params.syncLimit ?? DEFAULT_SYNC_LIMIT;
|
|
4627
4636
|
}
|
|
4637
|
+
get transactionValidationViewer() {
|
|
4638
|
+
return this._transactionValidationViewer;
|
|
4639
|
+
}
|
|
4628
4640
|
static async paramsHandler(params) {
|
|
4629
4641
|
return {
|
|
4630
4642
|
...await super.paramsHandler(params),
|
|
@@ -4637,6 +4649,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4637
4649
|
this._blockValidationViewer = await this.locator.getInstance(BlockValidationViewerMoniker2);
|
|
4638
4650
|
this._chainContractViewer = await this.locator.getInstance(ChainContractViewerMoniker4);
|
|
4639
4651
|
this._finalizationViewer = await this.locator.getInstance(FinalizationViewerMoniker4);
|
|
4652
|
+
this._transactionValidationViewer = await this.locator.getInstance(TransactionValidationViewerMoniker);
|
|
4640
4653
|
}
|
|
4641
4654
|
async prunePendingBlocks({
|
|
4642
4655
|
batchSize = 10,
|
|
@@ -4668,7 +4681,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4668
4681
|
remainingBlockMap.length === remainingBlocks.length,
|
|
4669
4682
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
4670
4683
|
);
|
|
4671
|
-
const validationResults = await this.blockValidationViewer.validateBlocks(remainingBlocks, { value: true, state:
|
|
4684
|
+
const validationResults = await this.blockValidationViewer.validateBlocks(remainingBlocks, { value: true, state: true });
|
|
4672
4685
|
for (const [i, r] of validationResults.entries()) {
|
|
4673
4686
|
const validated = isHydratedBlockWithHashMeta(r);
|
|
4674
4687
|
if (!validated) {
|
|
@@ -4725,7 +4738,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4725
4738
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
4726
4739
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
4727
4740
|
);
|
|
4728
|
-
const validationResults =
|
|
4741
|
+
const validationResults = await this.transactionValidationViewer.validateTransactions(remainingTransactions, { value: true, state: true });
|
|
4729
4742
|
for (const [i, r] of validationResults.entries()) {
|
|
4730
4743
|
const validated = isHydratedTransactionWithHashMeta(r);
|
|
4731
4744
|
if (!validated) {
|
|
@@ -4881,7 +4894,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4881
4894
|
}
|
|
4882
4895
|
};
|
|
4883
4896
|
__publicField(SimpleMempoolRunner, "defaultMoniker", MempoolRunnerMoniker);
|
|
4884
|
-
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, ChainContractViewerMoniker4]);
|
|
4897
|
+
__publicField(SimpleMempoolRunner, "dependencies", [FinalizationViewerMoniker4, BlockValidationViewerMoniker2, TransactionValidationViewerMoniker, ChainContractViewerMoniker4]);
|
|
4885
4898
|
__publicField(SimpleMempoolRunner, "monikers", [MempoolRunnerMoniker]);
|
|
4886
4899
|
SimpleMempoolRunner = __decorateClass([
|
|
4887
4900
|
creatableProvider()
|
|
@@ -5699,16 +5712,133 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
5699
5712
|
creatableProvider()
|
|
5700
5713
|
], SimpleTimeSyncViewer);
|
|
5701
5714
|
|
|
5715
|
+
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
5716
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
5717
|
+
import { PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
5718
|
+
import {
|
|
5719
|
+
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
5720
|
+
asXL1BlockRange as asXL1BlockRange12,
|
|
5721
|
+
BlockViewerMoniker as BlockViewerMoniker5,
|
|
5722
|
+
ChainContractViewerMoniker as ChainContractViewerMoniker5,
|
|
5723
|
+
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig6,
|
|
5724
|
+
isHydratedTransaction,
|
|
5725
|
+
TransactionValidationViewerMoniker as TransactionValidationViewerMoniker2
|
|
5726
|
+
} from "@xyo-network/xl1-protocol-lib";
|
|
5727
|
+
var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider {
|
|
5728
|
+
moniker = SimpleTransactionValidationViewer.defaultMoniker;
|
|
5729
|
+
_accountBalanceViewer;
|
|
5730
|
+
_blockViewer;
|
|
5731
|
+
_chainContractViewer;
|
|
5732
|
+
get blockViewer() {
|
|
5733
|
+
return this._blockViewer;
|
|
5734
|
+
}
|
|
5735
|
+
get chainContractViewer() {
|
|
5736
|
+
return this._chainContractViewer;
|
|
5737
|
+
}
|
|
5738
|
+
get maxUncleWindowSize() {
|
|
5739
|
+
return this.params.maxUncleWindowSize;
|
|
5740
|
+
}
|
|
5741
|
+
static async paramsHandler(params) {
|
|
5742
|
+
return {
|
|
5743
|
+
...await super.paramsHandler(params),
|
|
5744
|
+
protocol: params.protocol,
|
|
5745
|
+
state: params.state,
|
|
5746
|
+
maxUncleWindowSize: params.maxUncleWindowSize ?? 100
|
|
5747
|
+
};
|
|
5748
|
+
}
|
|
5749
|
+
async createHandler() {
|
|
5750
|
+
await super.createHandler();
|
|
5751
|
+
this._accountBalanceViewer = await this.locator.getInstance(AccountBalanceViewerMoniker3);
|
|
5752
|
+
this._chainContractViewer = await this.locator.getInstance(ChainContractViewerMoniker5);
|
|
5753
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker5);
|
|
5754
|
+
}
|
|
5755
|
+
async qualifiedValidateTransaction(block, config) {
|
|
5756
|
+
const result = await this.qualifiedValidateTransactions([block], config);
|
|
5757
|
+
return [result[0][0], result[1]];
|
|
5758
|
+
}
|
|
5759
|
+
async qualifiedValidateTransactions(transactions, config) {
|
|
5760
|
+
const { value, state } = config ?? {
|
|
5761
|
+
shape: true,
|
|
5762
|
+
links: true,
|
|
5763
|
+
state: true,
|
|
5764
|
+
head: void 0
|
|
5765
|
+
};
|
|
5766
|
+
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder23.addHashMeta(b[0]), PayloadBuilder23.addHashMeta(b[1])])));
|
|
5767
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx45(
|
|
5768
|
+
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
5769
|
+
() => `Specified a head that is not in the chain [${config.head}]`
|
|
5770
|
+
) : void 0;
|
|
5771
|
+
const headBlock = head ?? (await this.blockViewer.currentBlock())[0];
|
|
5772
|
+
const validateProtocol = value ? this.doValidateProtocol.bind(this) : void 0;
|
|
5773
|
+
const validateState = state ? this.doValidateState.bind(this) : void 0;
|
|
5774
|
+
const chainId = headBlock.chain;
|
|
5775
|
+
const qualification = { head: headBlock._hash, range: asXL1BlockRange12([0, headBlock.block], true) };
|
|
5776
|
+
const [protocolResults, stateResults] = await Promise.all([
|
|
5777
|
+
validateProtocol?.(transactionsWithMeta, chainId),
|
|
5778
|
+
validateState?.(transactionsWithMeta, chainId)
|
|
5779
|
+
]);
|
|
5780
|
+
const blockResults = transactionsWithMeta.map((r, i) => {
|
|
5781
|
+
const errors = [];
|
|
5782
|
+
if (protocolResults && !isHydratedTransaction(protocolResults[i])) {
|
|
5783
|
+
errors.push(...protocolResults[i]);
|
|
5784
|
+
}
|
|
5785
|
+
if (stateResults && !isHydratedTransaction(stateResults[i])) {
|
|
5786
|
+
errors.push(...stateResults[i]);
|
|
5787
|
+
}
|
|
5788
|
+
return errors.length === 0 ? r : errors;
|
|
5789
|
+
});
|
|
5790
|
+
return [blockResults, qualification];
|
|
5791
|
+
}
|
|
5792
|
+
qualifiedValidateUncle(_transactions, _config) {
|
|
5793
|
+
throw new Error("Method not implemented.");
|
|
5794
|
+
}
|
|
5795
|
+
async validateTransaction(block, config) {
|
|
5796
|
+
return (await this.validateTransactions([block], config))[0];
|
|
5797
|
+
}
|
|
5798
|
+
async validateTransactions(transactions, config) {
|
|
5799
|
+
return (await this.qualifiedValidateTransactions(transactions, config))[0];
|
|
5800
|
+
}
|
|
5801
|
+
async doValidateProtocol(transactions, chainId) {
|
|
5802
|
+
return await Promise.all(transactions.map(async (tx) => {
|
|
5803
|
+
const errors = await this.params.protocol(
|
|
5804
|
+
{ ...this.context, chainId },
|
|
5805
|
+
tx
|
|
5806
|
+
);
|
|
5807
|
+
return errors.length === 0 ? tx : errors;
|
|
5808
|
+
}));
|
|
5809
|
+
}
|
|
5810
|
+
async doValidateState(transactions, chainId) {
|
|
5811
|
+
return await Promise.all(transactions.map(async (tx) => {
|
|
5812
|
+
const errors = await this.params.state(
|
|
5813
|
+
{
|
|
5814
|
+
...this.context,
|
|
5815
|
+
chainId,
|
|
5816
|
+
accountBalanceViewer: this._accountBalanceViewer,
|
|
5817
|
+
blockViewer: this.blockViewer
|
|
5818
|
+
},
|
|
5819
|
+
tx
|
|
5820
|
+
);
|
|
5821
|
+
return errors.length === 0 ? tx : errors;
|
|
5822
|
+
}));
|
|
5823
|
+
}
|
|
5824
|
+
};
|
|
5825
|
+
__publicField(SimpleTransactionValidationViewer, "defaultMoniker", TransactionValidationViewerMoniker2);
|
|
5826
|
+
__publicField(SimpleTransactionValidationViewer, "dependencies", [AccountBalanceViewerMoniker3, ChainContractViewerMoniker5, BlockViewerMoniker5]);
|
|
5827
|
+
__publicField(SimpleTransactionValidationViewer, "monikers", [TransactionValidationViewerMoniker2]);
|
|
5828
|
+
SimpleTransactionValidationViewer = __decorateClass([
|
|
5829
|
+
creatableProvider()
|
|
5830
|
+
], SimpleTransactionValidationViewer);
|
|
5831
|
+
|
|
5702
5832
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
5703
5833
|
import {
|
|
5704
|
-
assertEx as
|
|
5834
|
+
assertEx as assertEx46,
|
|
5705
5835
|
exists as exists10
|
|
5706
5836
|
} from "@xylabs/sdk-js";
|
|
5707
5837
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
5708
5838
|
import {
|
|
5709
5839
|
asSignedHydratedTransactionWithHashMeta,
|
|
5710
5840
|
asSignedTransactionBoundWitness,
|
|
5711
|
-
BlockViewerMoniker as
|
|
5841
|
+
BlockViewerMoniker as BlockViewerMoniker6,
|
|
5712
5842
|
isTransactionBoundWitnessWithHashMeta,
|
|
5713
5843
|
TransactionViewerMoniker
|
|
5714
5844
|
} from "@xyo-network/xl1-protocol-lib";
|
|
@@ -5720,7 +5850,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
5720
5850
|
}
|
|
5721
5851
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
5722
5852
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
5723
|
-
|
|
5853
|
+
assertEx46(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
5724
5854
|
try {
|
|
5725
5855
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
5726
5856
|
if (!block) return null;
|
|
@@ -5763,7 +5893,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
5763
5893
|
}
|
|
5764
5894
|
async createHandler() {
|
|
5765
5895
|
await super.createHandler();
|
|
5766
|
-
this._blockViewer = await this.locator.getInstance(
|
|
5896
|
+
this._blockViewer = await this.locator.getInstance(BlockViewerMoniker6);
|
|
5767
5897
|
}
|
|
5768
5898
|
async transactionByBlockHashAndIndex(blockHash, transactionIndex = 0) {
|
|
5769
5899
|
return await this.byBlockHashAndIndex(blockHash, transactionIndex);
|
|
@@ -5776,7 +5906,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
5776
5906
|
}
|
|
5777
5907
|
};
|
|
5778
5908
|
__publicField(SimpleTransactionViewer, "defaultMoniker", TransactionViewerMoniker);
|
|
5779
|
-
__publicField(SimpleTransactionViewer, "dependencies", [
|
|
5909
|
+
__publicField(SimpleTransactionViewer, "dependencies", [BlockViewerMoniker6]);
|
|
5780
5910
|
__publicField(SimpleTransactionViewer, "monikers", [TransactionViewerMoniker]);
|
|
5781
5911
|
SimpleTransactionViewer = __decorateClass([
|
|
5782
5912
|
creatableProvider()
|
|
@@ -5784,13 +5914,13 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
5784
5914
|
|
|
5785
5915
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
5786
5916
|
import {
|
|
5787
|
-
assertEx as
|
|
5917
|
+
assertEx as assertEx47,
|
|
5788
5918
|
exists as exists11,
|
|
5789
5919
|
isNull as isNull2
|
|
5790
5920
|
} from "@xylabs/sdk-js";
|
|
5791
5921
|
import {
|
|
5792
5922
|
asXL1BlockNumber as asXL1BlockNumber12,
|
|
5793
|
-
BlockViewerMoniker as
|
|
5923
|
+
BlockViewerMoniker as BlockViewerMoniker7,
|
|
5794
5924
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
5795
5925
|
} from "@xyo-network/xl1-protocol-lib";
|
|
5796
5926
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
@@ -5855,8 +5985,8 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5855
5985
|
}
|
|
5856
5986
|
async createHandler() {
|
|
5857
5987
|
await super.createHandler();
|
|
5858
|
-
this._blockViewer =
|
|
5859
|
-
this.params.blockViewer ?? await this.locator.getInstance(
|
|
5988
|
+
this._blockViewer = assertEx47(
|
|
5989
|
+
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
5860
5990
|
() => "BlockViewer instance is required"
|
|
5861
5991
|
);
|
|
5862
5992
|
this._blockHashMap = new MemoryMap();
|
|
@@ -5864,13 +5994,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5864
5994
|
this._transactionHashMap = new MemoryMap();
|
|
5865
5995
|
}
|
|
5866
5996
|
currentBlock() {
|
|
5867
|
-
return
|
|
5997
|
+
return assertEx47(this._chain.at(-1));
|
|
5868
5998
|
}
|
|
5869
5999
|
currentBlockHash() {
|
|
5870
|
-
return
|
|
6000
|
+
return assertEx47(this._chain.at(-1)?.[0]._hash);
|
|
5871
6001
|
}
|
|
5872
6002
|
currentBlockNumber() {
|
|
5873
|
-
return
|
|
6003
|
+
return assertEx47(this._chain.at(-1)?.[0].block);
|
|
5874
6004
|
}
|
|
5875
6005
|
async payloadByHash(hash) {
|
|
5876
6006
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -5941,7 +6071,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5941
6071
|
}
|
|
5942
6072
|
};
|
|
5943
6073
|
__publicField(SimpleWindowedBlockViewer, "defaultMoniker", WindowedBlockViewerMoniker2);
|
|
5944
|
-
__publicField(SimpleWindowedBlockViewer, "dependencies", [
|
|
6074
|
+
__publicField(SimpleWindowedBlockViewer, "dependencies", [BlockViewerMoniker7]);
|
|
5945
6075
|
__publicField(SimpleWindowedBlockViewer, "monikers", [WindowedBlockViewerMoniker2]);
|
|
5946
6076
|
SimpleWindowedBlockViewer = __decorateClass([
|
|
5947
6077
|
creatableProvider()
|
|
@@ -6029,13 +6159,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6029
6159
|
};
|
|
6030
6160
|
|
|
6031
6161
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6032
|
-
import { assertEx as
|
|
6162
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
6033
6163
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6034
6164
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6035
6165
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6036
6166
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6037
6167
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6038
|
-
return
|
|
6168
|
+
return assertEx48(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6039
6169
|
}
|
|
6040
6170
|
|
|
6041
6171
|
// src/wallet/generateXyoBaseWalletFromPhrase.ts
|
|
@@ -6127,6 +6257,7 @@ export {
|
|
|
6127
6257
|
SimpleStakeTotalsViewer,
|
|
6128
6258
|
SimpleStakeViewer,
|
|
6129
6259
|
SimpleTimeSyncViewer,
|
|
6260
|
+
SimpleTransactionValidationViewer,
|
|
6130
6261
|
SimpleTransactionViewer,
|
|
6131
6262
|
SimpleWindowedBlockViewer,
|
|
6132
6263
|
SimpleXyoClient,
|