@xyo-network/xl1-protocol-sdk 1.26.42 → 1.26.44
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/config/Actor.d.ts +4 -4
- package/dist/neutral/config/Actors.d.ts +4 -4
- package/dist/neutral/config/Base.d.ts +4 -4
- package/dist/neutral/config/Config.d.ts +8 -8
- package/dist/neutral/config/HostActor.d.ts +4 -4
- package/dist/neutral/config/Validation.d.ts +4 -4
- package/dist/neutral/config/Validation.d.ts.map +1 -1
- package/dist/neutral/context/Actor.d.ts +4 -4
- package/dist/neutral/context/HostActor.d.ts +4 -4
- package/dist/neutral/getFileConfig.mjs +5 -15
- package/dist/neutral/getFileConfig.mjs.map +1 -1
- package/dist/neutral/index.mjs +42 -33
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +4 -4
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +3 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +9 -19
- package/dist/neutral/test/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/neutral/index.mjs
CHANGED
|
@@ -956,7 +956,7 @@ var TelemetryConfigZod = z14.object({
|
|
|
956
956
|
}).describe("Telemetry configuration options");
|
|
957
957
|
|
|
958
958
|
// src/config/Validation.ts
|
|
959
|
-
import { AddressZod as AddressZod2
|
|
959
|
+
import { AddressZod as AddressZod2 } from "@xylabs/sdk-js";
|
|
960
960
|
import { globalRegistry as globalRegistry11, z as z15 } from "zod";
|
|
961
961
|
|
|
962
962
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
@@ -1891,26 +1891,16 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
1891
1891
|
|
|
1892
1892
|
// src/config/Validation.ts
|
|
1893
1893
|
var ValidationConfigZod = z15.object({
|
|
1894
|
-
allowedRewardRedeemers: z15.
|
|
1895
|
-
if (typeof val === "string") {
|
|
1896
|
-
return val.split(",").map((s) => asAddress(s.trim()));
|
|
1897
|
-
}
|
|
1898
|
-
return val;
|
|
1899
|
-
}, z15.array(AddressZod2).optional().register(globalRegistry11, {
|
|
1894
|
+
allowedRewardRedeemers: z15.array(AddressZod2).optional().register(globalRegistry11, {
|
|
1900
1895
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
1901
1896
|
title: "allowedRewardRedeemers",
|
|
1902
1897
|
type: "array"
|
|
1903
|
-
})
|
|
1904
|
-
allowedRewardEscrowAccountSigners: z15.
|
|
1905
|
-
if (typeof val === "string") {
|
|
1906
|
-
return val.split(",").map((s) => asAddress(s.trim()));
|
|
1907
|
-
}
|
|
1908
|
-
return val;
|
|
1909
|
-
}, z15.array(AddressZod2).optional().register(globalRegistry11, {
|
|
1898
|
+
}),
|
|
1899
|
+
allowedRewardEscrowAccountSigners: z15.array(AddressZod2).optional().register(globalRegistry11, {
|
|
1910
1900
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
1911
1901
|
title: "allowedRewardEscrowAccountSigners",
|
|
1912
1902
|
type: "array"
|
|
1913
|
-
})
|
|
1903
|
+
}),
|
|
1914
1904
|
minCandidates: z15.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry11, {
|
|
1915
1905
|
default: DEFAULT_MIN_CANDIDATES,
|
|
1916
1906
|
description: "Minimum number of uncle candidates before selecting the best uncle",
|
|
@@ -3216,7 +3206,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3216
3206
|
|
|
3217
3207
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3218
3208
|
import {
|
|
3219
|
-
asAddress
|
|
3209
|
+
asAddress,
|
|
3220
3210
|
assertEx as assertEx26,
|
|
3221
3211
|
spanRootAsync as spanRootAsync3
|
|
3222
3212
|
} from "@xylabs/sdk-js";
|
|
@@ -3240,7 +3230,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3240
3230
|
const balances = {};
|
|
3241
3231
|
for (const summary of summaries) {
|
|
3242
3232
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
3243
|
-
const validAddress =
|
|
3233
|
+
const validAddress = asAddress(address, () => `Invalid address: ${address}`);
|
|
3244
3234
|
balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance);
|
|
3245
3235
|
}
|
|
3246
3236
|
}
|
|
@@ -3430,7 +3420,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3430
3420
|
|
|
3431
3421
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3432
3422
|
import {
|
|
3433
|
-
asAddress as
|
|
3423
|
+
asAddress as asAddress2,
|
|
3434
3424
|
assertEx as assertEx30,
|
|
3435
3425
|
spanRootAsync as spanRootAsync6
|
|
3436
3426
|
} from "@xylabs/sdk-js";
|
|
@@ -3454,10 +3444,10 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3454
3444
|
const transfers = {};
|
|
3455
3445
|
for (const summary of summaries) {
|
|
3456
3446
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
3457
|
-
const validFrom =
|
|
3447
|
+
const validFrom = asAddress2(from, () => `Invalid address: ${from}`);
|
|
3458
3448
|
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
3459
3449
|
for (const [to, transfer] of Object.entries(toMap)) {
|
|
3460
|
-
const validTo =
|
|
3450
|
+
const validTo = asAddress2(to, () => `Invalid address: ${to}`);
|
|
3461
3451
|
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
3462
3452
|
}
|
|
3463
3453
|
}
|
|
@@ -4588,11 +4578,13 @@ import {
|
|
|
4588
4578
|
import {
|
|
4589
4579
|
BlockValidationViewerMoniker as BlockValidationViewerMoniker2,
|
|
4590
4580
|
ChainContractViewerMoniker as ChainContractViewerMoniker4,
|
|
4581
|
+
DeadLetterQueueRunnerMoniker,
|
|
4591
4582
|
DEFAULT_MAX_EXP_AHEAD,
|
|
4592
4583
|
FinalizationViewerMoniker as FinalizationViewerMoniker4,
|
|
4593
4584
|
isSignedHydratedBlockWithHashMeta,
|
|
4594
4585
|
isSignedHydratedTransactionWithHashMeta,
|
|
4595
4586
|
MempoolRunnerMoniker,
|
|
4587
|
+
TransactionRejectionSchema,
|
|
4596
4588
|
TransactionValidationViewerMoniker
|
|
4597
4589
|
} from "@xyo-network/xl1-protocol-lib";
|
|
4598
4590
|
import { Mutex } from "async-mutex";
|
|
@@ -4602,6 +4594,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4602
4594
|
moniker = SimpleMempoolRunner.defaultMoniker;
|
|
4603
4595
|
_blockValidationViewer;
|
|
4604
4596
|
_chainContractViewer;
|
|
4597
|
+
_deadLetterQueueRunner;
|
|
4605
4598
|
_finalizationViewer;
|
|
4606
4599
|
_transactionValidationViewer;
|
|
4607
4600
|
_syncMutex = new Mutex();
|
|
@@ -4649,6 +4642,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4649
4642
|
this._chainContractViewer = await this.locator.getInstance(ChainContractViewerMoniker4);
|
|
4650
4643
|
this._finalizationViewer = await this.locator.getInstance(FinalizationViewerMoniker4);
|
|
4651
4644
|
this._transactionValidationViewer = await this.locator.getInstance(TransactionValidationViewerMoniker);
|
|
4645
|
+
this._deadLetterQueueRunner = await this.locator.tryGetInstance(DeadLetterQueueRunnerMoniker);
|
|
4652
4646
|
}
|
|
4653
4647
|
async prunePendingBlocks({
|
|
4654
4648
|
batchSize = 10,
|
|
@@ -4751,6 +4745,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4751
4745
|
if (!validated) {
|
|
4752
4746
|
this.logger?.debug(`Pruning transaction ${bundles[remainingTransactionMap[i]]._hash} during transaction validation`);
|
|
4753
4747
|
this.logger?.debug(` - validation result: ${r.at(0)?.message}`);
|
|
4748
|
+
await this.routeRejectedTransaction(remainingTransactions[i], r);
|
|
4754
4749
|
}
|
|
4755
4750
|
valid[remainingTransactionMap[i]] = validated;
|
|
4756
4751
|
}
|
|
@@ -4819,6 +4814,20 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4819
4814
|
this._syncTimerId = null;
|
|
4820
4815
|
}
|
|
4821
4816
|
}
|
|
4817
|
+
async routeRejectedTransaction(transaction, errors) {
|
|
4818
|
+
if (!this._deadLetterQueueRunner) return;
|
|
4819
|
+
const rejectionErrors = errors.map((e) => ({
|
|
4820
|
+
hash: transaction[0]._hash,
|
|
4821
|
+
name: e.name ?? "TransactionStateValidationError",
|
|
4822
|
+
message: String(e.message ?? e)
|
|
4823
|
+
}));
|
|
4824
|
+
await this._deadLetterQueueRunner.rejectTransaction({
|
|
4825
|
+
schema: TransactionRejectionSchema,
|
|
4826
|
+
transaction,
|
|
4827
|
+
errors: rejectionErrors,
|
|
4828
|
+
rejector: "mempool"
|
|
4829
|
+
});
|
|
4830
|
+
}
|
|
4822
4831
|
async simpleBlockValidationCheck(payloads) {
|
|
4823
4832
|
const headNumber = await this.finalizationViewer.headNumber();
|
|
4824
4833
|
const chainId = await this.chainContractViewer.chainId();
|
|
@@ -5376,7 +5385,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
5376
5385
|
], SimpleStakeEventsViewer);
|
|
5377
5386
|
|
|
5378
5387
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
5379
|
-
import { asAddress as
|
|
5388
|
+
import { asAddress as asAddress3 } from "@xylabs/sdk-js";
|
|
5380
5389
|
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5381
5390
|
import {
|
|
5382
5391
|
StakeTotalsViewerMoniker,
|
|
@@ -5402,7 +5411,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
5402
5411
|
let active = 0n;
|
|
5403
5412
|
const positions = await this.stakeViewer.activeStakes();
|
|
5404
5413
|
for (const position of positions) {
|
|
5405
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
5414
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress3(position.staked) === asAddress3(staked)) {
|
|
5406
5415
|
active += position.amount;
|
|
5407
5416
|
}
|
|
5408
5417
|
}
|
|
@@ -5412,7 +5421,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
5412
5421
|
let active = 0n;
|
|
5413
5422
|
const positions = await this.stakeViewer.activeStakes();
|
|
5414
5423
|
for (const position of positions) {
|
|
5415
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
5424
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asAddress3(position.staker) === asAddress3(staker)) {
|
|
5416
5425
|
active += position.amount;
|
|
5417
5426
|
}
|
|
5418
5427
|
}
|
|
@@ -5439,7 +5448,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
5439
5448
|
let pending = 0n;
|
|
5440
5449
|
const positions = await this.stakeViewer.removedStakes();
|
|
5441
5450
|
for (const position of positions) {
|
|
5442
|
-
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) &&
|
|
5451
|
+
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) && asAddress3(position.staker) === asAddress3(staker)) {
|
|
5443
5452
|
pending += position.amount;
|
|
5444
5453
|
}
|
|
5445
5454
|
}
|
|
@@ -5459,7 +5468,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
5459
5468
|
let withdrawn = 0n;
|
|
5460
5469
|
const positions = await this.stakeViewer.withdrawnStakes();
|
|
5461
5470
|
for (const position of positions) {
|
|
5462
|
-
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time &&
|
|
5471
|
+
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time && asAddress3(position.staker) === asAddress3(staker)) {
|
|
5463
5472
|
withdrawn += position.amount;
|
|
5464
5473
|
}
|
|
5465
5474
|
}
|
|
@@ -5475,7 +5484,7 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
5475
5484
|
|
|
5476
5485
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
5477
5486
|
import {
|
|
5478
|
-
asAddress as
|
|
5487
|
+
asAddress as asAddress4,
|
|
5479
5488
|
toAddress as toAddress6
|
|
5480
5489
|
} from "@xylabs/sdk-js";
|
|
5481
5490
|
import { assertEx as assertEx42 } from "@xylabs/sdk-js";
|
|
@@ -5506,7 +5515,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5506
5515
|
let active = 0n;
|
|
5507
5516
|
const positions = await this.activeStakes();
|
|
5508
5517
|
for (const position of positions) {
|
|
5509
|
-
if (position.removeBlock === 0 &&
|
|
5518
|
+
if (position.removeBlock === 0 && asAddress4(position.staked) === asAddress4(staked)) {
|
|
5510
5519
|
active += position.amount;
|
|
5511
5520
|
}
|
|
5512
5521
|
}
|
|
@@ -5516,7 +5525,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5516
5525
|
let active = 0n;
|
|
5517
5526
|
const positions = await this.activeStakes();
|
|
5518
5527
|
for (const position of positions) {
|
|
5519
|
-
if (position.removeBlock === 0 &&
|
|
5528
|
+
if (position.removeBlock === 0 && asAddress4(position.staker) === asAddress4(staker)) {
|
|
5520
5529
|
active += position.amount;
|
|
5521
5530
|
}
|
|
5522
5531
|
}
|
|
@@ -5549,7 +5558,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5549
5558
|
let pending = 0n;
|
|
5550
5559
|
const positions = await this.removedStakes();
|
|
5551
5560
|
for (const position of positions) {
|
|
5552
|
-
if (position.removeBlock !== 0 && position.withdrawBlock === 0 &&
|
|
5561
|
+
if (position.removeBlock !== 0 && position.withdrawBlock === 0 && asAddress4(position.staker) === asAddress4(staker)) {
|
|
5553
5562
|
pending += position.amount;
|
|
5554
5563
|
}
|
|
5555
5564
|
}
|
|
@@ -5565,15 +5574,15 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5565
5574
|
return assertEx42(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
5566
5575
|
}
|
|
5567
5576
|
stakeByStaker(staker, slot) {
|
|
5568
|
-
return this.positions.filter((s) =>
|
|
5577
|
+
return this.positions.filter((s) => asAddress4(s.staker) === asAddress4(staker))[slot];
|
|
5569
5578
|
}
|
|
5570
5579
|
stakesByStaked(staked, range = [0, void 0]) {
|
|
5571
5580
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
5572
|
-
return this.positions.filter((s) =>
|
|
5581
|
+
return this.positions.filter((s) => asAddress4(s.staked) === asAddress4(staked) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
5573
5582
|
}
|
|
5574
5583
|
stakesByStaker(staker, range = [0, void 0]) {
|
|
5575
5584
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
5576
|
-
return this.positions.filter((s) =>
|
|
5585
|
+
return this.positions.filter((s) => asAddress4(s.staker) === asAddress4(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
5577
5586
|
}
|
|
5578
5587
|
stakingTokenAddress() {
|
|
5579
5588
|
return toAddress6("0x000000000000000000000000000011");
|
|
@@ -5592,7 +5601,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5592
5601
|
let withdrawn = 0n;
|
|
5593
5602
|
const positions = await this.withdrawnStakes();
|
|
5594
5603
|
for (const position of positions) {
|
|
5595
|
-
if (position.withdrawBlock !== 0 &&
|
|
5604
|
+
if (position.withdrawBlock !== 0 && asAddress4(position.staker) === asAddress4(staker)) {
|
|
5596
5605
|
withdrawn += position.amount;
|
|
5597
5606
|
}
|
|
5598
5607
|
}
|