@xyo-network/xl1-protocol-sdk 1.26.25 → 1.26.28
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/index.mjs +252 -348
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/primitives/index.d.ts +0 -1
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/step/completedStepRewardAddress.d.ts +1 -4
- package/dist/neutral/primitives/step/completedStepRewardAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/step/derivedReceiveAddress.d.ts +1 -3
- package/dist/neutral/primitives/step/derivedReceiveAddress.d.ts.map +1 -1
- package/dist/neutral/primitives/step/index.d.ts +0 -2
- package/dist/neutral/primitives/step/index.d.ts.map +1 -1
- package/dist/neutral/primitives/transaction/elevatedPayloads.d.ts +1 -4
- package/dist/neutral/primitives/transaction/elevatedPayloads.d.ts.map +1 -1
- package/dist/neutral/{transaction → test}/buildRandomTransaction.d.ts +1 -1
- package/dist/neutral/test/buildRandomTransaction.d.ts.map +1 -0
- package/dist/neutral/test/index.d.ts +1 -0
- package/dist/neutral/test/index.d.ts.map +1 -1
- package/dist/neutral/transaction/index.d.ts +0 -2
- package/dist/neutral/transaction/index.d.ts.map +1 -1
- package/dist/neutral/transaction/script.d.ts +1 -11
- package/dist/neutral/transaction/script.d.ts.map +1 -1
- package/package.json +7 -11
- package/dist/neutral/test/index.mjs +0 -2003
- package/dist/neutral/test/index.mjs.map +0 -1
- package/dist/neutral/transaction/buildRandomTransaction.d.ts.map +0 -1
package/dist/neutral/index.mjs
CHANGED
|
@@ -1229,7 +1229,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1229
1229
|
import {
|
|
1230
1230
|
assertEx as assertEx13,
|
|
1231
1231
|
exists,
|
|
1232
|
-
toAddress as
|
|
1232
|
+
toAddress as toAddress2
|
|
1233
1233
|
} from "@xylabs/sdk-js";
|
|
1234
1234
|
import {
|
|
1235
1235
|
asTransfer,
|
|
@@ -1251,43 +1251,24 @@ function mergeTransfers(transfers) {
|
|
|
1251
1251
|
return result;
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
-
// src/primitives/step/completedStepRewardAddress.ts
|
|
1255
|
-
import { toAddress as toAddress2 } from "@xylabs/sdk-js";
|
|
1256
|
-
import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
|
|
1257
|
-
import { keccak256 } from "ethers";
|
|
1258
|
-
function completedStepRewardAddress({ block, step }) {
|
|
1259
|
-
const resolvedStepSize = step < StepSizes5.length ? StepSizes5[step] : step;
|
|
1260
|
-
const addressKey = new TextEncoder().encode(`${block}|${resolvedStepSize}`);
|
|
1261
|
-
return toAddress2(keccak256(addressKey).slice(-40), { prefix: false });
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
// src/primitives/step/derivedReceiveAddress.ts
|
|
1265
|
-
import { toAddress as toAddress3 } from "@xylabs/sdk-js";
|
|
1266
|
-
import { isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1267
|
-
import { keccak256 as keccak2562 } from "ethers";
|
|
1268
|
-
function derivedReceiveAddress(address, scope) {
|
|
1269
|
-
const addressKey = new TextEncoder().encode(isDefined9(scope) ? `${scope}|${address}` : address);
|
|
1270
|
-
return toAddress3(keccak2562(addressKey).slice(-40), { prefix: false });
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
1254
|
// src/primitives/step/stepBlockRange.ts
|
|
1274
|
-
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as
|
|
1255
|
+
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
|
|
1275
1256
|
function stepBlockRange({ block, step }) {
|
|
1276
|
-
const stepSize2 =
|
|
1257
|
+
const stepSize2 = StepSizes5[step];
|
|
1277
1258
|
const start = block - stepSize2;
|
|
1278
1259
|
return asXL1BlockRange4([start, start + stepSize2 - 1], { name: "stepBlockRange" });
|
|
1279
1260
|
}
|
|
1280
1261
|
|
|
1281
1262
|
// src/primitives/step/stepTransferIndex.ts
|
|
1282
1263
|
import { assertEx as assertEx11 } from "@xylabs/sdk-js";
|
|
1283
|
-
import { StepSizes as
|
|
1264
|
+
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
|
|
1284
1265
|
function stepTransferIndex(block, step) {
|
|
1285
1266
|
let rewardTransferCount = 0;
|
|
1286
1267
|
let rewardTransferIndex = -1;
|
|
1287
|
-
for (let i = 3; i <
|
|
1288
|
-
const stepSize2 =
|
|
1268
|
+
for (let i = 3; i < StepSizes6.length; i++) {
|
|
1269
|
+
const stepSize2 = StepSizes6[i];
|
|
1289
1270
|
if (block % stepSize2 === 0) {
|
|
1290
|
-
if (stepSize2 ===
|
|
1271
|
+
if (stepSize2 === StepSizes6[step]) {
|
|
1291
1272
|
rewardTransferIndex = rewardTransferCount;
|
|
1292
1273
|
}
|
|
1293
1274
|
rewardTransferCount++;
|
|
@@ -1299,9 +1280,9 @@ function stepTransferIndex(block, step) {
|
|
|
1299
1280
|
|
|
1300
1281
|
// src/primitives/chain/step/stepRewardBlock.ts
|
|
1301
1282
|
import { assertEx as assertEx12 } from "@xylabs/sdk-js";
|
|
1302
|
-
import { StepSizes as
|
|
1283
|
+
import { StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
1303
1284
|
async function stepRewardBlock(context, blockViewer, { block, step }) {
|
|
1304
|
-
assertEx12(block %
|
|
1285
|
+
assertEx12(block % StepSizes7[step] === 0, () => `Block must be the first block of the step [${StepSizes7[step]}], got ${block}`);
|
|
1305
1286
|
return assertEx12(await blockViewer.blockByNumber(block), () => `Could not find block for block number ${block}`);
|
|
1306
1287
|
}
|
|
1307
1288
|
|
|
@@ -1317,11 +1298,11 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1317
1298
|
sortedTransferAmounts.length === transferCount,
|
|
1318
1299
|
() => `Step Transfers mismatch ${block} (${blockBw._hash}) [${sortedTransferAmounts.length} - ${transferCount}]`
|
|
1319
1300
|
);
|
|
1320
|
-
return
|
|
1301
|
+
return toAddress2(sortedTransferAmounts[transferIndex][0]);
|
|
1321
1302
|
}
|
|
1322
1303
|
|
|
1323
1304
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
1324
|
-
import { assertEx as assertEx14, isDefined as
|
|
1305
|
+
import { assertEx as assertEx14, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1325
1306
|
import {
|
|
1326
1307
|
asAttoXL1,
|
|
1327
1308
|
asXL1BlockRange as asXL1BlockRange5,
|
|
@@ -1343,7 +1324,7 @@ var asOptionalAddressPairPayload = AsObjectFactory.createOptional(isAddressPairP
|
|
|
1343
1324
|
// src/payloads/netBalancesForPayloads.ts
|
|
1344
1325
|
import {
|
|
1345
1326
|
hexToBigInt as hexToBigInt2,
|
|
1346
|
-
toAddress as
|
|
1327
|
+
toAddress as toAddress3
|
|
1347
1328
|
} from "@xylabs/sdk-js";
|
|
1348
1329
|
import { span } from "@xylabs/sdk-js";
|
|
1349
1330
|
import { isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -1354,8 +1335,8 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1354
1335
|
if (isTransfer2(payload)) {
|
|
1355
1336
|
const { from } = payload;
|
|
1356
1337
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1357
|
-
balances[
|
|
1358
|
-
balances[
|
|
1338
|
+
balances[toAddress3(address)] = (balances[toAddress3(address)] ?? 0n) + hexToBigInt2(amount);
|
|
1339
|
+
balances[toAddress3(from)] = (balances[toAddress3(from)] ?? 0n) - hexToBigInt2(amount);
|
|
1359
1340
|
}
|
|
1360
1341
|
}
|
|
1361
1342
|
}
|
|
@@ -1366,7 +1347,7 @@ var netBalancesForPayloads = (context, payloads) => {
|
|
|
1366
1347
|
// src/payloads/netSchemasForPayloads.ts
|
|
1367
1348
|
import {
|
|
1368
1349
|
hexToBigInt as hexToBigInt3,
|
|
1369
|
-
toAddress as
|
|
1350
|
+
toAddress as toAddress4
|
|
1370
1351
|
} from "@xylabs/sdk-js";
|
|
1371
1352
|
import { span as span2 } from "@xylabs/sdk-js";
|
|
1372
1353
|
import { isTransfer as isTransfer3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -1377,8 +1358,8 @@ var netSchemasForPayloads = (context, payloads) => {
|
|
|
1377
1358
|
if (isTransfer3(payload)) {
|
|
1378
1359
|
const { from } = payload;
|
|
1379
1360
|
for (const [address, amount] of Object.entries(payload.transfers)) {
|
|
1380
|
-
balances[
|
|
1381
|
-
balances[
|
|
1361
|
+
balances[toAddress4(address)] = (balances[toAddress4(address)] ?? 0n) + hexToBigInt3(amount);
|
|
1362
|
+
balances[toAddress4(from)] = (balances[toAddress4(from)] ?? 0n) - hexToBigInt3(amount);
|
|
1382
1363
|
}
|
|
1383
1364
|
}
|
|
1384
1365
|
}
|
|
@@ -1416,7 +1397,7 @@ function stepInRange(step, range) {
|
|
|
1416
1397
|
return stepRange[0] >= range[0] && stepRange[1] <= range[1];
|
|
1417
1398
|
}
|
|
1418
1399
|
async function stepRewardTotal(context, blockViewer, { block, step }, multipliers) {
|
|
1419
|
-
const cacheKey = `${block}|${step}|${
|
|
1400
|
+
const cacheKey = `${block}|${step}|${isDefined9(multipliers)}`;
|
|
1420
1401
|
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
1421
1402
|
const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
|
|
1422
1403
|
assertEx14(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
@@ -1529,7 +1510,7 @@ async function addDataLakePayloads([boundWitness, payloads], dataLakeViewer) {
|
|
|
1529
1510
|
}
|
|
1530
1511
|
|
|
1531
1512
|
// src/primitives/mapToMapType.ts
|
|
1532
|
-
import { isDefined as
|
|
1513
|
+
import { isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
1533
1514
|
function mapToMapType(map) {
|
|
1534
1515
|
return {
|
|
1535
1516
|
get: (key) => map.get(key),
|
|
@@ -1548,7 +1529,7 @@ function mapToMapType(map) {
|
|
|
1548
1529
|
const result = [];
|
|
1549
1530
|
for (const key of keys) {
|
|
1550
1531
|
const value = map.get(key);
|
|
1551
|
-
if (
|
|
1532
|
+
if (isDefined10(value)) {
|
|
1552
1533
|
result.push(value);
|
|
1553
1534
|
}
|
|
1554
1535
|
}
|
|
@@ -1563,7 +1544,7 @@ function mapToMapType(map) {
|
|
|
1563
1544
|
}
|
|
1564
1545
|
|
|
1565
1546
|
// src/primitives/readPayloadMapFromStore.ts
|
|
1566
|
-
import { isDefined as
|
|
1547
|
+
import { isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
1567
1548
|
function readPayloadMapFromStore(store) {
|
|
1568
1549
|
if (isReadArchivist(store)) {
|
|
1569
1550
|
return {
|
|
@@ -1574,7 +1555,7 @@ function readPayloadMapFromStore(store) {
|
|
|
1574
1555
|
return await store.get(hashes);
|
|
1575
1556
|
},
|
|
1576
1557
|
has: async (hash) => {
|
|
1577
|
-
return
|
|
1558
|
+
return isDefined11((await store.get([hash]))[0]);
|
|
1578
1559
|
}
|
|
1579
1560
|
};
|
|
1580
1561
|
}
|
|
@@ -1590,7 +1571,7 @@ function payloadMapFromStore(store) {
|
|
|
1590
1571
|
return await store.get(hashes);
|
|
1591
1572
|
},
|
|
1592
1573
|
has: async (hash) => {
|
|
1593
|
-
return
|
|
1574
|
+
return isDefined11((await store.get([hash]))[0]);
|
|
1594
1575
|
},
|
|
1595
1576
|
clear: async () => {
|
|
1596
1577
|
return await store.clear();
|
|
@@ -1636,7 +1617,7 @@ function rewardFromBlockNumber(blockNumber) {
|
|
|
1636
1617
|
import { XYO_NETWORK_STAKING_ADDRESS } from "@xyo-network/xl1-protocol-lib";
|
|
1637
1618
|
|
|
1638
1619
|
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
1639
|
-
import { isDefined as
|
|
1620
|
+
import { isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
1640
1621
|
|
|
1641
1622
|
// src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
|
|
1642
1623
|
async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
|
|
@@ -1655,7 +1636,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
|
1655
1636
|
for (const event of stakeEvents) {
|
|
1656
1637
|
if (event.time > time) break;
|
|
1657
1638
|
if (event.args.staked !== staked) continue;
|
|
1658
|
-
if (
|
|
1639
|
+
if (isDefined12(staker) && event.args.staker !== staker) continue;
|
|
1659
1640
|
if (event.name === "StakeAdded") {
|
|
1660
1641
|
result += event.args.amount;
|
|
1661
1642
|
} else if (event.name === "StakeRemoved") {
|
|
@@ -1697,13 +1678,13 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
|
|
|
1697
1678
|
|
|
1698
1679
|
// src/primitives/stake/allStakersForRange.ts
|
|
1699
1680
|
import {
|
|
1700
|
-
toAddress as
|
|
1681
|
+
toAddress as toAddress5
|
|
1701
1682
|
} from "@xylabs/sdk-js";
|
|
1702
1683
|
async function allStakersForRange(chain, externalRange, staked) {
|
|
1703
1684
|
const mergedEvents = await mergedAddRemoveStakeEventsByStaker(chain, [0, externalRange[1]], staked);
|
|
1704
1685
|
const resultWithZeros = {};
|
|
1705
1686
|
for (const event of mergedEvents) {
|
|
1706
|
-
const staker =
|
|
1687
|
+
const staker = toAddress5(event.args.staker);
|
|
1707
1688
|
resultWithZeros[staker] = resultWithZeros[staker] ?? 0n;
|
|
1708
1689
|
if (event.name === "StakeAdded") {
|
|
1709
1690
|
resultWithZeros[staker] += event.args.amount;
|
|
@@ -1714,7 +1695,7 @@ async function allStakersForRange(chain, externalRange, staked) {
|
|
|
1714
1695
|
const nonZero = Object.entries(resultWithZeros).filter(([, amount]) => amount > 0n).map(([address]) => address);
|
|
1715
1696
|
const result = {};
|
|
1716
1697
|
for (const address of nonZero) {
|
|
1717
|
-
result[
|
|
1698
|
+
result[toAddress5(address)] = resultWithZeros[toAddress5(address)];
|
|
1718
1699
|
}
|
|
1719
1700
|
return result;
|
|
1720
1701
|
}
|
|
@@ -1730,13 +1711,13 @@ async function allStakersForStep(context, blockViewer, stakeEventsViewer, stepCo
|
|
|
1730
1711
|
}
|
|
1731
1712
|
|
|
1732
1713
|
// src/primitives/stake/weightedStakeForRangeByPosition.ts
|
|
1733
|
-
import { isDefined as
|
|
1714
|
+
import { isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
1734
1715
|
import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol-lib";
|
|
1735
1716
|
async function weightedStakeForRangeByPosition(context, blockViewer, stakeEventsViewer, externalRange, staked, positionId) {
|
|
1736
|
-
const cacheKey =
|
|
1717
|
+
const cacheKey = isDefined13(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
|
|
1737
1718
|
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
1738
1719
|
let weightedStakeSum = 0n;
|
|
1739
|
-
if (
|
|
1720
|
+
if (isDefined13(positionId)) {
|
|
1740
1721
|
const mergedEvents = (await mergedAddRemoveStakeEventsByPosition(
|
|
1741
1722
|
stakeEventsViewer,
|
|
1742
1723
|
[0, externalRange[1]],
|
|
@@ -1744,7 +1725,7 @@ async function weightedStakeForRangeByPosition(context, blockViewer, stakeEvents
|
|
|
1744
1725
|
)).toSorted((a, b) => a.time - b.time);
|
|
1745
1726
|
let currentTime = externalRange[0];
|
|
1746
1727
|
let currentStake = 0n;
|
|
1747
|
-
if (
|
|
1728
|
+
if (isDefined13(staked) && mergedEvents.at(0)?.args.staked !== staked) {
|
|
1748
1729
|
return 0n;
|
|
1749
1730
|
}
|
|
1750
1731
|
for (const event of mergedEvents) {
|
|
@@ -1833,27 +1814,6 @@ async function hydratedBlockByNumber(context, blockNumber) {
|
|
|
1833
1814
|
}, { ...context, timeBudgetLimit: 500 });
|
|
1834
1815
|
}
|
|
1835
1816
|
|
|
1836
|
-
// src/primitives/transaction/elevatedPayloads.ts
|
|
1837
|
-
import { isAllowedBlockPayload } from "@xyo-network/xl1-protocol-lib";
|
|
1838
|
-
var ELEVATE_OPCODE = "elevate";
|
|
1839
|
-
function elevatedPayloads([tx, payloads]) {
|
|
1840
|
-
const opCodes = (tx.script ?? []).filter((operation) => operation.startsWith(`${ELEVATE_OPCODE}|`));
|
|
1841
|
-
const elevatedPayloads2 = [];
|
|
1842
|
-
for (const opCode of opCodes) {
|
|
1843
|
-
const [code, hash] = opCode.split("|");
|
|
1844
|
-
if (code === ELEVATE_OPCODE) {
|
|
1845
|
-
const elevatedPayload = payloads.find((payload) => payload._hash === hash);
|
|
1846
|
-
if (isAllowedBlockPayload(elevatedPayload)) {
|
|
1847
|
-
elevatedPayloads2.push(elevatedPayload);
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
if (opCodes.length === elevatedPayloads2.length) {
|
|
1852
|
-
return elevatedPayloads2;
|
|
1853
|
-
}
|
|
1854
|
-
throw new Error("Not all elevated payloads could be found in the transaction payloads");
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
1817
|
// src/primitives/uncle/getProducerKey.ts
|
|
1858
1818
|
function getProducerKey(block) {
|
|
1859
1819
|
return block[0].addresses.toSorted().join(",");
|
|
@@ -2160,31 +2120,14 @@ var bundle = (root, transaction) => {
|
|
|
2160
2120
|
|
|
2161
2121
|
// src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts
|
|
2162
2122
|
import { PayloadBundleSchema as PayloadBundleSchema2 } from "@xyo-network/sdk-js";
|
|
2163
|
-
import { PayloadBuilder as
|
|
2164
|
-
|
|
2165
|
-
// src/transaction/buildRandomTransaction.ts
|
|
2166
|
-
import { Account } from "@xyo-network/sdk-js";
|
|
2167
|
-
import { asXL1BlockNumber as asXL1BlockNumber4, isAllowedBlockPayload as isAllowedBlockPayload2 } from "@xyo-network/xl1-protocol-lib";
|
|
2168
|
-
|
|
2169
|
-
// src/createTransferPayload.ts
|
|
2170
|
-
import { toHex } from "@xylabs/sdk-js";
|
|
2171
|
-
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/sdk-js";
|
|
2172
|
-
import { TransferSchema } from "@xyo-network/xl1-protocol-lib";
|
|
2173
|
-
function createTransferPayload(from, transfers, context) {
|
|
2174
|
-
return new PayloadBuilder6({ schema: TransferSchema }).fields({
|
|
2175
|
-
epoch: Date.now(),
|
|
2176
|
-
from,
|
|
2177
|
-
transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex(v)])),
|
|
2178
|
-
context
|
|
2179
|
-
}).build();
|
|
2180
|
-
}
|
|
2123
|
+
import { PayloadBuilder as PayloadBuilder11 } from "@xyo-network/sdk-js";
|
|
2181
2124
|
|
|
2182
2125
|
// src/transaction/buildTransaction.ts
|
|
2183
|
-
import { assertEx as assertEx18, toHex
|
|
2126
|
+
import { assertEx as assertEx18, toHex } from "@xylabs/sdk-js";
|
|
2184
2127
|
import {
|
|
2185
2128
|
asAnyPayload as asAnyPayload2,
|
|
2186
2129
|
BoundWitnessBuilder,
|
|
2187
|
-
PayloadBuilder as
|
|
2130
|
+
PayloadBuilder as PayloadBuilder6
|
|
2188
2131
|
} from "@xyo-network/sdk-js";
|
|
2189
2132
|
import { defaultTransactionFees } from "@xyo-network/xl1-protocol-lib";
|
|
2190
2133
|
async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer, nbf, exp, from, fees = defaultTransactionFees) {
|
|
@@ -2194,15 +2137,15 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2194
2137
|
const txBoundWitnessFields = {
|
|
2195
2138
|
chain,
|
|
2196
2139
|
fees: {
|
|
2197
|
-
base:
|
|
2198
|
-
gasLimit:
|
|
2199
|
-
gasPrice:
|
|
2200
|
-
priority:
|
|
2140
|
+
base: toHex(fees.base),
|
|
2141
|
+
gasLimit: toHex(fees.gasLimit),
|
|
2142
|
+
gasPrice: toHex(fees.gasPrice),
|
|
2143
|
+
priority: toHex(fees.priority)
|
|
2201
2144
|
},
|
|
2202
2145
|
nbf,
|
|
2203
2146
|
exp
|
|
2204
2147
|
};
|
|
2205
|
-
const elevatedHashes = await
|
|
2148
|
+
const elevatedHashes = await PayloadBuilder6.hashes(onChainPayloads);
|
|
2206
2149
|
const script = [];
|
|
2207
2150
|
for (const elevatedHash of elevatedHashes) {
|
|
2208
2151
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -2215,40 +2158,26 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
2215
2158
|
fields.script = script;
|
|
2216
2159
|
}
|
|
2217
2160
|
const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({ $signatures: [] }).payloads([...onChainPayloads, ...offChainPayloads]).signers(Array.isArray(signer) ? signer : [signer]).build();
|
|
2218
|
-
return [await
|
|
2161
|
+
return [await PayloadBuilder6.addHashMeta(tx), await PayloadBuilder6.addHashMeta(txPayloads.map((p) => asAnyPayload2(p, true)))];
|
|
2219
2162
|
}
|
|
2220
2163
|
|
|
2221
|
-
// src/transaction/buildRandomTransaction.ts
|
|
2222
|
-
var buildRandomTransaction = async (chain, payloads, account, nbf = asXL1BlockNumber4(0, true), exp = asXL1BlockNumber4(nbf + 1e3, true), privatePayloadSchemas = [], receiverAddress) => {
|
|
2223
|
-
const elevatedPayloads2 = (payloads ?? []).filter(isAllowedBlockPayload2);
|
|
2224
|
-
const additionalPayloads = (payloads ?? []).filter((payload) => !isAllowedBlockPayload2(payload));
|
|
2225
|
-
const sender = account ?? await Account.random();
|
|
2226
|
-
if (elevatedPayloads2?.length === 0) {
|
|
2227
|
-
const receiver = receiverAddress ?? (await Account.random()).address;
|
|
2228
|
-
const transferPayload = createTransferPayload(sender.address, { [receiver]: 1n });
|
|
2229
|
-
elevatedPayloads2.push(transferPayload);
|
|
2230
|
-
}
|
|
2231
|
-
const hydratedTransaction = await buildTransaction(chain, elevatedPayloads2, additionalPayloads, sender, nbf, exp);
|
|
2232
|
-
return [hydratedTransaction[0], hydratedTransaction[1].filter((p) => !privatePayloadSchemas.includes(p.schema))];
|
|
2233
|
-
};
|
|
2234
|
-
|
|
2235
2164
|
// src/transaction/buildUnsignedTransaction.ts
|
|
2236
|
-
import { toHex as
|
|
2237
|
-
import { BoundWitnessBuilder as BoundWitnessBuilder2, PayloadBuilder as
|
|
2165
|
+
import { toHex as toHex2 } from "@xylabs/sdk-js";
|
|
2166
|
+
import { BoundWitnessBuilder as BoundWitnessBuilder2, PayloadBuilder as PayloadBuilder7 } from "@xyo-network/sdk-js";
|
|
2238
2167
|
import { defaultTransactionFees as defaultTransactionFees2 } from "@xyo-network/xl1-protocol-lib";
|
|
2239
2168
|
async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads, nbf, exp, from, fees = defaultTransactionFees2) {
|
|
2240
2169
|
const txBoundWitnessFields = {
|
|
2241
2170
|
chain,
|
|
2242
2171
|
fees: {
|
|
2243
|
-
base:
|
|
2244
|
-
gasLimit:
|
|
2245
|
-
gasPrice:
|
|
2246
|
-
priority:
|
|
2172
|
+
base: toHex2(fees.base),
|
|
2173
|
+
gasLimit: toHex2(fees.gasLimit),
|
|
2174
|
+
gasPrice: toHex2(fees.gasPrice),
|
|
2175
|
+
priority: toHex2(fees.priority)
|
|
2247
2176
|
},
|
|
2248
2177
|
nbf,
|
|
2249
2178
|
exp
|
|
2250
2179
|
};
|
|
2251
|
-
const elevatedHashes = await
|
|
2180
|
+
const elevatedHashes = await PayloadBuilder7.hashes(onChainPayloads);
|
|
2252
2181
|
const script = [];
|
|
2253
2182
|
for (const elevatedHash of elevatedHashes) {
|
|
2254
2183
|
script.push(`elevate|${elevatedHash}`);
|
|
@@ -2265,7 +2194,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
2265
2194
|
}
|
|
2266
2195
|
|
|
2267
2196
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
2268
|
-
import { delay as delay2, isDefined as
|
|
2197
|
+
import { delay as delay2, isDefined as isDefined14 } from "@xylabs/sdk-js";
|
|
2269
2198
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
2270
2199
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
2271
2200
|
var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
@@ -2274,7 +2203,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2274
2203
|
let attempts = 0;
|
|
2275
2204
|
while (true) {
|
|
2276
2205
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
2277
|
-
if (
|
|
2206
|
+
if (isDefined14(tx)) {
|
|
2278
2207
|
options?.logger?.log("\u2705 Transaction confirmed:", txHash, "\n");
|
|
2279
2208
|
return tx;
|
|
2280
2209
|
} else {
|
|
@@ -2299,7 +2228,7 @@ import {
|
|
|
2299
2228
|
} from "@xyo-network/sdk-js";
|
|
2300
2229
|
import {
|
|
2301
2230
|
asSignedHydratedTransaction,
|
|
2302
|
-
isAllowedBlockPayload
|
|
2231
|
+
isAllowedBlockPayload,
|
|
2303
2232
|
isSignedTransactionBoundWitnessWithStorageMeta
|
|
2304
2233
|
} from "@xyo-network/xl1-protocol-lib";
|
|
2305
2234
|
var tryHydrateTransaction = async ({ chainMap }, hash) => {
|
|
@@ -2350,18 +2279,18 @@ var tryHydrateElevatedTransaction = async ({ chainMap }, hash) => {
|
|
|
2350
2279
|
}
|
|
2351
2280
|
const [transaction, payloads] = hydratedTransaction;
|
|
2352
2281
|
const opCodes = (transaction.script ?? []).filter((operation) => operation.startsWith("elevate|"));
|
|
2353
|
-
const
|
|
2282
|
+
const elevatedPayloads = [];
|
|
2354
2283
|
for (const opCode of opCodes) {
|
|
2355
2284
|
const [code, hash2] = opCode.split("|");
|
|
2356
2285
|
if (code === "elevated") {
|
|
2357
2286
|
const elevatedPayload = payloads.find((payload) => payload._hash === hash2);
|
|
2358
|
-
if (
|
|
2359
|
-
|
|
2287
|
+
if (isAllowedBlockPayload(elevatedPayload)) {
|
|
2288
|
+
elevatedPayloads.push(elevatedPayload);
|
|
2360
2289
|
}
|
|
2361
2290
|
}
|
|
2362
2291
|
}
|
|
2363
|
-
if (opCodes.length ===
|
|
2364
|
-
return [transaction,
|
|
2292
|
+
if (opCodes.length === elevatedPayloads.length) {
|
|
2293
|
+
return [transaction, elevatedPayloads.map((p) => asAnyPayload3(p, true))];
|
|
2365
2294
|
}
|
|
2366
2295
|
return void 0;
|
|
2367
2296
|
};
|
|
@@ -2370,11 +2299,11 @@ var hydrateElevatedTransaction = async (context, hash) => {
|
|
|
2370
2299
|
};
|
|
2371
2300
|
|
|
2372
2301
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
2373
|
-
import { PayloadBuilder as
|
|
2302
|
+
import { PayloadBuilder as PayloadBuilder8 } from "@xyo-network/sdk-js";
|
|
2374
2303
|
function transactionBlockByteCount([transaction, payloads]) {
|
|
2375
|
-
const cleanTransaction =
|
|
2304
|
+
const cleanTransaction = PayloadBuilder8.omitStorageMeta(transaction);
|
|
2376
2305
|
const transactionBytes = JSON.stringify(cleanTransaction).length;
|
|
2377
|
-
const cleanPayloads =
|
|
2306
|
+
const cleanPayloads = PayloadBuilder8.omitStorageMeta(payloads);
|
|
2378
2307
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
2379
2308
|
}
|
|
2380
2309
|
|
|
@@ -2400,8 +2329,8 @@ function transactionElevatedPayloadHashes(transaction) {
|
|
|
2400
2329
|
}
|
|
2401
2330
|
function transactionElevatedPayloads([transaction, payloads]) {
|
|
2402
2331
|
const hashes = transactionElevatedPayloadHashes(transaction);
|
|
2403
|
-
const
|
|
2404
|
-
return
|
|
2332
|
+
const elevatedPayloads = payloads.filter((payload) => hashes.includes(payload._hash));
|
|
2333
|
+
return elevatedPayloads;
|
|
2405
2334
|
}
|
|
2406
2335
|
|
|
2407
2336
|
// src/transaction/primitives/transactionRequiredGas.ts
|
|
@@ -2411,55 +2340,25 @@ function transactionBytesRequiredGas([transaction, payloads]) {
|
|
|
2411
2340
|
return AttoXL12(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes));
|
|
2412
2341
|
}
|
|
2413
2342
|
function transactionRequiredGas(hydratedTransaction) {
|
|
2414
|
-
const
|
|
2415
|
-
const hashes =
|
|
2343
|
+
const elevatedPayloads = transactionElevatedPayloads(hydratedTransaction);
|
|
2344
|
+
const hashes = elevatedPayloads.length + 1;
|
|
2416
2345
|
const signatures = hydratedTransaction[0].addresses.length;
|
|
2417
|
-
return AttoXL12(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(
|
|
2346
|
+
return AttoXL12(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads.length));
|
|
2418
2347
|
}
|
|
2419
2348
|
|
|
2420
|
-
// src/transaction/script.ts
|
|
2421
|
-
import { asHash as asHash3 } from "@xylabs/sdk-js";
|
|
2422
|
-
import { assertEx as assertEx20, filterAs } from "@xylabs/sdk-js";
|
|
2423
|
-
import { isHashMeta } from "@xyo-network/sdk-js";
|
|
2424
|
-
import { isAllowedBlockPayload as isAllowedBlockPayload4 } from "@xyo-network/xl1-protocol-lib";
|
|
2425
|
-
var tryExtractElevatedHashesFromScript = (strings) => {
|
|
2426
|
-
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
2427
|
-
return filterAs(hashes, (h) => asHash3(h));
|
|
2428
|
-
};
|
|
2429
|
-
var extractElevatedHashesFromScript = (strings) => {
|
|
2430
|
-
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
2431
|
-
const filtered = filterAs(hashes, (h) => asHash3(h));
|
|
2432
|
-
assertEx20(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2433
|
-
return filtered;
|
|
2434
|
-
};
|
|
2435
|
-
var tryExtractElevatedHashes = (tx) => {
|
|
2436
|
-
const [bw, payloads] = tx;
|
|
2437
|
-
const { script } = bw;
|
|
2438
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
2439
|
-
return payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayload4).filter(isHashMeta);
|
|
2440
|
-
};
|
|
2441
|
-
var extractElevatedHashes = (tx) => {
|
|
2442
|
-
const [bw, payloads] = tx;
|
|
2443
|
-
const { script } = bw;
|
|
2444
|
-
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
2445
|
-
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayload4).filter(isHashMeta);
|
|
2446
|
-
assertEx20(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
2447
|
-
return filtered;
|
|
2448
|
-
};
|
|
2449
|
-
|
|
2450
2349
|
// src/transaction/signTransaction.ts
|
|
2451
2350
|
import {
|
|
2452
|
-
assertEx as
|
|
2351
|
+
assertEx as assertEx20,
|
|
2453
2352
|
hexFromArrayBuffer,
|
|
2454
2353
|
toArrayBuffer
|
|
2455
2354
|
} from "@xylabs/sdk-js";
|
|
2456
|
-
import { PayloadBuilder as
|
|
2355
|
+
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/sdk-js";
|
|
2457
2356
|
async function signTransaction(tx, account) {
|
|
2458
|
-
|
|
2357
|
+
assertEx20(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
2459
2358
|
const unsignedTx = structuredClone(tx);
|
|
2460
2359
|
unsignedTx.addresses = [account.address];
|
|
2461
2360
|
unsignedTx.previous_hashes = [account.previousHash ?? null];
|
|
2462
|
-
const hash = await
|
|
2361
|
+
const hash = await PayloadBuilder9.dataHash(unsignedTx);
|
|
2463
2362
|
const hashBytes = toArrayBuffer(hash);
|
|
2464
2363
|
const [signature] = await account.sign(hashBytes);
|
|
2465
2364
|
const result = {
|
|
@@ -2470,12 +2369,12 @@ async function signTransaction(tx, account) {
|
|
|
2470
2369
|
}
|
|
2471
2370
|
|
|
2472
2371
|
// src/transaction/TransactionBuilder.ts
|
|
2473
|
-
import { assertEx as
|
|
2474
|
-
import { PayloadBuilder as
|
|
2372
|
+
import { assertEx as assertEx21, Base } from "@xylabs/sdk-js";
|
|
2373
|
+
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/sdk-js";
|
|
2475
2374
|
import {
|
|
2476
|
-
asXL1BlockNumber as
|
|
2375
|
+
asXL1BlockNumber as asXL1BlockNumber4,
|
|
2477
2376
|
defaultTransactionFees as defaultTransactionFees3,
|
|
2478
|
-
isAllowedBlockPayload as
|
|
2377
|
+
isAllowedBlockPayload as isAllowedBlockPayload2,
|
|
2479
2378
|
minTransactionFees,
|
|
2480
2379
|
XYO_ZERO_ADDRESS
|
|
2481
2380
|
} from "@xyo-network/xl1-protocol-lib";
|
|
@@ -2490,16 +2389,16 @@ var TransactionBuilder = class extends Base {
|
|
|
2490
2389
|
super(options);
|
|
2491
2390
|
}
|
|
2492
2391
|
async build() {
|
|
2493
|
-
const chain =
|
|
2494
|
-
const fees =
|
|
2495
|
-
const blockRange =
|
|
2392
|
+
const chain = assertEx21(this._chain, () => "Chain must be set before building the transaction");
|
|
2393
|
+
const fees = assertEx21(this._fees, () => "Fees must be set before building the transaction");
|
|
2394
|
+
const blockRange = assertEx21(this._blockRange, () => "Block range must be set before building the transaction");
|
|
2496
2395
|
return await buildTransaction(
|
|
2497
2396
|
chain,
|
|
2498
2397
|
this._elevatedPayloads,
|
|
2499
2398
|
this._payloads,
|
|
2500
2399
|
this._signers,
|
|
2501
|
-
|
|
2502
|
-
|
|
2400
|
+
asXL1BlockNumber4(blockRange[0], true),
|
|
2401
|
+
asXL1BlockNumber4(blockRange[1], true),
|
|
2503
2402
|
this._signers[0]?.address,
|
|
2504
2403
|
fees
|
|
2505
2404
|
);
|
|
@@ -2514,15 +2413,15 @@ var TransactionBuilder = class extends Base {
|
|
|
2514
2413
|
this._elevatedPayloads,
|
|
2515
2414
|
this._payloads,
|
|
2516
2415
|
this._signers,
|
|
2517
|
-
|
|
2518
|
-
|
|
2416
|
+
asXL1BlockNumber4(0, true),
|
|
2417
|
+
asXL1BlockNumber4(1e3, true),
|
|
2519
2418
|
this._signers[0]?.address,
|
|
2520
2419
|
defaultTransactionFees3
|
|
2521
2420
|
);
|
|
2522
2421
|
}
|
|
2523
2422
|
elevatedPayload(payload) {
|
|
2524
|
-
const allowedPayload =
|
|
2525
|
-
const allowPayloadExists =
|
|
2423
|
+
const allowedPayload = isAllowedBlockPayload2(payload) ? payload : void 0;
|
|
2424
|
+
const allowPayloadExists = assertEx21(allowedPayload, () => "Payload must be an AllowedBlockPayload");
|
|
2526
2425
|
this._elevatedPayloads.push(allowPayloadExists);
|
|
2527
2426
|
return this;
|
|
2528
2427
|
}
|
|
@@ -2569,8 +2468,8 @@ var TransactionBuilder = class extends Base {
|
|
|
2569
2468
|
return this;
|
|
2570
2469
|
}
|
|
2571
2470
|
async removeElevatedPayload(payload) {
|
|
2572
|
-
const hash = await
|
|
2573
|
-
const existingHashes = await
|
|
2471
|
+
const hash = await PayloadBuilder10.hash(payload);
|
|
2472
|
+
const existingHashes = await PayloadBuilder10.hashes(this._elevatedPayloads);
|
|
2574
2473
|
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
2575
2474
|
if (existingPayloadIndex === -1) {
|
|
2576
2475
|
throw new Error("Payload not found in the transaction");
|
|
@@ -2579,8 +2478,8 @@ var TransactionBuilder = class extends Base {
|
|
|
2579
2478
|
return this;
|
|
2580
2479
|
}
|
|
2581
2480
|
async removePayload(payload) {
|
|
2582
|
-
const hash = await
|
|
2583
|
-
const existingHashes = await
|
|
2481
|
+
const hash = await PayloadBuilder10.hash(payload);
|
|
2482
|
+
const existingHashes = await PayloadBuilder10.hashes(this._payloads);
|
|
2584
2483
|
const existingPayloadIndex = existingHashes.indexOf(hash);
|
|
2585
2484
|
if (existingPayloadIndex === -1) {
|
|
2586
2485
|
throw new Error("Payload not found in the transaction");
|
|
@@ -2612,7 +2511,7 @@ var hydratedTransactionToPayloadBundle = (transaction) => {
|
|
|
2612
2511
|
};
|
|
2613
2512
|
var bundle2 = (root, transaction) => {
|
|
2614
2513
|
const payloads = flattenHydratedTransaction(transaction);
|
|
2615
|
-
return new
|
|
2514
|
+
return new PayloadBuilder11({ schema: PayloadBundleSchema2 }).fields({ payloads, root }).build();
|
|
2616
2515
|
};
|
|
2617
2516
|
|
|
2618
2517
|
// src/context/Actor.ts
|
|
@@ -2624,12 +2523,12 @@ var toActorConfigContext = zodToFactory5(ActorConfigContext, "toActorConfigConte
|
|
|
2624
2523
|
// src/CreatableProvider/AbstractCreatableProvider.ts
|
|
2625
2524
|
import {
|
|
2626
2525
|
AbstractCreatable as AbstractCreatable2,
|
|
2627
|
-
assertEx as
|
|
2526
|
+
assertEx as assertEx23,
|
|
2628
2527
|
IdLogger as IdLogger2
|
|
2629
2528
|
} from "@xylabs/sdk-js";
|
|
2630
2529
|
|
|
2631
2530
|
// src/CreatableProvider/ProviderFactory.ts
|
|
2632
|
-
import { assertEx as
|
|
2531
|
+
import { assertEx as assertEx22 } from "@xylabs/sdk-js";
|
|
2633
2532
|
function providerFactoryDescription(factory, labels) {
|
|
2634
2533
|
return `${factory.providerName}:${factory.defaultMoniker}:${JSON.stringify(labels ?? factory.labels ?? {})}`;
|
|
2635
2534
|
}
|
|
@@ -2650,7 +2549,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
2650
2549
|
this.dependencies = dependencies;
|
|
2651
2550
|
this.monikers = creatableProvider2.monikers;
|
|
2652
2551
|
this.scope = scope;
|
|
2653
|
-
|
|
2552
|
+
assertEx22(this.monikers.includes(this.defaultMoniker), () => "defaultMoniker must be in monikers");
|
|
2654
2553
|
this.labels = Object.assign({}, creatableProvider2.labels ?? {}, labels ?? {});
|
|
2655
2554
|
this.providerName = creatableProvider2.name;
|
|
2656
2555
|
this._uniqueId = Symbol(providerFactoryDescription(this));
|
|
@@ -2678,7 +2577,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
2678
2577
|
break;
|
|
2679
2578
|
}
|
|
2680
2579
|
case "context": {
|
|
2681
|
-
const context =
|
|
2580
|
+
const context = assertEx22(
|
|
2682
2581
|
params?.context,
|
|
2683
2582
|
() => "Context is required for context-scoped providers"
|
|
2684
2583
|
);
|
|
@@ -2699,7 +2598,7 @@ var ProviderFactory = class _ProviderFactory {
|
|
|
2699
2598
|
scopeObject[this.resolvedMoniker] = resultPromise;
|
|
2700
2599
|
const result = await resultPromise;
|
|
2701
2600
|
if (start) {
|
|
2702
|
-
|
|
2601
|
+
assertEx22(await result.start(), () => `Failed to start provider instance [${this.resolvedMoniker}]`);
|
|
2703
2602
|
}
|
|
2704
2603
|
return result;
|
|
2705
2604
|
}
|
|
@@ -2744,9 +2643,9 @@ var AbstractCreatableProvider = class extends AbstractCreatable2 {
|
|
|
2744
2643
|
return factory;
|
|
2745
2644
|
}
|
|
2746
2645
|
static async paramsHandler(params = {}) {
|
|
2747
|
-
const context =
|
|
2748
|
-
const config =
|
|
2749
|
-
const locator =
|
|
2646
|
+
const context = assertEx23(params.context, () => new Error("Context is required"));
|
|
2647
|
+
const config = assertEx23(context.config, () => new Error("Context config is required"));
|
|
2648
|
+
const locator = assertEx23(context.locator, () => new Error("Context locator is required"));
|
|
2750
2649
|
return await super.paramsHandler({
|
|
2751
2650
|
...params,
|
|
2752
2651
|
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
@@ -2857,7 +2756,7 @@ function labeledCreatableProviderFactory() {
|
|
|
2857
2756
|
|
|
2858
2757
|
// src/CreatableProvider/ProviderFactoryLocator.ts
|
|
2859
2758
|
import { hasAllLabels } from "@xylabs/sdk-js";
|
|
2860
|
-
import { assertEx as
|
|
2759
|
+
import { assertEx as assertEx24 } from "@xylabs/sdk-js";
|
|
2861
2760
|
var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
2862
2761
|
_context;
|
|
2863
2762
|
_registry;
|
|
@@ -2889,7 +2788,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
2889
2788
|
this._frozen = true;
|
|
2890
2789
|
}
|
|
2891
2790
|
async getInstance(moniker, { start = true, labels } = {}) {
|
|
2892
|
-
return
|
|
2791
|
+
return assertEx24(
|
|
2893
2792
|
await this.tryGetInstance(moniker, { start, labels }),
|
|
2894
2793
|
() => `No provider instance for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} could be created`
|
|
2895
2794
|
);
|
|
@@ -2904,7 +2803,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
2904
2803
|
* @returns A provider factory that matches the supplied moniker and labels or throws if one is not found
|
|
2905
2804
|
*/
|
|
2906
2805
|
locate(moniker, labels) {
|
|
2907
|
-
return
|
|
2806
|
+
return assertEx24(
|
|
2908
2807
|
this.tryLocate(moniker, labels),
|
|
2909
2808
|
() => `No module factory for the supplied config moniker [${moniker}]${labels ? ` & labels [${JSON.stringify(labels)}]` : ""} registered`
|
|
2910
2809
|
);
|
|
@@ -2926,10 +2825,10 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
2926
2825
|
* @param labels The labels for the module factory
|
|
2927
2826
|
*/
|
|
2928
2827
|
register(factory, labels, primary = false) {
|
|
2929
|
-
|
|
2828
|
+
assertEx24(!this._frozen, () => "Cannot register a module factory after the locator has been frozen");
|
|
2930
2829
|
if (this.validateDepsOnRegister) {
|
|
2931
2830
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
2932
|
-
|
|
2831
|
+
assertEx24(missingDeps.length === 0, () => `Cannot register module factory [${factory.uniqueId.description}] due to missing dependencies: ${missingDeps.join(", ")}`);
|
|
2933
2832
|
}
|
|
2934
2833
|
registerCreatableProviderFactory(this._registry, factory, labels, primary);
|
|
2935
2834
|
return this;
|
|
@@ -2977,7 +2876,7 @@ var ProviderFactoryLocator = class _ProviderFactoryLocator {
|
|
|
2977
2876
|
for (const moniker in this.registry) {
|
|
2978
2877
|
for (const factory of this.registry[moniker] ?? []) {
|
|
2979
2878
|
const missingDeps = factory.dependencies.filter((dep) => !this.registered(dep));
|
|
2980
|
-
|
|
2879
|
+
assertEx24(missingDeps.length === 0, () => `Module factory [${factory.uniqueId.description}] is missing dependencies: ${missingDeps.join(", ")}`);
|
|
2981
2880
|
}
|
|
2982
2881
|
}
|
|
2983
2882
|
}
|
|
@@ -3011,14 +2910,14 @@ var asHostActorConfigContext = zodAsFactory6(HostActorConfigContext, "asHostActo
|
|
|
3011
2910
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3012
2911
|
|
|
3013
2912
|
// src/createDeclarationPayload.ts
|
|
3014
|
-
import { isDefined as
|
|
3015
|
-
import { PayloadBuilder as
|
|
2913
|
+
import { isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
2914
|
+
import { PayloadBuilder as PayloadBuilder12 } from "@xyo-network/sdk-js";
|
|
3016
2915
|
import {
|
|
3017
2916
|
ChainStakeIntentSchema
|
|
3018
2917
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3019
2918
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3020
|
-
const expiration =
|
|
3021
|
-
const redeclarationIntent = new
|
|
2919
|
+
const expiration = isDefined15(exp) ? exp : nbf + 1e4;
|
|
2920
|
+
const redeclarationIntent = new PayloadBuilder12({ schema: ChainStakeIntentSchema }).fields({
|
|
3022
2921
|
from: address,
|
|
3023
2922
|
intent,
|
|
3024
2923
|
nbf,
|
|
@@ -3027,6 +2926,19 @@ var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
|
3027
2926
|
return redeclarationIntent;
|
|
3028
2927
|
};
|
|
3029
2928
|
|
|
2929
|
+
// src/createTransferPayload.ts
|
|
2930
|
+
import { toHex as toHex3 } from "@xylabs/sdk-js";
|
|
2931
|
+
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
2932
|
+
import { TransferSchema } from "@xyo-network/xl1-protocol-lib";
|
|
2933
|
+
function createTransferPayload(from, transfers, context) {
|
|
2934
|
+
return new PayloadBuilder13({ schema: TransferSchema }).fields({
|
|
2935
|
+
epoch: Date.now(),
|
|
2936
|
+
from,
|
|
2937
|
+
transfers: Object.fromEntries(Object.entries(transfers).map(([k, v]) => [k, toHex3(v)])),
|
|
2938
|
+
context
|
|
2939
|
+
}).build();
|
|
2940
|
+
}
|
|
2941
|
+
|
|
3030
2942
|
// src/eip-712/Payloads/EIP712Data.ts
|
|
3031
2943
|
import { AsObjectFactory as AsObjectFactory2 } from "@xylabs/sdk-js";
|
|
3032
2944
|
import {
|
|
@@ -3103,7 +3015,7 @@ var signEIP712Message = async (signer, data) => {
|
|
|
3103
3015
|
};
|
|
3104
3016
|
|
|
3105
3017
|
// src/eip-712/verify.ts
|
|
3106
|
-
import { asHash as
|
|
3018
|
+
import { asHash as asHash3, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
3107
3019
|
import { PayloadBuilder as PayloadBuilder15 } from "@xyo-network/sdk-js";
|
|
3108
3020
|
import { verifyTypedData } from "ethers";
|
|
3109
3021
|
var verifyEIP712Message = async (data, sig) => {
|
|
@@ -3113,7 +3025,7 @@ var verifyEIP712Message = async (data, sig) => {
|
|
|
3113
3025
|
hash
|
|
3114
3026
|
} = sig;
|
|
3115
3027
|
const { schema, ...fields } = data;
|
|
3116
|
-
const signedHash =
|
|
3028
|
+
const signedHash = asHash3(hash);
|
|
3117
3029
|
if (isUndefined5(signedHash) || signedHash !== await PayloadBuilder15.hash(data)) return false;
|
|
3118
3030
|
const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
|
|
3119
3031
|
return recoveredAddress.toLowerCase() === address.toLowerCase();
|
|
@@ -3182,22 +3094,22 @@ var toPositiveBigInt = (value) => {
|
|
|
3182
3094
|
|
|
3183
3095
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3184
3096
|
import {
|
|
3185
|
-
asHash as
|
|
3186
|
-
assertEx as
|
|
3097
|
+
asHash as asHash4,
|
|
3098
|
+
assertEx as assertEx31,
|
|
3187
3099
|
exists as exists3,
|
|
3188
|
-
isDefined as
|
|
3100
|
+
isDefined as isDefined16,
|
|
3189
3101
|
ZERO_ADDRESS
|
|
3190
3102
|
} from "@xylabs/sdk-js";
|
|
3191
3103
|
import {
|
|
3192
3104
|
AccountBalanceViewerMoniker,
|
|
3193
3105
|
asRange,
|
|
3194
|
-
asXL1BlockNumber as
|
|
3106
|
+
asXL1BlockNumber as asXL1BlockNumber7,
|
|
3195
3107
|
asXL1BlockRange as asXL1BlockRange10,
|
|
3196
3108
|
AttoXL1 as AttoXL13,
|
|
3197
3109
|
BlockViewerMoniker,
|
|
3198
3110
|
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig4,
|
|
3199
3111
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig4,
|
|
3200
|
-
StepSizes as
|
|
3112
|
+
StepSizes as StepSizes11,
|
|
3201
3113
|
TransferSchema as TransferSchema2
|
|
3202
3114
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3203
3115
|
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
@@ -3255,18 +3167,18 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
|
|
|
3255
3167
|
|
|
3256
3168
|
// src/summary/primitives/balances/balancesStepSummaryFromRange.ts
|
|
3257
3169
|
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3258
|
-
import { assertEx as
|
|
3170
|
+
import { assertEx as assertEx25 } from "@xylabs/sdk-js";
|
|
3259
3171
|
import { isAnyPayload as isAnyPayload2 } from "@xyo-network/sdk-js";
|
|
3260
|
-
import { asXL1BlockNumber as
|
|
3172
|
+
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3261
3173
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3262
3174
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3263
3175
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
3264
3176
|
return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
|
|
3265
|
-
const [frameHead] =
|
|
3177
|
+
const [frameHead] = assertEx25(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3266
3178
|
const frameSize = range[1] - range[0] + 1;
|
|
3267
3179
|
const key = `${frameHead._hash}|${frameSize}`;
|
|
3268
3180
|
return frameSize === 1 ? await spanRootAsync2(`balancesStepSummaryFromRange.frameSize=1[${key}]`, async () => {
|
|
3269
|
-
const [, payloads] =
|
|
3181
|
+
const [, payloads] = assertEx25(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3270
3182
|
const balances = {};
|
|
3271
3183
|
for (const [address, balance] of Object.entries(netBalancesForPayloads(context, payloads))) {
|
|
3272
3184
|
balances[address] = toSignedBigInt(balance);
|
|
@@ -3278,8 +3190,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3278
3190
|
balances
|
|
3279
3191
|
};
|
|
3280
3192
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3281
|
-
const step =
|
|
3282
|
-
|
|
3193
|
+
const step = StepSizes8.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3194
|
+
assertEx25(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3283
3195
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3284
3196
|
if (isAnyPayload2(summaryResult)) {
|
|
3285
3197
|
return summaryResult;
|
|
@@ -3325,7 +3237,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3325
3237
|
// src/summary/primitives/balances/balancesSummary.ts
|
|
3326
3238
|
import {
|
|
3327
3239
|
asAddress as asAddress2,
|
|
3328
|
-
assertEx as
|
|
3240
|
+
assertEx as assertEx26,
|
|
3329
3241
|
spanRootAsync as spanRootAsync3
|
|
3330
3242
|
} from "@xylabs/sdk-js";
|
|
3331
3243
|
import {
|
|
@@ -3337,7 +3249,7 @@ import {
|
|
|
3337
3249
|
async function balancesSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3338
3250
|
return await spanRootAsync3("balancesSummary", async () => {
|
|
3339
3251
|
const headHash = isChainQualifiedHeadConfig(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3340
|
-
const [head] =
|
|
3252
|
+
const [head] = assertEx26(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3341
3253
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3342
3254
|
const range = isChainQualifiedRangeConfig(config) ? config.range : asXL1BlockRange7([0, headBoundWitness.block], true);
|
|
3343
3255
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange7(
|
|
@@ -3357,21 +3269,21 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3357
3269
|
}
|
|
3358
3270
|
|
|
3359
3271
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
3360
|
-
import { assertEx as
|
|
3272
|
+
import { assertEx as assertEx27 } from "@xylabs/sdk-js";
|
|
3361
3273
|
import {
|
|
3362
3274
|
isAnyPayload as isAnyPayload3,
|
|
3363
3275
|
isBoundWitness,
|
|
3364
|
-
isHashMeta
|
|
3276
|
+
isHashMeta,
|
|
3365
3277
|
PayloadBuilder as PayloadBuilder16
|
|
3366
3278
|
} from "@xyo-network/sdk-js";
|
|
3367
|
-
import { StepSizes as
|
|
3279
|
+
import { StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3368
3280
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3369
|
-
const [frameHead] =
|
|
3281
|
+
const [frameHead] = assertEx27(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3370
3282
|
const frameSize = range[1] - range[0] + 1;
|
|
3371
3283
|
let result;
|
|
3372
3284
|
if (frameSize === 1) {
|
|
3373
|
-
const [block, payloads] =
|
|
3374
|
-
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness(x) &&
|
|
3285
|
+
const [block, payloads] = assertEx27(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3286
|
+
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness(x) && isHashMeta(x))];
|
|
3375
3287
|
const schemas = {};
|
|
3376
3288
|
for (const bw of boundWitnesses) {
|
|
3377
3289
|
schemas[bw.schema] = (schemas[bw.schema] ?? 0) + 1;
|
|
@@ -3386,8 +3298,8 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3386
3298
|
schemas
|
|
3387
3299
|
});
|
|
3388
3300
|
} else {
|
|
3389
|
-
const step =
|
|
3390
|
-
|
|
3301
|
+
const step = StepSizes9.indexOf(frameSize);
|
|
3302
|
+
assertEx27(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
3391
3303
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3392
3304
|
if (isAnyPayload3(summaryResult)) {
|
|
3393
3305
|
result = summaryResult;
|
|
@@ -3426,7 +3338,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3426
3338
|
}
|
|
3427
3339
|
|
|
3428
3340
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
3429
|
-
import { assertEx as
|
|
3341
|
+
import { assertEx as assertEx28, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
3430
3342
|
import {
|
|
3431
3343
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3,
|
|
3432
3344
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -3436,7 +3348,7 @@ import {
|
|
|
3436
3348
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3437
3349
|
return await spanRootAsync4("schemasSummary", async () => {
|
|
3438
3350
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3439
|
-
const [head] =
|
|
3351
|
+
const [head] = assertEx28(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3440
3352
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3441
3353
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
3442
3354
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -3456,9 +3368,9 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3456
3368
|
}
|
|
3457
3369
|
|
|
3458
3370
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3459
|
-
import { assertEx as
|
|
3371
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3460
3372
|
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/sdk-js";
|
|
3461
|
-
import { asXL1BlockNumber as
|
|
3373
|
+
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
|
|
3462
3374
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
3463
3375
|
return `${frameHeadHash}|${frameSize}`;
|
|
3464
3376
|
}
|
|
@@ -3466,11 +3378,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3466
3378
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3467
3379
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
3468
3380
|
return await spanRootAsync5("transfersStepSummaryFromRange", async () => {
|
|
3469
|
-
const [frameHead] =
|
|
3381
|
+
const [frameHead] = assertEx29(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3470
3382
|
const frameSize = range[1] - range[0] + 1;
|
|
3471
3383
|
let result;
|
|
3472
3384
|
if (frameSize === 1) {
|
|
3473
|
-
const [, payloads] =
|
|
3385
|
+
const [, payloads] = assertEx29(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3474
3386
|
const transfers = {};
|
|
3475
3387
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3476
3388
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -3485,8 +3397,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3485
3397
|
transfers
|
|
3486
3398
|
};
|
|
3487
3399
|
} else {
|
|
3488
|
-
const step =
|
|
3489
|
-
|
|
3400
|
+
const step = StepSizes10.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3401
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
|
|
3490
3402
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3491
3403
|
const summaryResult = await summaryMap.get(key);
|
|
3492
3404
|
if (isAnyPayload4(summaryResult)) {
|
|
@@ -3539,7 +3451,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3539
3451
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3540
3452
|
import {
|
|
3541
3453
|
asAddress as asAddress3,
|
|
3542
|
-
assertEx as
|
|
3454
|
+
assertEx as assertEx30,
|
|
3543
3455
|
spanRootAsync as spanRootAsync6
|
|
3544
3456
|
} from "@xylabs/sdk-js";
|
|
3545
3457
|
import {
|
|
@@ -3551,7 +3463,7 @@ import {
|
|
|
3551
3463
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3552
3464
|
return await spanRootAsync6("transferSummary", async () => {
|
|
3553
3465
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3554
|
-
const [head] =
|
|
3466
|
+
const [head] = assertEx30(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3555
3467
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3556
3468
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
3557
3469
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -3577,9 +3489,9 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3577
3489
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3578
3490
|
var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
3579
3491
|
moniker = SimpleAccountBalanceViewer.defaultMoniker;
|
|
3580
|
-
_balanceStepSemaphores =
|
|
3492
|
+
_balanceStepSemaphores = StepSizes11.map(() => new Semaphore2(20));
|
|
3581
3493
|
_blockViewer;
|
|
3582
|
-
_transferStepSemaphores =
|
|
3494
|
+
_transferStepSemaphores = StepSizes11.map(() => new Semaphore2(20));
|
|
3583
3495
|
get balancesSummaryMap() {
|
|
3584
3496
|
return this.params.balancesSummaryMap;
|
|
3585
3497
|
}
|
|
@@ -3592,8 +3504,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3592
3504
|
static async paramsHandler(params = {}) {
|
|
3593
3505
|
return {
|
|
3594
3506
|
...await super.paramsHandler(params),
|
|
3595
|
-
balancesSummaryMap:
|
|
3596
|
-
transfersSummaryMap:
|
|
3507
|
+
balancesSummaryMap: assertEx31(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
3508
|
+
transfersSummaryMap: assertEx31(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
3597
3509
|
};
|
|
3598
3510
|
}
|
|
3599
3511
|
async accountBalance(address, config) {
|
|
@@ -3614,11 +3526,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3614
3526
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
3615
3527
|
const transfers = transferIndexes.map((index) => {
|
|
3616
3528
|
const hash = block[0].payload_hashes[index];
|
|
3617
|
-
return
|
|
3529
|
+
return assertEx31(
|
|
3618
3530
|
block[1].find((p) => p._hash === hash),
|
|
3619
3531
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
3620
3532
|
);
|
|
3621
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
3533
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
3622
3534
|
if (transfers.length === 0) {
|
|
3623
3535
|
continue;
|
|
3624
3536
|
}
|
|
@@ -3647,7 +3559,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3647
3559
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
3648
3560
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
3649
3561
|
0,
|
|
3650
|
-
|
|
3562
|
+
assertEx31(
|
|
3651
3563
|
await this.blockViewer.blockByHash(head),
|
|
3652
3564
|
() => `Error: Could not find block with hash ${head}`
|
|
3653
3565
|
)[0].block
|
|
@@ -3662,11 +3574,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3662
3574
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
3663
3575
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
3664
3576
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
3665
|
-
|
|
3577
|
+
assertEx31(
|
|
3666
3578
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
3667
3579
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
3668
3580
|
);
|
|
3669
|
-
|
|
3581
|
+
assertEx31(
|
|
3670
3582
|
head2 === qualifiedHeadHash,
|
|
3671
3583
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
3672
3584
|
);
|
|
@@ -3700,8 +3612,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3700
3612
|
}
|
|
3701
3613
|
async distillTransferHistory(address, range, max = 50) {
|
|
3702
3614
|
return await this.spanAsync("distillTransferHistory", async () => {
|
|
3703
|
-
if (range[1] - range[0] <=
|
|
3704
|
-
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) =>
|
|
3615
|
+
if (range[1] - range[0] <= StepSizes11[0] || max <= 1) {
|
|
3616
|
+
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber7(n, true));
|
|
3705
3617
|
}
|
|
3706
3618
|
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true));
|
|
3707
3619
|
const transferSummaryPairs = await Promise.all(frames.map(
|
|
@@ -3715,7 +3627,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3715
3627
|
});
|
|
3716
3628
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
3717
3629
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
3718
|
-
if (frame[1] - frame[0] + 1 >
|
|
3630
|
+
if (frame[1] - frame[0] + 1 > StepSizes11[0]) {
|
|
3719
3631
|
const values = await this.distillTransferHistory(address, asXL1BlockRange10([frame[0], frame[1] - 1], true), max - resultBlockNumbers.size);
|
|
3720
3632
|
for (const value of values) {
|
|
3721
3633
|
resultBlockNumbers.add(value);
|
|
@@ -3736,8 +3648,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3736
3648
|
async qualifiedAccountBalanceHistory(address, headOrRange) {
|
|
3737
3649
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
3738
3650
|
const range = asRange(headOrRange);
|
|
3739
|
-
const headHash =
|
|
3740
|
-
const [head] =
|
|
3651
|
+
const headHash = asHash4(headOrRange);
|
|
3652
|
+
const [head] = assertEx31(isDefined16(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
3741
3653
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
3742
3654
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
3743
3655
|
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
@@ -3746,11 +3658,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3746
3658
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
3747
3659
|
const transfers = transferIndexes.map((index) => {
|
|
3748
3660
|
const hash = block[0].payload_hashes[index];
|
|
3749
|
-
return
|
|
3661
|
+
return assertEx31(
|
|
3750
3662
|
block[1].find((p) => p._hash === hash),
|
|
3751
3663
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
3752
3664
|
);
|
|
3753
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
3665
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
3754
3666
|
if (transfers.length === 0) {
|
|
3755
3667
|
continue;
|
|
3756
3668
|
}
|
|
@@ -3776,14 +3688,14 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
3776
3688
|
|
|
3777
3689
|
// src/simple/block/SimpleBlockViewer.ts
|
|
3778
3690
|
import {
|
|
3779
|
-
assertEx as
|
|
3691
|
+
assertEx as assertEx32,
|
|
3780
3692
|
exists as exists4,
|
|
3781
3693
|
isUndefined as isUndefined6
|
|
3782
3694
|
} from "@xylabs/sdk-js";
|
|
3783
3695
|
import {
|
|
3784
3696
|
asSignedHydratedBlockWithHashMeta,
|
|
3785
3697
|
asSignedHydratedBlockWithStorageMeta,
|
|
3786
|
-
asXL1BlockNumber as
|
|
3698
|
+
asXL1BlockNumber as asXL1BlockNumber8,
|
|
3787
3699
|
BlockViewerMoniker as BlockViewerMoniker2,
|
|
3788
3700
|
DataLakeViewerMoniker,
|
|
3789
3701
|
FinalizationViewerMoniker
|
|
@@ -3848,7 +3760,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3848
3760
|
static async paramsHandler(params) {
|
|
3849
3761
|
return {
|
|
3850
3762
|
...await super.paramsHandler(params),
|
|
3851
|
-
finalizedArchivist:
|
|
3763
|
+
finalizedArchivist: assertEx32(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
3852
3764
|
};
|
|
3853
3765
|
}
|
|
3854
3766
|
async blockByHash(hash) {
|
|
@@ -3877,8 +3789,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3877
3789
|
}
|
|
3878
3790
|
async blocksByHash(hash, limit = 50) {
|
|
3879
3791
|
return await this.spanAsync("blocksByHash", async () => {
|
|
3880
|
-
|
|
3881
|
-
|
|
3792
|
+
assertEx32(limit > 0, () => "limit must be greater than 0");
|
|
3793
|
+
assertEx32(limit <= 100, () => "limit must be less than 100");
|
|
3882
3794
|
const blocks = [];
|
|
3883
3795
|
let current = await this.blockByHash(hash);
|
|
3884
3796
|
while (current && blocks.length < limit) {
|
|
@@ -3892,8 +3804,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3892
3804
|
}
|
|
3893
3805
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
3894
3806
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
3895
|
-
|
|
3896
|
-
|
|
3807
|
+
assertEx32(limit > 0, () => "limit must be greater than 0");
|
|
3808
|
+
assertEx32(limit <= 100, () => "limit must be less than 100");
|
|
3897
3809
|
const chainContext = await this.getChainContextRead();
|
|
3898
3810
|
if (isUndefined6(chainContext.head)) {
|
|
3899
3811
|
return [];
|
|
@@ -3903,7 +3815,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3903
3815
|
while (current && blocks.length < limit) {
|
|
3904
3816
|
blocks.push(current);
|
|
3905
3817
|
if (current[0].block === 0) break;
|
|
3906
|
-
const previousNumber =
|
|
3818
|
+
const previousNumber = asXL1BlockNumber8(current[0].block - 1, true);
|
|
3907
3819
|
current = await this.blockByNumberWithContext(chainContext, previousNumber);
|
|
3908
3820
|
}
|
|
3909
3821
|
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true));
|
|
@@ -3911,7 +3823,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3911
3823
|
}
|
|
3912
3824
|
async chainId(blockNumber = "latest") {
|
|
3913
3825
|
return await this.spanAsync("chainId", async () => {
|
|
3914
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
3826
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx32(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
3915
3827
|
}, this.context);
|
|
3916
3828
|
}
|
|
3917
3829
|
async createHandler() {
|
|
@@ -4000,7 +3912,7 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4000
3912
|
], SimpleBlockRewardViewer);
|
|
4001
3913
|
|
|
4002
3914
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4003
|
-
import { assertEx as
|
|
3915
|
+
import { assertEx as assertEx33 } from "@xylabs/sdk-js";
|
|
4004
3916
|
import { PayloadBuilder as PayloadBuilder17 } from "@xyo-network/sdk-js";
|
|
4005
3917
|
import {
|
|
4006
3918
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
@@ -4052,7 +3964,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4052
3964
|
head: void 0
|
|
4053
3965
|
};
|
|
4054
3966
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder17.addHashMeta(b[0]), PayloadBuilder17.addHashMeta(b[1])])));
|
|
4055
|
-
const head = isChainQualifiedHeadConfig5(config) ?
|
|
3967
|
+
const head = isChainQualifiedHeadConfig5(config) ? assertEx33(
|
|
4056
3968
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
4057
3969
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4058
3970
|
) : void 0;
|
|
@@ -4132,7 +4044,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
4132
4044
|
|
|
4133
4045
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
4134
4046
|
import {
|
|
4135
|
-
assertEx as
|
|
4047
|
+
assertEx as assertEx34
|
|
4136
4048
|
} from "@xylabs/sdk-js";
|
|
4137
4049
|
import {
|
|
4138
4050
|
ChainContractViewerMoniker as ChainContractViewerMoniker2,
|
|
@@ -4153,7 +4065,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4153
4065
|
let contractViewer = this;
|
|
4154
4066
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4155
4067
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
4156
|
-
contractViewer =
|
|
4068
|
+
contractViewer = assertEx34(await contractViewer.forkedChainContractViewer());
|
|
4157
4069
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4158
4070
|
chainId = await contractViewer.chainId();
|
|
4159
4071
|
}
|
|
@@ -4205,7 +4117,7 @@ var SimpleXyoClient = class {
|
|
|
4205
4117
|
|
|
4206
4118
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
4207
4119
|
import {
|
|
4208
|
-
assertEx as
|
|
4120
|
+
assertEx as assertEx35,
|
|
4209
4121
|
exists as exists6
|
|
4210
4122
|
} from "@xylabs/sdk-js";
|
|
4211
4123
|
import { isAnyPayload as isAnyPayload6, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
@@ -4272,7 +4184,7 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4272
4184
|
async insert(items) {
|
|
4273
4185
|
const allowedItems = items.map((item) => {
|
|
4274
4186
|
if (isAnyPayload6(item) && this.isAllowed(item)) {
|
|
4275
|
-
|
|
4187
|
+
assertEx35(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
4276
4188
|
return item;
|
|
4277
4189
|
}
|
|
4278
4190
|
return null;
|
|
@@ -4422,7 +4334,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
4422
4334
|
|
|
4423
4335
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
4424
4336
|
import {
|
|
4425
|
-
assertEx as
|
|
4337
|
+
assertEx as assertEx36
|
|
4426
4338
|
} from "@xylabs/sdk-js";
|
|
4427
4339
|
import {
|
|
4428
4340
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
@@ -4452,7 +4364,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4452
4364
|
static async paramsHandler(params) {
|
|
4453
4365
|
return {
|
|
4454
4366
|
...await super.paramsHandler(params),
|
|
4455
|
-
finalizedArchivist:
|
|
4367
|
+
finalizedArchivist: assertEx36(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
4456
4368
|
};
|
|
4457
4369
|
}
|
|
4458
4370
|
chainId() {
|
|
@@ -4460,18 +4372,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4460
4372
|
}
|
|
4461
4373
|
async createHandler() {
|
|
4462
4374
|
await super.createHandler();
|
|
4463
|
-
this._chainId =
|
|
4375
|
+
this._chainId = assertEx36(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
4464
4376
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4465
4377
|
}
|
|
4466
4378
|
async head() {
|
|
4467
4379
|
return await this.spanAsync("head", async () => {
|
|
4468
|
-
const currentHead =
|
|
4380
|
+
const currentHead = assertEx36(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
4469
4381
|
const cache = this.hydratedBlockCache;
|
|
4470
4382
|
const block = await cache.get(currentHead._hash);
|
|
4471
4383
|
if (!block) {
|
|
4472
4384
|
console.log(`Could not find current block with hash ${currentHead._hash}`);
|
|
4473
4385
|
}
|
|
4474
|
-
return
|
|
4386
|
+
return assertEx36(block, () => "Could not find current block");
|
|
4475
4387
|
}, this.context);
|
|
4476
4388
|
}
|
|
4477
4389
|
async headBlock() {
|
|
@@ -4497,8 +4409,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4497
4409
|
}
|
|
4498
4410
|
async getCurrentHead() {
|
|
4499
4411
|
const chainArchivist = this.finalizedArchivist;
|
|
4500
|
-
const result =
|
|
4501
|
-
|
|
4412
|
+
const result = assertEx36(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
4413
|
+
assertEx36(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
4502
4414
|
return result;
|
|
4503
4415
|
}
|
|
4504
4416
|
};
|
|
@@ -4528,13 +4440,13 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
4528
4440
|
|
|
4529
4441
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
4530
4442
|
import {
|
|
4531
|
-
assertEx as
|
|
4443
|
+
assertEx as assertEx37,
|
|
4532
4444
|
BigIntToJsonZod,
|
|
4533
|
-
isDefined as
|
|
4445
|
+
isDefined as isDefined17
|
|
4534
4446
|
} from "@xylabs/sdk-js";
|
|
4535
4447
|
import { PayloadBuilder as PayloadBuilder19 } from "@xyo-network/sdk-js";
|
|
4536
4448
|
import {
|
|
4537
|
-
asXL1BlockNumber as
|
|
4449
|
+
asXL1BlockNumber as asXL1BlockNumber9,
|
|
4538
4450
|
DataLakeRunnerMoniker as DataLakeRunnerMoniker3,
|
|
4539
4451
|
isSignedHydratedTransaction,
|
|
4540
4452
|
TransferSchema as TransferSchema3,
|
|
@@ -4561,23 +4473,23 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
4561
4473
|
return this._signer;
|
|
4562
4474
|
}
|
|
4563
4475
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
4564
|
-
const viewer =
|
|
4476
|
+
const viewer = assertEx37(this.connection.viewer, () => "No viewer available on connection");
|
|
4565
4477
|
const {
|
|
4566
4478
|
nbf,
|
|
4567
4479
|
exp,
|
|
4568
4480
|
chain,
|
|
4569
4481
|
fees
|
|
4570
4482
|
} = options ?? {};
|
|
4571
|
-
const resolvedChainId =
|
|
4572
|
-
const resolvedNbf =
|
|
4573
|
-
const resolvedExp =
|
|
4483
|
+
const resolvedChainId = isDefined17(chain) ? chain : await viewer.chainId();
|
|
4484
|
+
const resolvedNbf = asXL1BlockNumber9(isDefined17(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
4485
|
+
const resolvedExp = asXL1BlockNumber9(isDefined17(exp) ? exp : resolvedNbf + 10, true);
|
|
4574
4486
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
4575
4487
|
return await this.addTransactionToChain(tx, await PayloadBuilder19.addHashMeta(offChain));
|
|
4576
4488
|
}
|
|
4577
4489
|
async addTransactionToChain(tx, offChain = []) {
|
|
4578
4490
|
const connection = this.connection;
|
|
4579
4491
|
const signer = this.signer;
|
|
4580
|
-
const runner =
|
|
4492
|
+
const runner = assertEx37(connection.runner, () => "No runner available on connection");
|
|
4581
4493
|
let signedTx;
|
|
4582
4494
|
if (isSignedHydratedTransaction(tx)) {
|
|
4583
4495
|
const [bw, payloads] = tx;
|
|
@@ -4592,7 +4504,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
4592
4504
|
}
|
|
4593
4505
|
async confirmSubmittedTransaction(txHash, options) {
|
|
4594
4506
|
return await confirmSubmittedTransaction(
|
|
4595
|
-
|
|
4507
|
+
assertEx37(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
4596
4508
|
txHash,
|
|
4597
4509
|
options
|
|
4598
4510
|
);
|
|
@@ -4626,7 +4538,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
4626
4538
|
|
|
4627
4539
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
4628
4540
|
import {
|
|
4629
|
-
assertEx as
|
|
4541
|
+
assertEx as assertEx38,
|
|
4630
4542
|
exists as exists8
|
|
4631
4543
|
} from "@xylabs/sdk-js";
|
|
4632
4544
|
import {
|
|
@@ -4687,8 +4599,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4687
4599
|
static async paramsHandler(params) {
|
|
4688
4600
|
return {
|
|
4689
4601
|
...await super.paramsHandler(params),
|
|
4690
|
-
pendingBlocksArchivist:
|
|
4691
|
-
pendingTransactionsArchivist:
|
|
4602
|
+
pendingBlocksArchivist: assertEx38(params?.pendingBlocksArchivist, () => "pendingBlocksArchivist is required"),
|
|
4603
|
+
pendingTransactionsArchivist: assertEx38(params?.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required")
|
|
4692
4604
|
};
|
|
4693
4605
|
}
|
|
4694
4606
|
async createHandler() {
|
|
@@ -4724,7 +4636,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4724
4636
|
return b;
|
|
4725
4637
|
}
|
|
4726
4638
|
}).filter(exists8);
|
|
4727
|
-
|
|
4639
|
+
assertEx38(
|
|
4728
4640
|
remainingBlockMap.length === remainingBlocks.length,
|
|
4729
4641
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
4730
4642
|
);
|
|
@@ -4784,7 +4696,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
4784
4696
|
return t;
|
|
4785
4697
|
}
|
|
4786
4698
|
}).filter(exists8);
|
|
4787
|
-
|
|
4699
|
+
assertEx38(
|
|
4788
4700
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
4789
4701
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
4790
4702
|
);
|
|
@@ -4956,10 +4868,10 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
4956
4868
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
4957
4869
|
import {
|
|
4958
4870
|
exists as exists9,
|
|
4959
|
-
isDefined as
|
|
4871
|
+
isDefined as isDefined18,
|
|
4960
4872
|
isHash as isHash2
|
|
4961
4873
|
} from "@xylabs/sdk-js";
|
|
4962
|
-
import { isHashMeta as
|
|
4874
|
+
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
4963
4875
|
import {
|
|
4964
4876
|
MempoolViewerMoniker,
|
|
4965
4877
|
WindowedBlockViewerMoniker
|
|
@@ -4985,7 +4897,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
4985
4897
|
let cursor = void 0;
|
|
4986
4898
|
if (isHash2(providedCursor)) {
|
|
4987
4899
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
4988
|
-
if (
|
|
4900
|
+
if (isDefined18(p)) {
|
|
4989
4901
|
cursor = p._sequence;
|
|
4990
4902
|
}
|
|
4991
4903
|
}
|
|
@@ -4994,7 +4906,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
4994
4906
|
limit: 100,
|
|
4995
4907
|
cursor
|
|
4996
4908
|
});
|
|
4997
|
-
const filteredBundles = bundles.filter(isPayloadBundle2).filter(
|
|
4909
|
+
const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
|
|
4998
4910
|
return (await Promise.all(filteredBundles.map(async (bundle3) => await bundledPayloadToHydratedBlock(bundle3)))).filter(exists9);
|
|
4999
4911
|
}
|
|
5000
4912
|
async pendingTransactions({
|
|
@@ -5004,7 +4916,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5004
4916
|
let cursor = void 0;
|
|
5005
4917
|
if (isHash2(providedCursor)) {
|
|
5006
4918
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
5007
|
-
if (
|
|
4919
|
+
if (isDefined18(p)) {
|
|
5008
4920
|
cursor = p._sequence;
|
|
5009
4921
|
}
|
|
5010
4922
|
}
|
|
@@ -5015,11 +4927,11 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5015
4927
|
cursor
|
|
5016
4928
|
});
|
|
5017
4929
|
this.logger?.info(`Fetched pending transactions: ${bundles.length} bundles`);
|
|
5018
|
-
const filteredBundles = bundles.filter(isPayloadBundle2).filter(
|
|
4930
|
+
const filteredBundles = bundles.filter(isPayloadBundle2).filter(isHashMeta2);
|
|
5019
4931
|
const hydratedWithBundle = (await Promise.all(
|
|
5020
4932
|
filteredBundles.map(async (bundle3) => {
|
|
5021
4933
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
5022
|
-
return
|
|
4934
|
+
return isDefined18(tx) ? { bundle: bundle3, tx } : void 0;
|
|
5023
4935
|
})
|
|
5024
4936
|
)).filter(exists9);
|
|
5025
4937
|
const currentBlock = await this.windowedBlockViewer.currentBlock();
|
|
@@ -5174,7 +5086,7 @@ var SimpleXyoNetwork = class {
|
|
|
5174
5086
|
};
|
|
5175
5087
|
|
|
5176
5088
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
5177
|
-
import { assertEx as
|
|
5089
|
+
import { assertEx as assertEx39 } from "@xylabs/sdk-js";
|
|
5178
5090
|
var SimpleXyoPermissions = class {
|
|
5179
5091
|
invoker;
|
|
5180
5092
|
_store;
|
|
@@ -5183,7 +5095,7 @@ var SimpleXyoPermissions = class {
|
|
|
5183
5095
|
this.invoker = store.invoker;
|
|
5184
5096
|
}
|
|
5185
5097
|
get store() {
|
|
5186
|
-
return
|
|
5098
|
+
return assertEx39(this._store, () => "Store must be defined to get permissions");
|
|
5187
5099
|
}
|
|
5188
5100
|
async getPermissions() {
|
|
5189
5101
|
return await this.store.getPermissions();
|
|
@@ -5236,7 +5148,7 @@ var SimpleXyoPermissions = class {
|
|
|
5236
5148
|
};
|
|
5237
5149
|
|
|
5238
5150
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
5239
|
-
import { assertEx as
|
|
5151
|
+
import { assertEx as assertEx40 } from "@xylabs/sdk-js";
|
|
5240
5152
|
var MemoryPermissionsStore = class {
|
|
5241
5153
|
_invoker;
|
|
5242
5154
|
permissions = [];
|
|
@@ -5244,7 +5156,7 @@ var MemoryPermissionsStore = class {
|
|
|
5244
5156
|
this._invoker = invoker;
|
|
5245
5157
|
}
|
|
5246
5158
|
get invoker() {
|
|
5247
|
-
return
|
|
5159
|
+
return assertEx40(this._invoker, () => "Invoker must be defined to get permissions");
|
|
5248
5160
|
}
|
|
5249
5161
|
async getPermissions() {
|
|
5250
5162
|
await Promise.resolve();
|
|
@@ -5287,7 +5199,7 @@ SimpleXyoRunner = __decorateClass([
|
|
|
5287
5199
|
], SimpleXyoRunner);
|
|
5288
5200
|
|
|
5289
5201
|
// src/simple/signer/SimpleXyoSigner.ts
|
|
5290
|
-
import { Account
|
|
5202
|
+
import { Account, PayloadBuilder as PayloadBuilder22 } from "@xyo-network/sdk-js";
|
|
5291
5203
|
import {
|
|
5292
5204
|
SignedHydratedTransactionWithHashMetaZod,
|
|
5293
5205
|
XyoSignerMoniker as XyoSignerMoniker2
|
|
@@ -5306,7 +5218,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5306
5218
|
localLogger?.warn(`No account provided to SimpleXyoSigner, generating a random account.
|
|
5307
5219
|
This account will not be persisted and any transactions signed with it may be lost.
|
|
5308
5220
|
`);
|
|
5309
|
-
account = await
|
|
5221
|
+
account = await Account.random();
|
|
5310
5222
|
}
|
|
5311
5223
|
return { ...await super.paramsHandler(params), account };
|
|
5312
5224
|
}
|
|
@@ -5314,11 +5226,11 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5314
5226
|
return this.params.account.address;
|
|
5315
5227
|
}
|
|
5316
5228
|
/** @deprecated - use signTransaction instead */
|
|
5317
|
-
async createSignedTransaction(chain,
|
|
5229
|
+
async createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbf, exp, fees, from) {
|
|
5318
5230
|
const fromAddress = from ?? await this.address();
|
|
5319
5231
|
const transaction = await buildTransaction(
|
|
5320
5232
|
chain,
|
|
5321
|
-
|
|
5233
|
+
elevatedPayloads,
|
|
5322
5234
|
additionalPayloads,
|
|
5323
5235
|
this.params.account,
|
|
5324
5236
|
nbf,
|
|
@@ -5335,7 +5247,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5335
5247
|
};
|
|
5336
5248
|
|
|
5337
5249
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
5338
|
-
import { isDefined as
|
|
5250
|
+
import { isDefined as isDefined19 } from "@xylabs/sdk-js";
|
|
5339
5251
|
import {
|
|
5340
5252
|
StakeEventsViewerMoniker
|
|
5341
5253
|
} from "@xyo-network/xl1-protocol-lib";
|
|
@@ -5350,7 +5262,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
5350
5262
|
stakeEvents(range, { name } = {}) {
|
|
5351
5263
|
const positions = this.positionsFromRange(range);
|
|
5352
5264
|
const events = this.eventsFromPositions(positions);
|
|
5353
|
-
if (
|
|
5265
|
+
if (isDefined19(name)) {
|
|
5354
5266
|
return events.filter((event) => event.name === name);
|
|
5355
5267
|
}
|
|
5356
5268
|
return events;
|
|
@@ -5416,7 +5328,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
5416
5328
|
|
|
5417
5329
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
5418
5330
|
import { asAddress as asAddress4 } from "@xylabs/sdk-js";
|
|
5419
|
-
import { assertEx as
|
|
5331
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5420
5332
|
import {
|
|
5421
5333
|
StakeTotalsViewerMoniker,
|
|
5422
5334
|
StakeViewerMoniker
|
|
@@ -5459,7 +5371,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
5459
5371
|
}
|
|
5460
5372
|
async createHandler() {
|
|
5461
5373
|
await super.createHandler();
|
|
5462
|
-
this._stakeViewer =
|
|
5374
|
+
this._stakeViewer = assertEx41(
|
|
5463
5375
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
5464
5376
|
() => "Failed to create StakeViewer"
|
|
5465
5377
|
);
|
|
@@ -5515,9 +5427,9 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
5515
5427
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
5516
5428
|
import {
|
|
5517
5429
|
asAddress as asAddress5,
|
|
5518
|
-
toAddress as
|
|
5430
|
+
toAddress as toAddress6
|
|
5519
5431
|
} from "@xylabs/sdk-js";
|
|
5520
|
-
import { assertEx as
|
|
5432
|
+
import { assertEx as assertEx42 } from "@xylabs/sdk-js";
|
|
5521
5433
|
import {
|
|
5522
5434
|
StakeEventsViewerMoniker as StakeEventsViewerMoniker2,
|
|
5523
5435
|
StakeViewerMoniker as StakeViewerMoniker2
|
|
@@ -5526,7 +5438,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5526
5438
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
5527
5439
|
_chainStakeEventsViewer;
|
|
5528
5440
|
get stakeEvents() {
|
|
5529
|
-
return
|
|
5441
|
+
return assertEx42(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
5530
5442
|
}
|
|
5531
5443
|
get positions() {
|
|
5532
5444
|
return this.params.positions;
|
|
@@ -5566,7 +5478,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5566
5478
|
}
|
|
5567
5479
|
async createHandler() {
|
|
5568
5480
|
await super.createHandler();
|
|
5569
|
-
this._chainStakeEventsViewer =
|
|
5481
|
+
this._chainStakeEventsViewer = assertEx42(
|
|
5570
5482
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
5571
5483
|
() => "Failed to create StakeEventsViewer"
|
|
5572
5484
|
);
|
|
@@ -5598,10 +5510,10 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5598
5510
|
return this.positions.filter((s) => s.withdrawBlock === 0 && s.removeBlock !== 0);
|
|
5599
5511
|
}
|
|
5600
5512
|
rewardsContract() {
|
|
5601
|
-
return
|
|
5513
|
+
return toAddress6(toAddress6(1n));
|
|
5602
5514
|
}
|
|
5603
5515
|
stakeById(id) {
|
|
5604
|
-
return
|
|
5516
|
+
return assertEx42(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
5605
5517
|
}
|
|
5606
5518
|
stakeByStaker(staker, slot) {
|
|
5607
5519
|
return this.positions.filter((s) => asAddress5(s.staker) === asAddress5(staker))[slot];
|
|
@@ -5615,7 +5527,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
5615
5527
|
return this.positions.filter((s) => asAddress5(s.staker) === asAddress5(staker) && s.addBlock <= endBlock && s.removeBlock <= endBlock);
|
|
5616
5528
|
}
|
|
5617
5529
|
stakingTokenAddress() {
|
|
5618
|
-
return
|
|
5530
|
+
return toAddress6("0x000000000000000000000000000011");
|
|
5619
5531
|
}
|
|
5620
5532
|
async withdrawn() {
|
|
5621
5533
|
let withdrawn = 0n;
|
|
@@ -5650,13 +5562,13 @@ SimpleStakeViewer = __decorateClass([
|
|
|
5650
5562
|
|
|
5651
5563
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
5652
5564
|
import {
|
|
5653
|
-
asHash as
|
|
5654
|
-
assertEx as
|
|
5655
|
-
isDefined as
|
|
5565
|
+
asHash as asHash5,
|
|
5566
|
+
assertEx as assertEx43,
|
|
5567
|
+
isDefined as isDefined20
|
|
5656
5568
|
} from "@xylabs/sdk-js";
|
|
5657
5569
|
import {
|
|
5658
5570
|
asTimePayload as asTimePayload2,
|
|
5659
|
-
asXL1BlockNumber as
|
|
5571
|
+
asXL1BlockNumber as asXL1BlockNumber10,
|
|
5660
5572
|
BlockViewerMoniker as BlockViewerMoniker4,
|
|
5661
5573
|
TimeSchema,
|
|
5662
5574
|
TimeSyncViewerMoniker
|
|
@@ -5673,10 +5585,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
5673
5585
|
async convertTime(fromDomain, toDomain, from) {
|
|
5674
5586
|
switch (fromDomain) {
|
|
5675
5587
|
case "xl1": {
|
|
5676
|
-
const [block, payloads] =
|
|
5588
|
+
const [block, payloads] = assertEx43(await this.blockViewer.blockByNumber(asXL1BlockNumber10(from, true)), () => "Block not found");
|
|
5677
5589
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
5678
5590
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
5679
|
-
const timePayload = asTimePayload2(
|
|
5591
|
+
const timePayload = asTimePayload2(isDefined20(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
5680
5592
|
if (timePayload === void 0) return 0;
|
|
5681
5593
|
switch (toDomain) {
|
|
5682
5594
|
case "xl1": {
|
|
@@ -5728,10 +5640,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
5728
5640
|
return [Date.now(), null];
|
|
5729
5641
|
}
|
|
5730
5642
|
case "ethereum": {
|
|
5731
|
-
const provider =
|
|
5643
|
+
const provider = assertEx43(this.ethProvider, () => "Ethereum provider not configured");
|
|
5732
5644
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
5733
5645
|
const block = await provider.getBlock(blockNumber);
|
|
5734
|
-
const blockHash =
|
|
5646
|
+
const blockHash = asHash5(assertEx43(block?.hash, () => "Block hash not found"), true);
|
|
5735
5647
|
return [blockNumber, blockHash];
|
|
5736
5648
|
}
|
|
5737
5649
|
default: {
|
|
@@ -5746,12 +5658,12 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
5746
5658
|
// this is for the previous block
|
|
5747
5659
|
xl1,
|
|
5748
5660
|
// this is for the previous block
|
|
5749
|
-
xl1Hash:
|
|
5661
|
+
xl1Hash: assertEx43(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
5750
5662
|
epoch: Date.now()
|
|
5751
5663
|
};
|
|
5752
|
-
if (
|
|
5664
|
+
if (isDefined20(this.ethProvider)) {
|
|
5753
5665
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
5754
|
-
const ethereumHash =
|
|
5666
|
+
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
5755
5667
|
timePayload.ethereum = ethereum;
|
|
5756
5668
|
timePayload.ethereumHash = ethereumHash;
|
|
5757
5669
|
}
|
|
@@ -5766,7 +5678,7 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
5766
5678
|
], SimpleTimeSyncViewer);
|
|
5767
5679
|
|
|
5768
5680
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
5769
|
-
import { assertEx as
|
|
5681
|
+
import { assertEx as assertEx44 } from "@xylabs/sdk-js";
|
|
5770
5682
|
import { PayloadBuilder as PayloadBuilder23 } from "@xyo-network/sdk-js";
|
|
5771
5683
|
import {
|
|
5772
5684
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
@@ -5817,7 +5729,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
5817
5729
|
head: void 0
|
|
5818
5730
|
};
|
|
5819
5731
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder23.addHashMeta(b[0]), PayloadBuilder23.addHashMeta(b[1])])));
|
|
5820
|
-
const head = isChainQualifiedHeadConfig6(config) ?
|
|
5732
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx44(
|
|
5821
5733
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
5822
5734
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
5823
5735
|
) : void 0;
|
|
@@ -5884,7 +5796,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
5884
5796
|
|
|
5885
5797
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
5886
5798
|
import {
|
|
5887
|
-
assertEx as
|
|
5799
|
+
assertEx as assertEx45,
|
|
5888
5800
|
exists as exists10
|
|
5889
5801
|
} from "@xylabs/sdk-js";
|
|
5890
5802
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
@@ -5903,7 +5815,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
5903
5815
|
}
|
|
5904
5816
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
5905
5817
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
5906
|
-
|
|
5818
|
+
assertEx45(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
5907
5819
|
try {
|
|
5908
5820
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
5909
5821
|
if (!block) return null;
|
|
@@ -5967,12 +5879,12 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
5967
5879
|
|
|
5968
5880
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
5969
5881
|
import {
|
|
5970
|
-
assertEx as
|
|
5882
|
+
assertEx as assertEx46,
|
|
5971
5883
|
exists as exists11,
|
|
5972
5884
|
isNull as isNull2
|
|
5973
5885
|
} from "@xylabs/sdk-js";
|
|
5974
5886
|
import {
|
|
5975
|
-
asXL1BlockNumber as
|
|
5887
|
+
asXL1BlockNumber as asXL1BlockNumber11,
|
|
5976
5888
|
BlockViewerMoniker as BlockViewerMoniker7,
|
|
5977
5889
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
5978
5890
|
} from "@xyo-network/xl1-protocol-lib";
|
|
@@ -6025,7 +5937,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6025
5937
|
let block = this._blockNumberMap.get(blockNumber);
|
|
6026
5938
|
while (block && (limit === void 0 || result.length < limit)) {
|
|
6027
5939
|
result.unshift(block);
|
|
6028
|
-
const previousBlockNumber =
|
|
5940
|
+
const previousBlockNumber = asXL1BlockNumber11(block[0].block - 1, true);
|
|
6029
5941
|
block = previousBlockNumber >= 0 ? this._blockNumberMap.get(previousBlockNumber) : void 0;
|
|
6030
5942
|
}
|
|
6031
5943
|
return result;
|
|
@@ -6038,7 +5950,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6038
5950
|
}
|
|
6039
5951
|
async createHandler() {
|
|
6040
5952
|
await super.createHandler();
|
|
6041
|
-
this._blockViewer =
|
|
5953
|
+
this._blockViewer = assertEx46(
|
|
6042
5954
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
6043
5955
|
() => "BlockViewer instance is required"
|
|
6044
5956
|
);
|
|
@@ -6047,13 +5959,13 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6047
5959
|
this._transactionHashMap = new MemoryMap();
|
|
6048
5960
|
}
|
|
6049
5961
|
currentBlock() {
|
|
6050
|
-
return
|
|
5962
|
+
return assertEx46(this._chain.at(-1));
|
|
6051
5963
|
}
|
|
6052
5964
|
currentBlockHash() {
|
|
6053
|
-
return
|
|
5965
|
+
return assertEx46(this._chain.at(-1)?.[0]._hash);
|
|
6054
5966
|
}
|
|
6055
5967
|
currentBlockNumber() {
|
|
6056
|
-
return
|
|
5968
|
+
return assertEx46(this._chain.at(-1)?.[0].block);
|
|
6057
5969
|
}
|
|
6058
5970
|
async payloadByHash(hash) {
|
|
6059
5971
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -6212,13 +6124,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6212
6124
|
};
|
|
6213
6125
|
|
|
6214
6126
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6215
|
-
import { assertEx as
|
|
6127
|
+
import { assertEx as assertEx47 } from "@xylabs/sdk-js";
|
|
6216
6128
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6217
6129
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6218
6130
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6219
6131
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6220
6132
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6221
|
-
return
|
|
6133
|
+
return assertEx47(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6222
6134
|
}
|
|
6223
6135
|
|
|
6224
6136
|
// src/wallet/generateXyoBaseWalletFromPhrase.ts
|
|
@@ -6371,7 +6283,6 @@ export {
|
|
|
6371
6283
|
blockPayloadsFromHydratedBlock,
|
|
6372
6284
|
blockRangeSteps,
|
|
6373
6285
|
blockRate,
|
|
6374
|
-
buildRandomTransaction,
|
|
6375
6286
|
buildTransaction,
|
|
6376
6287
|
buildUnsignedTransaction,
|
|
6377
6288
|
bundledPayloadToHydratedBlock,
|
|
@@ -6381,7 +6292,6 @@ export {
|
|
|
6381
6292
|
calculateStepSizeRate,
|
|
6382
6293
|
calculateTimeRate,
|
|
6383
6294
|
chainStepRewardAddress,
|
|
6384
|
-
completedStepRewardAddress,
|
|
6385
6295
|
confirmSubmittedTransaction,
|
|
6386
6296
|
contextCache,
|
|
6387
6297
|
crackOperation,
|
|
@@ -6390,13 +6300,9 @@ export {
|
|
|
6390
6300
|
createDeclarationIntent,
|
|
6391
6301
|
createTransferPayload,
|
|
6392
6302
|
deepCalculateFramesFromRange,
|
|
6393
|
-
derivedReceiveAddress,
|
|
6394
|
-
elevatedPayloads,
|
|
6395
6303
|
externalBlockNumberFromXL1BlockNumber,
|
|
6396
6304
|
externalBlockRangeFromStep,
|
|
6397
6305
|
externalBlockRangeFromXL1BlockRange,
|
|
6398
|
-
extractElevatedHashes,
|
|
6399
|
-
extractElevatedHashesFromScript,
|
|
6400
6306
|
findBestUncle,
|
|
6401
6307
|
findMostRecentBlock,
|
|
6402
6308
|
findUncles,
|
|
@@ -6501,8 +6407,6 @@ export {
|
|
|
6501
6407
|
transfersStepSummaryFromRange,
|
|
6502
6408
|
transfersSummary,
|
|
6503
6409
|
transfersSummaryKey,
|
|
6504
|
-
tryExtractElevatedHashes,
|
|
6505
|
-
tryExtractElevatedHashesFromScript,
|
|
6506
6410
|
tryHydrateBlock,
|
|
6507
6411
|
tryHydrateElevatedTransaction,
|
|
6508
6412
|
tryHydrateTransaction,
|