@xyo-network/xl1-protocol-sdk 2.0.5 → 2.0.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/block/hydrate/createBoundWitnessHydrator.d.ts +20 -20
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts.map +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts.map +1 -1
- package/dist/neutral/index.mjs +189 -132
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/payloads/AddressPairPayload.d.ts +1 -1
- package/dist/neutral/payloads/AddressPairPayload.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findUncles.d.ts +5 -5
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +6 -6
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +3 -3
- package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts +1 -1
- package/dist/neutral/simple/datalake/AbstractRestDataLake.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +3 -3
- package/dist/neutral/simple/index.d.ts +1 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/network/SimpleXyoNetwork.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/simple/sync/RestSyncViewer.d.ts +22 -0
- package/dist/neutral/simple/sync/RestSyncViewer.d.ts.map +1 -0
- package/dist/neutral/simple/sync/index.d.ts +2 -0
- package/dist/neutral/simple/sync/index.d.ts.map +1 -0
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +15 -15
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts +1 -1
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts.map +1 -1
- package/dist/neutral/summary/model/SchemasStepSummary.d.ts +1 -1
- package/dist/neutral/summary/model/SchemasStepSummary.d.ts.map +1 -1
- package/dist/neutral/summary/model/TransfersSummary.d.ts +1 -1
- package/dist/neutral/summary/model/TransfersSummary.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -1
- package/dist/neutral/test/createGenesisBlock.d.ts.map +1 -1
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +73 -70
- package/dist/neutral/test/index.mjs.map +3 -3
- package/dist/neutral/transaction/TransactionBuilder.d.ts +6 -6
- package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +3 -3
- package/package.json +19 -61
package/dist/neutral/index.mjs
CHANGED
|
@@ -2621,7 +2621,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
2621
2621
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
2622
2622
|
|
|
2623
2623
|
// src/transaction/buildTransaction.ts
|
|
2624
|
-
import {
|
|
2624
|
+
import { asAddress, toHex } from "@xylabs/sdk-js";
|
|
2625
2625
|
import {
|
|
2626
2626
|
asAnyPayload as asAnyPayload2,
|
|
2627
2627
|
BoundWitnessBuilder,
|
|
@@ -2650,7 +2650,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2650
2650
|
}
|
|
2651
2651
|
const fields = {
|
|
2652
2652
|
...txBoundWitnessFields,
|
|
2653
|
-
from: from ?? (Array.isArray(signer) ?
|
|
2653
|
+
from: from ?? asAddress(Array.isArray(signer) ? signer.at(0)?.address : signer.address, true)
|
|
2654
2654
|
};
|
|
2655
2655
|
if (script.length > 0) {
|
|
2656
2656
|
fields.script = script;
|
|
@@ -2736,7 +2736,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2736
2736
|
};
|
|
2737
2737
|
|
|
2738
2738
|
// src/transaction/hydrateTransaction.ts
|
|
2739
|
-
import { assertEx as
|
|
2739
|
+
import { assertEx as assertEx19 } from "@xylabs/sdk-js";
|
|
2740
2740
|
import {
|
|
2741
2741
|
asAnyPayload as asAnyPayload3,
|
|
2742
2742
|
hydrateTypedBoundWitness,
|
|
@@ -2811,7 +2811,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
2811
2811
|
return void 0;
|
|
2812
2812
|
};
|
|
2813
2813
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
2814
|
-
return
|
|
2814
|
+
return assertEx19(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
2815
2815
|
};
|
|
2816
2816
|
|
|
2817
2817
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -2864,13 +2864,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
2864
2864
|
|
|
2865
2865
|
// src/transaction/signTransaction.ts
|
|
2866
2866
|
import {
|
|
2867
|
-
assertEx as
|
|
2867
|
+
assertEx as assertEx20,
|
|
2868
2868
|
hexFromArrayBuffer,
|
|
2869
2869
|
toArrayBuffer
|
|
2870
2870
|
} from "@xylabs/sdk-js";
|
|
2871
2871
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
2872
2872
|
async function signTransaction(tx, account) {
|
|
2873
|
-
|
|
2873
|
+
assertEx20(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2874
2874
|
const unsignedTx = structuredClone(tx);
|
|
2875
2875
|
unsignedTx.addresses = [account.address];
|
|
2876
2876
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -2885,7 +2885,11 @@ async function signTransaction(tx, account) {
|
|
|
2885
2885
|
}
|
|
2886
2886
|
|
|
2887
2887
|
// src/transaction/TransactionBuilder.ts
|
|
2888
|
-
import {
|
|
2888
|
+
import {
|
|
2889
|
+
asAddress as asAddress2,
|
|
2890
|
+
assertEx as assertEx21,
|
|
2891
|
+
Base
|
|
2892
|
+
} from "@xylabs/sdk-js";
|
|
2889
2893
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
2890
2894
|
import {
|
|
2891
2895
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -2905,9 +2909,9 @@ var TransactionBuilder = class extends Base {
|
|
|
2905
2909
|
super(options);
|
|
2906
2910
|
}
|
|
2907
2911
|
async build() {
|
|
2908
|
-
const chain =
|
|
2909
|
-
const fees =
|
|
2910
|
-
const blockRange =
|
|
2912
|
+
const chain = assertEx21(this._chain, () => "Chain must be set before building the transaction");
|
|
2913
|
+
const fees = assertEx21(this._fees, () => "Fees must be set before building the transaction");
|
|
2914
|
+
const blockRange = assertEx21(this._blockRange, () => "Block range must be set before building the transaction");
|
|
2911
2915
|
return await buildTransaction(
|
|
2912
2916
|
chain,
|
|
2913
2917
|
this._elevatedPayloads,
|
|
@@ -2915,7 +2919,7 @@ var TransactionBuilder = class extends Base {
|
|
|
2915
2919
|
this._signers,
|
|
2916
2920
|
asXL1BlockNumber4(blockRange[0], true),
|
|
2917
2921
|
asXL1BlockNumber4(blockRange[1], true),
|
|
2918
|
-
this._signers[0]?.address,
|
|
2922
|
+
asAddress2(this._signers[0]?.address),
|
|
2919
2923
|
fees
|
|
2920
2924
|
);
|
|
2921
2925
|
}
|
|
@@ -2931,13 +2935,13 @@ var TransactionBuilder = class extends Base {
|
|
|
2931
2935
|
this._signers,
|
|
2932
2936
|
asXL1BlockNumber4(0, true),
|
|
2933
2937
|
asXL1BlockNumber4(1e3, true),
|
|
2934
|
-
this._signers[0]?.address,
|
|
2938
|
+
asAddress2(this._signers[0]?.address),
|
|
2935
2939
|
defaultTransactionFees3
|
|
2936
2940
|
);
|
|
2937
2941
|
}
|
|
2938
2942
|
elevatedPayload(payload) {
|
|
2939
2943
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
2940
|
-
const allowPayloadExists =
|
|
2944
|
+
const allowPayloadExists = assertEx21(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
2941
2945
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
2942
2946
|
return this;
|
|
2943
2947
|
}
|
|
@@ -3039,12 +3043,12 @@ var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigConte
|
|
|
3039
3043
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3040
3044
|
import {
|
|
3041
3045
|
AbstractCreatable,
|
|
3042
|
-
assertEx as
|
|
3046
|
+
assertEx as assertEx23,
|
|
3043
3047
|
IdLogger
|
|
3044
3048
|
} from "@xylabs/sdk-js";
|
|
3045
3049
|
|
|
3046
3050
|
// src/CreatableProvider/ProviderFactory.ts
|
|
3047
|
-
import { assertEx as
|
|
3051
|
+
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
3048
3052
|
function providerFactoryDescription(factory, labels) {
|
|
3049
3053
|
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
3050
3054
|
}
|
|
@@ -3065,7 +3069,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3065
3069
|
this.dependencies = dependencies;
|
|
3066
3070
|
this.monikers = creatableProvider2.monikers;
|
|
3067
3071
|
this.scope = scope;
|
|
3068
|
-
|
|
3072
|
+
assertEx22(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
3069
3073
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
3070
3074
|
this.providerName = creatableProvider2.name;
|
|
3071
3075
|
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
@@ -3093,7 +3097,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3093
3097
|
break;
|
|
3094
3098
|
}
|
|
3095
3099
|
case "context": {
|
|
3096
|
-
const context =
|
|
3100
|
+
const context = assertEx22(
|
|
3097
3101
|
params?.context,
|
|
3098
3102
|
() => "Context is required for context-scoped providers"
|
|
3099
3103
|
);
|
|
@@ -3114,7 +3118,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3114
3118
|
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
3115
3119
|
const result = await resultPromise;
|
|
3116
3120
|
if (start) {
|
|
3117
|
-
|
|
3121
|
+
assertEx22(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
3118
3122
|
}
|
|
3119
3123
|
return result;
|
|
3120
3124
|
}
|
|
@@ -3159,9 +3163,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3159
3163
|
return factory;
|
|
3160
3164
|
}
|
|
3161
3165
|
static async paramsHandler(params = {}) {
|
|
3162
|
-
const context =
|
|
3163
|
-
const config =
|
|
3164
|
-
const locator =
|
|
3166
|
+
const context = assertEx23(params.context, () => new Error("Context is required"));
|
|
3167
|
+
const config = assertEx23(context.config, () => new Error("Context config is required"));
|
|
3168
|
+
const locator = assertEx23(context.locator, () => new Error("Context locator is required"));
|
|
3165
3169
|
return await super.paramsHandler({
|
|
3166
3170
|
...params,
|
|
3167
3171
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3273,7 +3277,7 @@ function labeledCreatableProviderFactory() {
|
|
|
3273
3277
|
|
|
3274
3278
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
3275
3279
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
3276
|
-
import { assertEx as
|
|
3280
|
+
import { assertEx as assertEx24 } from "@xylabs/sdk-js";
|
|
3277
3281
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
3278
3282
|
_context;
|
|
3279
3283
|
_registry;
|
|
@@ -3305,7 +3309,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3305
3309
|
this._frozen = true;
|
|
3306
3310
|
}
|
|
3307
3311
|
async getInstance(moniker, { start = true, labels } = {}) {
|
|
3308
|
-
return
|
|
3312
|
+
return assertEx24(
|
|
3309
3313
|
await this.tryGetInstance(moniker, { start, labels }),
|
|
3310
3314
|
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
3311
3315
|
);
|
|
@@ -3320,7 +3324,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3320
3324
|
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
3321
3325
|
*/
|
|
3322
3326
|
locate(moniker, labels) {
|
|
3323
|
-
return
|
|
3327
|
+
return assertEx24(
|
|
3324
3328
|
this.tryLocate(moniker, labels),
|
|
3325
3329
|
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
3326
3330
|
);
|
|
@@ -3342,10 +3346,10 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3342
3346
|
* @param labels The labels for the module factory
|
|
3343
3347
|
*/
|
|
3344
3348
|
register(factory, labels, primary = false) {
|
|
3345
|
-
|
|
3349
|
+
assertEx24(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
3346
3350
|
if (this.validateDepsOnRegister) {
|
|
3347
3351
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3348
|
-
|
|
3352
|
+
assertEx24(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
3349
3353
|
}
|
|
3350
3354
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
3351
3355
|
return this;
|
|
@@ -3393,7 +3397,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3393
3397
|
for (const moniker in this.registry) {
|
|
3394
3398
|
for (const factory of this.registry[moniker] ?? []) {
|
|
3395
3399
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3396
|
-
|
|
3400
|
+
assertEx24(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
3397
3401
|
}
|
|
3398
3402
|
}
|
|
3399
3403
|
}
|
|
@@ -3613,7 +3617,7 @@ var toPositiveBigInt = (value) => {
|
|
|
3613
3617
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3614
3618
|
import {
|
|
3615
3619
|
asHash as asHash4,
|
|
3616
|
-
assertEx as
|
|
3620
|
+
assertEx as assertEx31,
|
|
3617
3621
|
exists as exists3,
|
|
3618
3622
|
isDefined as isDefined17,
|
|
3619
3623
|
ZERO_ADDRESS
|
|
@@ -3685,18 +3689,18 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
|
|
|
3685
3689
|
|
|
3686
3690
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3687
3691
|
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3688
|
-
import { assertEx as
|
|
3692
|
+
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3689
3693
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3690
3694
|
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
3691
3695
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3692
3696
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3693
3697
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3694
3698
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3695
|
-
const [frameHead] =
|
|
3699
|
+
const [frameHead] = assertEx25(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3696
3700
|
const frameSize = range[1] - range[0] + 1;
|
|
3697
3701
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3698
3702
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3699
|
-
const [, payloads] =
|
|
3703
|
+
const [, payloads] = assertEx25(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3700
3704
|
const balances = {};
|
|
3701
3705
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3702
3706
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3709,7 +3713,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3709
3713
|
};
|
|
3710
3714
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3711
3715
|
const step = StepSizes7.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3712
|
-
|
|
3716
|
+
assertEx25(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes7.join(", ")}`);
|
|
3713
3717
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3714
3718
|
if (isAnyPayload3(summaryResult)) {
|
|
3715
3719
|
return summaryResult;
|
|
@@ -3754,8 +3758,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3754
3758
|
|
|
3755
3759
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3756
3760
|
import {
|
|
3757
|
-
asAddress,
|
|
3758
|
-
assertEx as
|
|
3761
|
+
asAddress as asAddress3,
|
|
3762
|
+
assertEx as assertEx26,
|
|
3759
3763
|
spanRootAsync as spanRootAsync3
|
|
3760
3764
|
} from "@xylabs/sdk-js";
|
|
3761
3765
|
import {
|
|
@@ -3767,7 +3771,7 @@ import {
|
|
|
3767
3771
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3768
3772
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
3769
3773
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3770
|
-
const [head] =
|
|
3774
|
+
const [head] = assertEx26(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3771
3775
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3772
3776
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
3773
3777
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
@@ -3778,7 +3782,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3778
3782
|
const balances = {};
|
|
3779
3783
|
for (const summary of summaries) {
|
|
3780
3784
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
3781
|
-
const validAddress =
|
|
3785
|
+
const validAddress = asAddress3(address, () => `Invalid address: ${address}`);
|
|
3782
3786
|
balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance);
|
|
3783
3787
|
}
|
|
3784
3788
|
}
|
|
@@ -3787,7 +3791,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3787
3791
|
}
|
|
3788
3792
|
|
|
3789
3793
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
3790
|
-
import { assertEx as
|
|
3794
|
+
import { assertEx as assertEx27 } from "@xylabs/sdk-js";
|
|
3791
3795
|
import {
|
|
3792
3796
|
isAnyPayload as isAnyPayload4,
|
|
3793
3797
|
isBoundWitness as isBoundWitness2,
|
|
@@ -3796,11 +3800,11 @@ import {
|
|
|
3796
3800
|
} from "@xyo-network/sdk-js";
|
|
3797
3801
|
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3798
3802
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3799
|
-
const [frameHead] =
|
|
3803
|
+
const [frameHead] = assertEx27(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3800
3804
|
const frameSize = range[1] - range[0] + 1;
|
|
3801
3805
|
let result;
|
|
3802
3806
|
if (frameSize === 1) {
|
|
3803
|
-
const [block, payloads] =
|
|
3807
|
+
const [block, payloads] = assertEx27(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3804
3808
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
3805
3809
|
const schemas = {};
|
|
3806
3810
|
for (const bw of boundWitnesses) {
|
|
@@ -3817,7 +3821,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3817
3821
|
});
|
|
3818
3822
|
} else {
|
|
3819
3823
|
const step = StepSizes8.indexOf(frameSize);
|
|
3820
|
-
|
|
3824
|
+
assertEx27(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3821
3825
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3822
3826
|
if (isAnyPayload4(summaryResult)) {
|
|
3823
3827
|
result = summaryResult;
|
|
@@ -3856,7 +3860,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3856
3860
|
}
|
|
3857
3861
|
|
|
3858
3862
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
3859
|
-
import { assertEx as
|
|
3863
|
+
import { assertEx as assertEx28, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
3860
3864
|
import {
|
|
3861
3865
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
3862
3866
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -3866,7 +3870,7 @@ import {
|
|
|
3866
3870
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3867
3871
|
return await spanRootAsync4("schemasSummary", async () => {
|
|
3868
3872
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3869
|
-
const [head] =
|
|
3873
|
+
const [head] = assertEx28(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3870
3874
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3871
3875
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
3872
3876
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -3886,7 +3890,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3886
3890
|
}
|
|
3887
3891
|
|
|
3888
3892
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3889
|
-
import { assertEx as
|
|
3893
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3890
3894
|
import { isAnyPayload as isAnyPayload5 } from "@xyo-network/sdk-js";
|
|
3891
3895
|
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3892
3896
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
@@ -3896,11 +3900,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3896
3900
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3897
3901
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
3898
3902
|
return await spanRootAsync5("transfersStepSummaryFromRange", async () => {
|
|
3899
|
-
const [frameHead] =
|
|
3903
|
+
const [frameHead] = assertEx29(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3900
3904
|
const frameSize = range[1] - range[0] + 1;
|
|
3901
3905
|
let result;
|
|
3902
3906
|
if (frameSize === 1) {
|
|
3903
|
-
const [, payloads] =
|
|
3907
|
+
const [, payloads] = assertEx29(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3904
3908
|
const transfers = {};
|
|
3905
3909
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3906
3910
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -3916,7 +3920,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3916
3920
|
};
|
|
3917
3921
|
} else {
|
|
3918
3922
|
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3919
|
-
|
|
3923
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
3920
3924
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3921
3925
|
const summaryResult = await summaryMap.get(key);
|
|
3922
3926
|
if (isAnyPayload5(summaryResult)) {
|
|
@@ -3968,8 +3972,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3968
3972
|
|
|
3969
3973
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3970
3974
|
import {
|
|
3971
|
-
asAddress as
|
|
3972
|
-
assertEx as
|
|
3975
|
+
asAddress as asAddress4,
|
|
3976
|
+
assertEx as assertEx30,
|
|
3973
3977
|
spanRootAsync as spanRootAsync6
|
|
3974
3978
|
} from "@xylabs/sdk-js";
|
|
3975
3979
|
import {
|
|
@@ -3981,7 +3985,7 @@ import {
|
|
|
3981
3985
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3982
3986
|
return await spanRootAsync6("transferSummary", async () => {
|
|
3983
3987
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3984
|
-
const [head] =
|
|
3988
|
+
const [head] = assertEx30(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3985
3989
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3986
3990
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
3987
3991
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -3992,10 +3996,10 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3992
3996
|
const transfers = {};
|
|
3993
3997
|
for (const summary of summaries) {
|
|
3994
3998
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
3995
|
-
const validFrom =
|
|
3999
|
+
const validFrom = asAddress4(from, () => `Invalid address: ${from}`);
|
|
3996
4000
|
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
3997
4001
|
for (const [to, transfer] of Object.entries(toMap)) {
|
|
3998
|
-
const validTo =
|
|
4002
|
+
const validTo = asAddress4(to, () => `Invalid address: ${to}`);
|
|
3999
4003
|
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
4000
4004
|
}
|
|
4001
4005
|
}
|
|
@@ -4022,8 +4026,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4022
4026
|
static async paramsHandler(params = {}) {
|
|
4023
4027
|
return {
|
|
4024
4028
|
...await super.paramsHandler(params),
|
|
4025
|
-
balancesSummaryMap:
|
|
4026
|
-
transfersSummaryMap:
|
|
4029
|
+
balancesSummaryMap: assertEx31(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4030
|
+
transfersSummaryMap: assertEx31(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4027
4031
|
};
|
|
4028
4032
|
}
|
|
4029
4033
|
async accountBalance(address, config) {
|
|
@@ -4044,7 +4048,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4044
4048
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4045
4049
|
const transfers = transferIndexes.map((index) => {
|
|
4046
4050
|
const hash = block[0].payload_hashes[index];
|
|
4047
|
-
return
|
|
4051
|
+
return assertEx31(
|
|
4048
4052
|
block[1].find((p) => p._hash === hash),
|
|
4049
4053
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4050
4054
|
);
|
|
@@ -4077,7 +4081,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4077
4081
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4078
4082
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4079
4083
|
0,
|
|
4080
|
-
|
|
4084
|
+
assertEx31(
|
|
4081
4085
|
await this.blockViewer.blockByHash(head),
|
|
4082
4086
|
() => `Error: Could not find block with hash ${head}`
|
|
4083
4087
|
)[0].block
|
|
@@ -4092,11 +4096,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4092
4096
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4093
4097
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4094
4098
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4095
|
-
|
|
4099
|
+
assertEx31(
|
|
4096
4100
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4097
4101
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4098
4102
|
);
|
|
4099
|
-
|
|
4103
|
+
assertEx31(
|
|
4100
4104
|
head2 === qualifiedHeadHash,
|
|
4101
4105
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4102
4106
|
);
|
|
@@ -4167,7 +4171,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4167
4171
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4168
4172
|
const range = asRange(headOrRange);
|
|
4169
4173
|
const headHash = asHash4(headOrRange);
|
|
4170
|
-
const [head] =
|
|
4174
|
+
const [head] = assertEx31(isDefined17(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4171
4175
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4172
4176
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4173
4177
|
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
@@ -4176,7 +4180,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4176
4180
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4177
4181
|
const transfers = transferIndexes.map((index) => {
|
|
4178
4182
|
const hash = block[0].payload_hashes[index];
|
|
4179
|
-
return
|
|
4183
|
+
return assertEx31(
|
|
4180
4184
|
block[1].find((p) => p._hash === hash),
|
|
4181
4185
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4182
4186
|
);
|
|
@@ -4206,7 +4210,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4206
4210
|
|
|
4207
4211
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4208
4212
|
import {
|
|
4209
|
-
assertEx as
|
|
4213
|
+
assertEx as assertEx32,
|
|
4210
4214
|
exists as exists4,
|
|
4211
4215
|
isUndefined as isUndefined8
|
|
4212
4216
|
} from "@xylabs/sdk-js";
|
|
@@ -4283,11 +4287,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4283
4287
|
static async paramsHandler(params) {
|
|
4284
4288
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4285
4289
|
if (headPollIntervalMs !== void 0) {
|
|
4286
|
-
|
|
4290
|
+
assertEx32(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4287
4291
|
}
|
|
4288
4292
|
return {
|
|
4289
4293
|
...await super.paramsHandler(params),
|
|
4290
|
-
finalizedArchivist:
|
|
4294
|
+
finalizedArchivist: assertEx32(params.finalizedArchivist, () => "finalizedArchivist is required"),
|
|
4291
4295
|
headPollIntervalMs
|
|
4292
4296
|
};
|
|
4293
4297
|
}
|
|
@@ -4316,8 +4320,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4316
4320
|
}
|
|
4317
4321
|
async blocksByHash(hash, limit = 50) {
|
|
4318
4322
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4319
|
-
|
|
4320
|
-
|
|
4323
|
+
assertEx32(limit > 0, () => "limit must be greater than 0");
|
|
4324
|
+
assertEx32(limit <= 100, () => "limit must be less than 100");
|
|
4321
4325
|
const blocks = [];
|
|
4322
4326
|
let current = await this.blockByHash(hash);
|
|
4323
4327
|
while (current && blocks.length < limit) {
|
|
@@ -4331,8 +4335,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4331
4335
|
}
|
|
4332
4336
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4333
4337
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4334
|
-
|
|
4335
|
-
|
|
4338
|
+
assertEx32(limit > 0, () => "limit must be greater than 0");
|
|
4339
|
+
assertEx32(limit <= 100, () => "limit must be less than 100");
|
|
4336
4340
|
const chainContext = await this.getChainContextRead();
|
|
4337
4341
|
if (isUndefined8(chainContext.head)) {
|
|
4338
4342
|
return [];
|
|
@@ -4350,7 +4354,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4350
4354
|
}
|
|
4351
4355
|
async chainId(blockNumber = "latest") {
|
|
4352
4356
|
return await this.spanAsync("chainId", async () => {
|
|
4353
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
4357
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx32(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
4354
4358
|
}, this.context);
|
|
4355
4359
|
}
|
|
4356
4360
|
async createHandler() {
|
|
@@ -4479,7 +4483,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4479
4483
|
], SimpleBlockRewardViewer);
|
|
4480
4484
|
|
|
4481
4485
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4482
|
-
import { assertEx as
|
|
4486
|
+
import { assertEx as assertEx33 } from "@xylabs/sdk-js";
|
|
4483
4487
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4484
4488
|
import {
|
|
4485
4489
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4532,7 +4536,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4532
4536
|
head: void 0
|
|
4533
4537
|
};
|
|
4534
4538
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
|
|
4535
|
-
const head = isChainQualifiedHeadConfig5(config) ?
|
|
4539
|
+
const head = isChainQualifiedHeadConfig5(config) ? assertEx33(
|
|
4536
4540
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
4537
4541
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4538
4542
|
) : void 0;
|
|
@@ -4614,7 +4618,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
4614
4618
|
|
|
4615
4619
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
4616
4620
|
import {
|
|
4617
|
-
assertEx as
|
|
4621
|
+
assertEx as assertEx34
|
|
4618
4622
|
} from "@xylabs/sdk-js";
|
|
4619
4623
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
4620
4624
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
@@ -4632,7 +4636,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4632
4636
|
let contractViewer = this;
|
|
4633
4637
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4634
4638
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
4635
|
-
contractViewer =
|
|
4639
|
+
contractViewer = assertEx34(await contractViewer.forkedChainContractViewer());
|
|
4636
4640
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4637
4641
|
chainId = await contractViewer.chainId();
|
|
4638
4642
|
}
|
|
@@ -4685,13 +4689,13 @@ var SimpleXyoClient = class {
|
|
|
4685
4689
|
};
|
|
4686
4690
|
|
|
4687
4691
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
4688
|
-
import { assertEx as
|
|
4692
|
+
import { assertEx as assertEx35, exists as exists6 } from "@xylabs/sdk-js";
|
|
4689
4693
|
import { isAnyPayload as isAnyPayload7, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
4690
4694
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
4691
4695
|
import { z as z29 } from "zod/mini";
|
|
4692
4696
|
|
|
4693
4697
|
// src/simple/datalake/AbstractRestDataLake.ts
|
|
4694
|
-
import { FetchClientError, FetchJsonClient } from "@xylabs/
|
|
4698
|
+
import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
4695
4699
|
import {
|
|
4696
4700
|
exists as exists5
|
|
4697
4701
|
} from "@xylabs/sdk-js";
|
|
@@ -4754,7 +4758,7 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4754
4758
|
async insert(items) {
|
|
4755
4759
|
const allowedItems = items.map((item) => {
|
|
4756
4760
|
if (isAnyPayload7(item) && this.isAllowed(item)) {
|
|
4757
|
-
|
|
4761
|
+
assertEx35(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
4758
4762
|
return item;
|
|
4759
4763
|
}
|
|
4760
4764
|
return null;
|
|
@@ -4897,7 +4901,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
4897
4901
|
], SimpleFinalizationRunner);
|
|
4898
4902
|
|
|
4899
4903
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
4900
|
-
import { assertEx as
|
|
4904
|
+
import { assertEx as assertEx36 } from "@xylabs/sdk-js";
|
|
4901
4905
|
import {
|
|
4902
4906
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
4903
4907
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -4926,7 +4930,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4926
4930
|
static async paramsHandler(params) {
|
|
4927
4931
|
return {
|
|
4928
4932
|
...await super.paramsHandler(params),
|
|
4929
|
-
finalizedArchivist:
|
|
4933
|
+
finalizedArchivist: assertEx36(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
4930
4934
|
};
|
|
4931
4935
|
}
|
|
4932
4936
|
chainId() {
|
|
@@ -4934,18 +4938,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4934
4938
|
}
|
|
4935
4939
|
async createHandler() {
|
|
4936
4940
|
await super.createHandler();
|
|
4937
|
-
this._chainId =
|
|
4941
|
+
this._chainId = assertEx36(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
4938
4942
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4939
4943
|
}
|
|
4940
4944
|
async head() {
|
|
4941
4945
|
return await this.spanAsync("head", async () => {
|
|
4942
|
-
const currentHead =
|
|
4946
|
+
const currentHead = assertEx36(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
4943
4947
|
const cache = this.hydratedBlockCache;
|
|
4944
4948
|
const block = await cache.get(currentHead._hash);
|
|
4945
4949
|
if (!block) {
|
|
4946
4950
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
4947
4951
|
}
|
|
4948
|
-
return
|
|
4952
|
+
return assertEx36(block, () => "Could not find current block");
|
|
4949
4953
|
}, this.context);
|
|
4950
4954
|
}
|
|
4951
4955
|
async headBlock() {
|
|
@@ -4971,8 +4975,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4971
4975
|
}
|
|
4972
4976
|
async getCurrentHead() {
|
|
4973
4977
|
const chainArchivist = this.finalizedArchivist;
|
|
4974
|
-
const result =
|
|
4975
|
-
|
|
4978
|
+
const result = assertEx36(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
4979
|
+
assertEx36(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
4976
4980
|
return result;
|
|
4977
4981
|
}
|
|
4978
4982
|
};
|
|
@@ -5002,7 +5006,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5002
5006
|
|
|
5003
5007
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5004
5008
|
import {
|
|
5005
|
-
assertEx as
|
|
5009
|
+
assertEx as assertEx37,
|
|
5006
5010
|
BigIntToJsonZod,
|
|
5007
5011
|
isDefined as isDefined18
|
|
5008
5012
|
} from "@xylabs/sdk-js";
|
|
@@ -5035,7 +5039,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5035
5039
|
return this._signer;
|
|
5036
5040
|
}
|
|
5037
5041
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5038
|
-
const viewer =
|
|
5042
|
+
const viewer = assertEx37(this.connection.viewer, () => "No viewer available on connection");
|
|
5039
5043
|
const {
|
|
5040
5044
|
nbf,
|
|
5041
5045
|
exp,
|
|
@@ -5051,7 +5055,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5051
5055
|
async addTransactionToChain(tx, offChain = []) {
|
|
5052
5056
|
const connection = this.connection;
|
|
5053
5057
|
const signer = this.signer;
|
|
5054
|
-
const runner =
|
|
5058
|
+
const runner = assertEx37(connection.runner, () => "No runner available on connection");
|
|
5055
5059
|
let signedTx;
|
|
5056
5060
|
if (isSignedHydratedTransaction(tx)) {
|
|
5057
5061
|
const [bw, payloads] = tx;
|
|
@@ -5066,7 +5070,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5066
5070
|
}
|
|
5067
5071
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5068
5072
|
return await confirmSubmittedTransaction(
|
|
5069
|
-
|
|
5073
|
+
assertEx37(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5070
5074
|
txHash,
|
|
5071
5075
|
options
|
|
5072
5076
|
);
|
|
@@ -5103,7 +5107,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5103
5107
|
|
|
5104
5108
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5105
5109
|
import {
|
|
5106
|
-
assertEx as
|
|
5110
|
+
assertEx as assertEx38,
|
|
5107
5111
|
exists as exists8
|
|
5108
5112
|
} from "@xylabs/sdk-js";
|
|
5109
5113
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5178,8 +5182,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5178
5182
|
static async paramsHandler(params) {
|
|
5179
5183
|
return {
|
|
5180
5184
|
...await super.paramsHandler(params),
|
|
5181
|
-
pendingBlocksArchivist:
|
|
5182
|
-
pendingTransactionsArchivist:
|
|
5185
|
+
pendingBlocksArchivist: assertEx38(params?.pendingBlocksArchivist, () => "pendingBlocksArchivist is required"),
|
|
5186
|
+
pendingTransactionsArchivist: assertEx38(params?.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required")
|
|
5183
5187
|
};
|
|
5184
5188
|
}
|
|
5185
5189
|
async createHandler() {
|
|
@@ -5217,7 +5221,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5217
5221
|
return b;
|
|
5218
5222
|
}
|
|
5219
5223
|
}).filter(exists8);
|
|
5220
|
-
|
|
5224
|
+
assertEx38(
|
|
5221
5225
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5222
5226
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5223
5227
|
);
|
|
@@ -5279,7 +5283,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5279
5283
|
return t;
|
|
5280
5284
|
}
|
|
5281
5285
|
}).filter(exists8);
|
|
5282
|
-
|
|
5286
|
+
assertEx38(
|
|
5283
5287
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5284
5288
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5285
5289
|
);
|
|
@@ -5745,8 +5749,7 @@ function deduplicateWithBundleBySigner(items) {
|
|
|
5745
5749
|
}
|
|
5746
5750
|
|
|
5747
5751
|
// src/simple/network/SimpleXyoNetwork.ts
|
|
5748
|
-
import { fetchJsonGet } from "@xylabs/
|
|
5749
|
-
import { isUndefined as isUndefined9 } from "@xylabs/sdk-js";
|
|
5752
|
+
import { fetchJsonGet, isUndefined as isUndefined9 } from "@xylabs/sdk-js";
|
|
5750
5753
|
import { isNetworkStatus } from "@xyo-network/xl1-protocol-lib";
|
|
5751
5754
|
|
|
5752
5755
|
// src/simple/network/lib/FailedNetworkStatusPayloads.ts
|
|
@@ -5819,7 +5822,7 @@ var SimpleXyoNetwork = class {
|
|
|
5819
5822
|
};
|
|
5820
5823
|
|
|
5821
5824
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
5822
|
-
import { assertEx as
|
|
5825
|
+
import { assertEx as assertEx39 } from "@xylabs/sdk-js";
|
|
5823
5826
|
var SimpleXyoPermissions = class {
|
|
5824
5827
|
invoker;
|
|
5825
5828
|
_store;
|
|
@@ -5828,7 +5831,7 @@ var SimpleXyoPermissions = class {
|
|
|
5828
5831
|
this.invoker = store.invoker;
|
|
5829
5832
|
}
|
|
5830
5833
|
get store() {
|
|
5831
|
-
return
|
|
5834
|
+
return assertEx39(this._store, () => "Store must be defined to get permissions");
|
|
5832
5835
|
}
|
|
5833
5836
|
async getPermissions() {
|
|
5834
5837
|
return await this.store.getPermissions();
|
|
@@ -5881,7 +5884,7 @@ var SimpleXyoPermissions = class {
|
|
|
5881
5884
|
};
|
|
5882
5885
|
|
|
5883
5886
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
5884
|
-
import { assertEx as
|
|
5887
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5885
5888
|
var MemoryPermissionsStore = class {
|
|
5886
5889
|
_invoker;
|
|
5887
5890
|
permissions = [];
|
|
@@ -5889,7 +5892,7 @@ var MemoryPermissionsStore = class {
|
|
|
5889
5892
|
this._invoker = invoker;
|
|
5890
5893
|
}
|
|
5891
5894
|
get invoker() {
|
|
5892
|
-
return
|
|
5895
|
+
return assertEx40(this._invoker, () => "Invoker must be defined to get permissions");
|
|
5893
5896
|
}
|
|
5894
5897
|
async getPermissions() {
|
|
5895
5898
|
await Promise.resolve();
|
|
@@ -5929,6 +5932,7 @@ SimpleXyoRunner = __decorateClass([
|
|
|
5929
5932
|
], SimpleXyoRunner);
|
|
5930
5933
|
|
|
5931
5934
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
5935
|
+
import { asAddress as asAddress5 } from "@xylabs/sdk-js";
|
|
5932
5936
|
import { Account, PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
5933
5937
|
import {
|
|
5934
5938
|
SignedHydratedTransactionWithHashMetaZod,
|
|
@@ -5953,7 +5957,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5953
5957
|
return { ...await super.paramsHandler(params), account };
|
|
5954
5958
|
}
|
|
5955
5959
|
address() {
|
|
5956
|
-
return this.params.account.address;
|
|
5960
|
+
return asAddress5(this.params.account.address, true);
|
|
5957
5961
|
}
|
|
5958
5962
|
/** @deprecated - use signTransaction instead */
|
|
5959
5963
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
@@ -6055,8 +6059,8 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6055
6059
|
], SimpleStakeEventsViewer);
|
|
6056
6060
|
|
|
6057
6061
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6058
|
-
import { asAddress as
|
|
6059
|
-
import { assertEx as
|
|
6062
|
+
import { asAddress as asAddress6 } from "@xylabs/sdk-js";
|
|
6063
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
6060
6064
|
import {
|
|
6061
6065
|
StakeTotalsViewerMoniker,
|
|
6062
6066
|
StakeViewerMoniker
|
|
@@ -6081,7 +6085,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6081
6085
|
let active = 0n;
|
|
6082
6086
|
const positions = await this.stakeViewer.activeStakes();
|
|
6083
6087
|
for (const position of positions) {
|
|
6084
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6088
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress6(position.staked) === asAddress6(staked)) {
|
|
6085
6089
|
active += position.amount;
|
|
6086
6090
|
}
|
|
6087
6091
|
}
|
|
@@ -6091,7 +6095,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6091
6095
|
let active = 0n;
|
|
6092
6096
|
const positions = await this.stakeViewer.activeStakes();
|
|
6093
6097
|
for (const position of positions) {
|
|
6094
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6098
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress6(position.staker) === asAddress6(staker)) {
|
|
6095
6099
|
active += position.amount;
|
|
6096
6100
|
}
|
|
6097
6101
|
}
|
|
@@ -6099,7 +6103,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6099
6103
|
}
|
|
6100
6104
|
async createHandler() {
|
|
6101
6105
|
await super.createHandler();
|
|
6102
|
-
this._stakeViewer =
|
|
6106
|
+
this._stakeViewer = assertEx41(
|
|
6103
6107
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6104
6108
|
() => "Failed to create StakeViewer"
|
|
6105
6109
|
);
|
|
@@ -6118,7 +6122,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6118
6122
|
let pending = 0n;
|
|
6119
6123
|
const positions = await this.stakeViewer.removedStakes();
|
|
6120
6124
|
for (const position of positions) {
|
|
6121
|
-
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) &&
|
|
6125
|
+
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) && asAddress6(position.staker) === asAddress6(staker)) {
|
|
6122
6126
|
pending += position.amount;
|
|
6123
6127
|
}
|
|
6124
6128
|
}
|
|
@@ -6138,7 +6142,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6138
6142
|
let withdrawn = 0n;
|
|
6139
6143
|
const positions = await this.stakeViewer.withdrawnStakes();
|
|
6140
6144
|
for (const position of positions) {
|
|
6141
|
-
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time &&
|
|
6145
|
+
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time && asAddress6(position.staker) === asAddress6(staker)) {
|
|
6142
6146
|
withdrawn += position.amount;
|
|
6143
6147
|
}
|
|
6144
6148
|
}
|
|
@@ -6154,8 +6158,8 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6154
6158
|
|
|
6155
6159
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6156
6160
|
import {
|
|
6157
|
-
asAddress as
|
|
6158
|
-
assertEx as
|
|
6161
|
+
asAddress as asAddress7,
|
|
6162
|
+
assertEx as assertEx42,
|
|
6159
6163
|
toAddress as toAddress6
|
|
6160
6164
|
} from "@xylabs/sdk-js";
|
|
6161
6165
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -6163,7 +6167,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6163
6167
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6164
6168
|
_chainStakeEventsViewer;
|
|
6165
6169
|
get stakeEvents() {
|
|
6166
|
-
return
|
|
6170
|
+
return assertEx42(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6167
6171
|
}
|
|
6168
6172
|
get positions() {
|
|
6169
6173
|
return this.params.positions;
|
|
@@ -6182,7 +6186,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6182
6186
|
let active = 0n;
|
|
6183
6187
|
const positions = await this.activeStakes();
|
|
6184
6188
|
for (const position of positions) {
|
|
6185
|
-
if (position.removeBlock === 0 &&
|
|
6189
|
+
if (position.removeBlock === 0 && asAddress7(position.staked) === asAddress7(staked)) {
|
|
6186
6190
|
active += position.amount;
|
|
6187
6191
|
}
|
|
6188
6192
|
}
|
|
@@ -6192,7 +6196,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6192
6196
|
let active = 0n;
|
|
6193
6197
|
const positions = await this.activeStakes();
|
|
6194
6198
|
for (const position of positions) {
|
|
6195
|
-
if (position.removeBlock === 0 &&
|
|
6199
|
+
if (position.removeBlock === 0 && asAddress7(position.staker) === asAddress7(staker)) {
|
|
6196
6200
|
active += position.amount;
|
|
6197
6201
|
}
|
|
6198
6202
|
}
|
|
@@ -6203,7 +6207,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6203
6207
|
}
|
|
6204
6208
|
async createHandler() {
|
|
6205
6209
|
await super.createHandler();
|
|
6206
|
-
this._chainStakeEventsViewer =
|
|
6210
|
+
this._chainStakeEventsViewer = assertEx42(
|
|
6207
6211
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6208
6212
|
() => "Failed to create StakeEventsViewer"
|
|
6209
6213
|
);
|
|
@@ -6225,7 +6229,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6225
6229
|
let pending = 0n;
|
|
6226
6230
|
const positions = await this.removedStakes();
|
|
6227
6231
|
for (const position of positions) {
|
|
6228
|
-
if (position.removeBlock !== 0 && position.withdrawBlock === 0 &&
|
|
6232
|
+
if (position.removeBlock !== 0 && position.withdrawBlock === 0 && asAddress7(position.staker) === asAddress7(staker)) {
|
|
6229
6233
|
pending += position.amount;
|
|
6230
6234
|
}
|
|
6231
6235
|
}
|
|
@@ -6238,18 +6242,18 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6238
6242
|
return toAddress6(toAddress6(1n));
|
|
6239
6243
|
}
|
|
6240
6244
|
stakeById(id) {
|
|
6241
|
-
return
|
|
6245
|
+
return assertEx42(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6242
6246
|
}
|
|
6243
6247
|
stakeByStaker(staker, slot) {
|
|
6244
|
-
return this.positions.filter((s) =>
|
|
6248
|
+
return this.positions.filter((s) => asAddress7(s.staker) === asAddress7(staker))[slot];
|
|
6245
6249
|
}
|
|
6246
6250
|
stakesByStaked(staked, range = [0, void 0]) {
|
|
6247
6251
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6248
|
-
return this.positions.filter((s) =>
|
|
6252
|
+
return this.positions.filter((s) => asAddress7(s.staked) === asAddress7(staked) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6249
6253
|
}
|
|
6250
6254
|
stakesByStaker(staker, range = [0, void 0]) {
|
|
6251
6255
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6252
|
-
return this.positions.filter((s) =>
|
|
6256
|
+
return this.positions.filter((s) => asAddress7(s.staker) === asAddress7(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6253
6257
|
}
|
|
6254
6258
|
stakingTokenAddress() {
|
|
6255
6259
|
return toAddress6("0x000000000000000000000000000011");
|
|
@@ -6268,7 +6272,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6268
6272
|
let withdrawn = 0n;
|
|
6269
6273
|
const positions = await this.withdrawnStakes();
|
|
6270
6274
|
for (const position of positions) {
|
|
6271
|
-
if (position.withdrawBlock !== 0 &&
|
|
6275
|
+
if (position.withdrawBlock !== 0 && asAddress7(position.staker) === asAddress7(staker)) {
|
|
6272
6276
|
withdrawn += position.amount;
|
|
6273
6277
|
}
|
|
6274
6278
|
}
|
|
@@ -6285,10 +6289,62 @@ SimpleStakeViewer = __decorateClass([
|
|
|
6285
6289
|
creatableProvider()
|
|
6286
6290
|
], SimpleStakeViewer);
|
|
6287
6291
|
|
|
6292
|
+
// src/simple/sync/RestSyncViewer.ts
|
|
6293
|
+
import { FetchClientError as FetchClientError2, FetchJsonClient as FetchJsonClient2 } from "@xylabs/sdk-js";
|
|
6294
|
+
import {
|
|
6295
|
+
SyncStepSummaryMetadataZod,
|
|
6296
|
+
SyncStepSummaryStatusZod,
|
|
6297
|
+
SyncStepSummaryZod,
|
|
6298
|
+
SyncViewerMoniker
|
|
6299
|
+
} from "@xyo-network/xl1-protocol-lib";
|
|
6300
|
+
var RestSyncViewer = class extends AbstractCreatableProvider {
|
|
6301
|
+
moniker = RestSyncViewer.defaultMoniker;
|
|
6302
|
+
get client() {
|
|
6303
|
+
return new FetchJsonClient2();
|
|
6304
|
+
}
|
|
6305
|
+
get endpoint() {
|
|
6306
|
+
return this.params.endpoint.replace(/\/+$/, "");
|
|
6307
|
+
}
|
|
6308
|
+
async stepSummary(step, block) {
|
|
6309
|
+
try {
|
|
6310
|
+
const response = await this.client.get(this.url(`step-summaries/${step}/${block}`));
|
|
6311
|
+
return SyncStepSummaryZod.parse(response.data);
|
|
6312
|
+
} catch (ex) {
|
|
6313
|
+
if (this.isNotFound(ex)) return null;
|
|
6314
|
+
throw ex;
|
|
6315
|
+
}
|
|
6316
|
+
}
|
|
6317
|
+
async stepSummaryMetadata(step, block) {
|
|
6318
|
+
try {
|
|
6319
|
+
const response = await this.client.get(this.url(`step-summaries/${step}/${block}/meta`));
|
|
6320
|
+
return SyncStepSummaryMetadataZod.parse(response.data);
|
|
6321
|
+
} catch (ex) {
|
|
6322
|
+
if (this.isNotFound(ex)) return null;
|
|
6323
|
+
throw ex;
|
|
6324
|
+
}
|
|
6325
|
+
}
|
|
6326
|
+
async stepSummaryStatus() {
|
|
6327
|
+
const response = await this.client.get(this.url("step-summaries"));
|
|
6328
|
+
return SyncStepSummaryStatusZod.parse(response.data);
|
|
6329
|
+
}
|
|
6330
|
+
isNotFound(ex) {
|
|
6331
|
+
return ex instanceof FetchClientError2 && ex.response.status === 404;
|
|
6332
|
+
}
|
|
6333
|
+
url(path) {
|
|
6334
|
+
return `${this.endpoint}/${path.replace(/^\/+/, "")}`;
|
|
6335
|
+
}
|
|
6336
|
+
};
|
|
6337
|
+
__publicField(RestSyncViewer, "defaultMoniker", SyncViewerMoniker);
|
|
6338
|
+
__publicField(RestSyncViewer, "dependencies", []);
|
|
6339
|
+
__publicField(RestSyncViewer, "monikers", [SyncViewerMoniker]);
|
|
6340
|
+
RestSyncViewer = __decorateClass([
|
|
6341
|
+
creatableProvider()
|
|
6342
|
+
], RestSyncViewer);
|
|
6343
|
+
|
|
6288
6344
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6289
6345
|
import {
|
|
6290
6346
|
asHash as asHash5,
|
|
6291
|
-
assertEx as
|
|
6347
|
+
assertEx as assertEx43,
|
|
6292
6348
|
isDefined as isDefined21
|
|
6293
6349
|
} from "@xylabs/sdk-js";
|
|
6294
6350
|
import {
|
|
@@ -6310,7 +6366,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6310
6366
|
async convertTime(fromDomain, toDomain, from) {
|
|
6311
6367
|
switch (fromDomain) {
|
|
6312
6368
|
case "xl1": {
|
|
6313
|
-
const [block, payloads] =
|
|
6369
|
+
const [block, payloads] = assertEx43(await this.blockViewer.blockByNumber(asXL1BlockNumber10(from, true)), () => "Block not found");
|
|
6314
6370
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6315
6371
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6316
6372
|
const timePayload = asTimePayload2(isDefined21(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -6365,10 +6421,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6365
6421
|
return [Date.now(), null];
|
|
6366
6422
|
}
|
|
6367
6423
|
case "ethereum": {
|
|
6368
|
-
const provider =
|
|
6424
|
+
const provider = assertEx43(this.ethProvider, () => "Ethereum provider not configured");
|
|
6369
6425
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6370
6426
|
const block = await provider.getBlock(blockNumber);
|
|
6371
|
-
const blockHash = asHash5(
|
|
6427
|
+
const blockHash = asHash5(assertEx43(block?.hash, () => "Block hash not found"), true);
|
|
6372
6428
|
return [blockNumber, blockHash];
|
|
6373
6429
|
}
|
|
6374
6430
|
default: {
|
|
@@ -6383,7 +6439,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6383
6439
|
// this is for the previous block
|
|
6384
6440
|
xl1,
|
|
6385
6441
|
// this is for the previous block
|
|
6386
|
-
xl1Hash:
|
|
6442
|
+
xl1Hash: assertEx43(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6387
6443
|
epoch: Date.now()
|
|
6388
6444
|
};
|
|
6389
6445
|
if (isDefined21(this.ethProvider)) {
|
|
@@ -6403,7 +6459,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6403
6459
|
], SimpleTimeSyncViewer);
|
|
6404
6460
|
|
|
6405
6461
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6406
|
-
import { assertEx as
|
|
6462
|
+
import { assertEx as assertEx44 } from "@xylabs/sdk-js";
|
|
6407
6463
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6408
6464
|
import {
|
|
6409
6465
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6454,7 +6510,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6454
6510
|
head: void 0
|
|
6455
6511
|
};
|
|
6456
6512
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
|
|
6457
|
-
const head = isChainQualifiedHeadConfig6(config) ?
|
|
6513
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx44(
|
|
6458
6514
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
6459
6515
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6460
6516
|
) : void 0;
|
|
@@ -6520,7 +6576,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
6520
6576
|
], SimpleTransactionValidationViewer);
|
|
6521
6577
|
|
|
6522
6578
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
6523
|
-
import { assertEx as
|
|
6579
|
+
import { assertEx as assertEx45, exists as exists10 } from "@xylabs/sdk-js";
|
|
6524
6580
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
6525
6581
|
import {
|
|
6526
6582
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -6537,7 +6593,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
6537
6593
|
}
|
|
6538
6594
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
6539
6595
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
6540
|
-
|
|
6596
|
+
assertEx45(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
6541
6597
|
try {
|
|
6542
6598
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
6543
6599
|
if (!block) return null;
|
|
@@ -6601,7 +6657,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
6601
6657
|
|
|
6602
6658
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
6603
6659
|
import {
|
|
6604
|
-
assertEx as
|
|
6660
|
+
assertEx as assertEx46,
|
|
6605
6661
|
exists as exists11,
|
|
6606
6662
|
isNull as isNull2
|
|
6607
6663
|
} from "@xylabs/sdk-js";
|
|
@@ -6672,7 +6728,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6672
6728
|
}
|
|
6673
6729
|
async createHandler() {
|
|
6674
6730
|
await super.createHandler();
|
|
6675
|
-
this._blockViewer =
|
|
6731
|
+
this._blockViewer = assertEx46(
|
|
6676
6732
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
6677
6733
|
() => "BlockViewer instance is required"
|
|
6678
6734
|
);
|
|
@@ -6681,13 +6737,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6681
6737
|
this._transactionHashMap = new MemoryMap();
|
|
6682
6738
|
}
|
|
6683
6739
|
currentBlock() {
|
|
6684
|
-
return
|
|
6740
|
+
return assertEx46(this._chain.at(-1));
|
|
6685
6741
|
}
|
|
6686
6742
|
currentBlockHash() {
|
|
6687
|
-
return
|
|
6743
|
+
return assertEx46(this._chain.at(-1)?.[0]._hash);
|
|
6688
6744
|
}
|
|
6689
6745
|
currentBlockNumber() {
|
|
6690
|
-
return
|
|
6746
|
+
return assertEx46(this._chain.at(-1)?.[0].block);
|
|
6691
6747
|
}
|
|
6692
6748
|
async payloadByHash(hash) {
|
|
6693
6749
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -6846,13 +6902,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6846
6902
|
};
|
|
6847
6903
|
|
|
6848
6904
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6849
|
-
import { assertEx as
|
|
6905
|
+
import { assertEx as assertEx47 } from "@xylabs/sdk-js";
|
|
6850
6906
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6851
6907
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6852
6908
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6853
6909
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6854
6910
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6855
|
-
return
|
|
6911
|
+
return assertEx47(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6856
6912
|
}
|
|
6857
6913
|
|
|
6858
6914
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -6948,6 +7004,7 @@ export {
|
|
|
6948
7004
|
RestDataLakeConfigZod,
|
|
6949
7005
|
RestDataLakeRunner,
|
|
6950
7006
|
RestDataLakeViewer,
|
|
7007
|
+
RestSyncViewer,
|
|
6951
7008
|
RewardMultipliers,
|
|
6952
7009
|
RouterDataLakeConfigZod,
|
|
6953
7010
|
RpcRemoteConfigBaseZod,
|