@xyo-network/xl1-protocol-sdk 3.0.13 → 3.0.15
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 +16 -10
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/boundwitness/buildUnsignedBoundWitness.d.ts +10 -0
- package/dist/neutral/boundwitness/buildUnsignedBoundWitness.d.ts.map +1 -0
- package/dist/neutral/boundwitness/index.d.ts +2 -0
- package/dist/neutral/boundwitness/index.d.ts.map +1 -0
- package/dist/neutral/config/Actor.d.ts +96 -60
- package/dist/neutral/config/Actor.d.ts.map +1 -1
- package/dist/neutral/config/Actors.d.ts +16 -10
- package/dist/neutral/config/Actors.d.ts.map +1 -1
- package/dist/neutral/config/Base.d.ts +16 -10
- package/dist/neutral/config/Base.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +64 -40
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/HostActor.d.ts +96 -60
- package/dist/neutral/config/HostActor.d.ts.map +1 -1
- package/dist/neutral/config/Validation.d.ts +16 -10
- package/dist/neutral/config/Validation.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +96 -60
- package/dist/neutral/context/Actor.d.ts.map +1 -1
- package/dist/neutral/context/HostActor.d.ts +96 -60
- package/dist/neutral/context/HostActor.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +32 -20
- package/dist/neutral/getFileConfig.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.mjs +4 -9
- package/dist/neutral/getFileConfig.mjs.map +3 -3
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +74 -79
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +96 -60
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +5 -6
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +4 -9
- package/dist/neutral/test/index.mjs.map +3 -3
- package/dist/neutral/transaction/signTransaction.d.ts +11 -36
- package/dist/neutral/transaction/signTransaction.d.ts.map +1 -1
- package/package.json +7 -6
package/dist/neutral/index.mjs
CHANGED
|
@@ -985,6 +985,13 @@ async function validateTransactionsOpcodes(txs) {
|
|
|
985
985
|
return txElevatedPayloads;
|
|
986
986
|
}
|
|
987
987
|
|
|
988
|
+
// src/boundwitness/buildUnsignedBoundWitness.ts
|
|
989
|
+
import { BoundWitnessBuilder } from "@xyo-network/sdk-js";
|
|
990
|
+
async function buildUnsignedBoundWitness(payloads) {
|
|
991
|
+
const [boundWitness, builtPayloads] = await new BoundWitnessBuilder().meta({ $signatures: [] }).payloads(payloads).build(false);
|
|
992
|
+
return [boundWitness, builtPayloads];
|
|
993
|
+
}
|
|
994
|
+
|
|
988
995
|
// src/capabilities/Backing.ts
|
|
989
996
|
function backingsSatisfied(required, available) {
|
|
990
997
|
for (const need of required) {
|
|
@@ -1969,7 +1976,7 @@ var TelemetryConfigZod = z11.object({
|
|
|
1969
1976
|
}).describe("Telemetry configuration options");
|
|
1970
1977
|
|
|
1971
1978
|
// src/config/Validation.ts
|
|
1972
|
-
import {
|
|
1979
|
+
import { SignerAuthorizationZod } from "@xyo-network/xl1-validation";
|
|
1973
1980
|
import { globalRegistry as globalRegistry8, z as z12 } from "zod";
|
|
1974
1981
|
|
|
1975
1982
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
@@ -2889,14 +2896,9 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2889
2896
|
|
|
2890
2897
|
// src/config/Validation.ts
|
|
2891
2898
|
var ValidationConfigZod = z12.object({
|
|
2892
|
-
|
|
2893
|
-
description: "
|
|
2894
|
-
title: "
|
|
2895
|
-
type: "array"
|
|
2896
|
-
}),
|
|
2897
|
-
allowedRewardEscrowAccountSigners: z12.array(XyoAddressZod2).optional().register(globalRegistry8, {
|
|
2898
|
-
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2899
|
-
title: "allowedRewardEscrowAccountSigners",
|
|
2899
|
+
signerAuthorizations: z12.array(SignerAuthorizationZod).default([]).register(globalRegistry8, {
|
|
2900
|
+
description: "Authorizations granting signers the right to sign for addresses derived by a given function (e.g. completed-step-reward, derived-receive). Empty = self-transfers only.",
|
|
2901
|
+
title: "validation.signerAuthorizations",
|
|
2900
2902
|
type: "array"
|
|
2901
2903
|
}),
|
|
2902
2904
|
minCandidates: z12.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry8, {
|
|
@@ -3161,7 +3163,7 @@ import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
|
3161
3163
|
import { assertEx as assertEx22, toHex } from "@xylabs/sdk-js";
|
|
3162
3164
|
import {
|
|
3163
3165
|
asAnyPayload as asAnyPayload2,
|
|
3164
|
-
BoundWitnessBuilder,
|
|
3166
|
+
BoundWitnessBuilder as BoundWitnessBuilder2,
|
|
3165
3167
|
PayloadBuilder as PayloadBuilder7
|
|
3166
3168
|
} from "@xyo-network/sdk-js";
|
|
3167
3169
|
import { defaultTransactionFees } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -3189,7 +3191,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
3189
3191
|
if (script.length > 0) {
|
|
3190
3192
|
fields.script = script;
|
|
3191
3193
|
}
|
|
3192
|
-
const boundWitnessBuilder = new
|
|
3194
|
+
const boundWitnessBuilder = new BoundWitnessBuilder2();
|
|
3193
3195
|
const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).signers(Array.isArray(signer) ? signer : [signer]);
|
|
3194
3196
|
const [tx, txPayloads] = await builder.build();
|
|
3195
3197
|
return [await PayloadBuilder7.addHashMeta(tx), await PayloadBuilder7.addHashMeta(txPayloads.map((p) => asAnyPayload2(p, true)))];
|
|
@@ -3197,7 +3199,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
3197
3199
|
|
|
3198
3200
|
// src/transaction/buildUnsignedTransaction.ts
|
|
3199
3201
|
import { toHex as toHex2 } from "@xylabs/sdk-js";
|
|
3200
|
-
import { BoundWitnessBuilder as
|
|
3202
|
+
import { BoundWitnessBuilder as BoundWitnessBuilder3, PayloadBuilder as PayloadBuilder8 } from "@xyo-network/sdk-js";
|
|
3201
3203
|
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol-lib";
|
|
3202
3204
|
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
3203
3205
|
const txBoundWitnessFields = {
|
|
@@ -3220,7 +3222,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
3220
3222
|
if (script.length > 0) {
|
|
3221
3223
|
fields.script = script;
|
|
3222
3224
|
}
|
|
3223
|
-
const boundWitnessBuilder = new
|
|
3225
|
+
const boundWitnessBuilder = new BoundWitnessBuilder3();
|
|
3224
3226
|
const builder = boundWitnessBuilder.fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]);
|
|
3225
3227
|
const [tx, txPayloads] = await builder.build(false);
|
|
3226
3228
|
return [tx, txPayloads];
|
|
@@ -3398,19 +3400,20 @@ import {
|
|
|
3398
3400
|
toArrayBuffer
|
|
3399
3401
|
} from "@xylabs/sdk-js";
|
|
3400
3402
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
3401
|
-
async function
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
const
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
const result = {
|
|
3410
|
-
...unsignedTx,
|
|
3403
|
+
async function signBoundWitness(bw, account) {
|
|
3404
|
+
const unsigned = structuredClone(bw);
|
|
3405
|
+
unsigned.addresses = [account.address];
|
|
3406
|
+
unsigned.previous_hashes = [account.previousHash ?? null];
|
|
3407
|
+
const hash = await PayloadBuilder10.dataHash(unsigned);
|
|
3408
|
+
const [signature] = await account.sign(toArrayBuffer(hash));
|
|
3409
|
+
return {
|
|
3410
|
+
...unsigned,
|
|
3411
3411
|
$signatures: [hexFromArrayBuffer(signature)]
|
|
3412
3412
|
};
|
|
3413
|
-
|
|
3413
|
+
}
|
|
3414
|
+
async function signTransaction(tx, account) {
|
|
3415
|
+
assertEx24(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
3416
|
+
return await signBoundWitness(tx, account);
|
|
3414
3417
|
}
|
|
3415
3418
|
|
|
3416
3419
|
// src/transaction/TransactionBuilder.ts
|
|
@@ -6375,11 +6378,9 @@ SimpleXyoRunner = __decorateClass([
|
|
|
6375
6378
|
], SimpleXyoRunner);
|
|
6376
6379
|
|
|
6377
6380
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
6381
|
+
import { assertEx as assertEx47 } from "@xylabs/sdk-js";
|
|
6378
6382
|
import { Account, PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
6379
|
-
import {
|
|
6380
|
-
SignedHydratedTransactionWithHashMetaZod,
|
|
6381
|
-
XyoSignerMoniker as XyoSignerMoniker2
|
|
6382
|
-
} from "@xyo-network/xl1-protocol-lib";
|
|
6383
|
+
import { asSignedHydratedTransactionWithHashMeta, XyoSignerMoniker as XyoSignerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6383
6384
|
var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
6384
6385
|
static connectionTypes = ["wallet"];
|
|
6385
6386
|
static defaultMoniker = XyoSignerMoniker2;
|
|
@@ -6393,7 +6394,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6393
6394
|
account = params.account;
|
|
6394
6395
|
} else {
|
|
6395
6396
|
const localLogger = params?.logger ?? params?.context?.logger;
|
|
6396
|
-
localLogger?.warn(`No account provided to SimpleXyoSigner, generating a random account.
|
|
6397
|
+
localLogger?.warn(`No account provided to SimpleXyoSigner, generating a random account.
|
|
6397
6398
|
This account will not be persisted and any transactions signed with it may be lost.
|
|
6398
6399
|
`);
|
|
6399
6400
|
account = await Account.random();
|
|
@@ -6403,24 +6404,16 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
6403
6404
|
address() {
|
|
6404
6405
|
return this.params.account.address;
|
|
6405
6406
|
}
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
additionalPayloads,
|
|
6413
|
-
this.params.account,
|
|
6414
|
-
nbf,
|
|
6415
|
-
exp,
|
|
6416
|
-
fromAddress,
|
|
6417
|
-
fees
|
|
6418
|
-
);
|
|
6419
|
-
return transaction[0];
|
|
6407
|
+
async sign(bw) {
|
|
6408
|
+
const signed = await signBoundWitness(bw[0], this.params.account);
|
|
6409
|
+
return [
|
|
6410
|
+
await PayloadBuilder23.addHashMeta(signed),
|
|
6411
|
+
await PayloadBuilder23.addHashMeta(bw[1])
|
|
6412
|
+
];
|
|
6420
6413
|
}
|
|
6421
6414
|
async signTransaction(tx) {
|
|
6422
|
-
|
|
6423
|
-
return
|
|
6415
|
+
assertEx47(tx[0].from === this.params.account.address, () => "Signer address does not match transaction from address");
|
|
6416
|
+
return asSignedHydratedTransactionWithHashMeta(await this.sign(tx), true);
|
|
6424
6417
|
}
|
|
6425
6418
|
};
|
|
6426
6419
|
|
|
@@ -6505,7 +6498,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6505
6498
|
], SimpleStakeEventsViewer);
|
|
6506
6499
|
|
|
6507
6500
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6508
|
-
import { assertEx as
|
|
6501
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
6509
6502
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/sdk-js";
|
|
6510
6503
|
import {
|
|
6511
6504
|
StakeTotalsViewerMoniker,
|
|
@@ -6549,7 +6542,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6549
6542
|
}
|
|
6550
6543
|
async createHandler() {
|
|
6551
6544
|
await super.createHandler();
|
|
6552
|
-
this._stakeViewer =
|
|
6545
|
+
this._stakeViewer = assertEx48(
|
|
6553
6546
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6554
6547
|
() => "Failed to create StakeViewer"
|
|
6555
6548
|
);
|
|
@@ -6605,14 +6598,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6605
6598
|
], SimpleStakeTotalsViewer);
|
|
6606
6599
|
|
|
6607
6600
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6608
|
-
import { assertEx as
|
|
6601
|
+
import { assertEx as assertEx49, toAddress } from "@xylabs/sdk-js";
|
|
6609
6602
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/sdk-js";
|
|
6610
6603
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6611
6604
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6612
6605
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6613
6606
|
_chainStakeEventsViewer;
|
|
6614
6607
|
get stakeEvents() {
|
|
6615
|
-
return
|
|
6608
|
+
return assertEx49(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6616
6609
|
}
|
|
6617
6610
|
get positions() {
|
|
6618
6611
|
return this.params.positions;
|
|
@@ -6652,7 +6645,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6652
6645
|
}
|
|
6653
6646
|
async createHandler() {
|
|
6654
6647
|
await super.createHandler();
|
|
6655
|
-
this._chainStakeEventsViewer =
|
|
6648
|
+
this._chainStakeEventsViewer = assertEx49(
|
|
6656
6649
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6657
6650
|
() => "Failed to create StakeEventsViewer"
|
|
6658
6651
|
);
|
|
@@ -6687,7 +6680,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6687
6680
|
return toAddress(toAddress(1n));
|
|
6688
6681
|
}
|
|
6689
6682
|
stakeById(id) {
|
|
6690
|
-
return
|
|
6683
|
+
return assertEx49(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6691
6684
|
}
|
|
6692
6685
|
stakeByStaker(staker, slot) {
|
|
6693
6686
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6791,7 +6784,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6791
6784
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6792
6785
|
import {
|
|
6793
6786
|
asHash as asHash5,
|
|
6794
|
-
assertEx as
|
|
6787
|
+
assertEx as assertEx50,
|
|
6795
6788
|
isDefined as isDefined22
|
|
6796
6789
|
} from "@xylabs/sdk-js";
|
|
6797
6790
|
import {
|
|
@@ -6813,7 +6806,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6813
6806
|
async convertTime(fromDomain, toDomain, from) {
|
|
6814
6807
|
switch (fromDomain) {
|
|
6815
6808
|
case "xl1": {
|
|
6816
|
-
const [block, payloads] =
|
|
6809
|
+
const [block, payloads] = assertEx50(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6817
6810
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6818
6811
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6819
6812
|
const timePayload = asTimePayload2(isDefined22(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -6869,10 +6862,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6869
6862
|
return [Date.now(), null];
|
|
6870
6863
|
}
|
|
6871
6864
|
case "ethereum": {
|
|
6872
|
-
const provider =
|
|
6865
|
+
const provider = assertEx50(this.ethProvider, () => "Ethereum provider not configured");
|
|
6873
6866
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6874
6867
|
const block = await provider.getBlock(blockNumber);
|
|
6875
|
-
const blockHash = asHash5(
|
|
6868
|
+
const blockHash = asHash5(assertEx50(block?.hash, () => "Block hash not found"), true);
|
|
6876
6869
|
return [blockNumber, blockHash];
|
|
6877
6870
|
}
|
|
6878
6871
|
default: {
|
|
@@ -6887,7 +6880,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6887
6880
|
// this is for the previous block
|
|
6888
6881
|
xl1,
|
|
6889
6882
|
// this is for the previous block
|
|
6890
|
-
xl1Hash:
|
|
6883
|
+
xl1Hash: assertEx50(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6891
6884
|
epoch: Date.now()
|
|
6892
6885
|
};
|
|
6893
6886
|
if (isDefined22(this.ethProvider)) {
|
|
@@ -6909,7 +6902,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6909
6902
|
], SimpleTimeSyncViewer);
|
|
6910
6903
|
|
|
6911
6904
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6912
|
-
import { assertEx as
|
|
6905
|
+
import { assertEx as assertEx51 } from "@xylabs/sdk-js";
|
|
6913
6906
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6914
6907
|
import {
|
|
6915
6908
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6963,7 +6956,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6963
6956
|
let head;
|
|
6964
6957
|
if (isChainQualifiedHeadConfig6(config)) {
|
|
6965
6958
|
const headBlockResult = await this.blockViewer.blockByHash(config.head);
|
|
6966
|
-
head = headBlockResult == null ?
|
|
6959
|
+
head = headBlockResult == null ? assertEx51(
|
|
6967
6960
|
void 0,
|
|
6968
6961
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6969
6962
|
) : headBlockResult[0];
|
|
@@ -7035,10 +7028,10 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
7035
7028
|
], SimpleTransactionValidationViewer);
|
|
7036
7029
|
|
|
7037
7030
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
7038
|
-
import { assertEx as
|
|
7031
|
+
import { assertEx as assertEx52, exists as exists10 } from "@xylabs/sdk-js";
|
|
7039
7032
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
7040
7033
|
import {
|
|
7041
|
-
asSignedHydratedTransactionWithHashMeta,
|
|
7034
|
+
asSignedHydratedTransactionWithHashMeta as asSignedHydratedTransactionWithHashMeta2,
|
|
7042
7035
|
asSignedTransactionBoundWitness,
|
|
7043
7036
|
BlockViewerMoniker as BlockViewerMoniker6,
|
|
7044
7037
|
isTransactionBoundWitnessWithHashMeta as isTransactionBoundWitnessWithHashMeta2,
|
|
@@ -7052,7 +7045,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7052
7045
|
}
|
|
7053
7046
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
7054
7047
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
7055
|
-
|
|
7048
|
+
assertEx52(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
7056
7049
|
try {
|
|
7057
7050
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
7058
7051
|
if (!block) return null;
|
|
@@ -7085,7 +7078,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
7085
7078
|
const transaction = asSignedTransactionBoundWitness(await this.blockViewer.payloadByHash(transactionHash));
|
|
7086
7079
|
if (transaction) {
|
|
7087
7080
|
const payloads = await this.blockViewer.payloadsByHash(transaction.payload_hashes);
|
|
7088
|
-
return
|
|
7081
|
+
return asSignedHydratedTransactionWithHashMeta2([transaction, payloads]) ?? null;
|
|
7089
7082
|
}
|
|
7090
7083
|
return null;
|
|
7091
7084
|
} catch {
|
|
@@ -7117,7 +7110,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
7117
7110
|
|
|
7118
7111
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
7119
7112
|
import {
|
|
7120
|
-
assertEx as
|
|
7113
|
+
assertEx as assertEx53,
|
|
7121
7114
|
exists as exists11,
|
|
7122
7115
|
isNull as isNull2
|
|
7123
7116
|
} from "@xylabs/sdk-js";
|
|
@@ -7199,7 +7192,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7199
7192
|
}
|
|
7200
7193
|
async createHandler() {
|
|
7201
7194
|
await super.createHandler();
|
|
7202
|
-
this._blockViewer =
|
|
7195
|
+
this._blockViewer = assertEx53(
|
|
7203
7196
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
7204
7197
|
() => "BlockViewer instance is required"
|
|
7205
7198
|
);
|
|
@@ -7208,13 +7201,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
7208
7201
|
this._transactionHashMap = new MemoryMap2();
|
|
7209
7202
|
}
|
|
7210
7203
|
currentBlock() {
|
|
7211
|
-
return
|
|
7204
|
+
return assertEx53(this._chain.at(-1));
|
|
7212
7205
|
}
|
|
7213
7206
|
currentBlockHash() {
|
|
7214
|
-
return
|
|
7207
|
+
return assertEx53(this._chain.at(-1)?.[0]._hash);
|
|
7215
7208
|
}
|
|
7216
7209
|
currentBlockNumber() {
|
|
7217
|
-
return
|
|
7210
|
+
return assertEx53(this._chain.at(-1)?.[0].block);
|
|
7218
7211
|
}
|
|
7219
7212
|
async payloadByHash(hash) {
|
|
7220
7213
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -7375,7 +7368,7 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
7375
7368
|
};
|
|
7376
7369
|
|
|
7377
7370
|
// src/test/buildRandomChain.ts
|
|
7378
|
-
import { asAddress as asAddress2, assertEx as
|
|
7371
|
+
import { asAddress as asAddress2, assertEx as assertEx56 } from "@xylabs/sdk-js";
|
|
7379
7372
|
import {
|
|
7380
7373
|
Account as Account4,
|
|
7381
7374
|
asSchema as asSchema9,
|
|
@@ -7394,10 +7387,10 @@ import {
|
|
|
7394
7387
|
} from "@xyo-network/xl1-protocol-lib";
|
|
7395
7388
|
|
|
7396
7389
|
// src/test/buildBlock.ts
|
|
7397
|
-
import { assertEx as
|
|
7390
|
+
import { assertEx as assertEx54, isDefined as isDefined23 } from "@xylabs/sdk-js";
|
|
7398
7391
|
import {
|
|
7399
7392
|
asAnyPayload as asAnyPayload5,
|
|
7400
|
-
BoundWitnessBuilder as
|
|
7393
|
+
BoundWitnessBuilder as BoundWitnessBuilder4,
|
|
7401
7394
|
PayloadBuilder as PayloadBuilder25
|
|
7402
7395
|
} from "@xyo-network/sdk-js";
|
|
7403
7396
|
import {
|
|
@@ -7477,7 +7470,7 @@ function buildStepHashes(blockNumber, inStepHashes, previousBlockHash, chainStep
|
|
|
7477
7470
|
const completedStepReward = calculateCompletedStepReward(i, stepRewardPoolBalance);
|
|
7478
7471
|
completedStepRewardTransfers.push(createTransferPayload(chainStepRewardAddress2, { [completedStepRewardHolderAddress]: completedStepReward }));
|
|
7479
7472
|
}
|
|
7480
|
-
step_hashes.push(
|
|
7473
|
+
step_hashes.push(assertEx54(previousBlockHash, () => `Previous block hash is required for step ${step} at block ${blockNumber}`));
|
|
7481
7474
|
} else if (isDefined23(inStepHashes.at(i))) {
|
|
7482
7475
|
step_hashes.push(inStepHashes[i]);
|
|
7483
7476
|
}
|
|
@@ -7522,7 +7515,7 @@ async function buildBlock(options) {
|
|
|
7522
7515
|
...txElevatedPayloads,
|
|
7523
7516
|
...completedStepRewardTransfers
|
|
7524
7517
|
];
|
|
7525
|
-
const boundWitnessBuilder = new
|
|
7518
|
+
const boundWitnessBuilder = new BoundWitnessBuilder4();
|
|
7526
7519
|
const builder = boundWitnessBuilder.fields({
|
|
7527
7520
|
block,
|
|
7528
7521
|
chain: chainId,
|
|
@@ -7531,7 +7524,7 @@ async function buildBlock(options) {
|
|
|
7531
7524
|
protocol
|
|
7532
7525
|
}).meta({ $epoch: Date.now(), $signatures: [] }).signers(signers).payloads(await PayloadBuilder25.addStorageMeta(payloads));
|
|
7533
7526
|
const [bw, txPayloads] = await builder.build();
|
|
7534
|
-
|
|
7527
|
+
assertEx54(isBlockBoundWitness(bw), () => "Build of BlockBoundWitness failed");
|
|
7535
7528
|
return [await PayloadBuilder25.addStorageMeta(bw), txPayloads.map((p) => asAnyPayload5(p, true))];
|
|
7536
7529
|
}
|
|
7537
7530
|
|
|
@@ -7552,7 +7545,7 @@ async function buildNextBlock(previousBlock, txs, blockPayloads, signers, chainS
|
|
|
7552
7545
|
}
|
|
7553
7546
|
|
|
7554
7547
|
// src/test/buildRandomGenesisBlock.ts
|
|
7555
|
-
import { asAddress, assertEx as
|
|
7548
|
+
import { asAddress, assertEx as assertEx55 } from "@xylabs/sdk-js";
|
|
7556
7549
|
import {
|
|
7557
7550
|
Account as Account3,
|
|
7558
7551
|
asAnyPayload as asAnyPayload6,
|
|
@@ -7596,7 +7589,7 @@ var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNu
|
|
|
7596
7589
|
};
|
|
7597
7590
|
|
|
7598
7591
|
// src/test/buildRandomGenesisBlock.ts
|
|
7599
|
-
var TestChainId =
|
|
7592
|
+
var TestChainId = assertEx55(asAddress("c5fe2e6F6841Cbab12d8C0618Be2DF8C6156cC44"));
|
|
7600
7593
|
|
|
7601
7594
|
// src/test/createGenesisBlock.ts
|
|
7602
7595
|
import { PayloadBuilder as PayloadBuilder28 } from "@xyo-network/sdk-js";
|
|
@@ -7651,7 +7644,7 @@ var createGenesisBlock = async (initialBlockProducer, nextContractAddress, genes
|
|
|
7651
7644
|
};
|
|
7652
7645
|
|
|
7653
7646
|
// src/test/buildRandomChain.ts
|
|
7654
|
-
var TestGenesisBlockRewardAddress =
|
|
7647
|
+
var TestGenesisBlockRewardAddress = assertEx56(asAddress2("fa7f0bb865a4bfff3d5e2c726d3e063297014da9"));
|
|
7655
7648
|
var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId, transactionAccount, receiverAddresses) => {
|
|
7656
7649
|
const chainIdToUse = chainId ?? TestChainId;
|
|
7657
7650
|
const blocks = [];
|
|
@@ -7695,7 +7688,7 @@ var buildRandomChain = async (blockProducer, count = 10, previousBlock, chainId,
|
|
|
7695
7688
|
receiverAddress
|
|
7696
7689
|
));
|
|
7697
7690
|
}
|
|
7698
|
-
const previousBlock2 =
|
|
7691
|
+
const previousBlock2 = assertEx56(lastBlock?.[0], () => new Error("No last block"));
|
|
7699
7692
|
const block = await buildNextBlock(previousBlock2, txs, [], [blockProducer], transactionAccountToUse.address);
|
|
7700
7693
|
blocks.push(block);
|
|
7701
7694
|
remaining = remaining - 1;
|
|
@@ -7756,13 +7749,13 @@ function getTestProviderContext2(config) {
|
|
|
7756
7749
|
}
|
|
7757
7750
|
|
|
7758
7751
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
7759
|
-
import { assertEx as
|
|
7752
|
+
import { assertEx as assertEx57 } from "@xylabs/sdk-js";
|
|
7760
7753
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
7761
7754
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
7762
7755
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
7763
7756
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
7764
7757
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
7765
|
-
return
|
|
7758
|
+
return assertEx57(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
7766
7759
|
}
|
|
7767
7760
|
|
|
7768
7761
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7973,6 +7966,7 @@ export {
|
|
|
7973
7966
|
buildRandomChainArchivist,
|
|
7974
7967
|
buildRandomTransaction,
|
|
7975
7968
|
buildTransaction,
|
|
7969
|
+
buildUnsignedBoundWitness,
|
|
7976
7970
|
buildUnsignedTransaction,
|
|
7977
7971
|
bundledPayloadToHydratedBlock,
|
|
7978
7972
|
bundledPayloadToHydratedTransaction,
|
|
@@ -8088,6 +8082,7 @@ export {
|
|
|
8088
8082
|
schemasStepSummaryFromRange,
|
|
8089
8083
|
schemasSummary,
|
|
8090
8084
|
scoreUncle,
|
|
8085
|
+
signBoundWitness,
|
|
8091
8086
|
signEIP712Message,
|
|
8092
8087
|
signTransaction,
|
|
8093
8088
|
splitOnDecimal,
|