@xyo-network/xl1-protocol-sdk 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +5 -5
- package/dist/neutral/config/Actor.d.ts +31 -31
- package/dist/neutral/config/Actors.d.ts +6 -6
- package/dist/neutral/config/Base.d.ts +6 -6
- package/dist/neutral/config/Chain.d.ts +2 -2
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +22 -22
- package/dist/neutral/config/HostActor.d.ts +31 -31
- package/dist/neutral/config/Validation.d.ts +4 -4
- package/dist/neutral/context/Actor.d.ts +31 -31
- package/dist/neutral/context/HostActor.d.ts +31 -31
- package/dist/neutral/createDeclarationPayload.d.ts +2 -2
- package/dist/neutral/createDeclarationPayload.d.ts.map +1 -1
- package/dist/neutral/createTransferPayload.d.ts +3 -2
- package/dist/neutral/createTransferPayload.d.ts.map +1 -1
- package/dist/neutral/getFileConfig.d.ts +10 -10
- package/dist/neutral/getFileConfig.mjs +6 -5
- package/dist/neutral/getFileConfig.mjs.map +3 -3
- package/dist/neutral/index.mjs +155 -181
- package/dist/neutral/index.mjs.map +3 -3
- package/dist/neutral/instances/Address.d.ts +3 -2
- package/dist/neutral/instances/Address.d.ts.map +1 -1
- package/dist/neutral/instances/Signature.d.ts +3 -2
- package/dist/neutral/instances/Signature.d.ts.map +1 -1
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +31 -31
- package/dist/neutral/payloads/AddressPairPayload.d.ts +2 -2
- package/dist/neutral/payloads/AddressPairPayload.d.ts.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts +2 -2
- package/dist/neutral/payloads/netTransfersForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts +2 -2
- package/dist/neutral/primitives/chain/step/chainStepRewardAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts +2 -2
- package/dist/neutral/primitives/payload/mergeTransfers.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts +2 -2
- package/dist/neutral/primitives/stake/activeStakeAtTimeByAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts +2 -2
- package/dist/neutral/primitives/stake/allStakersForRange.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts +2 -2
- package/dist/neutral/primitives/stake/allStakersForStep.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts +2 -2
- package/dist/neutral/primitives/stake/mergedAddRemoveStakeEventsByStaker.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +2 -2
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findUncles.d.ts +2 -2
- package/dist/neutral/services/AccountTransfersService.d.ts +4 -3
- package/dist/neutral/services/AccountTransfersService.d.ts.map +1 -1
- package/dist/neutral/services/Election.d.ts +2 -2
- package/dist/neutral/services/Election.d.ts.map +1 -1
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts +4 -4
- package/dist/neutral/services/StakeIntentService/StakeIntentService.d.ts.map +1 -1
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts +5 -5
- package/dist/neutral/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts +8 -7
- package/dist/neutral/simple/StakeViewer/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +18 -18
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts +8 -7
- package/dist/neutral/simple/chainContractViewer/SimpleChainContractViewer.d.ts.map +1 -1
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts +4 -3
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +4 -3
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts +2 -2
- package/dist/neutral/summary/model/BalancesStepSummary.d.ts.map +1 -1
- package/dist/neutral/summary/model/TransfersSummary.d.ts +2 -2
- package/dist/neutral/summary/model/TransfersSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/test/BuildBlockOptions.d.ts +3 -2
- package/dist/neutral/test/BuildBlockOptions.d.ts.map +1 -1
- package/dist/neutral/test/buildNextBlock.d.ts +2 -5
- package/dist/neutral/test/buildNextBlock.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomChain.d.ts +2 -2
- package/dist/neutral/test/buildRandomChain.d.ts.map +1 -1
- package/dist/neutral/test/buildRandomTransaction.d.ts +2 -2
- package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -1
- package/dist/neutral/test/createGenesisBlock.d.ts +2 -2
- package/dist/neutral/test/createGenesisBlock.d.ts.map +1 -1
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts +3 -3
- package/dist/neutral/test/createProducerChainStakeIntentTransaction.d.ts.map +1 -1
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts +3 -3
- package/dist/neutral/test/getSimpleBlockViewerLocator.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +76 -80
- package/dist/neutral/test/index.mjs.map +3 -3
- package/dist/neutral/transaction/TransactionBuilder.d.ts +4 -4
- package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -1
- package/dist/neutral/transaction/buildTransaction.d.ts +2 -2
- package/dist/neutral/transaction/buildTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts +2 -2
- package/dist/neutral/transaction/buildUnsignedTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +2 -2
- package/package.json +12 -10
package/dist/neutral/index.mjs
CHANGED
|
@@ -1246,7 +1246,8 @@ import { globalRegistry as globalRegistry12, z as z17 } from "zod/mini";
|
|
|
1246
1246
|
import { z as z16 } from "zod/mini";
|
|
1247
1247
|
|
|
1248
1248
|
// src/config/Chain.ts
|
|
1249
|
-
import {
|
|
1249
|
+
import { HexZod } from "@xylabs/sdk-js";
|
|
1250
|
+
import { XyoAddressZod } from "@xyo-network/address";
|
|
1250
1251
|
import { globalRegistry, z as z2 } from "zod/mini";
|
|
1251
1252
|
var ChainConfigZod = z2.object({
|
|
1252
1253
|
id: z2.optional(HexZod).register(globalRegistry, {
|
|
@@ -1254,7 +1255,7 @@ var ChainConfigZod = z2.object({
|
|
|
1254
1255
|
title: "chain.id",
|
|
1255
1256
|
type: "string"
|
|
1256
1257
|
}),
|
|
1257
|
-
genesisRewardAddress: z2.optional(
|
|
1258
|
+
genesisRewardAddress: z2.optional(XyoAddressZod).register(globalRegistry, {
|
|
1258
1259
|
description: "Address to send the initial genesis rewards to, if a new chain is being created.",
|
|
1259
1260
|
title: "chain.genesisRewardAddress",
|
|
1260
1261
|
type: "Address"
|
|
@@ -1497,7 +1498,7 @@ var TelemetryConfigZod = z14.object({
|
|
|
1497
1498
|
}).describe("Telemetry configuration options");
|
|
1498
1499
|
|
|
1499
1500
|
// src/config/Validation.ts
|
|
1500
|
-
import {
|
|
1501
|
+
import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/address";
|
|
1501
1502
|
import { globalRegistry as globalRegistry11, z as z15 } from "zod";
|
|
1502
1503
|
|
|
1503
1504
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
@@ -1743,11 +1744,8 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1743
1744
|
}
|
|
1744
1745
|
|
|
1745
1746
|
// src/primitives/chain/step/chainStepRewardAddress.ts
|
|
1746
|
-
import {
|
|
1747
|
-
|
|
1748
|
-
exists,
|
|
1749
|
-
toAddress as toAddress2
|
|
1750
|
-
} from "@xylabs/sdk-js";
|
|
1747
|
+
import { assertEx as assertEx14, exists } from "@xylabs/sdk-js";
|
|
1748
|
+
import { toXyoAddress as toXyoAddress2 } from "@xyo-network/address";
|
|
1751
1749
|
import {
|
|
1752
1750
|
asTransfer,
|
|
1753
1751
|
isTransfer,
|
|
@@ -1755,13 +1753,14 @@ import {
|
|
|
1755
1753
|
} from "@xyo-network/xl1-protocol-lib";
|
|
1756
1754
|
|
|
1757
1755
|
// src/primitives/payload/mergeTransfers.ts
|
|
1758
|
-
import { hexToBigInt
|
|
1756
|
+
import { hexToBigInt } from "@xylabs/sdk-js";
|
|
1757
|
+
import { toXyoAddress } from "@xyo-network/address";
|
|
1759
1758
|
function mergeTransfers(transfers) {
|
|
1760
1759
|
const result = {};
|
|
1761
1760
|
for (const transfer of transfers) {
|
|
1762
1761
|
result[transfer.from] = result[transfer.from] ?? {};
|
|
1763
1762
|
for (const [to, value] of Object.entries(transfer.transfers)) {
|
|
1764
|
-
const typedTo =
|
|
1763
|
+
const typedTo = toXyoAddress(to, true);
|
|
1765
1764
|
result[transfer.from][typedTo] = (result[transfer.from][typedTo] ?? 0n) + hexToBigInt(value);
|
|
1766
1765
|
}
|
|
1767
1766
|
}
|
|
@@ -1815,7 +1814,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1815
1814
|
sortedTransferAmounts.length === transferCount,
|
|
1816
1815
|
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`
|
|
1817
1816
|
);
|
|
1818
|
-
return
|
|
1817
|
+
return toXyoAddress2(sortedTransferAmounts[transferIndex][0], true);
|
|
1819
1818
|
}
|
|
1820
1819
|
|
|
1821
1820
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
@@ -1839,11 +1838,9 @@ var asAddressPairPayload = AsObjectFactory.create(isAddressPairPayload);
|
|
|
1839
1838
|
var asOptionalAddressPairPayload = AsObjectFactory.createOptional(isAddressPairPayload);
|
|
1840
1839
|
|
|
1841
1840
|
// src/payloads/netBalancesForPayloads.ts
|
|
1842
|
-
import {
|
|
1843
|
-
hexToBigInt as hexToBigInt2,
|
|
1844
|
-
toAddress as toAddress3
|
|
1845
|
-
} from "@xylabs/sdk-js";
|
|
1841
|
+
import { hexToBigInt as hexToBigInt2 } from "@xylabs/sdk-js";
|
|
1846
1842
|
import { span } from "@xylabs/sdk-js";
|
|
1843
|
+
import { toXyoAddress as toXyoAddress3 } from "@xyo-network/address";
|
|
1847
1844
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
1848
1845
|
var netBalancesForPayloads = (context, payloads) => {
|
|
1849
1846
|
return span("netBalancesForPayloads", () => {
|
|
@@ -1852,8 +1849,8 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1852
1849
|
if (isTransfer2(payload)) {
|
|
1853
1850
|
const { from } = payload;
|
|
1854
1851
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1855
|
-
balances[
|
|
1856
|
-
balances[
|
|
1852
|
+
balances[toXyoAddress3(address, true)] = (balances[toXyoAddress3(address, true)] ?? 0n) + hexToBigInt2(amount);
|
|
1853
|
+
balances[toXyoAddress3(from, true)] = (balances[toXyoAddress3(from, true)] ?? 0n) - hexToBigInt2(amount);
|
|
1857
1854
|
}
|
|
1858
1855
|
}
|
|
1859
1856
|
}
|
|
@@ -1862,11 +1859,9 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1862
1859
|
};
|
|
1863
1860
|
|
|
1864
1861
|
// src/payloads/netSchemasForPayloads.ts
|
|
1865
|
-
import {
|
|
1866
|
-
hexToBigInt as hexToBigInt3,
|
|
1867
|
-
toAddress as toAddress4
|
|
1868
|
-
} from "@xylabs/sdk-js";
|
|
1862
|
+
import { hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
1869
1863
|
import { span as span2 } from "@xylabs/sdk-js";
|
|
1864
|
+
import { toXyoAddress as toXyoAddress4 } from "@xyo-network/address";
|
|
1870
1865
|
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol-lib";
|
|
1871
1866
|
var netSchemasForPayloads = (context, payloads) => {
|
|
1872
1867
|
return span2("netSchemasForPayloads", () => {
|
|
@@ -1875,8 +1870,8 @@ var netSchemasForPayloads = (context, payloads) => {
|
|
|
1875
1870
|
if (isTransfer3(payload)) {
|
|
1876
1871
|
const { from } = payload;
|
|
1877
1872
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1878
|
-
balances[
|
|
1879
|
-
balances[
|
|
1873
|
+
balances[toXyoAddress4(address, true)] = (balances[toXyoAddress4(address, true)] ?? 0n) + hexToBigInt3(amount);
|
|
1874
|
+
balances[toXyoAddress4(from, true)] = (balances[toXyoAddress4(from, true)] ?? 0n) - hexToBigInt3(amount);
|
|
1880
1875
|
}
|
|
1881
1876
|
}
|
|
1882
1877
|
}
|
|
@@ -1885,9 +1880,7 @@ var netSchemasForPayloads = (context, payloads) => {
|
|
|
1885
1880
|
};
|
|
1886
1881
|
|
|
1887
1882
|
// src/payloads/netTransfersForPayloads.ts
|
|
1888
|
-
import {
|
|
1889
|
-
hexToBigInt as hexToBigInt4
|
|
1890
|
-
} from "@xylabs/sdk-js";
|
|
1883
|
+
import { hexToBigInt as hexToBigInt4 } from "@xylabs/sdk-js";
|
|
1891
1884
|
import { span as span3 } from "@xylabs/sdk-js";
|
|
1892
1885
|
import { isTransfer as isTransfer4 } from "@xyo-network/xl1-protocol-lib";
|
|
1893
1886
|
function netTransfersForPayloads(context, payloads) {
|
|
@@ -2170,14 +2163,12 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
|
|
|
2170
2163
|
}
|
|
2171
2164
|
|
|
2172
2165
|
// src/primitives/stake/allStakersForRange.ts
|
|
2173
|
-
import {
|
|
2174
|
-
toAddress as toAddress5
|
|
2175
|
-
} from "@xylabs/sdk-js";
|
|
2166
|
+
import { toXyoAddress as toXyoAddress5 } from "@xyo-network/address";
|
|
2176
2167
|
async function allStakersForRange(chain, externalRange, staked) {
|
|
2177
2168
|
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, externalRange[1]], staked);
|
|
2178
2169
|
const resultWithZeros = {};
|
|
2179
2170
|
for (const event of mergedEvents) {
|
|
2180
|
-
const staker =
|
|
2171
|
+
const staker = toXyoAddress5(event.args.staker, true);
|
|
2181
2172
|
resultWithZeros[staker] = resultWithZeros[staker] ?? 0n;
|
|
2182
2173
|
if (event.name === "StakeAdded") {
|
|
2183
2174
|
resultWithZeros[staker] += event.args.amount;
|
|
@@ -2188,7 +2179,7 @@ async function allStakersForRange(chain, externalRange, staked) {
|
|
|
2188
2179
|
const nonZero = Object.entries(resultWithZeros).filter(([, amount]) => amount > 0n).map(([address]) => address);
|
|
2189
2180
|
const result = {};
|
|
2190
2181
|
for (const address of nonZero) {
|
|
2191
|
-
result[
|
|
2182
|
+
result[toXyoAddress5(address, true)] = resultWithZeros[toXyoAddress5(address, true)];
|
|
2192
2183
|
}
|
|
2193
2184
|
return result;
|
|
2194
2185
|
}
|
|
@@ -2408,12 +2399,12 @@ function findUncles(context, finalizedWindowedChain, blocks) {
|
|
|
2408
2399
|
|
|
2409
2400
|
// src/config/Validation.ts
|
|
2410
2401
|
var ValidationConfigZod = z15.object({
|
|
2411
|
-
allowedRewardRedeemers: z15.array(
|
|
2402
|
+
allowedRewardRedeemers: z15.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
2412
2403
|
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
2413
2404
|
title: "allowedRewardRedeemers",
|
|
2414
2405
|
type: "array"
|
|
2415
2406
|
}),
|
|
2416
|
-
allowedRewardEscrowAccountSigners: z15.array(
|
|
2407
|
+
allowedRewardEscrowAccountSigners: z15.array(XyoAddressZod2).optional().register(globalRegistry11, {
|
|
2417
2408
|
description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
|
|
2418
2409
|
title: "allowedRewardEscrowAccountSigners",
|
|
2419
2410
|
type: "array"
|
|
@@ -2621,7 +2612,7 @@ import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js
|
|
|
2621
2612
|
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
2622
2613
|
|
|
2623
2614
|
// src/transaction/buildTransaction.ts
|
|
2624
|
-
import {
|
|
2615
|
+
import { assertEx as assertEx19, toHex } from "@xylabs/sdk-js";
|
|
2625
2616
|
import {
|
|
2626
2617
|
asAnyPayload as asAnyPayload2,
|
|
2627
2618
|
BoundWitnessBuilder,
|
|
@@ -2650,7 +2641,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2650
2641
|
}
|
|
2651
2642
|
const fields = {
|
|
2652
2643
|
...txBoundWitnessFields,
|
|
2653
|
-
from: from ??
|
|
2644
|
+
from: from ?? (Array.isArray(signer) ? assertEx19(signer.at(0)?.address) : signer.address)
|
|
2654
2645
|
};
|
|
2655
2646
|
if (script.length > 0) {
|
|
2656
2647
|
fields.script = script;
|
|
@@ -2736,7 +2727,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2736
2727
|
};
|
|
2737
2728
|
|
|
2738
2729
|
// src/transaction/hydrateTransaction.ts
|
|
2739
|
-
import { assertEx as
|
|
2730
|
+
import { assertEx as assertEx20 } from "@xylabs/sdk-js";
|
|
2740
2731
|
import {
|
|
2741
2732
|
asAnyPayload as asAnyPayload3,
|
|
2742
2733
|
hydrateTypedBoundWitness,
|
|
@@ -2811,7 +2802,7 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
2811
2802
|
return void 0;
|
|
2812
2803
|
};
|
|
2813
2804
|
var hydrateElevatedTransaction = async (context, hash) => {
|
|
2814
|
-
return
|
|
2805
|
+
return assertEx20(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
2815
2806
|
};
|
|
2816
2807
|
|
|
2817
2808
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -2864,13 +2855,13 @@ function transactionRequiredGas(hydratedTransaction) {
|
|
|
2864
2855
|
|
|
2865
2856
|
// src/transaction/signTransaction.ts
|
|
2866
2857
|
import {
|
|
2867
|
-
assertEx as
|
|
2858
|
+
assertEx as assertEx21,
|
|
2868
2859
|
hexFromArrayBuffer,
|
|
2869
2860
|
toArrayBuffer
|
|
2870
2861
|
} from "@xylabs/sdk-js";
|
|
2871
2862
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
2872
2863
|
async function signTransaction(tx, account) {
|
|
2873
|
-
|
|
2864
|
+
assertEx21(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2874
2865
|
const unsignedTx = structuredClone(tx);
|
|
2875
2866
|
unsignedTx.addresses = [account.address];
|
|
2876
2867
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
@@ -2885,11 +2876,7 @@ async function signTransaction(tx, account) {
|
|
|
2885
2876
|
}
|
|
2886
2877
|
|
|
2887
2878
|
// src/transaction/TransactionBuilder.ts
|
|
2888
|
-
import {
|
|
2889
|
-
asAddress as asAddress2,
|
|
2890
|
-
assertEx as assertEx21,
|
|
2891
|
-
Base
|
|
2892
|
-
} from "@xylabs/sdk-js";
|
|
2879
|
+
import { assertEx as assertEx22, Base } from "@xylabs/sdk-js";
|
|
2893
2880
|
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
2894
2881
|
import {
|
|
2895
2882
|
asXL1BlockNumber as asXL1BlockNumber4,
|
|
@@ -2909,9 +2896,9 @@ var TransactionBuilder = class extends Base {
|
|
|
2909
2896
|
super(options);
|
|
2910
2897
|
}
|
|
2911
2898
|
async build() {
|
|
2912
|
-
const chain =
|
|
2913
|
-
const fees =
|
|
2914
|
-
const blockRange =
|
|
2899
|
+
const chain = assertEx22(this._chain, () => "Chain must be set before building the transaction");
|
|
2900
|
+
const fees = assertEx22(this._fees, () => "Fees must be set before building the transaction");
|
|
2901
|
+
const blockRange = assertEx22(this._blockRange, () => "Block range must be set before building the transaction");
|
|
2915
2902
|
return await buildTransaction(
|
|
2916
2903
|
chain,
|
|
2917
2904
|
this._elevatedPayloads,
|
|
@@ -2919,7 +2906,7 @@ var TransactionBuilder = class extends Base {
|
|
|
2919
2906
|
this._signers,
|
|
2920
2907
|
asXL1BlockNumber4(blockRange[0], true),
|
|
2921
2908
|
asXL1BlockNumber4(blockRange[1], true),
|
|
2922
|
-
|
|
2909
|
+
this._signers[0]?.address,
|
|
2923
2910
|
fees
|
|
2924
2911
|
);
|
|
2925
2912
|
}
|
|
@@ -2935,13 +2922,13 @@ var TransactionBuilder = class extends Base {
|
|
|
2935
2922
|
this._signers,
|
|
2936
2923
|
asXL1BlockNumber4(0, true),
|
|
2937
2924
|
asXL1BlockNumber4(1e3, true),
|
|
2938
|
-
|
|
2925
|
+
this._signers[0]?.address,
|
|
2939
2926
|
defaultTransactionFees3
|
|
2940
2927
|
);
|
|
2941
2928
|
}
|
|
2942
2929
|
elevatedPayload(payload) {
|
|
2943
2930
|
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
2944
|
-
const allowPayloadExists =
|
|
2931
|
+
const allowPayloadExists = assertEx22(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
2945
2932
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
2946
2933
|
return this;
|
|
2947
2934
|
}
|
|
@@ -3043,12 +3030,12 @@ var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigConte
|
|
|
3043
3030
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
3044
3031
|
import {
|
|
3045
3032
|
AbstractCreatable,
|
|
3046
|
-
assertEx as
|
|
3033
|
+
assertEx as assertEx24,
|
|
3047
3034
|
IdLogger
|
|
3048
3035
|
} from "@xylabs/sdk-js";
|
|
3049
3036
|
|
|
3050
3037
|
// src/CreatableProvider/ProviderFactory.ts
|
|
3051
|
-
import { assertEx as
|
|
3038
|
+
import { assertEx as assertEx23 } from "@xylabs/sdk-js";
|
|
3052
3039
|
function providerFactoryDescription(factory, labels) {
|
|
3053
3040
|
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
3054
3041
|
}
|
|
@@ -3069,7 +3056,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3069
3056
|
this.dependencies = dependencies;
|
|
3070
3057
|
this.monikers = creatableProvider2.monikers;
|
|
3071
3058
|
this.scope = scope;
|
|
3072
|
-
|
|
3059
|
+
assertEx23(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
3073
3060
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
3074
3061
|
this.providerName = creatableProvider2.name;
|
|
3075
3062
|
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
@@ -3097,7 +3084,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3097
3084
|
break;
|
|
3098
3085
|
}
|
|
3099
3086
|
case "context": {
|
|
3100
|
-
const context =
|
|
3087
|
+
const context = assertEx23(
|
|
3101
3088
|
params?.context,
|
|
3102
3089
|
() => "Context is required for context-scoped providers"
|
|
3103
3090
|
);
|
|
@@ -3118,7 +3105,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
3118
3105
|
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
3119
3106
|
const result = await resultPromise;
|
|
3120
3107
|
if (start) {
|
|
3121
|
-
|
|
3108
|
+
assertEx23(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
3122
3109
|
}
|
|
3123
3110
|
return result;
|
|
3124
3111
|
}
|
|
@@ -3163,9 +3150,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable {
|
|
|
3163
3150
|
return factory;
|
|
3164
3151
|
}
|
|
3165
3152
|
static async paramsHandler(params = {}) {
|
|
3166
|
-
const context =
|
|
3167
|
-
const config =
|
|
3168
|
-
const locator =
|
|
3153
|
+
const context = assertEx24(params.context, () => new Error("Context is required"));
|
|
3154
|
+
const config = assertEx24(context.config, () => new Error("Context config is required"));
|
|
3155
|
+
const locator = assertEx24(context.locator, () => new Error("Context locator is required"));
|
|
3169
3156
|
return await super.paramsHandler({
|
|
3170
3157
|
...params,
|
|
3171
3158
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -3277,7 +3264,7 @@ function labeledCreatableProviderFactory() {
|
|
|
3277
3264
|
|
|
3278
3265
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
3279
3266
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
3280
|
-
import { assertEx as
|
|
3267
|
+
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3281
3268
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
3282
3269
|
_context;
|
|
3283
3270
|
_registry;
|
|
@@ -3309,7 +3296,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3309
3296
|
this._frozen = true;
|
|
3310
3297
|
}
|
|
3311
3298
|
async getInstance(moniker, { start = true, labels } = {}) {
|
|
3312
|
-
return
|
|
3299
|
+
return assertEx25(
|
|
3313
3300
|
await this.tryGetInstance(moniker, { start, labels }),
|
|
3314
3301
|
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
3315
3302
|
);
|
|
@@ -3324,7 +3311,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3324
3311
|
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
3325
3312
|
*/
|
|
3326
3313
|
locate(moniker, labels) {
|
|
3327
|
-
return
|
|
3314
|
+
return assertEx25(
|
|
3328
3315
|
this.tryLocate(moniker, labels),
|
|
3329
3316
|
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
3330
3317
|
);
|
|
@@ -3346,10 +3333,10 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3346
3333
|
* @param labels The labels for the module factory
|
|
3347
3334
|
*/
|
|
3348
3335
|
register(factory, labels, primary = false) {
|
|
3349
|
-
|
|
3336
|
+
assertEx25(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
3350
3337
|
if (this.validateDepsOnRegister) {
|
|
3351
3338
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3352
|
-
|
|
3339
|
+
assertEx25(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
3353
3340
|
}
|
|
3354
3341
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
3355
3342
|
return this;
|
|
@@ -3397,7 +3384,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
3397
3384
|
for (const moniker in this.registry) {
|
|
3398
3385
|
for (const factory of this.registry[moniker] ?? []) {
|
|
3399
3386
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
3400
|
-
|
|
3387
|
+
assertEx25(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
3401
3388
|
}
|
|
3402
3389
|
}
|
|
3403
3390
|
}
|
|
@@ -3617,7 +3604,7 @@ var toPositiveBigInt = (value) => {
|
|
|
3617
3604
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3618
3605
|
import {
|
|
3619
3606
|
asHash as asHash4,
|
|
3620
|
-
assertEx as
|
|
3607
|
+
assertEx as assertEx32,
|
|
3621
3608
|
exists as exists3,
|
|
3622
3609
|
isDefined as isDefined17,
|
|
3623
3610
|
ZERO_ADDRESS
|
|
@@ -3688,19 +3675,18 @@ var isTransfersStepSummaryWithStorageMeta = (value) => {
|
|
|
3688
3675
|
var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersStepSummaryWithStorageMeta);
|
|
3689
3676
|
|
|
3690
3677
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3691
|
-
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3692
|
-
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3678
|
+
import { assertEx as assertEx26, spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3693
3679
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3694
3680
|
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
3695
3681
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3696
3682
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3697
3683
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3698
3684
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3699
|
-
const [frameHead] =
|
|
3685
|
+
const [frameHead] = assertEx26(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3700
3686
|
const frameSize = range[1] - range[0] + 1;
|
|
3701
3687
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3702
3688
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3703
|
-
const [, payloads] =
|
|
3689
|
+
const [, payloads] = assertEx26(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3704
3690
|
const balances = {};
|
|
3705
3691
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3706
3692
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3713,7 +3699,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3713
3699
|
};
|
|
3714
3700
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3715
3701
|
const step = StepSizes7.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3716
|
-
|
|
3702
|
+
assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes7.join(", ")}`);
|
|
3717
3703
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3718
3704
|
if (isAnyPayload3(summaryResult)) {
|
|
3719
3705
|
return summaryResult;
|
|
@@ -3757,11 +3743,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3757
3743
|
}
|
|
3758
3744
|
|
|
3759
3745
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3760
|
-
import {
|
|
3761
|
-
|
|
3762
|
-
assertEx as assertEx26,
|
|
3763
|
-
spanRootAsync as spanRootAsync3
|
|
3764
|
-
} from "@xylabs/sdk-js";
|
|
3746
|
+
import { assertEx as assertEx27, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
|
|
3747
|
+
import { asXyoAddress } from "@xyo-network/address";
|
|
3765
3748
|
import {
|
|
3766
3749
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
3767
3750
|
asXL1BlockRange as asXL1BlockRange7,
|
|
@@ -3771,7 +3754,7 @@ import {
|
|
|
3771
3754
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3772
3755
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
3773
3756
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3774
|
-
const [head] =
|
|
3757
|
+
const [head] = assertEx27(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3775
3758
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3776
3759
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
3777
3760
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
@@ -3782,7 +3765,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3782
3765
|
const balances = {};
|
|
3783
3766
|
for (const summary of summaries) {
|
|
3784
3767
|
for (const [address, balance] of Object.entries(summary.balances)) {
|
|
3785
|
-
const validAddress =
|
|
3768
|
+
const validAddress = asXyoAddress(address, () => `Invalid address: ${address}`);
|
|
3786
3769
|
balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance);
|
|
3787
3770
|
}
|
|
3788
3771
|
}
|
|
@@ -3791,7 +3774,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3791
3774
|
}
|
|
3792
3775
|
|
|
3793
3776
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
3794
|
-
import { assertEx as
|
|
3777
|
+
import { assertEx as assertEx28 } from "@xylabs/sdk-js";
|
|
3795
3778
|
import {
|
|
3796
3779
|
isAnyPayload as isAnyPayload4,
|
|
3797
3780
|
isBoundWitness as isBoundWitness2,
|
|
@@ -3800,11 +3783,11 @@ import {
|
|
|
3800
3783
|
} from "@xyo-network/sdk-js";
|
|
3801
3784
|
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3802
3785
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3803
|
-
const [frameHead] =
|
|
3786
|
+
const [frameHead] = assertEx28(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3804
3787
|
const frameSize = range[1] - range[0] + 1;
|
|
3805
3788
|
let result;
|
|
3806
3789
|
if (frameSize === 1) {
|
|
3807
|
-
const [block, payloads] =
|
|
3790
|
+
const [block, payloads] = assertEx28(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3808
3791
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
3809
3792
|
const schemas = {};
|
|
3810
3793
|
for (const bw of boundWitnesses) {
|
|
@@ -3821,7 +3804,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3821
3804
|
});
|
|
3822
3805
|
} else {
|
|
3823
3806
|
const step = StepSizes8.indexOf(frameSize);
|
|
3824
|
-
|
|
3807
|
+
assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3825
3808
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3826
3809
|
if (isAnyPayload4(summaryResult)) {
|
|
3827
3810
|
result = summaryResult;
|
|
@@ -3860,7 +3843,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3860
3843
|
}
|
|
3861
3844
|
|
|
3862
3845
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
3863
|
-
import { assertEx as
|
|
3846
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
3864
3847
|
import {
|
|
3865
3848
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
3866
3849
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -3870,7 +3853,7 @@ import {
|
|
|
3870
3853
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3871
3854
|
return await spanRootAsync4("schemasSummary", async () => {
|
|
3872
3855
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3873
|
-
const [head] =
|
|
3856
|
+
const [head] = assertEx29(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3874
3857
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3875
3858
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
3876
3859
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -3890,7 +3873,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3890
3873
|
}
|
|
3891
3874
|
|
|
3892
3875
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3893
|
-
import { assertEx as
|
|
3876
|
+
import { assertEx as assertEx30, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3894
3877
|
import { isAnyPayload as isAnyPayload5 } from "@xyo-network/sdk-js";
|
|
3895
3878
|
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3896
3879
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
@@ -3900,11 +3883,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3900
3883
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3901
3884
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
3902
3885
|
return await spanRootAsync5("transfersStepSummaryFromRange", async () => {
|
|
3903
|
-
const [frameHead] =
|
|
3886
|
+
const [frameHead] = assertEx30(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3904
3887
|
const frameSize = range[1] - range[0] + 1;
|
|
3905
3888
|
let result;
|
|
3906
3889
|
if (frameSize === 1) {
|
|
3907
|
-
const [, payloads] =
|
|
3890
|
+
const [, payloads] = assertEx30(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3908
3891
|
const transfers = {};
|
|
3909
3892
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3910
3893
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -3920,7 +3903,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3920
3903
|
};
|
|
3921
3904
|
} else {
|
|
3922
3905
|
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3923
|
-
|
|
3906
|
+
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
3924
3907
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3925
3908
|
const summaryResult = await summaryMap.get(key);
|
|
3926
3909
|
if (isAnyPayload5(summaryResult)) {
|
|
@@ -3971,11 +3954,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3971
3954
|
}
|
|
3972
3955
|
|
|
3973
3956
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3974
|
-
import {
|
|
3975
|
-
|
|
3976
|
-
assertEx as assertEx30,
|
|
3977
|
-
spanRootAsync as spanRootAsync6
|
|
3978
|
-
} from "@xylabs/sdk-js";
|
|
3957
|
+
import { assertEx as assertEx31, spanRootAsync as spanRootAsync6 } from "@xylabs/sdk-js";
|
|
3958
|
+
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/address";
|
|
3979
3959
|
import {
|
|
3980
3960
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
3981
3961
|
asXL1BlockRange as asXL1BlockRange9,
|
|
@@ -3985,7 +3965,7 @@ import {
|
|
|
3985
3965
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3986
3966
|
return await spanRootAsync6("transferSummary", async () => {
|
|
3987
3967
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3988
|
-
const [head] =
|
|
3968
|
+
const [head] = assertEx31(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3989
3969
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3990
3970
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
3991
3971
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -3996,10 +3976,10 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3996
3976
|
const transfers = {};
|
|
3997
3977
|
for (const summary of summaries) {
|
|
3998
3978
|
for (const [from, toMap] of Object.entries(summary.transfers)) {
|
|
3999
|
-
const validFrom =
|
|
3979
|
+
const validFrom = asXyoAddress2(from, () => `Invalid address: ${from}`);
|
|
4000
3980
|
transfers[validFrom] = transfers[validFrom] ?? {};
|
|
4001
3981
|
for (const [to, transfer] of Object.entries(toMap)) {
|
|
4002
|
-
const validTo =
|
|
3982
|
+
const validTo = asXyoAddress2(to, () => `Invalid address: ${to}`);
|
|
4003
3983
|
transfers[validFrom][validTo] = (transfers[validFrom][validTo] ?? 0n) + parseSignedBigInt(transfer);
|
|
4004
3984
|
}
|
|
4005
3985
|
}
|
|
@@ -4026,8 +4006,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4026
4006
|
static async paramsHandler(params = {}) {
|
|
4027
4007
|
return {
|
|
4028
4008
|
...await super.paramsHandler(params),
|
|
4029
|
-
balancesSummaryMap:
|
|
4030
|
-
transfersSummaryMap:
|
|
4009
|
+
balancesSummaryMap: assertEx32(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4010
|
+
transfersSummaryMap: assertEx32(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4031
4011
|
};
|
|
4032
4012
|
}
|
|
4033
4013
|
async accountBalance(address, config) {
|
|
@@ -4048,7 +4028,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4048
4028
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4049
4029
|
const transfers = transferIndexes.map((index) => {
|
|
4050
4030
|
const hash = block[0].payload_hashes[index];
|
|
4051
|
-
return
|
|
4031
|
+
return assertEx32(
|
|
4052
4032
|
block[1].find((p) => p._hash === hash),
|
|
4053
4033
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4054
4034
|
);
|
|
@@ -4081,7 +4061,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4081
4061
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4082
4062
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4083
4063
|
0,
|
|
4084
|
-
|
|
4064
|
+
assertEx32(
|
|
4085
4065
|
await this.blockViewer.blockByHash(head),
|
|
4086
4066
|
() => `Error: Could not find block with hash ${head}`
|
|
4087
4067
|
)[0].block
|
|
@@ -4096,11 +4076,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4096
4076
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4097
4077
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4098
4078
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4099
|
-
|
|
4079
|
+
assertEx32(
|
|
4100
4080
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4101
4081
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4102
4082
|
);
|
|
4103
|
-
|
|
4083
|
+
assertEx32(
|
|
4104
4084
|
head2 === qualifiedHeadHash,
|
|
4105
4085
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4106
4086
|
);
|
|
@@ -4171,7 +4151,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4171
4151
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4172
4152
|
const range = asRange(headOrRange);
|
|
4173
4153
|
const headHash = asHash4(headOrRange);
|
|
4174
|
-
const [head] =
|
|
4154
|
+
const [head] = assertEx32(isDefined17(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4175
4155
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4176
4156
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4177
4157
|
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
@@ -4180,7 +4160,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4180
4160
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4181
4161
|
const transfers = transferIndexes.map((index) => {
|
|
4182
4162
|
const hash = block[0].payload_hashes[index];
|
|
4183
|
-
return
|
|
4163
|
+
return assertEx32(
|
|
4184
4164
|
block[1].find((p) => p._hash === hash),
|
|
4185
4165
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4186
4166
|
);
|
|
@@ -4210,7 +4190,7 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4210
4190
|
|
|
4211
4191
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4212
4192
|
import {
|
|
4213
|
-
assertEx as
|
|
4193
|
+
assertEx as assertEx33,
|
|
4214
4194
|
exists as exists4,
|
|
4215
4195
|
isUndefined as isUndefined8
|
|
4216
4196
|
} from "@xylabs/sdk-js";
|
|
@@ -4287,11 +4267,11 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4287
4267
|
static async paramsHandler(params) {
|
|
4288
4268
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4289
4269
|
if (headPollIntervalMs !== void 0) {
|
|
4290
|
-
|
|
4270
|
+
assertEx33(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4291
4271
|
}
|
|
4292
4272
|
return {
|
|
4293
4273
|
...await super.paramsHandler(params),
|
|
4294
|
-
finalizedArchivist:
|
|
4274
|
+
finalizedArchivist: assertEx33(params.finalizedArchivist, () => "finalizedArchivist is required"),
|
|
4295
4275
|
headPollIntervalMs
|
|
4296
4276
|
};
|
|
4297
4277
|
}
|
|
@@ -4320,8 +4300,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4320
4300
|
}
|
|
4321
4301
|
async blocksByHash(hash, limit = 50) {
|
|
4322
4302
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4323
|
-
|
|
4324
|
-
|
|
4303
|
+
assertEx33(limit > 0, () => "limit must be greater than 0");
|
|
4304
|
+
assertEx33(limit <= 100, () => "limit must be less than 100");
|
|
4325
4305
|
const blocks = [];
|
|
4326
4306
|
let current = await this.blockByHash(hash);
|
|
4327
4307
|
while (current && blocks.length < limit) {
|
|
@@ -4335,8 +4315,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4335
4315
|
}
|
|
4336
4316
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4337
4317
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4338
|
-
|
|
4339
|
-
|
|
4318
|
+
assertEx33(limit > 0, () => "limit must be greater than 0");
|
|
4319
|
+
assertEx33(limit <= 100, () => "limit must be less than 100");
|
|
4340
4320
|
const chainContext = await this.getChainContextRead();
|
|
4341
4321
|
if (isUndefined8(chainContext.head)) {
|
|
4342
4322
|
return [];
|
|
@@ -4354,7 +4334,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4354
4334
|
}
|
|
4355
4335
|
async chainId(blockNumber = "latest") {
|
|
4356
4336
|
return await this.spanAsync("chainId", async () => {
|
|
4357
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
4337
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx33(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
4358
4338
|
}, this.context);
|
|
4359
4339
|
}
|
|
4360
4340
|
async createHandler() {
|
|
@@ -4483,7 +4463,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4483
4463
|
], SimpleBlockRewardViewer);
|
|
4484
4464
|
|
|
4485
4465
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4486
|
-
import { assertEx as
|
|
4466
|
+
import { assertEx as assertEx34 } from "@xylabs/sdk-js";
|
|
4487
4467
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4488
4468
|
import {
|
|
4489
4469
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4536,7 +4516,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4536
4516
|
head: void 0
|
|
4537
4517
|
};
|
|
4538
4518
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
|
|
4539
|
-
const head = isChainQualifiedHeadConfig5(config) ?
|
|
4519
|
+
const head = isChainQualifiedHeadConfig5(config) ? assertEx34(
|
|
4540
4520
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
4541
4521
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4542
4522
|
) : void 0;
|
|
@@ -4617,9 +4597,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
4617
4597
|
], SimpleBlockValidationViewer);
|
|
4618
4598
|
|
|
4619
4599
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
4620
|
-
import {
|
|
4621
|
-
assertEx as assertEx34
|
|
4622
|
-
} from "@xylabs/sdk-js";
|
|
4600
|
+
import { assertEx as assertEx35 } from "@xylabs/sdk-js";
|
|
4623
4601
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
4624
4602
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
4625
4603
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -4636,7 +4614,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4636
4614
|
let contractViewer = this;
|
|
4637
4615
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4638
4616
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
4639
|
-
contractViewer =
|
|
4617
|
+
contractViewer = assertEx35(await contractViewer.forkedChainContractViewer());
|
|
4640
4618
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4641
4619
|
chainId = await contractViewer.chainId();
|
|
4642
4620
|
}
|
|
@@ -4689,7 +4667,7 @@ var SimpleXyoClient = class {
|
|
|
4689
4667
|
};
|
|
4690
4668
|
|
|
4691
4669
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
4692
|
-
import { assertEx as
|
|
4670
|
+
import { assertEx as assertEx36, exists as exists6 } from "@xylabs/sdk-js";
|
|
4693
4671
|
import { isAnyPayload as isAnyPayload7, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
4694
4672
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
4695
4673
|
import { z as z29 } from "zod/mini";
|
|
@@ -4758,7 +4736,7 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4758
4736
|
async insert(items) {
|
|
4759
4737
|
const allowedItems = items.map((item) => {
|
|
4760
4738
|
if (isAnyPayload7(item) && this.isAllowed(item)) {
|
|
4761
|
-
|
|
4739
|
+
assertEx36(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
4762
4740
|
return item;
|
|
4763
4741
|
}
|
|
4764
4742
|
return null;
|
|
@@ -4901,7 +4879,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
4901
4879
|
], SimpleFinalizationRunner);
|
|
4902
4880
|
|
|
4903
4881
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
4904
|
-
import { assertEx as
|
|
4882
|
+
import { assertEx as assertEx37 } from "@xylabs/sdk-js";
|
|
4905
4883
|
import {
|
|
4906
4884
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
4907
4885
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -4930,7 +4908,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4930
4908
|
static async paramsHandler(params) {
|
|
4931
4909
|
return {
|
|
4932
4910
|
...await super.paramsHandler(params),
|
|
4933
|
-
finalizedArchivist:
|
|
4911
|
+
finalizedArchivist: assertEx37(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
4934
4912
|
};
|
|
4935
4913
|
}
|
|
4936
4914
|
chainId() {
|
|
@@ -4938,18 +4916,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4938
4916
|
}
|
|
4939
4917
|
async createHandler() {
|
|
4940
4918
|
await super.createHandler();
|
|
4941
|
-
this._chainId =
|
|
4919
|
+
this._chainId = assertEx37(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
4942
4920
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4943
4921
|
}
|
|
4944
4922
|
async head() {
|
|
4945
4923
|
return await this.spanAsync("head", async () => {
|
|
4946
|
-
const currentHead =
|
|
4924
|
+
const currentHead = assertEx37(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
4947
4925
|
const cache = this.hydratedBlockCache;
|
|
4948
4926
|
const block = await cache.get(currentHead._hash);
|
|
4949
4927
|
if (!block) {
|
|
4950
4928
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
4951
4929
|
}
|
|
4952
|
-
return
|
|
4930
|
+
return assertEx37(block, () => "Could not find current block");
|
|
4953
4931
|
}, this.context);
|
|
4954
4932
|
}
|
|
4955
4933
|
async headBlock() {
|
|
@@ -4975,8 +4953,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4975
4953
|
}
|
|
4976
4954
|
async getCurrentHead() {
|
|
4977
4955
|
const chainArchivist = this.finalizedArchivist;
|
|
4978
|
-
const result =
|
|
4979
|
-
|
|
4956
|
+
const result = assertEx37(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
4957
|
+
assertEx37(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
4980
4958
|
return result;
|
|
4981
4959
|
}
|
|
4982
4960
|
};
|
|
@@ -5006,7 +4984,7 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
5006
4984
|
|
|
5007
4985
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
5008
4986
|
import {
|
|
5009
|
-
assertEx as
|
|
4987
|
+
assertEx as assertEx38,
|
|
5010
4988
|
BigIntToJsonZod,
|
|
5011
4989
|
isDefined as isDefined18
|
|
5012
4990
|
} from "@xylabs/sdk-js";
|
|
@@ -5039,7 +5017,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5039
5017
|
return this._signer;
|
|
5040
5018
|
}
|
|
5041
5019
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5042
|
-
const viewer =
|
|
5020
|
+
const viewer = assertEx38(this.connection.viewer, () => "No viewer available on connection");
|
|
5043
5021
|
const {
|
|
5044
5022
|
nbf,
|
|
5045
5023
|
exp,
|
|
@@ -5055,7 +5033,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5055
5033
|
async addTransactionToChain(tx, offChain = []) {
|
|
5056
5034
|
const connection = this.connection;
|
|
5057
5035
|
const signer = this.signer;
|
|
5058
|
-
const runner =
|
|
5036
|
+
const runner = assertEx38(connection.runner, () => "No runner available on connection");
|
|
5059
5037
|
let signedTx;
|
|
5060
5038
|
if (isSignedHydratedTransaction(tx)) {
|
|
5061
5039
|
const [bw, payloads] = tx;
|
|
@@ -5070,7 +5048,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5070
5048
|
}
|
|
5071
5049
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5072
5050
|
return await confirmSubmittedTransaction(
|
|
5073
|
-
|
|
5051
|
+
assertEx38(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5074
5052
|
txHash,
|
|
5075
5053
|
options
|
|
5076
5054
|
);
|
|
@@ -5107,7 +5085,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5107
5085
|
|
|
5108
5086
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5109
5087
|
import {
|
|
5110
|
-
assertEx as
|
|
5088
|
+
assertEx as assertEx39,
|
|
5111
5089
|
exists as exists8
|
|
5112
5090
|
} from "@xylabs/sdk-js";
|
|
5113
5091
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5182,8 +5160,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5182
5160
|
static async paramsHandler(params) {
|
|
5183
5161
|
return {
|
|
5184
5162
|
...await super.paramsHandler(params),
|
|
5185
|
-
pendingBlocksArchivist:
|
|
5186
|
-
pendingTransactionsArchivist:
|
|
5163
|
+
pendingBlocksArchivist: assertEx39(params?.pendingBlocksArchivist, () => "pendingBlocksArchivist is required"),
|
|
5164
|
+
pendingTransactionsArchivist: assertEx39(params?.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required")
|
|
5187
5165
|
};
|
|
5188
5166
|
}
|
|
5189
5167
|
async createHandler() {
|
|
@@ -5221,7 +5199,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5221
5199
|
return b;
|
|
5222
5200
|
}
|
|
5223
5201
|
}).filter(exists8);
|
|
5224
|
-
|
|
5202
|
+
assertEx39(
|
|
5225
5203
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5226
5204
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5227
5205
|
);
|
|
@@ -5283,7 +5261,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5283
5261
|
return t;
|
|
5284
5262
|
}
|
|
5285
5263
|
}).filter(exists8);
|
|
5286
|
-
|
|
5264
|
+
assertEx39(
|
|
5287
5265
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5288
5266
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5289
5267
|
);
|
|
@@ -5822,7 +5800,7 @@ var SimpleXyoNetwork = class {
|
|
|
5822
5800
|
};
|
|
5823
5801
|
|
|
5824
5802
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
5825
|
-
import { assertEx as
|
|
5803
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5826
5804
|
var SimpleXyoPermissions = class {
|
|
5827
5805
|
invoker;
|
|
5828
5806
|
_store;
|
|
@@ -5831,7 +5809,7 @@ var SimpleXyoPermissions = class {
|
|
|
5831
5809
|
this.invoker = store.invoker;
|
|
5832
5810
|
}
|
|
5833
5811
|
get store() {
|
|
5834
|
-
return
|
|
5812
|
+
return assertEx40(this._store, () => "Store must be defined to get permissions");
|
|
5835
5813
|
}
|
|
5836
5814
|
async getPermissions() {
|
|
5837
5815
|
return await this.store.getPermissions();
|
|
@@ -5884,7 +5862,7 @@ var SimpleXyoPermissions = class {
|
|
|
5884
5862
|
};
|
|
5885
5863
|
|
|
5886
5864
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
5887
|
-
import { assertEx as
|
|
5865
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5888
5866
|
var MemoryPermissionsStore = class {
|
|
5889
5867
|
_invoker;
|
|
5890
5868
|
permissions = [];
|
|
@@ -5892,7 +5870,7 @@ var MemoryPermissionsStore = class {
|
|
|
5892
5870
|
this._invoker = invoker;
|
|
5893
5871
|
}
|
|
5894
5872
|
get invoker() {
|
|
5895
|
-
return
|
|
5873
|
+
return assertEx41(this._invoker, () => "Invoker must be defined to get permissions");
|
|
5896
5874
|
}
|
|
5897
5875
|
async getPermissions() {
|
|
5898
5876
|
await Promise.resolve();
|
|
@@ -5932,7 +5910,6 @@ SimpleXyoRunner = __decorateClass([
|
|
|
5932
5910
|
], SimpleXyoRunner);
|
|
5933
5911
|
|
|
5934
5912
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
5935
|
-
import { asAddress as asAddress5 } from "@xylabs/sdk-js";
|
|
5936
5913
|
import { Account, PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
5937
5914
|
import {
|
|
5938
5915
|
SignedHydratedTransactionWithHashMetaZod,
|
|
@@ -5957,7 +5934,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5957
5934
|
return { ...await super.paramsHandler(params), account };
|
|
5958
5935
|
}
|
|
5959
5936
|
address() {
|
|
5960
|
-
return
|
|
5937
|
+
return this.params.account.address;
|
|
5961
5938
|
}
|
|
5962
5939
|
/** @deprecated - use signTransaction instead */
|
|
5963
5940
|
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
@@ -6059,8 +6036,8 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6059
6036
|
], SimpleStakeEventsViewer);
|
|
6060
6037
|
|
|
6061
6038
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6062
|
-
import {
|
|
6063
|
-
import {
|
|
6039
|
+
import { assertEx as assertEx42 } from "@xylabs/sdk-js";
|
|
6040
|
+
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/address";
|
|
6064
6041
|
import {
|
|
6065
6042
|
StakeTotalsViewerMoniker,
|
|
6066
6043
|
StakeViewerMoniker
|
|
@@ -6085,7 +6062,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6085
6062
|
let active = 0n;
|
|
6086
6063
|
const positions = await this.stakeViewer.activeStakes();
|
|
6087
6064
|
for (const position of positions) {
|
|
6088
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6065
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asXyoAddress3(position.staked) === asXyoAddress3(staked)) {
|
|
6089
6066
|
active += position.amount;
|
|
6090
6067
|
}
|
|
6091
6068
|
}
|
|
@@ -6095,7 +6072,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6095
6072
|
let active = 0n;
|
|
6096
6073
|
const positions = await this.stakeViewer.activeStakes();
|
|
6097
6074
|
for (const position of positions) {
|
|
6098
|
-
if ((position.removeBlock === 0 || position.removeBlock > time) &&
|
|
6075
|
+
if ((position.removeBlock === 0 || position.removeBlock > time) && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6099
6076
|
active += position.amount;
|
|
6100
6077
|
}
|
|
6101
6078
|
}
|
|
@@ -6103,7 +6080,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6103
6080
|
}
|
|
6104
6081
|
async createHandler() {
|
|
6105
6082
|
await super.createHandler();
|
|
6106
|
-
this._stakeViewer =
|
|
6083
|
+
this._stakeViewer = assertEx42(
|
|
6107
6084
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6108
6085
|
() => "Failed to create StakeViewer"
|
|
6109
6086
|
);
|
|
@@ -6122,7 +6099,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6122
6099
|
let pending = 0n;
|
|
6123
6100
|
const positions = await this.stakeViewer.removedStakes();
|
|
6124
6101
|
for (const position of positions) {
|
|
6125
|
-
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) &&
|
|
6102
|
+
if (position.removeBlock !== 0 && position.removeBlock <= time && (position.withdrawBlock === 0 || position.withdrawBlock > time) && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6126
6103
|
pending += position.amount;
|
|
6127
6104
|
}
|
|
6128
6105
|
}
|
|
@@ -6142,7 +6119,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6142
6119
|
let withdrawn = 0n;
|
|
6143
6120
|
const positions = await this.stakeViewer.withdrawnStakes();
|
|
6144
6121
|
for (const position of positions) {
|
|
6145
|
-
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time &&
|
|
6122
|
+
if (position.withdrawBlock !== 0 && position.withdrawBlock <= time && asXyoAddress3(position.staker) === asXyoAddress3(staker)) {
|
|
6146
6123
|
withdrawn += position.amount;
|
|
6147
6124
|
}
|
|
6148
6125
|
}
|
|
@@ -6157,17 +6134,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6157
6134
|
], SimpleStakeTotalsViewer);
|
|
6158
6135
|
|
|
6159
6136
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6160
|
-
import {
|
|
6161
|
-
|
|
6162
|
-
assertEx as assertEx42,
|
|
6163
|
-
toAddress as toAddress6
|
|
6164
|
-
} from "@xylabs/sdk-js";
|
|
6137
|
+
import { assertEx as assertEx43, toAddress } from "@xylabs/sdk-js";
|
|
6138
|
+
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/address";
|
|
6165
6139
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6166
6140
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6167
6141
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6168
6142
|
_chainStakeEventsViewer;
|
|
6169
6143
|
get stakeEvents() {
|
|
6170
|
-
return
|
|
6144
|
+
return assertEx43(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6171
6145
|
}
|
|
6172
6146
|
get positions() {
|
|
6173
6147
|
return this.params.positions;
|
|
@@ -6186,7 +6160,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6186
6160
|
let active = 0n;
|
|
6187
6161
|
const positions = await this.activeStakes();
|
|
6188
6162
|
for (const position of positions) {
|
|
6189
|
-
if (position.removeBlock === 0 &&
|
|
6163
|
+
if (position.removeBlock === 0 && asXyoAddress4(position.staked) === asXyoAddress4(staked)) {
|
|
6190
6164
|
active += position.amount;
|
|
6191
6165
|
}
|
|
6192
6166
|
}
|
|
@@ -6196,7 +6170,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6196
6170
|
let active = 0n;
|
|
6197
6171
|
const positions = await this.activeStakes();
|
|
6198
6172
|
for (const position of positions) {
|
|
6199
|
-
if (position.removeBlock === 0 &&
|
|
6173
|
+
if (position.removeBlock === 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6200
6174
|
active += position.amount;
|
|
6201
6175
|
}
|
|
6202
6176
|
}
|
|
@@ -6207,7 +6181,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6207
6181
|
}
|
|
6208
6182
|
async createHandler() {
|
|
6209
6183
|
await super.createHandler();
|
|
6210
|
-
this._chainStakeEventsViewer =
|
|
6184
|
+
this._chainStakeEventsViewer = assertEx43(
|
|
6211
6185
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6212
6186
|
() => "Failed to create StakeEventsViewer"
|
|
6213
6187
|
);
|
|
@@ -6229,7 +6203,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6229
6203
|
let pending = 0n;
|
|
6230
6204
|
const positions = await this.removedStakes();
|
|
6231
6205
|
for (const position of positions) {
|
|
6232
|
-
if (position.removeBlock !== 0 && position.withdrawBlock === 0 &&
|
|
6206
|
+
if (position.removeBlock !== 0 && position.withdrawBlock === 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6233
6207
|
pending += position.amount;
|
|
6234
6208
|
}
|
|
6235
6209
|
}
|
|
@@ -6239,24 +6213,24 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6239
6213
|
return this.positions.filter((s) => s.withdrawBlock === 0 && s.removeBlock !== 0);
|
|
6240
6214
|
}
|
|
6241
6215
|
rewardsContract() {
|
|
6242
|
-
return
|
|
6216
|
+
return toAddress(toAddress(1n));
|
|
6243
6217
|
}
|
|
6244
6218
|
stakeById(id) {
|
|
6245
|
-
return
|
|
6219
|
+
return assertEx43(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6246
6220
|
}
|
|
6247
6221
|
stakeByStaker(staker, slot) {
|
|
6248
|
-
return this.positions.filter((s) =>
|
|
6222
|
+
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
6249
6223
|
}
|
|
6250
6224
|
stakesByStaked(staked, range = [0, void 0]) {
|
|
6251
6225
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6252
|
-
return this.positions.filter((s) =>
|
|
6226
|
+
return this.positions.filter((s) => asXyoAddress4(s.staked) === asXyoAddress4(staked) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6253
6227
|
}
|
|
6254
6228
|
stakesByStaker(staker, range = [0, void 0]) {
|
|
6255
6229
|
const endBlock = range[1] ?? Number.MAX_SAFE_INTEGER;
|
|
6256
|
-
return this.positions.filter((s) =>
|
|
6230
|
+
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
6257
6231
|
}
|
|
6258
6232
|
stakingTokenAddress() {
|
|
6259
|
-
return
|
|
6233
|
+
return toAddress("0x000000000000000000000000000011");
|
|
6260
6234
|
}
|
|
6261
6235
|
async withdrawn() {
|
|
6262
6236
|
let withdrawn = 0n;
|
|
@@ -6272,7 +6246,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6272
6246
|
let withdrawn = 0n;
|
|
6273
6247
|
const positions = await this.withdrawnStakes();
|
|
6274
6248
|
for (const position of positions) {
|
|
6275
|
-
if (position.withdrawBlock !== 0 &&
|
|
6249
|
+
if (position.withdrawBlock !== 0 && asXyoAddress4(position.staker) === asXyoAddress4(staker)) {
|
|
6276
6250
|
withdrawn += position.amount;
|
|
6277
6251
|
}
|
|
6278
6252
|
}
|
|
@@ -6344,7 +6318,7 @@ RestSyncViewer = __decorateClass([
|
|
|
6344
6318
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6345
6319
|
import {
|
|
6346
6320
|
asHash as asHash5,
|
|
6347
|
-
assertEx as
|
|
6321
|
+
assertEx as assertEx44,
|
|
6348
6322
|
isDefined as isDefined21
|
|
6349
6323
|
} from "@xylabs/sdk-js";
|
|
6350
6324
|
import {
|
|
@@ -6366,7 +6340,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6366
6340
|
async convertTime(fromDomain, toDomain, from) {
|
|
6367
6341
|
switch (fromDomain) {
|
|
6368
6342
|
case "xl1": {
|
|
6369
|
-
const [block, payloads] =
|
|
6343
|
+
const [block, payloads] = assertEx44(await this.blockViewer.blockByNumber(asXL1BlockNumber10(from, true)), () => "Block not found");
|
|
6370
6344
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6371
6345
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6372
6346
|
const timePayload = asTimePayload2(isDefined21(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -6421,10 +6395,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6421
6395
|
return [Date.now(), null];
|
|
6422
6396
|
}
|
|
6423
6397
|
case "ethereum": {
|
|
6424
|
-
const provider =
|
|
6398
|
+
const provider = assertEx44(this.ethProvider, () => "Ethereum provider not configured");
|
|
6425
6399
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6426
6400
|
const block = await provider.getBlock(blockNumber);
|
|
6427
|
-
const blockHash = asHash5(
|
|
6401
|
+
const blockHash = asHash5(assertEx44(block?.hash, () => "Block hash not found"), true);
|
|
6428
6402
|
return [blockNumber, blockHash];
|
|
6429
6403
|
}
|
|
6430
6404
|
default: {
|
|
@@ -6439,7 +6413,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6439
6413
|
// this is for the previous block
|
|
6440
6414
|
xl1,
|
|
6441
6415
|
// this is for the previous block
|
|
6442
|
-
xl1Hash:
|
|
6416
|
+
xl1Hash: assertEx44(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6443
6417
|
epoch: Date.now()
|
|
6444
6418
|
};
|
|
6445
6419
|
if (isDefined21(this.ethProvider)) {
|
|
@@ -6459,7 +6433,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6459
6433
|
], SimpleTimeSyncViewer);
|
|
6460
6434
|
|
|
6461
6435
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6462
|
-
import { assertEx as
|
|
6436
|
+
import { assertEx as assertEx45 } from "@xylabs/sdk-js";
|
|
6463
6437
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6464
6438
|
import {
|
|
6465
6439
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -6510,7 +6484,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6510
6484
|
head: void 0
|
|
6511
6485
|
};
|
|
6512
6486
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
|
|
6513
|
-
const head = isChainQualifiedHeadConfig6(config) ?
|
|
6487
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx45(
|
|
6514
6488
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
6515
6489
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6516
6490
|
) : void 0;
|
|
@@ -6576,7 +6550,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
6576
6550
|
], SimpleTransactionValidationViewer);
|
|
6577
6551
|
|
|
6578
6552
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
6579
|
-
import { assertEx as
|
|
6553
|
+
import { assertEx as assertEx46, exists as exists10 } from "@xylabs/sdk-js";
|
|
6580
6554
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
6581
6555
|
import {
|
|
6582
6556
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -6593,7 +6567,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
6593
6567
|
}
|
|
6594
6568
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
6595
6569
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
6596
|
-
|
|
6570
|
+
assertEx46(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
6597
6571
|
try {
|
|
6598
6572
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
6599
6573
|
if (!block) return null;
|
|
@@ -6657,7 +6631,7 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
6657
6631
|
|
|
6658
6632
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
6659
6633
|
import {
|
|
6660
|
-
assertEx as
|
|
6634
|
+
assertEx as assertEx47,
|
|
6661
6635
|
exists as exists11,
|
|
6662
6636
|
isNull as isNull2
|
|
6663
6637
|
} from "@xylabs/sdk-js";
|
|
@@ -6728,7 +6702,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6728
6702
|
}
|
|
6729
6703
|
async createHandler() {
|
|
6730
6704
|
await super.createHandler();
|
|
6731
|
-
this._blockViewer =
|
|
6705
|
+
this._blockViewer = assertEx47(
|
|
6732
6706
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
6733
6707
|
() => "BlockViewer instance is required"
|
|
6734
6708
|
);
|
|
@@ -6737,13 +6711,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6737
6711
|
this._transactionHashMap = new MemoryMap();
|
|
6738
6712
|
}
|
|
6739
6713
|
currentBlock() {
|
|
6740
|
-
return
|
|
6714
|
+
return assertEx47(this._chain.at(-1));
|
|
6741
6715
|
}
|
|
6742
6716
|
currentBlockHash() {
|
|
6743
|
-
return
|
|
6717
|
+
return assertEx47(this._chain.at(-1)?.[0]._hash);
|
|
6744
6718
|
}
|
|
6745
6719
|
currentBlockNumber() {
|
|
6746
|
-
return
|
|
6720
|
+
return assertEx47(this._chain.at(-1)?.[0].block);
|
|
6747
6721
|
}
|
|
6748
6722
|
async payloadByHash(hash) {
|
|
6749
6723
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -6902,13 +6876,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6902
6876
|
};
|
|
6903
6877
|
|
|
6904
6878
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6905
|
-
import { assertEx as
|
|
6879
|
+
import { assertEx as assertEx48 } from "@xylabs/sdk-js";
|
|
6906
6880
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6907
6881
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6908
6882
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6909
6883
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6910
6884
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6911
|
-
return
|
|
6885
|
+
return assertEx48(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6912
6886
|
}
|
|
6913
6887
|
|
|
6914
6888
|
// src/validation/lib/isLocalhost.ts
|