@xyo-network/xl1-protocol-sdk 2.0.8 → 2.0.10
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/block/hydrate/createBoundWitnessHydrator.d.ts +12 -12
- package/dist/neutral/block/primitives/frames/deepCalculateFramesFromRange.d.ts +7 -1
- package/dist/neutral/block/primitives/frames/deepCalculateFramesFromRange.d.ts.map +1 -1
- 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 +198 -210
- package/dist/neutral/index.mjs.map +4 -4
- 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/block/SimpleBlockViewer.d.ts +2 -2
- 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/finalization/SimpleFinalizationViewer.d.ts +2 -2
- 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/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +10 -10
- 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/balancesMaxStep.d.ts +9 -0
- package/dist/neutral/summary/primitives/balances/balancesMaxStep.d.ts.map +1 -0
- 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/balances/index.d.ts +1 -0
- package/dist/neutral/summary/primitives/balances/index.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/index.d.ts +1 -0
- package/dist/neutral/summary/primitives/schemas/index.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/schemasMaxStep.d.ts +8 -0
- package/dist/neutral/summary/primitives/schemas/schemasMaxStep.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/index.d.ts +1 -0
- package/dist/neutral/summary/primitives/transfers/index.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersMaxStep.d.ts +10 -0
- package/dist/neutral/summary/primitives/transfers/transfersMaxStep.d.ts.map +1 -0
- 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 +8 -8
- 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 +4 -4
- package/package.json +15 -13
package/dist/neutral/index.mjs
CHANGED
|
@@ -873,10 +873,11 @@ function calculateFramesFromRange(range, step) {
|
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
876
|
-
|
|
876
|
+
import { StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol-lib";
|
|
877
|
+
function deepCalculateFramesFromRange(range, startingStep = StepSizes2.length - 1) {
|
|
877
878
|
const fitted = [];
|
|
878
879
|
let remaining = [range];
|
|
879
|
-
const actualStartingStep = Math.min(startingStep,
|
|
880
|
+
const actualStartingStep = Math.min(startingStep, StepSizes2.length - 1);
|
|
880
881
|
for (let step = actualStartingStep; step >= 0; step--) {
|
|
881
882
|
const newRemaining = [];
|
|
882
883
|
for (const range2 of remaining) {
|
|
@@ -1246,7 +1247,8 @@ import { globalRegistry as globalRegistry12, z as z17 } from "zod/mini";
|
|
|
1246
1247
|
import { z as z16 } from "zod/mini";
|
|
1247
1248
|
|
|
1248
1249
|
// src/config/Chain.ts
|
|
1249
|
-
import {
|
|
1250
|
+
import { HexZod } from "@xylabs/sdk-js";
|
|
1251
|
+
import { XyoAddressZod } from "@xyo-network/address";
|
|
1250
1252
|
import { globalRegistry, z as z2 } from "zod/mini";
|
|
1251
1253
|
var ChainConfigZod = z2.object({
|
|
1252
1254
|
id: z2.optional(HexZod).register(globalRegistry, {
|
|
@@ -1254,7 +1256,7 @@ var ChainConfigZod = z2.object({
|
|
|
1254
1256
|
title: "chain.id",
|
|
1255
1257
|
type: "string"
|
|
1256
1258
|
}),
|
|
1257
|
-
genesisRewardAddress: z2.optional(
|
|
1259
|
+
genesisRewardAddress: z2.optional(XyoAddressZod).register(globalRegistry, {
|
|
1258
1260
|
description: "Address to send the initial genesis rewards to, if a new chain is being created.",
|
|
1259
1261
|
title: "chain.genesisRewardAddress",
|
|
1260
1262
|
type: "Address"
|
|
@@ -1497,15 +1499,15 @@ var TelemetryConfigZod = z14.object({
|
|
|
1497
1499
|
}).describe("Telemetry configuration options");
|
|
1498
1500
|
|
|
1499
1501
|
// src/config/Validation.ts
|
|
1500
|
-
import {
|
|
1502
|
+
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/address";
|
|
1501
1503
|
import { globalRegistry as globalRegistry11, z as z15 } from "zod";
|
|
1502
1504
|
|
|
1503
1505
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
1504
|
-
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as
|
|
1506
|
+
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
|
|
1505
1507
|
function blockRangeSteps(range, steps) {
|
|
1506
1508
|
const result = [];
|
|
1507
1509
|
for (const step of steps) {
|
|
1508
|
-
const stepSize2 =
|
|
1510
|
+
const stepSize2 = StepSizes3[step];
|
|
1509
1511
|
const startOfFirstStepCandidate = range[0] - range[0] % stepSize2 + stepSize2;
|
|
1510
1512
|
const startOfFirstStep = asXL1BlockNumber2(
|
|
1511
1513
|
startOfFirstStepCandidate,
|
|
@@ -1618,7 +1620,7 @@ import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
|
1618
1620
|
import {
|
|
1619
1621
|
asXL1BlockRange as asXL1BlockRange2,
|
|
1620
1622
|
isValidStep,
|
|
1621
|
-
StepSizes as
|
|
1623
|
+
StepSizes as StepSizes4
|
|
1622
1624
|
} from "@xyo-network/xl1-protocol-lib";
|
|
1623
1625
|
var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
1624
1626
|
const end = start + step * count;
|
|
@@ -1627,7 +1629,7 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
|
1627
1629
|
};
|
|
1628
1630
|
var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
|
|
1629
1631
|
assertEx9(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
|
|
1630
|
-
const step =
|
|
1632
|
+
const step = StepSizes4[stepIndex];
|
|
1631
1633
|
return await stepRate(viewer, start, step, count, timeUnit);
|
|
1632
1634
|
};
|
|
1633
1635
|
|
|
@@ -1743,11 +1745,8 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1743
1745
|
}
|
|
1744
1746
|
|
|
1745
1747
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
1746
|
-
import {
|
|
1747
|
-
|
|
1748
|
-
exists,
|
|
1749
|
-
toAddress as toAddress2
|
|
1750
|
-
} from "@xylabs/sdk-js";
|
|
1748
|
+
import { assertEx as assertEx14, exists } from "@xylabs/sdk-js";
|
|
1749
|
+
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/address";
|
|
1751
1750
|
import {
|
|
1752
1751
|
asTransfer,
|
|
1753
1752
|
isTransfer,
|
|
@@ -1755,13 +1754,14 @@ import {
|
|
|
1755
1754
|
} from "@xyo-network/xl1-protocol-lib";
|
|
1756
1755
|
|
|
1757
1756
|
// src/primitives/payload/mergeTransfers.ts
|
|
1758
|
-
import { hexToBigInt
|
|
1757
|
+
import { hexToBigInt } from "@xylabs/sdk-js";
|
|
1758
|
+
import { toXyoAddress } from "@xyo-network/address";
|
|
1759
1759
|
function mergeTransfers(transfers) {
|
|
1760
1760
|
const result = {};
|
|
1761
1761
|
for (const transfer of transfers) {
|
|
1762
1762
|
result[transfer.from] = result[transfer.from] ?? {};
|
|
1763
1763
|
for (const [to, value] of Object.entries(transfer.transfers)) {
|
|
1764
|
-
const typedTo =
|
|
1764
|
+
const typedTo = toXyoAddress(to, true);
|
|
1765
1765
|
result[transfer.from][typedTo] = (result[transfer.from][typedTo] ?? 0n) + hexToBigInt(value);
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
@@ -1769,23 +1769,23 @@ function mergeTransfers(transfers) {
|
|
|
1769
1769
|
}
|
|
1770
1770
|
|
|
1771
1771
|
// src/primitives/step/stepBlockRange.ts
|
|
1772
|
-
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as
|
|
1772
|
+
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
|
|
1773
1773
|
function stepBlockRange({ block, step }) {
|
|
1774
|
-
const stepSize2 =
|
|
1774
|
+
const stepSize2 = StepSizes5[step];
|
|
1775
1775
|
const start = block - stepSize2;
|
|
1776
1776
|
return asXL1BlockRange4([start, start + stepSize2 - 1], { name: "stepBlockRange" });
|
|
1777
1777
|
}
|
|
1778
1778
|
|
|
1779
1779
|
// src/primitives/step/stepTransferIndex.ts
|
|
1780
1780
|
import { assertEx as assertEx12 } from "@xylabs/sdk-js";
|
|
1781
|
-
import { StepSizes as
|
|
1781
|
+
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
|
|
1782
1782
|
function stepTransferIndex(block, step) {
|
|
1783
1783
|
let rewardTransferCount = 0;
|
|
1784
1784
|
let rewardTransferIndex = -1;
|
|
1785
|
-
for (let i = 3; i <
|
|
1786
|
-
const stepSize2 =
|
|
1785
|
+
for (let i = 3; i < StepSizes6.length; i++) {
|
|
1786
|
+
const stepSize2 = StepSizes6[i];
|
|
1787
1787
|
if (block % stepSize2 === 0) {
|
|
1788
|
-
if (stepSize2 ===
|
|
1788
|
+
if (stepSize2 === StepSizes6[step]) {
|
|
1789
1789
|
rewardTransferIndex = rewardTransferCount;
|
|
1790
1790
|
}
|
|
1791
1791
|
rewardTransferCount++;
|
|
@@ -1797,9 +1797,9 @@ function stepTransferIndex(block, step) {
|
|
|
1797
1797
|
|
|
1798
1798
|
// src/primitives/chain/step/stepRewardBlock.ts
|
|
1799
1799
|
import { assertEx as assertEx13 } from "@xylabs/sdk-js";
|
|
1800
|
-
import { StepSizes as
|
|
1800
|
+
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
1801
1801
|
async function stepRewardBlock(context, blockViewer, { block, step }) {
|
|
1802
|
-
assertEx13(block %
|
|
1802
|
+
assertEx13(block % StepSizes7[step] === 0, () => `Block must be the first block of the step [${StepSizes7[step]}], got ${block}`);
|
|
1803
1803
|
return assertEx13(await blockViewer.blockByNumber(block), () => `Could not find block for block number ${block}`);
|
|
1804
1804
|
}
|
|
1805
1805
|
|
|
@@ -1815,7 +1815,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1815
1815
|
sortedTransferAmounts.length === transferCount,
|
|
1816
1816
|
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`
|
|
1817
1817
|
);
|
|
1818
|
-
return
|
|
1818
|
+
return toXyoAddress2(sortedTransferAmounts[transferIndex][0], true);
|
|
1819
1819
|
}
|
|
1820
1820
|
|
|
1821
1821
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
@@ -1839,11 +1839,9 @@ var asAddressPairPayload = AsObjectFactory.create(isAddressPairPayload);
|
|
|
1839
1839
|
var asOptionalAddressPairPayload = AsObjectFactory.createOptional(isAddressPairPayload);
|
|
1840
1840
|
|
|
1841
1841
|
// src/payloads/netBalancesForPayloads.ts
|
|
1842
|
-
import {
|
|
1843
|
-
hexToBigInt as hexToBigInt2,
|
|
1844
|
-
toAddress as toAddress3
|
|
1845
|
-
} from "@xylabs/sdk-js";
|
|
1842
|
+
import { hexToBigInt as hexToBigInt2 } from "@xylabs/sdk-js";
|
|
1846
1843
|
import { span } from "@xylabs/sdk-js";
|
|
1844
|
+
import { toXyoAddress as toXyoAddress3 } from "@xyo-network/address";
|
|
1847
1845
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
1848
1846
|
var netBalancesForPayloads = (context, payloads) => {
|
|
1849
1847
|
return span("netBalancesForPayloads", () => {
|
|
@@ -1852,8 +1850,8 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1852
1850
|
if (isTransfer2(payload)) {
|
|
1853
1851
|
const { from } = payload;
|
|
1854
1852
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1855
|
-
balances[
|
|
1856
|
-
balances[
|
|
1853
|
+
balances[toXyoAddress3(address, true)] = (balances[toXyoAddress3(address, true)] ?? 0n) + hexToBigInt2(amount);
|
|
1854
|
+
balances[toXyoAddress3(from, true)] = (balances[toXyoAddress3(from, true)] ?? 0n) - hexToBigInt2(amount);
|
|
1857
1855
|
}
|
|
1858
1856
|
}
|
|
1859
1857
|
}
|
|
@@ -1862,11 +1860,9 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1862
1860
|
};
|
|
1863
1861
|
|
|
1864
1862
|
// src/payloads/netSchemasForPayloads.ts
|
|
1865
|
-
import {
|
|
1866
|
-
hexToBigInt as hexToBigInt3,
|
|
1867
|
-
toAddress as toAddress4
|
|
1868
|
-
} from "@xylabs/sdk-js";
|
|
1863
|
+
import { hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
1869
1864
|
import { span as span2 } from "@xylabs/sdk-js";
|
|
1865
|
+
import { toXyoAddress as toXyoAddress4 } from "@xyo-network/address";
|
|
1870
1866
|
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol-lib";
|
|
1871
1867
|
var netSchemasForPayloads = (context, payloads) => {
|
|
1872
1868
|
return span2("netSchemasForPayloads", () => {
|
|
@@ -1875,8 +1871,8 @@ var netSchemasForPayloads = (context, payloads) => {
|
|
|
1875
1871
|
if (isTransfer3(payload)) {
|
|
1876
1872
|
const { from } = payload;
|
|
1877
1873
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1878
|
-
balances[
|
|
1879
|
-
balances[
|
|
1874
|
+
balances[toXyoAddress4(address, true)] = (balances[toXyoAddress4(address, true)] ?? 0n) + hexToBigInt3(amount);
|
|
1875
|
+
balances[toXyoAddress4(from, true)] = (balances[toXyoAddress4(from, true)] ?? 0n) - hexToBigInt3(amount);
|
|
1880
1876
|
}
|
|
1881
1877
|
}
|
|
1882
1878
|
}
|
|
@@ -1885,9 +1881,7 @@ var netSchemasForPayloads = (context, payloads) => {
|
|
|
1885
1881
|
};
|
|
1886
1882
|
|
|
1887
1883
|
// src/payloads/netTransfersForPayloads.ts
|
|
1888
|
-
import {
|
|
1889
|
-
hexToBigInt as hexToBigInt4
|
|
1890
|
-
} from "@xylabs/sdk-js";
|
|
1884
|
+
import { hexToBigInt as hexToBigInt4 } from "@xylabs/sdk-js";
|
|
1891
1885
|
import { span as span3 } from "@xylabs/sdk-js";
|
|
1892
1886
|
import { isTransfer as isTransfer4 } from "@xyo-network/xl1-protocol-lib";
|
|
1893
1887
|
function netTransfersForPayloads(context, payloads) {
|
|
@@ -2170,14 +2164,12 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
|
|
|
2170
2164
|
}
|
|
2171
2165
|
|
|
2172
2166
|
// src/primitives/stake/allStakersForRange.ts
|
|
2173
|
-
import {
|
|
2174
|
-
toAddress as toAddress5
|
|
2175
|
-
} from "@xylabs/sdk-js";
|
|
2167
|
+
import { toXyoAddress as toXyoAddress5 } from "@xyo-network/address";
|
|
2176
2168
|
async function allStakersForRange(chain, externalRange, staked) {
|
|
2177
2169
|
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, externalRange[1]], staked);
|
|
2178
2170
|
const resultWithZeros = {};
|
|
2179
2171
|
for (const event of mergedEvents) {
|
|
2180
|
-
const staker =
|
|
2172
|
+
const staker = toXyoAddress5(event.args.staker, true);
|
|
2181
2173
|
resultWithZeros[staker] = resultWithZeros[staker] ?? 0n;
|
|
2182
2174
|
if (event.name === "StakeAdded") {
|
|
2183
2175
|
resultWithZeros[staker] += event.args.amount;
|
|
@@ -2188,7 +2180,7 @@ async function allStakersForRange(chain, externalRange, staked) {
|
|
|
2188
2180
|
const nonZero = Object.entries(resultWithZeros).filter(([, amount]) => amount > 0n).map(([address]) => address);
|
|
2189
2181
|
const result = {};
|
|
2190
2182
|
for (const address of nonZero) {
|
|
2191
|
-
result[
|
|
2183
|
+
result[toXyoAddress5(address, true)] = resultWithZeros[toXyoAddress5(address, true)];
|
|
2192
2184
|
}
|
|
2193
2185
|
return result;
|
|
2194
2186
|
}
|
|
@@ -2408,12 +2400,12 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2408
2400
|
|
|
2409
2401
|
// src/config/Validation.ts
|
|
2410
2402
|
var ValidationConfigZod = z15.object({
|
|
2411
|
-
allowedRewardRedeemers: z15.array(
|
|
2403
|
+
allowedRewardRedeemers: z15.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
2412
2404
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
2413
2405
|
title: "allowedRewardRedeemers",
|
|
2414
2406
|
type: "array"
|
|
2415
2407
|
}),
|
|
2416
|
-
allowedRewardEscrowAccountSigners: z15.array(
|
|
2408
|
+
allowedRewardEscrowAccountSigners: z15.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
2417
2409
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2418
2410
|
title: "allowedRewardEscrowAccountSigners",
|
|
2419
2411
|
type: "array"
|
|
@@ -2621,7 +2613,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
2621
2613
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
2622
2614
|
|
|
2623
2615
|
// src/transaction/buildTransaction.ts
|
|
2624
|
-
import {
|
|
2616
|
+
import { assertEx as assertEx19, toHex } from "@xylabs/sdk-js";
|
|
2625
2617
|
import {
|
|
2626
2618
|
asAnyPayload as asAnyPayload2,
|
|
2627
2619
|
BoundWitnessBuilder,
|
|
@@ -2650,7 +2642,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2650
2642
|
}
|
|
2651
2643
|
const fields = {
|
|
2652
2644
|
...txBoundWitnessFields,
|
|
2653
|
-
from: from ??
|
|
2645
|
+
from: from ?? (Array.isArray(signer) ? assertEx19(signer.at(0)?.address) : signer.address)
|
|
2654
2646
|
};
|
|
2655
2647
|
if (script.length > 0) {
|
|
2656
2648
|
fields.script = script;
|
|
@@ -2736,7 +2728,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2736
2728
|
};
|
|
2737
2729
|
|
|
2738
2730
|
// src/transaction/hydrateTransaction.ts
|
|
2739
|
-
import { assertEx as
|
|
2731
|
+
import { assertEx as assertEx20 } from "@xylabs/sdk-js";
|
|
2740
2732
|
import {
|
|
2741
2733
|
asAnyPayload as asAnyPayload3,
|
|
2742
2734
|
hydrateTypedBoundWitness,
|
|
@@ -2811,7 +2803,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
2811
2803
|
return void 0;
|
|
2812
2804
|
};
|
|
2813
2805
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
2814
|
-
return
|
|
2806
|
+
return assertEx20(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
2815
2807
|
};
|
|
2816
2808
|
|
|
2817
2809
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -2864,13 +2856,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
2864
2856
|
|
|
2865
2857
|
// src/transaction/signTransaction.ts
|
|
2866
2858
|
import {
|
|
2867
|
-
assertEx as
|
|
2859
|
+
assertEx as assertEx21,
|
|
2868
2860
|
hexFromArrayBuffer,
|
|
2869
2861
|
toArrayBuffer
|
|
2870
2862
|
} from "@xylabs/sdk-js";
|
|
2871
2863
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
2872
2864
|
async function signTransaction(tx, account) {
|
|
2873
|
-
|
|
2865
|
+
assertEx21(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2874
2866
|
const unsignedTx = structuredClone(tx);
|
|
2875
2867
|
unsignedTx.addresses = [account.address];
|
|
2876
2868
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -2885,11 +2877,7 @@ async function signTransaction(tx, account) {
|
|
|
2885
2877
|
}
|
|
2886
2878
|
|
|
2887
2879
|
// src/transaction/TransactionBuilder.ts
|
|
2888
|
-
import {
|
|
2889
|
-
asAddress as asAddress2,
|
|
2890
|
-
assertEx as assertEx21,
|
|
2891
|
-
Base
|
|
2892
|
-
} from "@xylabs/sdk-js";
|
|
2880
|
+
import { assertEx as assertEx22, Base } from "@xylabs/sdk-js";
|
|
2893
2881
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
2894
2882
|
import {
|
|
2895
2883
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -2909,9 +2897,9 @@ var TransactionBuilder = class extends Base {
|
|
|
2909
2897
|
super(options);
|
|
2910
2898
|
}
|
|
2911
2899
|
async build() {
|
|
2912
|
-
const chain =
|
|
2913
|
-
const fees =
|
|
2914
|
-
const blockRange =
|
|
2900
|
+
const chain = assertEx22(this._chain, () => "Chain must be set before building the transaction");
|
|
2901
|
+
const fees = assertEx22(this._fees, () => "Fees must be set before building the transaction");
|
|
2902
|
+
const blockRange = assertEx22(this._blockRange, () => "Block range must be set before building the transaction");
|
|
2915
2903
|
return await buildTransaction(
|
|
2916
2904
|
chain,
|
|
2917
2905
|
this._elevatedPayloads,
|
|
@@ -2919,7 +2907,7 @@ var TransactionBuilder = class extends Base {
|
|
|
2919
2907
|
this._signers,
|
|
2920
2908
|
asXL1BlockNumber4(blockRange[0], true),
|
|
2921
2909
|
asXL1BlockNumber4(blockRange[1], true),
|
|
2922
|
-
|
|
2910
|
+
this._signers[0]?.address,
|
|
2923
2911
|
fees
|
|
2924
2912
|
);
|
|
2925
2913
|
}
|
|
@@ -2935,13 +2923,13 @@ var TransactionBuilder = class extends Base {
|
|
|
2935
2923
|
this._signers,
|
|
2936
2924
|
asXL1BlockNumber4(0, true),
|
|
2937
2925
|
asXL1BlockNumber4(1e3, true),
|
|
2938
|
-
|
|
2926
|
+
this._signers[0]?.address,
|
|
2939
2927
|
defaultTransactionFees3
|
|
2940
2928
|
);
|
|
2941
2929
|
}
|
|
2942
2930
|
elevatedPayload(payload) {
|
|
2943
2931
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
2944
|
-
const allowPayloadExists =
|
|
2932
|
+
const allowPayloadExists = assertEx22(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
2945
2933
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
2946
2934
|
return this;
|
|
2947
2935
|
}
|
|
@@ -3043,12 +3031,12 @@ var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigConte
|
|
|
3043
3031
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3044
3032
|
import {
|
|
3045
3033
|
AbstractCreatable,
|
|
3046
|
-
assertEx as
|
|
3034
|
+
assertEx as assertEx24,
|
|
3047
3035
|
IdLogger
|
|
3048
3036
|
} from "@xylabs/sdk-js";
|
|
3049
3037
|
|
|
3050
3038
|
// src/CreatableProvider/ProviderFactory.ts
|
|
3051
|
-
import { assertEx as
|
|
3039
|
+
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3052
3040
|
function providerFactoryDescription(factory, labels) {
|
|
3053
3041
|
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
3054
3042
|
}
|
|
@@ -3069,7 +3057,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3069
3057
|
this.dependencies = dependencies;
|
|
3070
3058
|
this.monikers = creatableProvider2.monikers;
|
|
3071
3059
|
this.scope = scope;
|
|
3072
|
-
|
|
3060
|
+
assertEx23(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
3073
3061
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
3074
3062
|
this.providerName = creatableProvider2.name;
|
|
3075
3063
|
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
@@ -3097,7 +3085,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3097
3085
|
break;
|
|
3098
3086
|
}
|
|
3099
3087
|
case "context": {
|
|
3100
|
-
const context =
|
|
3088
|
+
const context = assertEx23(
|
|
3101
3089
|
params?.context,
|
|
3102
3090
|
() => "Context is required for context-scoped providers"
|
|
3103
3091
|
);
|
|
@@ -3118,7 +3106,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3118
3106
|
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
3119
3107
|
const result = await resultPromise;
|
|
3120
3108
|
if (start) {
|
|
3121
|
-
|
|
3109
|
+
assertEx23(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
3122
3110
|
}
|
|
3123
3111
|
return result;
|
|
3124
3112
|
}
|
|
@@ -3163,9 +3151,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3163
3151
|
return factory;
|
|
3164
3152
|
}
|
|
3165
3153
|
static async paramsHandler(params = {}) {
|
|
3166
|
-
const context =
|
|
3167
|
-
const config =
|
|
3168
|
-
const locator =
|
|
3154
|
+
const context = assertEx24(params.context, () => new Error("Context is required"));
|
|
3155
|
+
const config = assertEx24(context.config, () => new Error("Context config is required"));
|
|
3156
|
+
const locator = assertEx24(context.locator, () => new Error("Context locator is required"));
|
|
3169
3157
|
return await super.paramsHandler({
|
|
3170
3158
|
...params,
|
|
3171
3159
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3277,7 +3265,7 @@ function labeledCreatableProviderFactory() {
|
|
|
3277
3265
|
|
|
3278
3266
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
3279
3267
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
3280
|
-
import { assertEx as
|
|
3268
|
+
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3281
3269
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
3282
3270
|
_context;
|
|
3283
3271
|
_registry;
|
|
@@ -3309,7 +3297,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3309
3297
|
this._frozen = true;
|
|
3310
3298
|
}
|
|
3311
3299
|
async getInstance(moniker, { start = true, labels } = {}) {
|
|
3312
|
-
return
|
|
3300
|
+
return assertEx25(
|
|
3313
3301
|
await this.tryGetInstance(moniker, { start, labels }),
|
|
3314
3302
|
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
3315
3303
|
);
|
|
@@ -3324,7 +3312,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3324
3312
|
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
3325
3313
|
*/
|
|
3326
3314
|
locate(moniker, labels) {
|
|
3327
|
-
return
|
|
3315
|
+
return assertEx25(
|
|
3328
3316
|
this.tryLocate(moniker, labels),
|
|
3329
3317
|
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
3330
3318
|
);
|
|
@@ -3346,10 +3334,10 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3346
3334
|
* @param labels The labels for the module factory
|
|
3347
3335
|
*/
|
|
3348
3336
|
register(factory, labels, primary = false) {
|
|
3349
|
-
|
|
3337
|
+
assertEx25(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
3350
3338
|
if (this.validateDepsOnRegister) {
|
|
3351
3339
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3352
|
-
|
|
3340
|
+
assertEx25(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
3353
3341
|
}
|
|
3354
3342
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
3355
3343
|
return this;
|
|
@@ -3397,7 +3385,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3397
3385
|
for (const moniker in this.registry) {
|
|
3398
3386
|
for (const factory of this.registry[moniker] ?? []) {
|
|
3399
3387
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3400
|
-
|
|
3388
|
+
assertEx25(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
3401
3389
|
}
|
|
3402
3390
|
}
|
|
3403
3391
|
}
|
|
@@ -3617,7 +3605,7 @@ var toPositiveBigInt = (value) => {
|
|
|
3617
3605
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3618
3606
|
import {
|
|
3619
3607
|
asHash as asHash4,
|
|
3620
|
-
assertEx as
|
|
3608
|
+
assertEx as assertEx32,
|
|
3621
3609
|
exists as exists3,
|
|
3622
3610
|
isDefined as isDefined17,
|
|
3623
3611
|
ZERO_ADDRESS
|
|
@@ -3631,7 +3619,7 @@ import {
|
|
|
3631
3619
|
BlockViewerMoniker,
|
|
3632
3620
|
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig4,
|
|
3633
3621
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig4,
|
|
3634
|
-
StepSizes as
|
|
3622
|
+
StepSizes as StepSizes12,
|
|
3635
3623
|
TransferSchema as TransferSchema2
|
|
3636
3624
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3637
3625
|
import { Semaphore } from "async-mutex";
|
|
@@ -3687,20 +3675,22 @@ var isTransfersStepSummaryWithStorageMeta = (value) => {
|
|
|
3687
3675
|
};
|
|
3688
3676
|
var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersStepSummaryWithStorageMeta);
|
|
3689
3677
|
|
|
3678
|
+
// src/summary/primitives/balances/balancesMaxStep.ts
|
|
3679
|
+
var balancesMaxStep = 5;
|
|
3680
|
+
|
|
3690
3681
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3691
|
-
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3692
|
-
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3682
|
+
import { assertEx as assertEx26, spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3693
3683
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3694
|
-
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as
|
|
3684
|
+
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3695
3685
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3696
3686
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3697
3687
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3698
3688
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3699
|
-
const [frameHead] =
|
|
3689
|
+
const [frameHead] = assertEx26(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3700
3690
|
const frameSize = range[1] - range[0] + 1;
|
|
3701
3691
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3702
3692
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3703
|
-
const [, payloads] =
|
|
3693
|
+
const [, payloads] = assertEx26(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3704
3694
|
const balances = {};
|
|
3705
3695
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3706
3696
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3712,8 +3702,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3712
3702
|
balances
|
|
3713
3703
|
};
|
|
3714
3704
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3715
|
-
const step =
|
|
3716
|
-
|
|
3705
|
+
const step = StepSizes8.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3706
|
+
assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3717
3707
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3718
3708
|
if (isAnyPayload3(summaryResult)) {
|
|
3719
3709
|
return summaryResult;
|
|
@@ -3757,11 +3747,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3757
3747
|
}
|
|
3758
3748
|
|
|
3759
3749
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3760
|
-
import {
|
|
3761
|
-
|
|
3762
|
-
assertEx as assertEx26,
|
|
3763
|
-
spanRootAsync as spanRootAsync3
|
|
3764
|
-
} from "@xylabs/sdk-js";
|
|
3750
|
+
import { assertEx as assertEx27, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
3751
|
+
import { asXyoAddress } from "@xyo-network/address";
|
|
3765
3752
|
import {
|
|
3766
3753
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
3767
3754
|
asXL1BlockRange as asXL1BlockRange7,
|
|
@@ -3771,18 +3758,18 @@ import {
|
|
|
3771
3758
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3772
3759
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
3773
3760
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3774
|
-
const [head] =
|
|
3761
|
+
const [head] = assertEx27(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3775
3762
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3776
3763
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
3777
3764
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
3778
3765
|
range,
|
|
3779
3766
|
{ name: "balancesSummary" }
|
|
3780
|
-
));
|
|
3767
|
+
), balancesMaxStep);
|
|
3781
3768
|
const summaries = await Promise.all(ranges.map((range2) => balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range2)));
|
|
3782
3769
|
const balances = {};
|
|
3783
3770
|
for (const summary of summaries) {
|
|
3784
3771
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
3785
|
-
const validAddress =
|
|
3772
|
+
const validAddress = asXyoAddress(address, () => `Invalid address: ${address}`);
|
|
3786
3773
|
balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance);
|
|
3787
3774
|
}
|
|
3788
3775
|
}
|
|
@@ -3790,21 +3777,25 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3790
3777
|
}, { ...context, timeBudgetLimit: 500 });
|
|
3791
3778
|
}
|
|
3792
3779
|
|
|
3780
|
+
// src/summary/primitives/schemas/schemasMaxStep.ts
|
|
3781
|
+
import { StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3782
|
+
var schemasMaxStep = StepSizes9.length - 1;
|
|
3783
|
+
|
|
3793
3784
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
3794
|
-
import { assertEx as
|
|
3785
|
+
import { assertEx as assertEx28 } from "@xylabs/sdk-js";
|
|
3795
3786
|
import {
|
|
3796
3787
|
isAnyPayload as isAnyPayload4,
|
|
3797
3788
|
isBoundWitness as isBoundWitness2,
|
|
3798
3789
|
isHashMeta,
|
|
3799
3790
|
PayloadBuilder as PayloadBuilder17
|
|
3800
3791
|
} from "@xyo-network/sdk-js";
|
|
3801
|
-
import { StepSizes as
|
|
3792
|
+
import { StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
|
|
3802
3793
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3803
|
-
const [frameHead] =
|
|
3794
|
+
const [frameHead] = assertEx28(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3804
3795
|
const frameSize = range[1] - range[0] + 1;
|
|
3805
3796
|
let result;
|
|
3806
3797
|
if (frameSize === 1) {
|
|
3807
|
-
const [block, payloads] =
|
|
3798
|
+
const [block, payloads] = assertEx28(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3808
3799
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
3809
3800
|
const schemas = {};
|
|
3810
3801
|
for (const bw of boundWitnesses) {
|
|
@@ -3820,8 +3811,8 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3820
3811
|
schemas
|
|
3821
3812
|
});
|
|
3822
3813
|
} else {
|
|
3823
|
-
const step =
|
|
3824
|
-
|
|
3814
|
+
const step = StepSizes10.indexOf(frameSize);
|
|
3815
|
+
assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
|
|
3825
3816
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3826
3817
|
if (isAnyPayload4(summaryResult)) {
|
|
3827
3818
|
result = summaryResult;
|
|
@@ -3860,7 +3851,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3860
3851
|
}
|
|
3861
3852
|
|
|
3862
3853
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
3863
|
-
import { assertEx as
|
|
3854
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
3864
3855
|
import {
|
|
3865
3856
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
3866
3857
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -3870,13 +3861,13 @@ import {
|
|
|
3870
3861
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3871
3862
|
return await spanRootAsync4("schemasSummary", async () => {
|
|
3872
3863
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3873
|
-
const [head] =
|
|
3864
|
+
const [head] = assertEx29(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3874
3865
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3875
3866
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
3876
3867
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
3877
3868
|
range,
|
|
3878
3869
|
{ name: "schemasSummary" }
|
|
3879
|
-
));
|
|
3870
|
+
), schemasMaxStep);
|
|
3880
3871
|
const summaries = await Promise.all(ranges.map((range2) => schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range2)));
|
|
3881
3872
|
const results = {};
|
|
3882
3873
|
for (const summary of summaries) {
|
|
@@ -3889,10 +3880,13 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3889
3880
|
}, context);
|
|
3890
3881
|
}
|
|
3891
3882
|
|
|
3883
|
+
// src/summary/primitives/transfers/transfersMaxStep.ts
|
|
3884
|
+
var transfersMaxStep = 4;
|
|
3885
|
+
|
|
3892
3886
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3893
|
-
import { assertEx as
|
|
3887
|
+
import { assertEx as assertEx30, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3894
3888
|
import { isAnyPayload as isAnyPayload5 } from "@xyo-network/sdk-js";
|
|
3895
|
-
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as
|
|
3889
|
+
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol-lib";
|
|
3896
3890
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
3897
3891
|
return `${frameHeadHash}|${frameSize}`;
|
|
3898
3892
|
}
|
|
@@ -3900,11 +3894,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3900
3894
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3901
3895
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
3902
3896
|
return await spanRootAsync5("transfersStepSummaryFromRange", async () => {
|
|
3903
|
-
const [frameHead] =
|
|
3897
|
+
const [frameHead] = assertEx30(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3904
3898
|
const frameSize = range[1] - range[0] + 1;
|
|
3905
3899
|
let result;
|
|
3906
3900
|
if (frameSize === 1) {
|
|
3907
|
-
const [, payloads] =
|
|
3901
|
+
const [, payloads] = assertEx30(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3908
3902
|
const transfers = {};
|
|
3909
3903
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3910
3904
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -3919,8 +3913,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3919
3913
|
transfers
|
|
3920
3914
|
};
|
|
3921
3915
|
} else {
|
|
3922
|
-
const step =
|
|
3923
|
-
|
|
3916
|
+
const step = StepSizes11.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3917
|
+
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
3924
3918
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3925
3919
|
const summaryResult = await summaryMap.get(key);
|
|
3926
3920
|
if (isAnyPayload5(summaryResult)) {
|
|
@@ -3971,11 +3965,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3971
3965
|
}
|
|
3972
3966
|
|
|
3973
3967
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3974
|
-
import {
|
|
3975
|
-
|
|
3976
|
-
assertEx as assertEx30,
|
|
3977
|
-
spanRootAsync as spanRootAsync6
|
|
3978
|
-
} from "@xylabs/sdk-js";
|
|
3968
|
+
import { assertEx as assertEx31, spanRootAsync as spanRootAsync6 } from "@xylabs/sdk-js";
|
|
3969
|
+
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/address";
|
|
3979
3970
|
import {
|
|
3980
3971
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
3981
3972
|
asXL1BlockRange as asXL1BlockRange9,
|
|
@@ -3985,21 +3976,21 @@ import {
|
|
|
3985
3976
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3986
3977
|
return await spanRootAsync6("transferSummary", async () => {
|
|
3987
3978
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3988
|
-
const [head] =
|
|
3979
|
+
const [head] = assertEx31(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3989
3980
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3990
3981
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
3991
3982
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
3992
3983
|
range,
|
|
3993
3984
|
{ name: "transfersSummary" }
|
|
3994
|
-
));
|
|
3985
|
+
), transfersMaxStep);
|
|
3995
3986
|
const summaries = await Promise.all(ranges.map((range2) => transfersStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range2)));
|
|
3996
3987
|
const transfers = {};
|
|
3997
3988
|
for (const summary of summaries) {
|
|
3998
3989
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
3999
|
-
const validFrom =
|
|
3990
|
+
const validFrom = asXyoAddress2(from, () => `Invalid address: ${from}`);
|
|
4000
3991
|
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
4001
3992
|
for (const [to, transfer] of Object.entries(toMap)) {
|
|
4002
|
-
const validTo =
|
|
3993
|
+
const validTo = asXyoAddress2(to, () => `Invalid address: ${to}`);
|
|
4003
3994
|
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
4004
3995
|
}
|
|
4005
3996
|
}
|
|
@@ -4011,9 +4002,9 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
4011
4002
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
4012
4003
|
var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
4013
4004
|
moniker = SimpleAccountBalanceViewer.defaultMoniker;
|
|
4014
|
-
_balanceStepSemaphores =
|
|
4005
|
+
_balanceStepSemaphores = StepSizes12.map(() => new Semaphore(20));
|
|
4015
4006
|
_blockViewer;
|
|
4016
|
-
_transferStepSemaphores =
|
|
4007
|
+
_transferStepSemaphores = StepSizes12.map(() => new Semaphore(20));
|
|
4017
4008
|
get balancesSummaryMap() {
|
|
4018
4009
|
return this.params.balancesSummaryMap;
|
|
4019
4010
|
}
|
|
@@ -4026,8 +4017,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4026
4017
|
static async paramsHandler(params = {}) {
|
|
4027
4018
|
return {
|
|
4028
4019
|
...await super.paramsHandler(params),
|
|
4029
|
-
balancesSummaryMap:
|
|
4030
|
-
transfersSummaryMap:
|
|
4020
|
+
balancesSummaryMap: assertEx32(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4021
|
+
transfersSummaryMap: assertEx32(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4031
4022
|
};
|
|
4032
4023
|
}
|
|
4033
4024
|
async accountBalance(address, config) {
|
|
@@ -4048,7 +4039,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4048
4039
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4049
4040
|
const transfers = transferIndexes.map((index) => {
|
|
4050
4041
|
const hash = block[0].payload_hashes[index];
|
|
4051
|
-
return
|
|
4042
|
+
return assertEx32(
|
|
4052
4043
|
block[1].find((p) => p._hash === hash),
|
|
4053
4044
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4054
4045
|
);
|
|
@@ -4081,7 +4072,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4081
4072
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4082
4073
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4083
4074
|
0,
|
|
4084
|
-
|
|
4075
|
+
assertEx32(
|
|
4085
4076
|
await this.blockViewer.blockByHash(head),
|
|
4086
4077
|
() => `Error: Could not find block with hash ${head}`
|
|
4087
4078
|
)[0].block
|
|
@@ -4096,11 +4087,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4096
4087
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4097
4088
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4098
4089
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4099
|
-
|
|
4090
|
+
assertEx32(
|
|
4100
4091
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4101
4092
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4102
4093
|
);
|
|
4103
|
-
|
|
4094
|
+
assertEx32(
|
|
4104
4095
|
head2 === qualifiedHeadHash,
|
|
4105
4096
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4106
4097
|
);
|
|
@@ -4134,10 +4125,10 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4134
4125
|
}
|
|
4135
4126
|
async distillTransferHistory(address, range, max = 50) {
|
|
4136
4127
|
return await this.spanAsync("distillTransferHistory", async () => {
|
|
4137
|
-
if (range[1] - range[0] <=
|
|
4128
|
+
if (range[1] - range[0] <= StepSizes12[0] || max <= 1) {
|
|
4138
4129
|
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber7(n, true));
|
|
4139
4130
|
}
|
|
4140
|
-
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true));
|
|
4131
|
+
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true), transfersMaxStep);
|
|
4141
4132
|
const transferSummaryPairs = await Promise.all(frames.map(
|
|
4142
4133
|
async (frame) => {
|
|
4143
4134
|
return [frame, await transfersStepSummaryFromRange(this.context, this._transferStepSemaphores, this.blockViewer, this.transfersSummaryMap, frame)];
|
|
@@ -4149,7 +4140,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4149
4140
|
});
|
|
4150
4141
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
4151
4142
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
4152
|
-
if (frame[1] - frame[0] + 1 >
|
|
4143
|
+
if (frame[1] - frame[0] + 1 > StepSizes12[0]) {
|
|
4153
4144
|
const values = await this.distillTransferHistory(address, asXL1BlockRange10([frame[0], frame[1] - 1], true), max - resultBlockNumbers.size);
|
|
4154
4145
|
for (const value of values) {
|
|
4155
4146
|
resultBlockNumbers.add(value);
|
|
@@ -4171,7 +4162,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4171
4162
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4172
4163
|
const range = asRange(headOrRange);
|
|
4173
4164
|
const headHash = asHash4(headOrRange);
|
|
4174
|
-
const [head] =
|
|
4165
|
+
const [head] = assertEx32(isDefined17(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4175
4166
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4176
4167
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4177
4168
|
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
@@ -4180,7 +4171,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4180
4171
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4181
4172
|
const transfers = transferIndexes.map((index) => {
|
|
4182
4173
|
const hash = block[0].payload_hashes[index];
|
|
4183
|
-
return
|
|
4174
|
+
return assertEx32(
|
|
4184
4175
|
block[1].find((p) => p._hash === hash),
|
|
4185
4176
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4186
4177
|
);
|
|
@@ -4210,7 +4201,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4210
4201
|
|
|
4211
4202
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4212
4203
|
import {
|
|
4213
|
-
assertEx as
|
|
4204
|
+
assertEx as assertEx33,
|
|
4214
4205
|
exists as exists4,
|
|
4215
4206
|
isUndefined as isUndefined8
|
|
4216
4207
|
} from "@xylabs/sdk-js";
|
|
@@ -4287,11 +4278,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4287
4278
|
static async paramsHandler(params) {
|
|
4288
4279
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4289
4280
|
if (headPollIntervalMs !== void 0) {
|
|
4290
|
-
|
|
4281
|
+
assertEx33(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4291
4282
|
}
|
|
4292
4283
|
return {
|
|
4293
4284
|
...await super.paramsHandler(params),
|
|
4294
|
-
finalizedArchivist:
|
|
4285
|
+
finalizedArchivist: assertEx33(params.finalizedArchivist, () => "finalizedArchivist is required"),
|
|
4295
4286
|
headPollIntervalMs
|
|
4296
4287
|
};
|
|
4297
4288
|
}
|
|
@@ -4320,8 +4311,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4320
4311
|
}
|
|
4321
4312
|
async blocksByHash(hash, limit = 50) {
|
|
4322
4313
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4323
|
-
|
|
4324
|
-
|
|
4314
|
+
assertEx33(limit > 0, () => "limit must be greater than 0");
|
|
4315
|
+
assertEx33(limit <= 100, () => "limit must be less than 100");
|
|
4325
4316
|
const blocks = [];
|
|
4326
4317
|
let current = await this.blockByHash(hash);
|
|
4327
4318
|
while (current && blocks.length < limit) {
|
|
@@ -4335,8 +4326,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4335
4326
|
}
|
|
4336
4327
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4337
4328
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4338
|
-
|
|
4339
|
-
|
|
4329
|
+
assertEx33(limit > 0, () => "limit must be greater than 0");
|
|
4330
|
+
assertEx33(limit <= 100, () => "limit must be less than 100");
|
|
4340
4331
|
const chainContext = await this.getChainContextRead();
|
|
4341
4332
|
if (isUndefined8(chainContext.head)) {
|
|
4342
4333
|
return [];
|
|
@@ -4354,7 +4345,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4354
4345
|
}
|
|
4355
4346
|
async chainId(blockNumber = "latest") {
|
|
4356
4347
|
return await this.spanAsync("chainId", async () => {
|
|
4357
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
4348
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx33(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
4358
4349
|
}, this.context);
|
|
4359
4350
|
}
|
|
4360
4351
|
async createHandler() {
|
|
@@ -4483,7 +4474,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4483
4474
|
], SimpleBlockRewardViewer);
|
|
4484
4475
|
|
|
4485
4476
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4486
|
-
import { assertEx as
|
|
4477
|
+
import { assertEx as assertEx34 } from "@xylabs/sdk-js";
|
|
4487
4478
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4488
4479
|
import {
|
|
4489
4480
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4536,7 +4527,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4536
4527
|
head: void 0
|
|
4537
4528
|
};
|
|
4538
4529
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
|
|
4539
|
-
const head = isChainQualifiedHeadConfig5(config) ?
|
|
4530
|
+
const head = isChainQualifiedHeadConfig5(config) ? assertEx34(
|
|
4540
4531
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
4541
4532
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4542
4533
|
) : void 0;
|
|
@@ -4617,9 +4608,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
4617
4608
|
], SimpleBlockValidationViewer);
|
|
4618
4609
|
|
|
4619
4610
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
4620
|
-
import {
|
|
4621
|
-
assertEx as assertEx34
|
|
4622
|
-
} from "@xylabs/sdk-js";
|
|
4611
|
+
import { assertEx as assertEx35 } from "@xylabs/sdk-js";
|
|
4623
4612
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
4624
4613
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
4625
4614
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -4636,7 +4625,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4636
4625
|
let contractViewer = this;
|
|
4637
4626
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4638
4627
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
4639
|
-
contractViewer =
|
|
4628
|
+
contractViewer = assertEx35(await contractViewer.forkedChainContractViewer());
|
|
4640
4629
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4641
4630
|
chainId = await contractViewer.chainId();
|
|
4642
4631
|
}
|
|
@@ -4689,7 +4678,7 @@ var SimpleXyoClient = class {
|
|
|
4689
4678
|
};
|
|
4690
4679
|
|
|
4691
4680
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
4692
|
-
import { assertEx as
|
|
4681
|
+
import { assertEx as assertEx36, exists as exists6 } from "@xylabs/sdk-js";
|
|
4693
4682
|
import { isAnyPayload as isAnyPayload7, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
4694
4683
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
4695
4684
|
import { z as z29 } from "zod/mini";
|
|
@@ -4758,7 +4747,7 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4758
4747
|
async insert(items) {
|
|
4759
4748
|
const allowedItems = items.map((item) => {
|
|
4760
4749
|
if (isAnyPayload7(item) && this.isAllowed(item)) {
|
|
4761
|
-
|
|
4750
|
+
assertEx36(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
4762
4751
|
return item;
|
|
4763
4752
|
}
|
|
4764
4753
|
return null;
|
|
@@ -4901,7 +4890,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
4901
4890
|
], SimpleFinalizationRunner);
|
|
4902
4891
|
|
|
4903
4892
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
4904
|
-
import { assertEx as
|
|
4893
|
+
import { assertEx as assertEx37 } from "@xylabs/sdk-js";
|
|
4905
4894
|
import {
|
|
4906
4895
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
4907
4896
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -4930,7 +4919,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4930
4919
|
static async paramsHandler(params) {
|
|
4931
4920
|
return {
|
|
4932
4921
|
...await super.paramsHandler(params),
|
|
4933
|
-
finalizedArchivist:
|
|
4922
|
+
finalizedArchivist: assertEx37(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
4934
4923
|
};
|
|
4935
4924
|
}
|
|
4936
4925
|
chainId() {
|
|
@@ -4938,18 +4927,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4938
4927
|
}
|
|
4939
4928
|
async createHandler() {
|
|
4940
4929
|
await super.createHandler();
|
|
4941
|
-
this._chainId =
|
|
4930
|
+
this._chainId = assertEx37(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
4942
4931
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4943
4932
|
}
|
|
4944
4933
|
async head() {
|
|
4945
4934
|
return await this.spanAsync("head", async () => {
|
|
4946
|
-
const currentHead =
|
|
4935
|
+
const currentHead = assertEx37(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
4947
4936
|
const cache = this.hydratedBlockCache;
|
|
4948
4937
|
const block = await cache.get(currentHead._hash);
|
|
4949
4938
|
if (!block) {
|
|
4950
4939
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
4951
4940
|
}
|
|
4952
|
-
return
|
|
4941
|
+
return assertEx37(block, () => "Could not find current block");
|
|
4953
4942
|
}, this.context);
|
|
4954
4943
|
}
|
|
4955
4944
|
async headBlock() {
|
|
@@ -4975,8 +4964,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4975
4964
|
}
|
|
4976
4965
|
async getCurrentHead() {
|
|
4977
4966
|
const chainArchivist = this.finalizedArchivist;
|
|
4978
|
-
const result =
|
|
4979
|
-
|
|
4967
|
+
const result = assertEx37(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
4968
|
+
assertEx37(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
4980
4969
|
return result;
|
|
4981
4970
|
}
|
|
4982
4971
|
};
|
|
@@ -5006,7 +4995,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5006
4995
|
|
|
5007
4996
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5008
4997
|
import {
|
|
5009
|
-
assertEx as
|
|
4998
|
+
assertEx as assertEx38,
|
|
5010
4999
|
BigIntToJsonZod,
|
|
5011
5000
|
isDefined as isDefined18
|
|
5012
5001
|
} from "@xylabs/sdk-js";
|
|
@@ -5039,7 +5028,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5039
5028
|
return this._signer;
|
|
5040
5029
|
}
|
|
5041
5030
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5042
|
-
const viewer =
|
|
5031
|
+
const viewer = assertEx38(this.connection.viewer, () => "No viewer available on connection");
|
|
5043
5032
|
const {
|
|
5044
5033
|
nbf,
|
|
5045
5034
|
exp,
|
|
@@ -5055,7 +5044,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5055
5044
|
async addTransactionToChain(tx, offChain = []) {
|
|
5056
5045
|
const connection = this.connection;
|
|
5057
5046
|
const signer = this.signer;
|
|
5058
|
-
const runner =
|
|
5047
|
+
const runner = assertEx38(connection.runner, () => "No runner available on connection");
|
|
5059
5048
|
let signedTx;
|
|
5060
5049
|
if (isSignedHydratedTransaction(tx)) {
|
|
5061
5050
|
const [bw, payloads] = tx;
|
|
@@ -5070,7 +5059,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5070
5059
|
}
|
|
5071
5060
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5072
5061
|
return await confirmSubmittedTransaction(
|
|
5073
|
-
|
|
5062
|
+
assertEx38(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5074
5063
|
txHash,
|
|
5075
5064
|
options
|
|
5076
5065
|
);
|
|
@@ -5107,7 +5096,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5107
5096
|
|
|
5108
5097
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5109
5098
|
import {
|
|
5110
|
-
assertEx as
|
|
5099
|
+
assertEx as assertEx39,
|
|
5111
5100
|
exists as exists8
|
|
5112
5101
|
} from "@xylabs/sdk-js";
|
|
5113
5102
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5182,8 +5171,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5182
5171
|
static async paramsHandler(params) {
|
|
5183
5172
|
return {
|
|
5184
5173
|
...await super.paramsHandler(params),
|
|
5185
|
-
pendingBlocksArchivist:
|
|
5186
|
-
pendingTransactionsArchivist:
|
|
5174
|
+
pendingBlocksArchivist: assertEx39(params?.pendingBlocksArchivist, () => "pendingBlocksArchivist is required"),
|
|
5175
|
+
pendingTransactionsArchivist: assertEx39(params?.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required")
|
|
5187
5176
|
};
|
|
5188
5177
|
}
|
|
5189
5178
|
async createHandler() {
|
|
@@ -5221,7 +5210,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5221
5210
|
return b;
|
|
5222
5211
|
}
|
|
5223
5212
|
}).filter(exists8);
|
|
5224
|
-
|
|
5213
|
+
assertEx39(
|
|
5225
5214
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5226
5215
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5227
5216
|
);
|
|
@@ -5283,7 +5272,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5283
5272
|
return t;
|
|
5284
5273
|
}
|
|
5285
5274
|
}).filter(exists8);
|
|
5286
|
-
|
|
5275
|
+
assertEx39(
|
|
5287
5276
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5288
5277
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5289
5278
|
);
|
|
@@ -5822,7 +5811,7 @@ var SimpleXyoNetwork = class {
|
|
|
5822
5811
|
};
|
|
5823
5812
|
|
|
5824
5813
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
5825
|
-
import { assertEx as
|
|
5814
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5826
5815
|
var SimpleXyoPermissions = class {
|
|
5827
5816
|
invoker;
|
|
5828
5817
|
_store;
|
|
@@ -5831,7 +5820,7 @@ var SimpleXyoPermissions = class {
|
|
|
5831
5820
|
this.invoker = store.invoker;
|
|
5832
5821
|
}
|
|
5833
5822
|
get store() {
|
|
5834
|
-
return
|
|
5823
|
+
return assertEx40(this._store, () => "Store must be defined to get permissions");
|
|
5835
5824
|
}
|
|
5836
5825
|
async getPermissions() {
|
|
5837
5826
|
return await this.store.getPermissions();
|
|
@@ -5884,7 +5873,7 @@ var SimpleXyoPermissions = class {
|
|
|
5884
5873
|
};
|
|
5885
5874
|
|
|
5886
5875
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
5887
|
-
import { assertEx as
|
|
5876
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5888
5877
|
var MemoryPermissionsStore = class {
|
|
5889
5878
|
_invoker;
|
|
5890
5879
|
permissions = [];
|
|
@@ -5892,7 +5881,7 @@ var MemoryPermissionsStore = class {
|
|
|
5892
5881
|
this._invoker = invoker;
|
|
5893
5882
|
}
|
|
5894
5883
|
get invoker() {
|
|
5895
|
-
return
|
|
5884
|
+
return assertEx41(this._invoker, () => "Invoker must be defined to get permissions");
|
|
5896
5885
|
}
|
|
5897
5886
|
async getPermissions() {
|
|
5898
5887
|
await Promise.resolve();
|
|
@@ -5932,7 +5921,6 @@ SimpleXyoRunner = __decorateClass([
|
|
|
5932
5921
|
], SimpleXyoRunner);
|
|
5933
5922
|
|
|
5934
5923
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
5935
|
-
import { asAddress as asAddress5 } from "@xylabs/sdk-js";
|
|
5936
5924
|
import { Account, PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
5937
5925
|
import {
|
|
5938
5926
|
SignedHydratedTransactionWithHashMetaZod,
|
|
@@ -5957,7 +5945,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5957
5945
|
return { ...await super.paramsHandler(params), account };
|
|
5958
5946
|
}
|
|
5959
5947
|
address() {
|
|
5960
|
-
return
|
|
5948
|
+
return this.params.account.address;
|
|
5961
5949
|
}
|
|
5962
5950
|
/** @deprecated - use signTransaction instead */
|
|
5963
5951
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
@@ -6059,8 +6047,8 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6059
6047
|
], SimpleStakeEventsViewer);
|
|
6060
6048
|
|
|
6061
6049
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6062
|
-
import {
|
|
6063
|
-
import {
|
|
6050
|
+
import { assertEx as assertEx42 } from "@xylabs/sdk-js";
|
|
6051
|
+
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/address";
|
|
6064
6052
|
import {
|
|
6065
6053
|
StakeTotalsViewerMoniker,
|
|
6066
6054
|
StakeViewerMoniker
|
|
@@ -6085,7 +6073,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6085
6073
|
let active = 0n;
|
|
6086
6074
|
const positions = await this.stakeViewer.activeStakes();
|
|
6087
6075
|
for (const position of positions) {
|
|
6088
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6076
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asXyoAddress3(position.staked) === asXyoAddress3(staked)) {
|
|
6089
6077
|
active += position.amount;
|
|
6090
6078
|
}
|
|
6091
6079
|
}
|
|
@@ -6095,7 +6083,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6095
6083
|
let active = 0n;
|
|
6096
6084
|
const positions = await this.stakeViewer.activeStakes();
|
|
6097
6085
|
for (const position of positions) {
|
|
6098
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6086
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6099
6087
|
active += position.amount;
|
|
6100
6088
|
}
|
|
6101
6089
|
}
|
|
@@ -6103,7 +6091,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6103
6091
|
}
|
|
6104
6092
|
async createHandler() {
|
|
6105
6093
|
await super.createHandler();
|
|
6106
|
-
this._stakeViewer =
|
|
6094
|
+
this._stakeViewer = assertEx42(
|
|
6107
6095
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6108
6096
|
() => "Failed to create StakeViewer"
|
|
6109
6097
|
);
|
|
@@ -6122,7 +6110,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6122
6110
|
let pending = 0n;
|
|
6123
6111
|
const positions = await this.stakeViewer.removedStakes();
|
|
6124
6112
|
for (const position of positions) {
|
|
6125
|
-
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) &&
|
|
6113
|
+
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6126
6114
|
pending += position.amount;
|
|
6127
6115
|
}
|
|
6128
6116
|
}
|
|
@@ -6142,7 +6130,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6142
6130
|
let withdrawn = 0n;
|
|
6143
6131
|
const positions = await this.stakeViewer.withdrawnStakes();
|
|
6144
6132
|
for (const position of positions) {
|
|
6145
|
-
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time &&
|
|
6133
|
+
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6146
6134
|
withdrawn += position.amount;
|
|
6147
6135
|
}
|
|
6148
6136
|
}
|
|
@@ -6157,17 +6145,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6157
6145
|
], SimpleStakeTotalsViewer);
|
|
6158
6146
|
|
|
6159
6147
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6160
|
-
import {
|
|
6161
|
-
|
|
6162
|
-
assertEx as assertEx42,
|
|
6163
|
-
toAddress as toAddress6
|
|
6164
|
-
} from "@xylabs/sdk-js";
|
|
6148
|
+
import { assertEx as assertEx43, toAddress } from "@xylabs/sdk-js";
|
|
6149
|
+
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/address";
|
|
6165
6150
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6166
6151
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6167
6152
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6168
6153
|
_chainStakeEventsViewer;
|
|
6169
6154
|
get stakeEvents() {
|
|
6170
|
-
return
|
|
6155
|
+
return assertEx43(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6171
6156
|
}
|
|
6172
6157
|
get positions() {
|
|
6173
6158
|
return this.params.positions;
|
|
@@ -6186,7 +6171,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6186
6171
|
let active = 0n;
|
|
6187
6172
|
const positions = await this.activeStakes();
|
|
6188
6173
|
for (const position of positions) {
|
|
6189
|
-
if (position.removeBlock === 0 &&
|
|
6174
|
+
if (position.removeBlock === 0 && asXyoAddress4(position.staked) === asXyoAddress4(staked)) {
|
|
6190
6175
|
active += position.amount;
|
|
6191
6176
|
}
|
|
6192
6177
|
}
|
|
@@ -6196,7 +6181,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6196
6181
|
let active = 0n;
|
|
6197
6182
|
const positions = await this.activeStakes();
|
|
6198
6183
|
for (const position of positions) {
|
|
6199
|
-
if (position.removeBlock === 0 &&
|
|
6184
|
+
if (position.removeBlock === 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6200
6185
|
active += position.amount;
|
|
6201
6186
|
}
|
|
6202
6187
|
}
|
|
@@ -6207,7 +6192,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6207
6192
|
}
|
|
6208
6193
|
async createHandler() {
|
|
6209
6194
|
await super.createHandler();
|
|
6210
|
-
this._chainStakeEventsViewer =
|
|
6195
|
+
this._chainStakeEventsViewer = assertEx43(
|
|
6211
6196
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6212
6197
|
() => "Failed to create StakeEventsViewer"
|
|
6213
6198
|
);
|
|
@@ -6229,7 +6214,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6229
6214
|
let pending = 0n;
|
|
6230
6215
|
const positions = await this.removedStakes();
|
|
6231
6216
|
for (const position of positions) {
|
|
6232
|
-
if (position.removeBlock !== 0 && position.withdrawBlock === 0 &&
|
|
6217
|
+
if (position.removeBlock !== 0 && position.withdrawBlock === 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6233
6218
|
pending += position.amount;
|
|
6234
6219
|
}
|
|
6235
6220
|
}
|
|
@@ -6239,24 +6224,24 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6239
6224
|
return this.positions.filter((s) => s.withdrawBlock === 0 && s.removeBlock !== 0);
|
|
6240
6225
|
}
|
|
6241
6226
|
rewardsContract() {
|
|
6242
|
-
return
|
|
6227
|
+
return toAddress(toAddress(1n));
|
|
6243
6228
|
}
|
|
6244
6229
|
stakeById(id) {
|
|
6245
|
-
return
|
|
6230
|
+
return assertEx43(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6246
6231
|
}
|
|
6247
6232
|
stakeByStaker(staker, slot) {
|
|
6248
|
-
return this.positions.filter((s) =>
|
|
6233
|
+
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
6249
6234
|
}
|
|
6250
6235
|
stakesByStaked(staked, range = [0, void 0]) {
|
|
6251
6236
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6252
|
-
return this.positions.filter((s) =>
|
|
6237
|
+
return this.positions.filter((s) => asXyoAddress4(s.staked) === asXyoAddress4(staked) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6253
6238
|
}
|
|
6254
6239
|
stakesByStaker(staker, range = [0, void 0]) {
|
|
6255
6240
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6256
|
-
return this.positions.filter((s) =>
|
|
6241
|
+
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6257
6242
|
}
|
|
6258
6243
|
stakingTokenAddress() {
|
|
6259
|
-
return
|
|
6244
|
+
return toAddress("0x000000000000000000000000000011");
|
|
6260
6245
|
}
|
|
6261
6246
|
async withdrawn() {
|
|
6262
6247
|
let withdrawn = 0n;
|
|
@@ -6272,7 +6257,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6272
6257
|
let withdrawn = 0n;
|
|
6273
6258
|
const positions = await this.withdrawnStakes();
|
|
6274
6259
|
for (const position of positions) {
|
|
6275
|
-
if (position.withdrawBlock !== 0 &&
|
|
6260
|
+
if (position.withdrawBlock !== 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6276
6261
|
withdrawn += position.amount;
|
|
6277
6262
|
}
|
|
6278
6263
|
}
|
|
@@ -6344,7 +6329,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6344
6329
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6345
6330
|
import {
|
|
6346
6331
|
asHash as asHash5,
|
|
6347
|
-
assertEx as
|
|
6332
|
+
assertEx as assertEx44,
|
|
6348
6333
|
isDefined as isDefined21
|
|
6349
6334
|
} from "@xylabs/sdk-js";
|
|
6350
6335
|
import {
|
|
@@ -6366,7 +6351,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6366
6351
|
async convertTime(fromDomain, toDomain, from) {
|
|
6367
6352
|
switch (fromDomain) {
|
|
6368
6353
|
case "xl1": {
|
|
6369
|
-
const [block, payloads] =
|
|
6354
|
+
const [block, payloads] = assertEx44(await this.blockViewer.blockByNumber(asXL1BlockNumber10(from, true)), () => "Block not found");
|
|
6370
6355
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6371
6356
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6372
6357
|
const timePayload = asTimePayload2(isDefined21(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -6421,10 +6406,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6421
6406
|
return [Date.now(), null];
|
|
6422
6407
|
}
|
|
6423
6408
|
case "ethereum": {
|
|
6424
|
-
const provider =
|
|
6409
|
+
const provider = assertEx44(this.ethProvider, () => "Ethereum provider not configured");
|
|
6425
6410
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6426
6411
|
const block = await provider.getBlock(blockNumber);
|
|
6427
|
-
const blockHash = asHash5(
|
|
6412
|
+
const blockHash = asHash5(assertEx44(block?.hash, () => "Block hash not found"), true);
|
|
6428
6413
|
return [blockNumber, blockHash];
|
|
6429
6414
|
}
|
|
6430
6415
|
default: {
|
|
@@ -6439,7 +6424,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6439
6424
|
// this is for the previous block
|
|
6440
6425
|
xl1,
|
|
6441
6426
|
// this is for the previous block
|
|
6442
|
-
xl1Hash:
|
|
6427
|
+
xl1Hash: assertEx44(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6443
6428
|
epoch: Date.now()
|
|
6444
6429
|
};
|
|
6445
6430
|
if (isDefined21(this.ethProvider)) {
|
|
@@ -6459,7 +6444,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6459
6444
|
], SimpleTimeSyncViewer);
|
|
6460
6445
|
|
|
6461
6446
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6462
|
-
import { assertEx as
|
|
6447
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6463
6448
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6464
6449
|
import {
|
|
6465
6450
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6510,7 +6495,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6510
6495
|
head: void 0
|
|
6511
6496
|
};
|
|
6512
6497
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
|
|
6513
|
-
const head = isChainQualifiedHeadConfig6(config) ?
|
|
6498
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx45(
|
|
6514
6499
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
6515
6500
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6516
6501
|
) : void 0;
|
|
@@ -6576,7 +6561,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
6576
6561
|
], SimpleTransactionValidationViewer);
|
|
6577
6562
|
|
|
6578
6563
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
6579
|
-
import { assertEx as
|
|
6564
|
+
import { assertEx as assertEx46, exists as exists10 } from "@xylabs/sdk-js";
|
|
6580
6565
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
6581
6566
|
import {
|
|
6582
6567
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -6593,7 +6578,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
6593
6578
|
}
|
|
6594
6579
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
6595
6580
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
6596
|
-
|
|
6581
|
+
assertEx46(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
6597
6582
|
try {
|
|
6598
6583
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
6599
6584
|
if (!block) return null;
|
|
@@ -6657,7 +6642,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
6657
6642
|
|
|
6658
6643
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
6659
6644
|
import {
|
|
6660
|
-
assertEx as
|
|
6645
|
+
assertEx as assertEx47,
|
|
6661
6646
|
exists as exists11,
|
|
6662
6647
|
isNull as isNull2
|
|
6663
6648
|
} from "@xylabs/sdk-js";
|
|
@@ -6728,7 +6713,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6728
6713
|
}
|
|
6729
6714
|
async createHandler() {
|
|
6730
6715
|
await super.createHandler();
|
|
6731
|
-
this._blockViewer =
|
|
6716
|
+
this._blockViewer = assertEx47(
|
|
6732
6717
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
6733
6718
|
() => "BlockViewer instance is required"
|
|
6734
6719
|
);
|
|
@@ -6737,13 +6722,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6737
6722
|
this._transactionHashMap = new MemoryMap();
|
|
6738
6723
|
}
|
|
6739
6724
|
currentBlock() {
|
|
6740
|
-
return
|
|
6725
|
+
return assertEx47(this._chain.at(-1));
|
|
6741
6726
|
}
|
|
6742
6727
|
currentBlockHash() {
|
|
6743
|
-
return
|
|
6728
|
+
return assertEx47(this._chain.at(-1)?.[0]._hash);
|
|
6744
6729
|
}
|
|
6745
6730
|
currentBlockNumber() {
|
|
6746
|
-
return
|
|
6731
|
+
return assertEx47(this._chain.at(-1)?.[0].block);
|
|
6747
6732
|
}
|
|
6748
6733
|
async payloadByHash(hash) {
|
|
6749
6734
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -6902,13 +6887,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6902
6887
|
};
|
|
6903
6888
|
|
|
6904
6889
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6905
|
-
import { assertEx as
|
|
6890
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
6906
6891
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6907
6892
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6908
6893
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6909
6894
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6910
6895
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6911
|
-
return
|
|
6896
|
+
return assertEx48(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6912
6897
|
}
|
|
6913
6898
|
|
|
6914
6899
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -7085,6 +7070,7 @@ export {
|
|
|
7085
7070
|
asTransfersStepSummaryWithStorageMeta,
|
|
7086
7071
|
backedFactory,
|
|
7087
7072
|
backingsSatisfied,
|
|
7073
|
+
balancesMaxStep,
|
|
7088
7074
|
balancesStepSummaryFromRange,
|
|
7089
7075
|
balancesSummary,
|
|
7090
7076
|
blockFromBlockNumber,
|
|
@@ -7188,6 +7174,7 @@ export {
|
|
|
7188
7174
|
resolveConfig,
|
|
7189
7175
|
resolveProviders,
|
|
7190
7176
|
rewardFromBlockNumber,
|
|
7177
|
+
schemasMaxStep,
|
|
7191
7178
|
schemasStepSummaryFromRange,
|
|
7192
7179
|
schemasSummary,
|
|
7193
7180
|
scoreUncle,
|
|
@@ -7221,6 +7208,7 @@ export {
|
|
|
7221
7208
|
transactionElevatedPayloads,
|
|
7222
7209
|
transactionRequiredGas,
|
|
7223
7210
|
transactionsFromHydratedBlock,
|
|
7211
|
+
transfersMaxStep,
|
|
7224
7212
|
transfersStepSummaryFromRange,
|
|
7225
7213
|
transfersSummary,
|
|
7226
7214
|
transfersSummaryKey,
|