@xyo-network/xl1-protocol-sdk 2.0.7 → 2.0.9
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/CreatableProvider/AbstractCreatableProvider.d.ts +5 -5
- package/dist/neutral/config/Actor.d.ts +31 -31
- package/dist/neutral/config/Actors.d.ts +6 -6
- package/dist/neutral/config/Base.d.ts +6 -6
- package/dist/neutral/config/Chain.d.ts +2 -2
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +22 -22
- package/dist/neutral/config/HostActor.d.ts +31 -31
- package/dist/neutral/config/Validation.d.ts +4 -4
- package/dist/neutral/context/Actor.d.ts +31 -31
- package/dist/neutral/context/HostActor.d.ts +31 -31
- package/dist/neutral/createDeclarationPayload.d.ts +2 -2
- package/dist/neutral/createDeclarationPayload.d.ts.map +1 -1
- package/dist/neutral/createTransferPayload.d.ts +3 -2
- package/dist/neutral/createTransferPayload.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +10 -10
- package/dist/neutral/getFileConfig.mjs +6 -5
- package/dist/neutral/getFileConfig.mjs.map +3 -3
- package/dist/neutral/index.mjs +155 -181
- package/dist/neutral/index.mjs.map +3 -3
- package/dist/neutral/instances/Address.d.ts +3 -2
- package/dist/neutral/instances/Address.d.ts.map +1 -1
- package/dist/neutral/instances/Signature.d.ts +3 -2
- package/dist/neutral/instances/Signature.d.ts.map +1 -1
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +31 -31
- package/dist/neutral/payloads/AddressPairPayload.d.ts +2 -2
- package/dist/neutral/payloads/AddressPairPayload.d.ts.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts +2 -2
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts +2 -2
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts +2 -2
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts +2 -2
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts +2 -2
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts +2 -2
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +2 -2
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findUncles.d.ts +2 -2
- package/dist/neutral/services/AccountTransfersService.d.ts +4 -3
- package/dist/neutral/services/AccountTransfersService.d.ts.map +1 -1
- package/dist/neutral/services/Election.d.ts +2 -2
- package/dist/neutral/services/Election.d.ts.map +1 -1
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts +4 -4
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts.map +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts +5 -5
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts +8 -7
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +18 -18
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +8 -7
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts +4 -3
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +4 -3
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts +2 -2
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts.map +1 -1
- package/dist/neutral/summary/model/TransfersSummary.d.ts +2 -2
- package/dist/neutral/summary/model/TransfersSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/test/BuildBlockOptions.d.ts +3 -2
- package/dist/neutral/test/BuildBlockOptions.d.ts.map +1 -1
- package/dist/neutral/test/buildNextBlock.d.ts +2 -5
- package/dist/neutral/test/buildNextBlock.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomChain.d.ts +2 -2
- package/dist/neutral/test/buildRandomChain.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomTransaction.d.ts +2 -2
- package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -1
- package/dist/neutral/test/createGenesisBlock.d.ts +2 -2
- package/dist/neutral/test/createGenesisBlock.d.ts.map +1 -1
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts +3 -3
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts.map +1 -1
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts +3 -3
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +76 -80
- package/dist/neutral/test/index.mjs.map +3 -3
- package/dist/neutral/transaction/TransactionBuilder.d.ts +4 -4
- package/dist/neutral/transaction/TransactionBuilder.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/signTransaction.d.ts +2 -2
- package/package.json +12 -10
|
@@ -12,7 +12,6 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
12
12
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
13
13
|
|
|
14
14
|
// src/test/buildRandomTransaction.ts
|
|
15
|
-
import { asAddress as asAddress2 } from "@xylabs/sdk-js";
|
|
16
15
|
import { Account } from "@xyo-network/sdk-js";
|
|
17
16
|
import { asXL1BlockNumber, isAllowedBlockPayload } from "@xyo-network/xl1-protocol-lib";
|
|
18
17
|
|
|
@@ -30,7 +29,7 @@ function createTransferPayload(from, transfers, context) {
|
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
// src/transaction/buildTransaction.ts
|
|
33
|
-
import {
|
|
32
|
+
import { assertEx, toHex as toHex2 } from "@xylabs/sdk-js";
|
|
34
33
|
import {
|
|
35
34
|
asAnyPayload,
|
|
36
35
|
BoundWitnessBuilder,
|
|
@@ -59,7 +58,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
59
58
|
}
|
|
60
59
|
const fields = {
|
|
61
60
|
...txBoundWitnessFields,
|
|
62
|
-
from: from ??
|
|
61
|
+
from: from ?? (Array.isArray(signer) ? assertEx(signer.at(0)?.address) : signer.address)
|
|
63
62
|
};
|
|
64
63
|
if (script.length > 0) {
|
|
65
64
|
fields.script = script;
|
|
@@ -75,7 +74,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
75
74
|
const sender = account ?? await Account.random();
|
|
76
75
|
if (elevatedPayloads.length === 0) {
|
|
77
76
|
const receiver = receiverAddress ?? (await Account.random()).address;
|
|
78
|
-
const transferPayload = createTransferPayload(
|
|
77
|
+
const transferPayload = createTransferPayload(sender.address, { [receiver]: 1n });
|
|
79
78
|
elevatedPayloads.push(transferPayload);
|
|
80
79
|
}
|
|
81
80
|
const hydratedTransaction = await buildTransaction(chain, elevatedPayloads, additionalPayloads, sender, nbf, exp);
|
|
@@ -88,12 +87,12 @@ import { XYO_ZERO_ADDRESS as XYO_ZERO_ADDRESS3 } from "@xyo-network/xl1-protocol
|
|
|
88
87
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
89
88
|
import {
|
|
90
89
|
AbstractCreatable,
|
|
91
|
-
assertEx as
|
|
90
|
+
assertEx as assertEx3,
|
|
92
91
|
IdLogger
|
|
93
92
|
} from "@xylabs/sdk-js";
|
|
94
93
|
|
|
95
94
|
// src/CreatableProvider/ProviderFactory.ts
|
|
96
|
-
import { assertEx } from "@xylabs/sdk-js";
|
|
95
|
+
import { assertEx as assertEx2 } from "@xylabs/sdk-js";
|
|
97
96
|
function providerFactoryDescription(factory, labels) {
|
|
98
97
|
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
99
98
|
}
|
|
@@ -114,7 +113,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
114
113
|
this.dependencies = dependencies;
|
|
115
114
|
this.monikers = creatableProvider2.monikers;
|
|
116
115
|
this.scope = scope;
|
|
117
|
-
|
|
116
|
+
assertEx2(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
118
117
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
119
118
|
this.providerName = creatableProvider2.name;
|
|
120
119
|
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
@@ -142,7 +141,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
142
141
|
break;
|
|
143
142
|
}
|
|
144
143
|
case "context": {
|
|
145
|
-
const context =
|
|
144
|
+
const context = assertEx2(
|
|
146
145
|
params?.context,
|
|
147
146
|
() => "Context is required for context-scoped providers"
|
|
148
147
|
);
|
|
@@ -163,7 +162,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
163
162
|
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
164
163
|
const result = await resultPromise;
|
|
165
164
|
if (start) {
|
|
166
|
-
|
|
165
|
+
assertEx2(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
167
166
|
}
|
|
168
167
|
return result;
|
|
169
168
|
}
|
|
@@ -208,9 +207,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
208
207
|
return factory;
|
|
209
208
|
}
|
|
210
209
|
static async paramsHandler(params = {}) {
|
|
211
|
-
const context =
|
|
212
|
-
const config =
|
|
213
|
-
const locator =
|
|
210
|
+
const context = assertEx3(params.context, () => new Error("Context is required"));
|
|
211
|
+
const config = assertEx3(context.config, () => new Error("Context config is required"));
|
|
212
|
+
const locator = assertEx3(context.locator, () => new Error("Context locator is required"));
|
|
214
213
|
return await super.paramsHandler({
|
|
215
214
|
...params,
|
|
216
215
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -306,7 +305,7 @@ var hasLabels = (factory) => {
|
|
|
306
305
|
|
|
307
306
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
308
307
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
309
|
-
import { assertEx as
|
|
308
|
+
import { assertEx as assertEx4 } from "@xylabs/sdk-js";
|
|
310
309
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
311
310
|
_context;
|
|
312
311
|
_registry;
|
|
@@ -338,7 +337,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
338
337
|
this._frozen = true;
|
|
339
338
|
}
|
|
340
339
|
async getInstance(moniker, { start = true, labels } = {}) {
|
|
341
|
-
return
|
|
340
|
+
return assertEx4(
|
|
342
341
|
await this.tryGetInstance(moniker, { start, labels }),
|
|
343
342
|
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
344
343
|
);
|
|
@@ -353,7 +352,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
353
352
|
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
354
353
|
*/
|
|
355
354
|
locate(moniker, labels) {
|
|
356
|
-
return
|
|
355
|
+
return assertEx4(
|
|
357
356
|
this.tryLocate(moniker, labels),
|
|
358
357
|
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
359
358
|
);
|
|
@@ -375,10 +374,10 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
375
374
|
* @param labels The labels for the module factory
|
|
376
375
|
*/
|
|
377
376
|
register(factory, labels, primary = false) {
|
|
378
|
-
|
|
377
|
+
assertEx4(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
379
378
|
if (this.validateDepsOnRegister) {
|
|
380
379
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
381
|
-
|
|
380
|
+
assertEx4(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
382
381
|
}
|
|
383
382
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
384
383
|
return this;
|
|
@@ -426,7 +425,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
426
425
|
for (const moniker in this.registry) {
|
|
427
426
|
for (const factory of this.registry[moniker] ?? []) {
|
|
428
427
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
429
|
-
|
|
428
|
+
assertEx4(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
430
429
|
}
|
|
431
430
|
}
|
|
432
431
|
}
|
|
@@ -457,7 +456,8 @@ import { globalRegistry as globalRegistry12, z as z16 } from "zod/mini";
|
|
|
457
456
|
import { z as z15 } from "zod/mini";
|
|
458
457
|
|
|
459
458
|
// src/config/Chain.ts
|
|
460
|
-
import {
|
|
459
|
+
import { HexZod } from "@xylabs/sdk-js";
|
|
460
|
+
import { XyoAddressZod } from "@xyo-network/address";
|
|
461
461
|
import { globalRegistry, z } from "zod/mini";
|
|
462
462
|
var ChainConfigZod = z.object({
|
|
463
463
|
id: z.optional(HexZod).register(globalRegistry, {
|
|
@@ -465,7 +465,7 @@ var ChainConfigZod = z.object({
|
|
|
465
465
|
title: "chain.id",
|
|
466
466
|
type: "string"
|
|
467
467
|
}),
|
|
468
|
-
genesisRewardAddress: z.optional(
|
|
468
|
+
genesisRewardAddress: z.optional(XyoAddressZod).register(globalRegistry, {
|
|
469
469
|
description: "Address to send the initial genesis rewards to, if a new chain is being created.",
|
|
470
470
|
title: "chain.genesisRewardAddress",
|
|
471
471
|
type: "Address"
|
|
@@ -697,7 +697,7 @@ var TelemetryConfigZod = z13.object({
|
|
|
697
697
|
}).describe("Telemetry configuration options");
|
|
698
698
|
|
|
699
699
|
// src/config/Validation.ts
|
|
700
|
-
import {
|
|
700
|
+
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/address";
|
|
701
701
|
import { globalRegistry as globalRegistry11, z as z14 } from "zod";
|
|
702
702
|
|
|
703
703
|
// src/primitives/block/rate/blockRate.ts
|
|
@@ -705,7 +705,7 @@ import { isDefined as isDefined3, isFalsy } from "@xylabs/sdk-js";
|
|
|
705
705
|
import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
|
|
706
706
|
|
|
707
707
|
// src/primitives/block/rate/timeHelpers.ts
|
|
708
|
-
import { assertEx as
|
|
708
|
+
import { assertEx as assertEx5, isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
709
709
|
var rateMultipliers = {
|
|
710
710
|
millis: 1,
|
|
711
711
|
seconds: 1e3,
|
|
@@ -723,7 +723,7 @@ var timeDurations = (timeInMs) => ({
|
|
|
723
723
|
weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
|
|
724
724
|
});
|
|
725
725
|
var getTimeConfigInMilliseconds = (timeConfig) => {
|
|
726
|
-
const assertedTimeConfig =
|
|
726
|
+
const assertedTimeConfig = assertEx5(isDefined2(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
|
|
727
727
|
let totalMilliseconds = 0;
|
|
728
728
|
if ("years" in assertedTimeConfig) {
|
|
729
729
|
totalMilliseconds += assertedTimeConfig.years * 31536e6;
|
|
@@ -796,7 +796,7 @@ var calculateBlockRate = async (viewer, range, timeUnit) => {
|
|
|
796
796
|
};
|
|
797
797
|
|
|
798
798
|
// src/primitives/block/rate/stepRate.ts
|
|
799
|
-
import { assertEx as
|
|
799
|
+
import { assertEx as assertEx6 } from "@xylabs/sdk-js";
|
|
800
800
|
import {
|
|
801
801
|
asXL1BlockRange as asXL1BlockRange2,
|
|
802
802
|
isValidStep,
|
|
@@ -808,14 +808,14 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
|
808
808
|
return await calculateBlockRate(viewer, range, timeUnit);
|
|
809
809
|
};
|
|
810
810
|
var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
|
|
811
|
-
|
|
811
|
+
assertEx6(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
|
|
812
812
|
const step = StepSizes[stepIndex];
|
|
813
813
|
return await stepRate(viewer, start, step, count, timeUnit);
|
|
814
814
|
};
|
|
815
815
|
|
|
816
816
|
// src/primitives/block/rate/timeRate.ts
|
|
817
817
|
import {
|
|
818
|
-
assertEx as
|
|
818
|
+
assertEx as assertEx7,
|
|
819
819
|
isDefined as isDefined4,
|
|
820
820
|
isDefinedNotNull
|
|
821
821
|
} from "@xylabs/sdk-js";
|
|
@@ -823,11 +823,11 @@ import { asXL1BlockNumber as asXL1BlockNumber2, asXL1BlockRange as asXL1BlockRan
|
|
|
823
823
|
var DEFAULT_TOLERANCE_MS = 3e4;
|
|
824
824
|
var DEFAULT_MAX_ATTEMPTS = 10;
|
|
825
825
|
var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, toleranceMs = DEFAULT_TOLERANCE_MS, maxAttempts = DEFAULT_MAX_ATTEMPTS) => {
|
|
826
|
-
|
|
826
|
+
assertEx7(Object.keys(timeConfig ?? {}).length === 1, () => "Only one time unit should be specified in timeConfig");
|
|
827
827
|
const startBlock = isDefinedNotNull(startBlockNumber) ? await viewer.blockByNumber(startBlockNumber) : null;
|
|
828
828
|
const resolvedStartBlock = isDefinedNotNull(startBlock) ? startBlock[0] : (await viewer.currentBlock())[0];
|
|
829
829
|
const timeInMilliseconds = getTimeConfigInMilliseconds(timeConfig);
|
|
830
|
-
|
|
830
|
+
assertEx7(timeInMilliseconds > 0, () => "Time duration must be greater than zero");
|
|
831
831
|
const blocksPerMillisecondRate = 1 / (12 * 1e3);
|
|
832
832
|
const initialBlocksInDuration = Math.floor(blocksPerMillisecondRate * timeInMilliseconds);
|
|
833
833
|
const endBlockNumber = await findEndBlockRecursive(
|
|
@@ -845,14 +845,14 @@ var calculateTimeRate = async (viewer, timeConfig, startBlockNumber, timeUnit, t
|
|
|
845
845
|
);
|
|
846
846
|
};
|
|
847
847
|
var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBlocksBack, toleranceMs, attemptsRemaining) => {
|
|
848
|
-
|
|
848
|
+
assertEx7(attemptsRemaining >= 0, () => "Maximum attempts reached while searching for end block");
|
|
849
849
|
const startBlockEpoch = startBlock.$epoch;
|
|
850
850
|
const estimatedEndBlockNumber = asXL1BlockNumber2(startBlock.block - estimatedBlocksBack, true);
|
|
851
851
|
if (estimatedEndBlockNumber < 0) {
|
|
852
852
|
throw new Error("Estimated end block number is less than zero");
|
|
853
853
|
}
|
|
854
854
|
const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
|
|
855
|
-
const resolvedEndBlock =
|
|
855
|
+
const resolvedEndBlock = assertEx7(
|
|
856
856
|
isDefined4(endBlock?.[0]) ? endBlock[0] : void 0,
|
|
857
857
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
858
858
|
);
|
|
@@ -1016,30 +1016,30 @@ var flattenHydratedBlock = (hydratedBlock) => {
|
|
|
1016
1016
|
var flattenHydratedBlocks = (hydratedBlocks) => hydratedBlocks.flatMap((blk) => flattenHydratedBlock(blk));
|
|
1017
1017
|
|
|
1018
1018
|
// src/block/hydrate/hydrateBlock.ts
|
|
1019
|
-
import { assertEx as
|
|
1019
|
+
import { assertEx as assertEx8 } from "@xylabs/sdk-js";
|
|
1020
1020
|
import { asAnyPayload as asAnyPayload2 } from "@xyo-network/sdk-js";
|
|
1021
1021
|
import { asBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol-lib";
|
|
1022
1022
|
var hydrateBlock = async (context, hash, maxDepth = 1, minDepth = maxDepth) => {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1023
|
+
assertEx8(maxDepth >= 0, () => "maxDepth must be greater than or equal to 0");
|
|
1024
|
+
assertEx8(minDepth >= 0, () => "minDepth must be greater than or equal to 0");
|
|
1025
|
+
assertEx8(maxDepth >= minDepth, () => "maxDepth must be greater than or equal to minDepth");
|
|
1026
1026
|
const { chainMap } = context;
|
|
1027
1027
|
const [block] = await chainMap.get([hash]);
|
|
1028
|
-
const bw =
|
|
1029
|
-
|
|
1028
|
+
const bw = assertEx8(asBlockBoundWitnessWithStorageMeta(
|
|
1029
|
+
assertEx8(block, () => `block ${hash} not found`)
|
|
1030
1030
|
), () => `hash ${hash} is not a BlockBoundWitness`);
|
|
1031
1031
|
if (maxDepth === 0) return [bw, []];
|
|
1032
1032
|
const blkPayloads = (await chainMap.get(bw.payload_hashes)).map((p) => asAnyPayload2(p, true));
|
|
1033
|
-
if (minDepth === 1)
|
|
1033
|
+
if (minDepth === 1) assertEx8(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`);
|
|
1034
1034
|
if (maxDepth === 1) return [bw, blkPayloads];
|
|
1035
1035
|
const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta);
|
|
1036
1036
|
const transactionsPayloadHashes = transactions.flatMap((tx) => tx.payload_hashes);
|
|
1037
1037
|
const transactionsPayloads = (await chainMap.get(transactionsPayloadHashes)).map((p) => asAnyPayload2(p, true));
|
|
1038
|
-
|
|
1038
|
+
assertEx8(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`);
|
|
1039
1039
|
const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap((p) => p._hash));
|
|
1040
1040
|
const allPayloads = (await chainMap.get([...allPayloadsHashes])).map((p) => asAnyPayload2(p, true));
|
|
1041
1041
|
const allPayloadsFiltered = allPayloads.filter((p) => allPayloadsHashes.has(p._hash));
|
|
1042
|
-
if (maxDepth === 2)
|
|
1042
|
+
if (maxDepth === 2) assertEx8(allHashesPresent(
|
|
1043
1043
|
[...allPayloadsHashes],
|
|
1044
1044
|
allPayloadsFiltered
|
|
1045
1045
|
), () => `Unable to find all payloads for transactions in block ${hash}`);
|
|
@@ -1111,7 +1111,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
1111
1111
|
|
|
1112
1112
|
// src/block/primitives/validateTransactionOpcodes.ts
|
|
1113
1113
|
import {
|
|
1114
|
-
assertEx as
|
|
1114
|
+
assertEx as assertEx9,
|
|
1115
1115
|
isHash,
|
|
1116
1116
|
toSafeJsonString as toSafeJsonString2
|
|
1117
1117
|
} from "@xylabs/sdk-js";
|
|
@@ -1129,13 +1129,13 @@ async function validateTransactionsOpcodes(txs) {
|
|
|
1129
1129
|
case "elevate": {
|
|
1130
1130
|
const [hash, ...rest] = args;
|
|
1131
1131
|
const txPayloadsWithStorageMeta = await PayloadBuilder3.addStorageMeta(txPayloads);
|
|
1132
|
-
|
|
1132
|
+
assertEx9(rest.length === 0, () => `Invalid elevate operation ${opCode} ${args.join(", ")} - Too many Arguments`);
|
|
1133
1133
|
if (isHash(hash)) {
|
|
1134
|
-
|
|
1134
|
+
assertEx9(
|
|
1135
1135
|
txBw.payload_hashes.includes(hash),
|
|
1136
1136
|
() => `Invalid elevate operation ${opCode} ${args.join(", ")} - Hash not in payload hashes => ${toSafeJsonString2(txBw, 20)}`
|
|
1137
1137
|
);
|
|
1138
|
-
const txPayload =
|
|
1138
|
+
const txPayload = assertEx9(
|
|
1139
1139
|
txPayloadsWithStorageMeta.find((p) => p._hash === hash),
|
|
1140
1140
|
() => `Invalid elevate operation ${opCode} ${args.join(", ")} - Payload not found`
|
|
1141
1141
|
);
|
|
@@ -1183,7 +1183,7 @@ var findMostRecentBlock = async (chainArchivist, nextOptions = DEFAULT_NEXT_OPTI
|
|
|
1183
1183
|
};
|
|
1184
1184
|
|
|
1185
1185
|
// src/primitives/state/hydratedBlockByNumber.ts
|
|
1186
|
-
import { assertEx as
|
|
1186
|
+
import { assertEx as assertEx10, spanAsync as spanAsync2 } from "@xylabs/sdk-js";
|
|
1187
1187
|
async function hydratedBlockByNumber(context, blockNumber) {
|
|
1188
1188
|
return await spanAsync2("hydratedBlockByNumber", async () => {
|
|
1189
1189
|
if (blockNumber < 0) throw new Error(`Block number ${blockNumber} is less than 0`);
|
|
@@ -1191,7 +1191,7 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
1191
1191
|
if (blockNumber % 1 !== 0) throw new Error(`Block number ${blockNumber} is not an integer`);
|
|
1192
1192
|
const cacheKey = `${blockNumber}`;
|
|
1193
1193
|
return await withContextCacheResponse(context, "hydratedBlockByNumber", cacheKey, async () => {
|
|
1194
|
-
const block =
|
|
1194
|
+
const block = assertEx10(
|
|
1195
1195
|
await blockFromBlockNumber(context, blockNumber),
|
|
1196
1196
|
() => `Could not find block for block number ${blockNumber}`
|
|
1197
1197
|
);
|
|
@@ -1206,12 +1206,12 @@ var DEFAULT_BACKOFF_MS = 12e4;
|
|
|
1206
1206
|
|
|
1207
1207
|
// src/config/Validation.ts
|
|
1208
1208
|
var ValidationConfigZod = z14.object({
|
|
1209
|
-
allowedRewardRedeemers: z14.array(
|
|
1209
|
+
allowedRewardRedeemers: z14.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
1210
1210
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
1211
1211
|
title: "allowedRewardRedeemers",
|
|
1212
1212
|
type: "array"
|
|
1213
1213
|
}),
|
|
1214
|
-
allowedRewardEscrowAccountSigners: z14.array(
|
|
1214
|
+
allowedRewardEscrowAccountSigners: z14.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
1215
1215
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
1216
1216
|
title: "allowedRewardEscrowAccountSigners",
|
|
1217
1217
|
type: "array"
|
|
@@ -1280,7 +1280,7 @@ var ConfigZod = z18.extend(BaseConfigZod, {
|
|
|
1280
1280
|
|
|
1281
1281
|
// src/simple/block/SimpleBlockViewer.ts
|
|
1282
1282
|
import {
|
|
1283
|
-
assertEx as
|
|
1283
|
+
assertEx as assertEx11,
|
|
1284
1284
|
exists,
|
|
1285
1285
|
isUndefined as isUndefined3
|
|
1286
1286
|
} from "@xylabs/sdk-js";
|
|
@@ -1348,11 +1348,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
1348
1348
|
static async paramsHandler(params) {
|
|
1349
1349
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
1350
1350
|
if (headPollIntervalMs !== void 0) {
|
|
1351
|
-
|
|
1351
|
+
assertEx11(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
1352
1352
|
}
|
|
1353
1353
|
return {
|
|
1354
1354
|
...await super.paramsHandler(params),
|
|
1355
|
-
finalizedArchivist:
|
|
1355
|
+
finalizedArchivist: assertEx11(params.finalizedArchivist, () => "finalizedArchivist is required"),
|
|
1356
1356
|
headPollIntervalMs
|
|
1357
1357
|
};
|
|
1358
1358
|
}
|
|
@@ -1381,8 +1381,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
1381
1381
|
}
|
|
1382
1382
|
async blocksByHash(hash, limit = 50) {
|
|
1383
1383
|
return await this.spanAsync("blocksByHash", async () => {
|
|
1384
|
-
|
|
1385
|
-
|
|
1384
|
+
assertEx11(limit > 0, () => "limit must be greater than 0");
|
|
1385
|
+
assertEx11(limit <= 100, () => "limit must be less than 100");
|
|
1386
1386
|
const blocks = [];
|
|
1387
1387
|
let current = await this.blockByHash(hash);
|
|
1388
1388
|
while (current && blocks.length < limit) {
|
|
@@ -1396,8 +1396,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
1398
1398
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
1399
|
-
|
|
1400
|
-
|
|
1399
|
+
assertEx11(limit > 0, () => "limit must be greater than 0");
|
|
1400
|
+
assertEx11(limit <= 100, () => "limit must be less than 100");
|
|
1401
1401
|
const chainContext = await this.getChainContextRead();
|
|
1402
1402
|
if (isUndefined3(chainContext.head)) {
|
|
1403
1403
|
return [];
|
|
@@ -1415,7 +1415,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
async chainId(blockNumber = "latest") {
|
|
1417
1417
|
return await this.spanAsync("chainId", async () => {
|
|
1418
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
1418
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx11(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
1419
1419
|
}, this.context);
|
|
1420
1420
|
}
|
|
1421
1421
|
async createHandler() {
|
|
@@ -1527,9 +1527,7 @@ SimpleBlockViewer = __decorateClass([
|
|
|
1527
1527
|
], SimpleBlockViewer);
|
|
1528
1528
|
|
|
1529
1529
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
1530
|
-
import {
|
|
1531
|
-
assertEx as assertEx11
|
|
1532
|
-
} from "@xylabs/sdk-js";
|
|
1530
|
+
import { assertEx as assertEx12 } from "@xylabs/sdk-js";
|
|
1533
1531
|
import { ChainContractViewerMoniker, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
1534
1532
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
1535
1533
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -1546,7 +1544,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
1546
1544
|
let contractViewer = this;
|
|
1547
1545
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
1548
1546
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
1549
|
-
contractViewer =
|
|
1547
|
+
contractViewer = assertEx12(await contractViewer.forkedChainContractViewer());
|
|
1550
1548
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
1551
1549
|
chainId = await contractViewer.chainId();
|
|
1552
1550
|
}
|
|
@@ -1587,7 +1585,7 @@ SimpleChainContractViewer = __decorateClass([
|
|
|
1587
1585
|
], SimpleChainContractViewer);
|
|
1588
1586
|
|
|
1589
1587
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
1590
|
-
import { assertEx as
|
|
1588
|
+
import { assertEx as assertEx13 } from "@xylabs/sdk-js";
|
|
1591
1589
|
import {
|
|
1592
1590
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
1593
1591
|
ChainContractViewerMoniker as ChainContractViewerMoniker2,
|
|
@@ -1616,7 +1614,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
1616
1614
|
static async paramsHandler(params) {
|
|
1617
1615
|
return {
|
|
1618
1616
|
...await super.paramsHandler(params),
|
|
1619
|
-
finalizedArchivist:
|
|
1617
|
+
finalizedArchivist: assertEx13(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
1620
1618
|
};
|
|
1621
1619
|
}
|
|
1622
1620
|
chainId() {
|
|
@@ -1624,18 +1622,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
1624
1622
|
}
|
|
1625
1623
|
async createHandler() {
|
|
1626
1624
|
await super.createHandler();
|
|
1627
|
-
this._chainId =
|
|
1625
|
+
this._chainId = assertEx13(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
1628
1626
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
1629
1627
|
}
|
|
1630
1628
|
async head() {
|
|
1631
1629
|
return await this.spanAsync("head", async () => {
|
|
1632
|
-
const currentHead =
|
|
1630
|
+
const currentHead = assertEx13(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
1633
1631
|
const cache = this.hydratedBlockCache;
|
|
1634
1632
|
const block = await cache.get(currentHead._hash);
|
|
1635
1633
|
if (!block) {
|
|
1636
1634
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
1637
1635
|
}
|
|
1638
|
-
return
|
|
1636
|
+
return assertEx13(block, () => "Could not find current block");
|
|
1639
1637
|
}, this.context);
|
|
1640
1638
|
}
|
|
1641
1639
|
async headBlock() {
|
|
@@ -1661,8 +1659,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
1661
1659
|
}
|
|
1662
1660
|
async getCurrentHead() {
|
|
1663
1661
|
const chainArchivist = this.finalizedArchivist;
|
|
1664
|
-
const result =
|
|
1665
|
-
|
|
1662
|
+
const result = assertEx13(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
1663
|
+
assertEx13(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
1666
1664
|
return result;
|
|
1667
1665
|
}
|
|
1668
1666
|
};
|
|
@@ -1674,7 +1672,7 @@ SimpleFinalizationViewer = __decorateClass([
|
|
|
1674
1672
|
], SimpleFinalizationViewer);
|
|
1675
1673
|
|
|
1676
1674
|
// src/test/buildRandomChain.ts
|
|
1677
|
-
import { asAddress as
|
|
1675
|
+
import { asAddress as asAddress2, assertEx as assertEx16 } from "@xylabs/sdk-js";
|
|
1678
1676
|
import {
|
|
1679
1677
|
Account as Account3,
|
|
1680
1678
|
asSchema as asSchema2,
|
|
@@ -1693,7 +1691,7 @@ import {
|
|
|
1693
1691
|
} from "@xyo-network/xl1-protocol-lib";
|
|
1694
1692
|
|
|
1695
1693
|
// src/test/buildBlock.ts
|
|
1696
|
-
import { assertEx as
|
|
1694
|
+
import { assertEx as assertEx14, isDefined as isDefined8 } from "@xylabs/sdk-js";
|
|
1697
1695
|
import {
|
|
1698
1696
|
asAnyPayload as asAnyPayload3,
|
|
1699
1697
|
BoundWitnessBuilder as BoundWitnessBuilder2,
|
|
@@ -1797,7 +1795,7 @@ async function buildBlock(options) {
|
|
|
1797
1795
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
1798
1796
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
1799
1797
|
}
|
|
1800
|
-
step_hashes.push(
|
|
1798
|
+
step_hashes.push(assertEx14(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
1801
1799
|
} else {
|
|
1802
1800
|
if (isDefined8(inStepHashes.at(i))) {
|
|
1803
1801
|
step_hashes.push(inStepHashes[i]);
|
|
@@ -1820,7 +1818,7 @@ async function buildBlock(options) {
|
|
|
1820
1818
|
step_hashes,
|
|
1821
1819
|
protocol
|
|
1822
1820
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder4.addStorageMeta(payloads)).build();
|
|
1823
|
-
|
|
1821
|
+
assertEx14(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
1824
1822
|
return [await PayloadBuilder4.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload3(p, true))];
|
|
1825
1823
|
}
|
|
1826
1824
|
|
|
@@ -1841,7 +1839,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
1841
1839
|
}
|
|
1842
1840
|
|
|
1843
1841
|
// src/test/buildRandomGenesisBlock.ts
|
|
1844
|
-
import { asAddress
|
|
1842
|
+
import { asAddress, assertEx as assertEx15 } from "@xylabs/sdk-js";
|
|
1845
1843
|
import {
|
|
1846
1844
|
Account as Account2,
|
|
1847
1845
|
asAnyPayload as asAnyPayload4,
|
|
@@ -1868,10 +1866,9 @@ async function buildGenesisBlock(chainId, txs, blockPayloads, signers, chainStep
|
|
|
1868
1866
|
}
|
|
1869
1867
|
|
|
1870
1868
|
// src/test/buildRandomGenesisBlock.ts
|
|
1871
|
-
var TestChainId =
|
|
1869
|
+
var TestChainId = assertEx15(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
1872
1870
|
|
|
1873
1871
|
// src/test/createGenesisBlock.ts
|
|
1874
|
-
import { asAddress as asAddress5 } from "@xylabs/sdk-js";
|
|
1875
1872
|
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/sdk-js";
|
|
1876
1873
|
import {
|
|
1877
1874
|
BlockBoundWitnessSchemaPayload,
|
|
@@ -1884,7 +1881,6 @@ import {
|
|
|
1884
1881
|
} from "@xyo-network/xl1-schema";
|
|
1885
1882
|
|
|
1886
1883
|
// src/test/createProducerChainStakeIntentTransaction.ts
|
|
1887
|
-
import { asAddress as asAddress4 } from "@xylabs/sdk-js";
|
|
1888
1884
|
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/sdk-js";
|
|
1889
1885
|
import {
|
|
1890
1886
|
asXL1BlockNumber as asXL1BlockNumber6,
|
|
@@ -1911,7 +1907,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
1911
1907
|
ChainStakeIntentPayloadJsonSchemaPayload,
|
|
1912
1908
|
HashPayloadJsonSchemaPayload
|
|
1913
1909
|
]);
|
|
1914
|
-
const intentPayload = await createProducerChainStakeIntent(
|
|
1910
|
+
const intentPayload = await createProducerChainStakeIntent(initialBlockProducer.address, 1, 0);
|
|
1915
1911
|
blockPayloads.push(intentPayload);
|
|
1916
1912
|
if (genesisBlockRewardAmount > 0n) {
|
|
1917
1913
|
blockPayloads.push(await PayloadBuilder7.addHashMeta(createTransferPayload(
|
|
@@ -1923,7 +1919,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
1923
1919
|
};
|
|
1924
1920
|
|
|
1925
1921
|
// src/test/buildRandomChain.ts
|
|
1926
|
-
var TestGenesisBlockRewardAddress =
|
|
1922
|
+
var TestGenesisBlockRewardAddress = assertEx16(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
1927
1923
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
1928
1924
|
const chainIdToUse = chainId ?? TestChainId;
|
|
1929
1925
|
const blocks = [];
|
|
@@ -1935,13 +1931,13 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
1935
1931
|
blockProducer,
|
|
1936
1932
|
chainIdToUse,
|
|
1937
1933
|
1000000000n * 10n ** 18n,
|
|
1938
|
-
|
|
1934
|
+
transactionAccountToUse.address
|
|
1939
1935
|
);
|
|
1940
1936
|
blocks.push(block);
|
|
1941
1937
|
remaining = remaining - 1;
|
|
1942
1938
|
lastBlock = block;
|
|
1943
1939
|
}
|
|
1944
|
-
const resolvedReceiverAddresses = receiverAddresses ?? [
|
|
1940
|
+
const resolvedReceiverAddresses = receiverAddresses ?? [(await Account3.random()).address];
|
|
1945
1941
|
let saltCounter = 0;
|
|
1946
1942
|
while (remaining > 0) {
|
|
1947
1943
|
saltCounter += 1;
|
|
@@ -1960,8 +1956,8 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
1960
1956
|
receiverAddress
|
|
1961
1957
|
));
|
|
1962
1958
|
}
|
|
1963
|
-
const previousBlock2 =
|
|
1964
|
-
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer],
|
|
1959
|
+
const previousBlock2 = assertEx16(lastBlock?.[0], () => new Error("No last block"));
|
|
1960
|
+
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
1965
1961
|
blocks.push(block);
|
|
1966
1962
|
remaining = remaining - 1;
|
|
1967
1963
|
lastBlock = block;
|