@xyo-network/xl1-protocol-sdk 2.0.10 → 2.0.11
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/README.md +3 -6
- package/dist/neutral/ChainContextHelpers.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +1 -1
- package/dist/neutral/config/Actor.d.ts +6 -6
- package/dist/neutral/config/Actors.d.ts +1 -1
- package/dist/neutral/config/Base.d.ts +1 -1
- package/dist/neutral/config/Config.d.ts +4 -4
- package/dist/neutral/config/HostActor.d.ts +6 -6
- package/dist/neutral/config/Log.d.ts +1 -1
- package/dist/neutral/context/Actor.d.ts +6 -6
- package/dist/neutral/context/HostActor.d.ts +6 -6
- package/dist/neutral/getFileConfig.d.ts +2 -2
- package/dist/neutral/index.d.ts +1 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +348 -290
- package/dist/neutral/index.mjs.map +4 -4
- package/dist/neutral/model/CreatableProviderContext.zod.d.ts +6 -6
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +13 -2
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +33 -0
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts.map +1 -1
- package/dist/neutral/summary/model/BlocksStepSummary.d.ts +26 -0
- package/dist/neutral/summary/model/BlocksStepSummary.d.ts.map +1 -0
- package/dist/neutral/summary/model/index.d.ts +1 -0
- package/dist/neutral/summary/model/index.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/blocks/blocksMaxStep.d.ts +13 -0
- package/dist/neutral/summary/primitives/blocks/blocksMaxStep.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/blocks/blocksStepSummaryFromRange.d.ts +13 -0
- package/dist/neutral/summary/primitives/blocks/blocksStepSummaryFromRange.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/blocks/index.d.ts +3 -0
- package/dist/neutral/summary/primitives/blocks/index.d.ts.map +1 -0
- package/dist/neutral/summary/primitives/index.d.ts +1 -0
- package/dist/neutral/summary/primitives/index.d.ts.map +1 -1
- package/dist/neutral/test/index.mjs +218 -135
- package/dist/neutral/test/index.mjs.map +4 -4
- package/package.json +19 -20
- package/dist/neutral/driver/cache/LruCacheMap.d.ts +0 -15
- package/dist/neutral/driver/cache/LruCacheMap.d.ts.map +0 -1
- package/dist/neutral/driver/cache/index.d.ts +0 -2
- package/dist/neutral/driver/cache/index.d.ts.map +0 -1
- package/dist/neutral/driver/index.d.ts +0 -3
- package/dist/neutral/driver/index.d.ts.map +0 -1
- package/dist/neutral/driver/memory/MemoryMap.d.ts +0 -14
- package/dist/neutral/driver/memory/MemoryMap.d.ts.map +0 -1
- package/dist/neutral/driver/memory/index.d.ts +0 -2
- package/dist/neutral/driver/memory/index.d.ts.map +0 -1
package/dist/neutral/index.mjs
CHANGED
|
@@ -674,7 +674,7 @@ var tryHydrateBlock = async (archivist, hash, maxDepth = 1) => {
|
|
|
674
674
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
675
675
|
import {
|
|
676
676
|
asHash,
|
|
677
|
-
isDefined as
|
|
677
|
+
isDefined as isDefined3,
|
|
678
678
|
spanAsync
|
|
679
679
|
} from "@xylabs/sdk-js";
|
|
680
680
|
import { toSafeJsonString } from "@xylabs/sdk-js";
|
|
@@ -686,91 +686,12 @@ import {
|
|
|
686
686
|
|
|
687
687
|
// src/ChainContextHelpers.ts
|
|
688
688
|
import {
|
|
689
|
-
isDefined as
|
|
689
|
+
isDefined as isDefined2,
|
|
690
690
|
isObject,
|
|
691
691
|
isUndefined as isUndefined4,
|
|
692
692
|
timeBudget
|
|
693
693
|
} from "@xylabs/sdk-js";
|
|
694
|
-
|
|
695
|
-
// src/driver/cache/LruCacheMap.ts
|
|
696
|
-
import { LRUCache as LRUCache2 } from "lru-cache";
|
|
697
|
-
var LruCacheMap = class {
|
|
698
|
-
lruCache;
|
|
699
|
-
constructor(options) {
|
|
700
|
-
this.lruCache = new LRUCache2(options ?? { max: 5e3 });
|
|
701
|
-
}
|
|
702
|
-
clear() {
|
|
703
|
-
this.lruCache.clear();
|
|
704
|
-
}
|
|
705
|
-
delete(id) {
|
|
706
|
-
return this.lruCache.delete(id);
|
|
707
|
-
}
|
|
708
|
-
get(id) {
|
|
709
|
-
return this.lruCache.get(id);
|
|
710
|
-
}
|
|
711
|
-
getMany(id) {
|
|
712
|
-
const results = [];
|
|
713
|
-
for (const key of id) {
|
|
714
|
-
const value = this.lruCache.get(key);
|
|
715
|
-
if (value !== void 0) {
|
|
716
|
-
results.push(value);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
return results;
|
|
720
|
-
}
|
|
721
|
-
has(id) {
|
|
722
|
-
return this.lruCache.has(id);
|
|
723
|
-
}
|
|
724
|
-
set(id, data) {
|
|
725
|
-
this.lruCache.set(id, data);
|
|
726
|
-
}
|
|
727
|
-
setMany(entries) {
|
|
728
|
-
for (const [key, value] of entries) {
|
|
729
|
-
this.lruCache.set(key, value);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
// src/driver/memory/MemoryMap.ts
|
|
735
|
-
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
736
|
-
var MemoryMap = class {
|
|
737
|
-
map;
|
|
738
|
-
constructor() {
|
|
739
|
-
this.map = /* @__PURE__ */ new Map();
|
|
740
|
-
}
|
|
741
|
-
clear() {
|
|
742
|
-
this.map.clear();
|
|
743
|
-
}
|
|
744
|
-
delete(id) {
|
|
745
|
-
return this.map.delete(id);
|
|
746
|
-
}
|
|
747
|
-
get(id) {
|
|
748
|
-
return this.map.get(id);
|
|
749
|
-
}
|
|
750
|
-
getMany(ids) {
|
|
751
|
-
const results = [];
|
|
752
|
-
for (const id of ids) {
|
|
753
|
-
const data = this.map.get(id);
|
|
754
|
-
if (isDefined2(data)) {
|
|
755
|
-
results.push(data);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
return results;
|
|
759
|
-
}
|
|
760
|
-
has(id) {
|
|
761
|
-
return this.map.has(id);
|
|
762
|
-
}
|
|
763
|
-
set(id, data) {
|
|
764
|
-
this.map.set(id, data);
|
|
765
|
-
}
|
|
766
|
-
setMany(entries) {
|
|
767
|
-
for (const [key, value] of entries) {
|
|
768
|
-
this.map.set(key, value);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
};
|
|
772
|
-
|
|
773
|
-
// src/ChainContextHelpers.ts
|
|
694
|
+
import { LruCacheMap, MemoryMap } from "@xyo-network/xl1-driver-memory";
|
|
774
695
|
function contextCache(context, name, create) {
|
|
775
696
|
if (!isObject(context.caches)) {
|
|
776
697
|
throw new Error("Context does not have an appropriate caches property");
|
|
@@ -788,7 +709,7 @@ async function withContextCacheResponse(context, name, key, func, { max = 1e4 }
|
|
|
788
709
|
);
|
|
789
710
|
const { timeBudgetLimit = 0 } = context;
|
|
790
711
|
const cacheResult = await cache.get(key);
|
|
791
|
-
if (
|
|
712
|
+
if (isDefined2(cacheResult)) {
|
|
792
713
|
return cacheResult;
|
|
793
714
|
}
|
|
794
715
|
const result = timeBudgetLimit > 0 ? timeBudget(name, context.logger, func, timeBudgetLimit) : func();
|
|
@@ -803,7 +724,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
803
724
|
const { chainMap, head } = context;
|
|
804
725
|
return await withContextCacheResponse(context, "blockFromBlockNumber", cacheKey, async () => {
|
|
805
726
|
const [result] = await chainMap.get([head._hash]);
|
|
806
|
-
if (!
|
|
727
|
+
if (!isDefined3(result)) {
|
|
807
728
|
throw new Error(`Head block not found for hash: ${head._hash}`);
|
|
808
729
|
}
|
|
809
730
|
let currentBlock = asSignedBlockBoundWitnessWithStorageMeta(
|
|
@@ -816,8 +737,8 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
816
737
|
while (currentBlock.block > blockNumber) {
|
|
817
738
|
let jumpHash = currentBlock.previous;
|
|
818
739
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
819
|
-
for (const [step,
|
|
820
|
-
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block %
|
|
740
|
+
for (const [step, stepSize4] of StepSizes.entries()) {
|
|
741
|
+
const possibleJumpBlockNumber = currentBlock.block - currentBlock.block % stepSize4 - 1;
|
|
821
742
|
if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {
|
|
822
743
|
jumpBlockNumber = possibleJumpBlockNumber;
|
|
823
744
|
jumpHash = asHash(currentBlock.step_hashes?.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`);
|
|
@@ -826,7 +747,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
826
747
|
const [newBlock] = await chainMap.get([
|
|
827
748
|
asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`)
|
|
828
749
|
]);
|
|
829
|
-
if (!
|
|
750
|
+
if (!isDefined3(newBlock)) {
|
|
830
751
|
throw new Error(`Block not found for jump hash: ${jumpHash}`);
|
|
831
752
|
}
|
|
832
753
|
currentBlock = asSignedBlockBoundWitnessWithStorageMeta(
|
|
@@ -1414,11 +1335,11 @@ var RpcRemoteConfigZod = z11.union([HttpRpcRemoteConfigZod, PostMessageRpcRemote
|
|
|
1414
1335
|
var RemoteConfigZod = z11.object({ rpc: RpcRemoteConfigZod.optional() }).describe("Configuration for remote connections, including RPC");
|
|
1415
1336
|
|
|
1416
1337
|
// src/config/storage/driver/Mongo.ts
|
|
1417
|
-
import { isDefined as
|
|
1338
|
+
import { isDefined as isDefined4, isUndefined as isUndefined5 } from "@xylabs/sdk-js";
|
|
1418
1339
|
import { globalRegistry as globalRegistry8, z as z12 } from "zod";
|
|
1419
1340
|
var hasMongoConfig = (config) => {
|
|
1420
1341
|
if (isUndefined5(config)) return false;
|
|
1421
|
-
return
|
|
1342
|
+
return isDefined4(config.connectionString) && isDefined4(config.database) && isDefined4(config.domain);
|
|
1422
1343
|
};
|
|
1423
1344
|
var MongoConfigZod = z12.object({
|
|
1424
1345
|
// TODO: Create from other arguments
|
|
@@ -1507,13 +1428,13 @@ import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "
|
|
|
1507
1428
|
function blockRangeSteps(range, steps) {
|
|
1508
1429
|
const result = [];
|
|
1509
1430
|
for (const step of steps) {
|
|
1510
|
-
const
|
|
1511
|
-
const startOfFirstStepCandidate = range[0] - range[0] %
|
|
1431
|
+
const stepSize4 = StepSizes3[step];
|
|
1432
|
+
const startOfFirstStepCandidate = range[0] - range[0] % stepSize4 + stepSize4;
|
|
1512
1433
|
const startOfFirstStep = asXL1BlockNumber2(
|
|
1513
1434
|
startOfFirstStepCandidate,
|
|
1514
1435
|
{ name: "blockRangeSteps" }
|
|
1515
1436
|
);
|
|
1516
|
-
for (let block = startOfFirstStep; block <= range[1]; block = asXL1BlockNumber2(block +
|
|
1437
|
+
for (let block = startOfFirstStep; block <= range[1]; block = asXL1BlockNumber2(block + stepSize4, { name: "blockRangeSteps" })) {
|
|
1517
1438
|
result.push({ step, block });
|
|
1518
1439
|
}
|
|
1519
1440
|
}
|
|
@@ -1521,11 +1442,11 @@ function blockRangeSteps(range, steps) {
|
|
|
1521
1442
|
}
|
|
1522
1443
|
|
|
1523
1444
|
// src/primitives/block/rate/blockRate.ts
|
|
1524
|
-
import { isDefined as
|
|
1445
|
+
import { isDefined as isDefined6, isFalsy } from "@xylabs/sdk-js";
|
|
1525
1446
|
import { asXL1BlockRange } from "@xyo-network/xl1-protocol-lib";
|
|
1526
1447
|
|
|
1527
1448
|
// src/primitives/block/rate/timeHelpers.ts
|
|
1528
|
-
import { assertEx as assertEx8, isDefined as
|
|
1449
|
+
import { assertEx as assertEx8, isDefined as isDefined5 } from "@xylabs/sdk-js";
|
|
1529
1450
|
var rateMultipliers = {
|
|
1530
1451
|
millis: 1,
|
|
1531
1452
|
seconds: 1e3,
|
|
@@ -1543,7 +1464,7 @@ var timeDurations = (timeInMs) => ({
|
|
|
1543
1464
|
weeks: timeInMs / (1e3 * 60 * 60 * 24 * 7)
|
|
1544
1465
|
});
|
|
1545
1466
|
var getTimeConfigInMilliseconds = (timeConfig) => {
|
|
1546
|
-
const assertedTimeConfig = assertEx8(
|
|
1467
|
+
const assertedTimeConfig = assertEx8(isDefined5(timeConfig) ? timeConfig : void 0, () => "Time configuration must be provided");
|
|
1547
1468
|
let totalMilliseconds = 0;
|
|
1548
1469
|
if ("years" in assertedTimeConfig) {
|
|
1549
1470
|
totalMilliseconds += assertedTimeConfig.years * 31536e6;
|
|
@@ -1582,13 +1503,13 @@ var blockRate = (startBlock, endBlock, timeUnit) => {
|
|
|
1582
1503
|
throw new Error("Time difference must be greater than 0");
|
|
1583
1504
|
}
|
|
1584
1505
|
const rate = heightDifference / timeDifference;
|
|
1585
|
-
const timeUnitValue =
|
|
1586
|
-
const returnedTimeDifference =
|
|
1506
|
+
const timeUnitValue = isDefined6(timeUnit) ? timeUnit : "millis";
|
|
1507
|
+
const returnedTimeDifference = isDefined6(timeUnit) ? timeDurations(timeDifference)[timeUnit] : timeDifference;
|
|
1587
1508
|
const timePerBlock = returnedTimeDifference / heightDifference;
|
|
1588
1509
|
return {
|
|
1589
1510
|
range: asXL1BlockRange([startingBlock.block, endingBlock.block], true),
|
|
1590
1511
|
span: heightDifference,
|
|
1591
|
-
rate:
|
|
1512
|
+
rate: isDefined6(timeUnit) ? rate * rateMultipliers[timeUnit] : rate,
|
|
1592
1513
|
timeUnit: timeUnitValue,
|
|
1593
1514
|
timeDifference: returnedTimeDifference,
|
|
1594
1515
|
timePerBlock
|
|
@@ -1636,7 +1557,7 @@ var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit
|
|
|
1636
1557
|
// src/primitives/block/rate/timeRate.ts
|
|
1637
1558
|
import {
|
|
1638
1559
|
assertEx as assertEx10,
|
|
1639
|
-
isDefined as
|
|
1560
|
+
isDefined as isDefined7,
|
|
1640
1561
|
isDefinedNotNull
|
|
1641
1562
|
} from "@xylabs/sdk-js";
|
|
1642
1563
|
import { asXL1BlockNumber as asXL1BlockNumber3, asXL1BlockRange as asXL1BlockRange3 } from "@xyo-network/xl1-protocol-lib";
|
|
@@ -1673,7 +1594,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1673
1594
|
}
|
|
1674
1595
|
const endBlock = await viewer.blockByNumber(estimatedEndBlockNumber);
|
|
1675
1596
|
const resolvedEndBlock = assertEx10(
|
|
1676
|
-
|
|
1597
|
+
isDefined7(endBlock?.[0]) ? endBlock[0] : void 0,
|
|
1677
1598
|
() => `Could not retrieve block ${estimatedEndBlockNumber} for time rate calculation`
|
|
1678
1599
|
);
|
|
1679
1600
|
const endBlockEpoch = resolvedEndBlock.$epoch;
|
|
@@ -1710,7 +1631,7 @@ var findEndBlockRecursive = async (viewer, startBlock, targetTimeMs, estimatedBl
|
|
|
1710
1631
|
// src/primitives/chain/getWindowedChain.ts
|
|
1711
1632
|
import {
|
|
1712
1633
|
assertEx as assertEx11,
|
|
1713
|
-
isDefined as
|
|
1634
|
+
isDefined as isDefined8,
|
|
1714
1635
|
isNull,
|
|
1715
1636
|
spanRootAsync
|
|
1716
1637
|
} from "@xylabs/sdk-js";
|
|
@@ -1724,7 +1645,7 @@ async function getWindowedChain(context, blockViewer, maxWindowSize, previousCha
|
|
|
1724
1645
|
while (currentBlock !== null && newChain.length < maxWindowSize) {
|
|
1725
1646
|
const currentBlockNumber = currentBlock[0].block;
|
|
1726
1647
|
const nextBlock = newChain[0];
|
|
1727
|
-
if (
|
|
1648
|
+
if (isDefined8(nextBlock)) {
|
|
1728
1649
|
const nextBlockNumber = nextBlock[0].block;
|
|
1729
1650
|
assertEx11(
|
|
1730
1651
|
currentBlockNumber === nextBlockNumber - 1,
|
|
@@ -1771,9 +1692,9 @@ function mergeTransfers(transfers) {
|
|
|
1771
1692
|
// src/primitives/step/stepBlockRange.ts
|
|
1772
1693
|
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
|
|
1773
1694
|
function stepBlockRange({ block, step }) {
|
|
1774
|
-
const
|
|
1775
|
-
const start = block -
|
|
1776
|
-
return asXL1BlockRange4([start, start +
|
|
1695
|
+
const stepSize4 = StepSizes5[step];
|
|
1696
|
+
const start = block - stepSize4;
|
|
1697
|
+
return asXL1BlockRange4([start, start + stepSize4 - 1], { name: "stepBlockRange" });
|
|
1777
1698
|
}
|
|
1778
1699
|
|
|
1779
1700
|
// src/primitives/step/stepTransferIndex.ts
|
|
@@ -1783,9 +1704,9 @@ function stepTransferIndex(block, step) {
|
|
|
1783
1704
|
let rewardTransferCount = 0;
|
|
1784
1705
|
let rewardTransferIndex = -1;
|
|
1785
1706
|
for (let i = 3; i < StepSizes6.length; i++) {
|
|
1786
|
-
const
|
|
1787
|
-
if (block %
|
|
1788
|
-
if (
|
|
1707
|
+
const stepSize4 = StepSizes6[i];
|
|
1708
|
+
if (block % stepSize4 === 0) {
|
|
1709
|
+
if (stepSize4 === StepSizes6[step]) {
|
|
1789
1710
|
rewardTransferIndex = rewardTransferCount;
|
|
1790
1711
|
}
|
|
1791
1712
|
rewardTransferCount++;
|
|
@@ -1819,7 +1740,7 @@ async function chainStepRewardAddress(context, blockViewer, { block, step }) {
|
|
|
1819
1740
|
}
|
|
1820
1741
|
|
|
1821
1742
|
// src/primitives/chain/step/stepRewardTotal.ts
|
|
1822
|
-
import { assertEx as assertEx15, isDefined as
|
|
1743
|
+
import { assertEx as assertEx15, isDefined as isDefined9 } from "@xylabs/sdk-js";
|
|
1823
1744
|
import {
|
|
1824
1745
|
asAttoXL1,
|
|
1825
1746
|
asXL1BlockRange as asXL1BlockRange5,
|
|
@@ -1908,7 +1829,7 @@ function stepInRange(step, range) {
|
|
|
1908
1829
|
return stepRange[0] >= range[0] && stepRange[1] <= range[1];
|
|
1909
1830
|
}
|
|
1910
1831
|
async function stepRewardTotal(context, blockViewer, { block, step }, multipliers) {
|
|
1911
|
-
const cacheKey = `${block}|${step}|${
|
|
1832
|
+
const cacheKey = `${block}|${step}|${isDefined9(multipliers)}`;
|
|
1912
1833
|
return await withContextCacheResponse(context, "stepRewardTotal", cacheKey, async () => {
|
|
1913
1834
|
const [blockBw, payloads] = await stepRewardBlock(context, blockViewer, { block, step });
|
|
1914
1835
|
assertEx15(blockBw.block === block, () => `Block Mismatch: expected ${block}, got ${blockBw.block}`);
|
|
@@ -1997,7 +1918,7 @@ async function externalBlockRangeFromStep(context, blockViewer, stepIdentity) {
|
|
|
1997
1918
|
}
|
|
1998
1919
|
|
|
1999
1920
|
// src/primitives/mapToMapType.ts
|
|
2000
|
-
import { isDefined as
|
|
1921
|
+
import { isDefined as isDefined10 } from "@xylabs/sdk-js";
|
|
2001
1922
|
function mapToMapType(map) {
|
|
2002
1923
|
return {
|
|
2003
1924
|
get: (key) => map.get(key),
|
|
@@ -2016,7 +1937,7 @@ function mapToMapType(map) {
|
|
|
2016
1937
|
const result = [];
|
|
2017
1938
|
for (const key of keys) {
|
|
2018
1939
|
const value = map.get(key);
|
|
2019
|
-
if (
|
|
1940
|
+
if (isDefined10(value)) {
|
|
2020
1941
|
result.push(value);
|
|
2021
1942
|
}
|
|
2022
1943
|
}
|
|
@@ -2031,7 +1952,7 @@ function mapToMapType(map) {
|
|
|
2031
1952
|
}
|
|
2032
1953
|
|
|
2033
1954
|
// src/primitives/readPayloadMapFromStore.ts
|
|
2034
|
-
import { isDefined as
|
|
1955
|
+
import { isDefined as isDefined11 } from "@xylabs/sdk-js";
|
|
2035
1956
|
function readPayloadMapFromStore(store) {
|
|
2036
1957
|
if (isReadArchivist(store)) {
|
|
2037
1958
|
return {
|
|
@@ -2042,7 +1963,7 @@ function readPayloadMapFromStore(store) {
|
|
|
2042
1963
|
return await store.get(hashes);
|
|
2043
1964
|
},
|
|
2044
1965
|
has: async (hash) => {
|
|
2045
|
-
return
|
|
1966
|
+
return isDefined11((await store.get([hash]))[0]);
|
|
2046
1967
|
}
|
|
2047
1968
|
};
|
|
2048
1969
|
}
|
|
@@ -2058,7 +1979,7 @@ function payloadMapFromStore(store) {
|
|
|
2058
1979
|
return await store.get(hashes);
|
|
2059
1980
|
},
|
|
2060
1981
|
has: async (hash) => {
|
|
2061
|
-
return
|
|
1982
|
+
return isDefined11((await store.get([hash]))[0]);
|
|
2062
1983
|
},
|
|
2063
1984
|
clear: async () => {
|
|
2064
1985
|
return await store.clear();
|
|
@@ -2104,7 +2025,7 @@ function rewardFromBlockNumber(blockNumber) {
|
|
|
2104
2025
|
import { XYO_NETWORK_STAKING_ADDRESS } from "@xyo-network/xl1-protocol-lib";
|
|
2105
2026
|
|
|
2106
2027
|
// src/primitives/stake/activeStakeAtTimeByAddress.ts
|
|
2107
|
-
import { isDefined as
|
|
2028
|
+
import { isDefined as isDefined12 } from "@xylabs/sdk-js";
|
|
2108
2029
|
|
|
2109
2030
|
// src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts
|
|
2110
2031
|
async function mergedAddRemoveStakeEventsByStaker(chainEvents, range, staked, staker) {
|
|
@@ -2123,7 +2044,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
|
|
|
2123
2044
|
for (const event of stakeEvents) {
|
|
2124
2045
|
if (event.time > time) break;
|
|
2125
2046
|
if (event.args.staked !== staked) continue;
|
|
2126
|
-
if (
|
|
2047
|
+
if (isDefined12(staker) && event.args.staker !== staker) continue;
|
|
2127
2048
|
if (event.name === "StakeAdded") {
|
|
2128
2049
|
result += event.args.amount;
|
|
2129
2050
|
} else if (event.name === "StakeRemoved") {
|
|
@@ -2196,13 +2117,13 @@ async function allStakersForStep(context, blockViewer, stakeEventsViewer, stepCo
|
|
|
2196
2117
|
}
|
|
2197
2118
|
|
|
2198
2119
|
// src/primitives/stake/weightedStakeForRangeByPosition.ts
|
|
2199
|
-
import { isDefined as
|
|
2120
|
+
import { isDefined as isDefined13 } from "@xylabs/sdk-js";
|
|
2200
2121
|
import { asBlockNumber as asBlockNumber2 } from "@xyo-network/xl1-protocol-lib";
|
|
2201
2122
|
async function weightedStakeForRangeByPosition(context, blockViewer, stakeEventsViewer, externalRange, staked, positionId) {
|
|
2202
|
-
const cacheKey =
|
|
2123
|
+
const cacheKey = isDefined13(positionId) ? `${externalRange[0]}-${externalRange[1]}-${positionId}` : `${externalRange[0]}-${externalRange[1]}-all`;
|
|
2203
2124
|
return await withContextCacheResponse(context, "weightedStakeForRangeByPosition", cacheKey, async () => {
|
|
2204
2125
|
let weightedStakeSum = 0n;
|
|
2205
|
-
if (
|
|
2126
|
+
if (isDefined13(positionId)) {
|
|
2206
2127
|
const mergedEvents = (await mergedAddRemoveStakeEventsByPosition(
|
|
2207
2128
|
stakeEventsViewer,
|
|
2208
2129
|
[0, externalRange[1]],
|
|
@@ -2210,7 +2131,7 @@ async function weightedStakeForRangeByPosition(context, blockViewer, stakeEvents
|
|
|
2210
2131
|
)).toSorted((a, b) => a.time - b.time);
|
|
2211
2132
|
let currentTime = externalRange[0];
|
|
2212
2133
|
let currentStake = 0n;
|
|
2213
|
-
if (
|
|
2134
|
+
if (isDefined13(staked) && mergedEvents.at(0)?.args.staked !== staked) {
|
|
2214
2135
|
return 0n;
|
|
2215
2136
|
}
|
|
2216
2137
|
for (const event of mergedEvents) {
|
|
@@ -2384,11 +2305,11 @@ function toValidUncle(_context, finalizedWindowedChain, possibleUncle) {
|
|
|
2384
2305
|
}
|
|
2385
2306
|
const allUncleTransactions = prunedPossibleUncle.flatMap((b) => b[1]).filter(isTransactionBoundWitness2);
|
|
2386
2307
|
const allFinalizedTransactions = finalizedWindowedChain.flatMap((b) => b[1]).filter(isTransactionBoundWitness2);
|
|
2387
|
-
const txPossiblyBeforeWindow = allUncleTransactions.
|
|
2308
|
+
const txPossiblyBeforeWindow = allUncleTransactions.some((tx) => tx.nbf < finalizedWindowStartBlockNumber);
|
|
2388
2309
|
if (txPossiblyBeforeWindow) {
|
|
2389
2310
|
return;
|
|
2390
2311
|
}
|
|
2391
|
-
const txExistsInWindow = allUncleTransactions.
|
|
2312
|
+
const txExistsInWindow = allUncleTransactions.some((tx) => allFinalizedTransactions.some((finalTx) => finalTx._hash === tx._hash));
|
|
2392
2313
|
if (txExistsInWindow) {
|
|
2393
2314
|
return;
|
|
2394
2315
|
}
|
|
@@ -2686,7 +2607,7 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
2686
2607
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
2687
2608
|
import {
|
|
2688
2609
|
delay,
|
|
2689
|
-
isDefined as
|
|
2610
|
+
isDefined as isDefined14,
|
|
2690
2611
|
isNumber
|
|
2691
2612
|
} from "@xylabs/sdk-js";
|
|
2692
2613
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
@@ -2708,7 +2629,7 @@ var confirmSubmittedTransaction = async (viewer, txHash, options) => {
|
|
|
2708
2629
|
let attempts = 0;
|
|
2709
2630
|
while (true) {
|
|
2710
2631
|
const tx = await viewer.transaction.byHash(txHash) ?? void 0;
|
|
2711
|
-
if (
|
|
2632
|
+
if (isDefined14(tx)) {
|
|
2712
2633
|
options?.logger?.debug("Transaction confirmed", txHash);
|
|
2713
2634
|
return tx;
|
|
2714
2635
|
} else {
|
|
@@ -3420,13 +3341,13 @@ var asHostActorConfigContext = zodAsFactory7(HostActorConfigContext, "asHostActo
|
|
|
3420
3341
|
var toHostActorConfigContext = zodToFactory6(HostActorConfigContext, "toHostActorConfigContext");
|
|
3421
3342
|
|
|
3422
3343
|
// src/createDeclarationPayload.ts
|
|
3423
|
-
import { isDefined as
|
|
3344
|
+
import { isDefined as isDefined15 } from "@xylabs/sdk-js";
|
|
3424
3345
|
import { PayloadBuilder as PayloadBuilder13 } from "@xyo-network/sdk-js";
|
|
3425
3346
|
import {
|
|
3426
3347
|
ChainStakeIntentSchema
|
|
3427
3348
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3428
3349
|
var createDeclarationIntent = (address, intent, nbf, exp) => {
|
|
3429
|
-
const expiration =
|
|
3350
|
+
const expiration = isDefined15(exp) ? exp : nbf + 1e4;
|
|
3430
3351
|
const redeclarationIntent = new PayloadBuilder13({ schema: ChainStakeIntentSchema }).fields({
|
|
3431
3352
|
from: address,
|
|
3432
3353
|
intent,
|
|
@@ -3605,21 +3526,21 @@ var toPositiveBigInt = (value) => {
|
|
|
3605
3526
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3606
3527
|
import {
|
|
3607
3528
|
asHash as asHash4,
|
|
3608
|
-
assertEx as
|
|
3529
|
+
assertEx as assertEx33,
|
|
3609
3530
|
exists as exists3,
|
|
3610
|
-
isDefined as
|
|
3531
|
+
isDefined as isDefined16,
|
|
3611
3532
|
ZERO_ADDRESS
|
|
3612
3533
|
} from "@xylabs/sdk-js";
|
|
3613
3534
|
import {
|
|
3614
3535
|
AccountBalanceViewerMoniker,
|
|
3615
3536
|
asRange,
|
|
3616
|
-
asXL1BlockNumber as
|
|
3537
|
+
asXL1BlockNumber as asXL1BlockNumber8,
|
|
3617
3538
|
asXL1BlockRange as asXL1BlockRange10,
|
|
3618
3539
|
AttoXL1 as AttoXL13,
|
|
3619
3540
|
BlockViewerMoniker,
|
|
3620
3541
|
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig4,
|
|
3621
3542
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig4,
|
|
3622
|
-
StepSizes as
|
|
3543
|
+
StepSizes as StepSizes13,
|
|
3623
3544
|
TransferSchema as TransferSchema2
|
|
3624
3545
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3625
3546
|
import { Semaphore } from "async-mutex";
|
|
@@ -3639,41 +3560,56 @@ var isBalancesStepSummaryWithStorageMeta = (value) => {
|
|
|
3639
3560
|
};
|
|
3640
3561
|
var asBalancesStepSummaryWithStorageMeta = AsObjectFactory5.create(isBalancesStepSummaryWithStorageMeta);
|
|
3641
3562
|
|
|
3642
|
-
// src/summary/model/
|
|
3563
|
+
// src/summary/model/BlocksStepSummary.ts
|
|
3643
3564
|
import { AsObjectFactory as AsObjectFactory6 } from "@xylabs/sdk-js";
|
|
3644
3565
|
import {
|
|
3645
3566
|
asSchema as asSchema6,
|
|
3646
3567
|
isPayloadOfSchemaType as isPayloadOfSchemaType4,
|
|
3647
3568
|
isStorageMeta as isStorageMeta3
|
|
3648
3569
|
} from "@xyo-network/sdk-js";
|
|
3649
|
-
var
|
|
3650
|
-
var
|
|
3651
|
-
var
|
|
3570
|
+
var BlocksStepSummarySchema = asSchema6("network.xyo.step.summary.blocks", true);
|
|
3571
|
+
var isBlocksStepSummary = isPayloadOfSchemaType4(BlocksStepSummarySchema);
|
|
3572
|
+
var asBlocksStepSummary = AsObjectFactory6.create(isBlocksStepSummary);
|
|
3573
|
+
var isBlocksStepSummaryWithStorageMeta = (value) => {
|
|
3574
|
+
return isBlocksStepSummary(value) && isStorageMeta3(value);
|
|
3575
|
+
};
|
|
3576
|
+
var asBlocksStepSummaryWithStorageMeta = AsObjectFactory6.create(isBlocksStepSummaryWithStorageMeta);
|
|
3577
|
+
|
|
3578
|
+
// src/summary/model/SchemasStepSummary.ts
|
|
3579
|
+
import { AsObjectFactory as AsObjectFactory7 } from "@xylabs/sdk-js";
|
|
3580
|
+
import {
|
|
3581
|
+
asSchema as asSchema7,
|
|
3582
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType5,
|
|
3583
|
+
isStorageMeta as isStorageMeta4
|
|
3584
|
+
} from "@xyo-network/sdk-js";
|
|
3585
|
+
var SchemasStepSummarySchema = asSchema7("network.xyo.step.summary.schemas", true);
|
|
3586
|
+
var isSchemasStepSummary = isPayloadOfSchemaType5(SchemasStepSummarySchema);
|
|
3587
|
+
var asSchemasStepSummary = AsObjectFactory7.create(isSchemasStepSummary);
|
|
3652
3588
|
var isSchemasStepSummaryWithStorageMeta = (value) => {
|
|
3653
|
-
return isSchemasStepSummary(value) &&
|
|
3589
|
+
return isSchemasStepSummary(value) && isStorageMeta4(value);
|
|
3654
3590
|
};
|
|
3655
|
-
var asSchemasStepSummaryWithStorageMeta =
|
|
3591
|
+
var asSchemasStepSummaryWithStorageMeta = AsObjectFactory7.create(isSchemasStepSummaryWithStorageMeta);
|
|
3656
3592
|
|
|
3657
3593
|
// src/summary/model/StepSummary.ts
|
|
3658
3594
|
import {
|
|
3659
|
-
asSchema as
|
|
3595
|
+
asSchema as asSchema8
|
|
3660
3596
|
} from "@xyo-network/sdk-js";
|
|
3661
|
-
var StepSummarySchema =
|
|
3597
|
+
var StepSummarySchema = asSchema8("network.xyo.step.summary", true);
|
|
3662
3598
|
|
|
3663
3599
|
// src/summary/model/TransfersSummary.ts
|
|
3664
|
-
import { AsObjectFactory as
|
|
3600
|
+
import { AsObjectFactory as AsObjectFactory8 } from "@xylabs/sdk-js";
|
|
3665
3601
|
import {
|
|
3666
|
-
asSchema as
|
|
3667
|
-
isPayloadOfSchemaType as
|
|
3668
|
-
isStorageMeta as
|
|
3602
|
+
asSchema as asSchema9,
|
|
3603
|
+
isPayloadOfSchemaType as isPayloadOfSchemaType6,
|
|
3604
|
+
isStorageMeta as isStorageMeta5
|
|
3669
3605
|
} from "@xyo-network/sdk-js";
|
|
3670
|
-
var TransfersStepSummarySchema =
|
|
3671
|
-
var isTransfersStepSummary =
|
|
3672
|
-
var asTransfersStepSummary =
|
|
3606
|
+
var TransfersStepSummarySchema = asSchema9("network.xyo.step.summary.transfer", true);
|
|
3607
|
+
var isTransfersStepSummary = isPayloadOfSchemaType6(TransfersStepSummarySchema);
|
|
3608
|
+
var asTransfersStepSummary = AsObjectFactory8.create(isTransfersStepSummary);
|
|
3673
3609
|
var isTransfersStepSummaryWithStorageMeta = (value) => {
|
|
3674
|
-
return isTransfersStepSummary(value) &&
|
|
3610
|
+
return isTransfersStepSummary(value) && isStorageMeta5(value);
|
|
3675
3611
|
};
|
|
3676
|
-
var asTransfersStepSummaryWithStorageMeta =
|
|
3612
|
+
var asTransfersStepSummaryWithStorageMeta = AsObjectFactory8.create(isTransfersStepSummaryWithStorageMeta);
|
|
3677
3613
|
|
|
3678
3614
|
// src/summary/primitives/balances/balancesMaxStep.ts
|
|
3679
3615
|
var balancesMaxStep = 5;
|
|
@@ -3777,25 +3713,89 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3777
3713
|
}, { ...context, timeBudgetLimit: 500 });
|
|
3778
3714
|
}
|
|
3779
3715
|
|
|
3716
|
+
// src/summary/primitives/blocks/blocksMaxStep.ts
|
|
3717
|
+
var blocksMaxStep = 3;
|
|
3718
|
+
|
|
3719
|
+
// src/summary/primitives/blocks/blocksStepSummaryFromRange.ts
|
|
3720
|
+
import { assertEx as assertEx28, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
|
|
3721
|
+
import { isAnyPayload as isAnyPayload4 } from "@xyo-network/sdk-js";
|
|
3722
|
+
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3723
|
+
function blocksStepSummaryKey(frameHeadHash, frameSize) {
|
|
3724
|
+
return `${frameHeadHash}|${frameSize}`;
|
|
3725
|
+
}
|
|
3726
|
+
async function blocksStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3727
|
+
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3728
|
+
return await withContextCacheResponse(context, "blocksStepSummaryFromRange", cacheKey, async () => {
|
|
3729
|
+
return await spanRootAsync4("blocksStepSummaryFromRange", async () => {
|
|
3730
|
+
const frameHead = assertEx28(
|
|
3731
|
+
await blockViewer.blockByNumber(range[1]),
|
|
3732
|
+
() => `Block not found for number: ${range[1]}`
|
|
3733
|
+
);
|
|
3734
|
+
const frameHeadHash = frameHead[0]._hash;
|
|
3735
|
+
const frameSize = range[1] - range[0] + 1;
|
|
3736
|
+
let result;
|
|
3737
|
+
if (frameSize === 1) {
|
|
3738
|
+
result = {
|
|
3739
|
+
schema: BlocksStepSummarySchema,
|
|
3740
|
+
hash: frameHeadHash,
|
|
3741
|
+
stepSize: -1,
|
|
3742
|
+
blocks: [frameHead]
|
|
3743
|
+
};
|
|
3744
|
+
} else {
|
|
3745
|
+
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3746
|
+
assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
3747
|
+
const key = blocksStepSummaryKey(frameHeadHash, frameSize);
|
|
3748
|
+
const summaryResult = await summaryMap.get(key);
|
|
3749
|
+
if (isAnyPayload4(summaryResult)) {
|
|
3750
|
+
result = asBlocksStepSummary(summaryResult, { required: true });
|
|
3751
|
+
} else {
|
|
3752
|
+
await semaphores[step].acquire();
|
|
3753
|
+
try {
|
|
3754
|
+
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
3755
|
+
const subResults = await Promise.all(subRanges.map((subRange) => blocksStepSummaryFromRange(
|
|
3756
|
+
context,
|
|
3757
|
+
semaphores,
|
|
3758
|
+
blockViewer,
|
|
3759
|
+
summaryMap,
|
|
3760
|
+
subRange
|
|
3761
|
+
)));
|
|
3762
|
+
const blocks = subResults.flatMap((subResult) => subResult.blocks);
|
|
3763
|
+
result = {
|
|
3764
|
+
schema: BlocksStepSummarySchema,
|
|
3765
|
+
hash: frameHeadHash,
|
|
3766
|
+
stepSize: frameSize,
|
|
3767
|
+
blocks
|
|
3768
|
+
};
|
|
3769
|
+
await summaryMap.set(key, result);
|
|
3770
|
+
} finally {
|
|
3771
|
+
semaphores[step].release();
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
return result;
|
|
3776
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3777
|
+
}, { max: 1e5 });
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
3780
|
// src/summary/primitives/schemas/schemasMaxStep.ts
|
|
3781
|
-
import { StepSizes as
|
|
3782
|
-
var schemasMaxStep =
|
|
3781
|
+
import { StepSizes as StepSizes10 } from "@xyo-network/xl1-protocol-lib";
|
|
3782
|
+
var schemasMaxStep = StepSizes10.length - 1;
|
|
3783
3783
|
|
|
3784
3784
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
3785
|
-
import { assertEx as
|
|
3785
|
+
import { assertEx as assertEx29 } from "@xylabs/sdk-js";
|
|
3786
3786
|
import {
|
|
3787
|
-
isAnyPayload as
|
|
3787
|
+
isAnyPayload as isAnyPayload5,
|
|
3788
3788
|
isBoundWitness as isBoundWitness2,
|
|
3789
3789
|
isHashMeta,
|
|
3790
3790
|
PayloadBuilder as PayloadBuilder17
|
|
3791
3791
|
} from "@xyo-network/sdk-js";
|
|
3792
|
-
import { StepSizes as
|
|
3792
|
+
import { StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol-lib";
|
|
3793
3793
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3794
|
-
const [frameHead] =
|
|
3794
|
+
const [frameHead] = assertEx29(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3795
3795
|
const frameSize = range[1] - range[0] + 1;
|
|
3796
3796
|
let result;
|
|
3797
3797
|
if (frameSize === 1) {
|
|
3798
|
-
const [block, payloads] =
|
|
3798
|
+
const [block, payloads] = assertEx29(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3799
3799
|
const boundWitnesses = [block, ...payloads.filter((x) => isBoundWitness2(x) && isHashMeta(x))];
|
|
3800
3800
|
const schemas = {};
|
|
3801
3801
|
for (const bw of boundWitnesses) {
|
|
@@ -3811,10 +3811,10 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3811
3811
|
schemas
|
|
3812
3812
|
});
|
|
3813
3813
|
} else {
|
|
3814
|
-
const step =
|
|
3815
|
-
|
|
3814
|
+
const step = StepSizes11.indexOf(frameSize);
|
|
3815
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
3816
3816
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3817
|
-
if (
|
|
3817
|
+
if (isAnyPayload5(summaryResult)) {
|
|
3818
3818
|
result = summaryResult;
|
|
3819
3819
|
} else {
|
|
3820
3820
|
await semaphores[step].acquire();
|
|
@@ -3851,7 +3851,7 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3851
3851
|
}
|
|
3852
3852
|
|
|
3853
3853
|
// src/summary/primitives/schemas/schemasSummary.ts
|
|
3854
|
-
import { assertEx as
|
|
3854
|
+
import { assertEx as assertEx30, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3855
3855
|
import {
|
|
3856
3856
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
3857
3857
|
asXL1BlockRange as asXL1BlockRange8,
|
|
@@ -3859,9 +3859,9 @@ import {
|
|
|
3859
3859
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig2
|
|
3860
3860
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3861
3861
|
async function schemasSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3862
|
-
return await
|
|
3862
|
+
return await spanRootAsync5("schemasSummary", async () => {
|
|
3863
3863
|
const headHash = isChainQualifiedHeadConfig2(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3864
|
-
const [head] =
|
|
3864
|
+
const [head] = assertEx30(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3865
3865
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3866
3866
|
const range = isChainQualifiedRangeConfig2(config) ? config.range : asXL1BlockRange8([0, headBoundWitness.block], true);
|
|
3867
3867
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange8(
|
|
@@ -3884,21 +3884,21 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3884
3884
|
var transfersMaxStep = 4;
|
|
3885
3885
|
|
|
3886
3886
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3887
|
-
import { assertEx as
|
|
3888
|
-
import { isAnyPayload as
|
|
3889
|
-
import { asXL1BlockNumber as
|
|
3887
|
+
import { assertEx as assertEx31, spanRootAsync as spanRootAsync6 } from "@xylabs/sdk-js";
|
|
3888
|
+
import { isAnyPayload as isAnyPayload6 } from "@xyo-network/sdk-js";
|
|
3889
|
+
import { asXL1BlockNumber as asXL1BlockNumber7, StepSizes as StepSizes12 } from "@xyo-network/xl1-protocol-lib";
|
|
3890
3890
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
3891
3891
|
return `${frameHeadHash}|${frameSize}`;
|
|
3892
3892
|
}
|
|
3893
3893
|
async function transfersStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3894
3894
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3895
3895
|
return await withContextCacheResponse(context, "transfersStepSummaryFromRange", cacheKey, async () => {
|
|
3896
|
-
return await
|
|
3897
|
-
const [frameHead] =
|
|
3896
|
+
return await spanRootAsync6("transfersStepSummaryFromRange", async () => {
|
|
3897
|
+
const [frameHead] = assertEx31(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3898
3898
|
const frameSize = range[1] - range[0] + 1;
|
|
3899
3899
|
let result;
|
|
3900
3900
|
if (frameSize === 1) {
|
|
3901
|
-
const [, payloads] =
|
|
3901
|
+
const [, payloads] = assertEx31(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3902
3902
|
const transfers = {};
|
|
3903
3903
|
for (const [from, toMap] of Object.entries(netTransfersForPayloads(context, payloads))) {
|
|
3904
3904
|
transfers[from] = transfers[from] ?? {};
|
|
@@ -3913,11 +3913,11 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3913
3913
|
transfers
|
|
3914
3914
|
};
|
|
3915
3915
|
} else {
|
|
3916
|
-
const step =
|
|
3917
|
-
|
|
3916
|
+
const step = StepSizes12.indexOf(asXL1BlockNumber7(frameSize, true));
|
|
3917
|
+
assertEx31(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes12.join(", ")}`);
|
|
3918
3918
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3919
3919
|
const summaryResult = await summaryMap.get(key);
|
|
3920
|
-
if (
|
|
3920
|
+
if (isAnyPayload6(summaryResult)) {
|
|
3921
3921
|
result = asTransfersStepSummary(summaryResult, { required: true });
|
|
3922
3922
|
} else {
|
|
3923
3923
|
await semaphores[step].acquire();
|
|
@@ -3965,7 +3965,7 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3965
3965
|
}
|
|
3966
3966
|
|
|
3967
3967
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3968
|
-
import { assertEx as
|
|
3968
|
+
import { assertEx as assertEx32, spanRootAsync as spanRootAsync7 } from "@xylabs/sdk-js";
|
|
3969
3969
|
import { asXyoAddress as asXyoAddress2 } from "@xyo-network/address";
|
|
3970
3970
|
import {
|
|
3971
3971
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta5,
|
|
@@ -3974,9 +3974,9 @@ import {
|
|
|
3974
3974
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig3
|
|
3975
3975
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3976
3976
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3977
|
-
return await
|
|
3977
|
+
return await spanRootAsync7("transferSummary", async () => {
|
|
3978
3978
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3979
|
-
const [head] =
|
|
3979
|
+
const [head] = assertEx32(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3980
3980
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta5(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
3981
3981
|
const range = isChainQualifiedRangeConfig3(config) ? config.range : asXL1BlockRange9([0, headBoundWitness.block], true);
|
|
3982
3982
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange9(
|
|
@@ -4002,9 +4002,9 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
4002
4002
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
4003
4003
|
var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
4004
4004
|
moniker = SimpleAccountBalanceViewer.defaultMoniker;
|
|
4005
|
-
_balanceStepSemaphores =
|
|
4005
|
+
_balanceStepSemaphores = StepSizes13.map(() => new Semaphore(20));
|
|
4006
4006
|
_blockViewer;
|
|
4007
|
-
_transferStepSemaphores =
|
|
4007
|
+
_transferStepSemaphores = StepSizes13.map(() => new Semaphore(20));
|
|
4008
4008
|
get balancesSummaryMap() {
|
|
4009
4009
|
return this.params.balancesSummaryMap;
|
|
4010
4010
|
}
|
|
@@ -4017,8 +4017,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4017
4017
|
static async paramsHandler(params = {}) {
|
|
4018
4018
|
return {
|
|
4019
4019
|
...await super.paramsHandler(params),
|
|
4020
|
-
balancesSummaryMap:
|
|
4021
|
-
transfersSummaryMap:
|
|
4020
|
+
balancesSummaryMap: assertEx33(params.balancesSummaryMap, () => "balancesSummaryMap is required"),
|
|
4021
|
+
transfersSummaryMap: assertEx33(params.transfersSummaryMap, () => "transfersSummaryMap is required")
|
|
4022
4022
|
};
|
|
4023
4023
|
}
|
|
4024
4024
|
async accountBalance(address, config) {
|
|
@@ -4039,11 +4039,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4039
4039
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4040
4040
|
const transfers = transferIndexes.map((index) => {
|
|
4041
4041
|
const hash = block[0].payload_hashes[index];
|
|
4042
|
-
return
|
|
4042
|
+
return assertEx33(
|
|
4043
4043
|
block[1].find((p) => p._hash === hash),
|
|
4044
4044
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4045
4045
|
);
|
|
4046
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4046
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
4047
4047
|
if (transfers.length === 0) {
|
|
4048
4048
|
continue;
|
|
4049
4049
|
}
|
|
@@ -4072,7 +4072,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4072
4072
|
const head = isChainQualifiedHeadConfig4(config) ? config.head : await this.blockViewer.currentBlockHash();
|
|
4073
4073
|
const range = isChainQualifiedRangeConfig4(config) ? config.range : asXL1BlockRange10([
|
|
4074
4074
|
0,
|
|
4075
|
-
|
|
4075
|
+
assertEx33(
|
|
4076
4076
|
await this.blockViewer.blockByHash(head),
|
|
4077
4077
|
() => `Error: Could not find block with hash ${head}`
|
|
4078
4078
|
)[0].block
|
|
@@ -4087,11 +4087,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4087
4087
|
const qualifiedRange = qualifiedEntries[0][1][1].range;
|
|
4088
4088
|
const qualifiedHeadHash = qualifiedEntries[0][1][1].head;
|
|
4089
4089
|
for (const [_, [__, { range: range2, head: head2 }]] of qualifiedEntries) {
|
|
4090
|
-
|
|
4090
|
+
assertEx33(
|
|
4091
4091
|
range2[0] === qualifiedRange[0] && range2[1] === qualifiedRange[1],
|
|
4092
4092
|
() => "Inconsistent ranges in qualifiedAccountBalanceHistories"
|
|
4093
4093
|
);
|
|
4094
|
-
|
|
4094
|
+
assertEx33(
|
|
4095
4095
|
head2 === qualifiedHeadHash,
|
|
4096
4096
|
() => "Inconsistent head hashes in qualifiedAccountBalanceHistories"
|
|
4097
4097
|
);
|
|
@@ -4125,8 +4125,8 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4125
4125
|
}
|
|
4126
4126
|
async distillTransferHistory(address, range, max = 50) {
|
|
4127
4127
|
return await this.spanAsync("distillTransferHistory", async () => {
|
|
4128
|
-
if (range[1] - range[0] <=
|
|
4129
|
-
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) =>
|
|
4128
|
+
if (range[1] - range[0] <= StepSizes13[0] || max <= 1) {
|
|
4129
|
+
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber8(n, true));
|
|
4130
4130
|
}
|
|
4131
4131
|
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true), transfersMaxStep);
|
|
4132
4132
|
const transferSummaryPairs = await Promise.all(frames.map(
|
|
@@ -4140,7 +4140,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4140
4140
|
});
|
|
4141
4141
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
4142
4142
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
4143
|
-
if (frame[1] - frame[0] + 1 >
|
|
4143
|
+
if (frame[1] - frame[0] + 1 > StepSizes13[0]) {
|
|
4144
4144
|
const values = await this.distillTransferHistory(address, asXL1BlockRange10([frame[0], frame[1] - 1], true), max - resultBlockNumbers.size);
|
|
4145
4145
|
for (const value of values) {
|
|
4146
4146
|
resultBlockNumbers.add(value);
|
|
@@ -4162,7 +4162,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4162
4162
|
return await this.spanAsync("qualifiedAccountBalanceHistory", async () => {
|
|
4163
4163
|
const range = asRange(headOrRange);
|
|
4164
4164
|
const headHash = asHash4(headOrRange);
|
|
4165
|
-
const [head] =
|
|
4165
|
+
const [head] = assertEx33(isDefined16(headHash) ? await this.blockViewer.blockByHash(headHash) : await this.blockViewer.currentBlock(), () => "Could not resolve head block");
|
|
4166
4166
|
const startingRange = asXL1BlockRange10(range ?? [0, head.block], true);
|
|
4167
4167
|
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
4168
4168
|
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists3);
|
|
@@ -4171,11 +4171,11 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4171
4171
|
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema2 ? index : void 0).filter(exists3);
|
|
4172
4172
|
const transfers = transferIndexes.map((index) => {
|
|
4173
4173
|
const hash = block[0].payload_hashes[index];
|
|
4174
|
-
return
|
|
4174
|
+
return assertEx33(
|
|
4175
4175
|
block[1].find((p) => p._hash === hash),
|
|
4176
4176
|
() => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`
|
|
4177
4177
|
);
|
|
4178
|
-
}).filter(exists3).filter((t) => t.from === address ||
|
|
4178
|
+
}).filter(exists3).filter((t) => t.from === address || isDefined16(t.transfers[address]));
|
|
4179
4179
|
if (transfers.length === 0) {
|
|
4180
4180
|
continue;
|
|
4181
4181
|
}
|
|
@@ -4201,20 +4201,25 @@ SimpleAccountBalanceViewer = __decorateClass([
|
|
|
4201
4201
|
|
|
4202
4202
|
// src/simple/block/SimpleBlockViewer.ts
|
|
4203
4203
|
import {
|
|
4204
|
-
assertEx as
|
|
4204
|
+
assertEx as assertEx34,
|
|
4205
4205
|
exists as exists4,
|
|
4206
4206
|
isUndefined as isUndefined8
|
|
4207
4207
|
} from "@xylabs/sdk-js";
|
|
4208
|
+
import { LruCacheMap as LruCacheMap2 } from "@xyo-network/xl1-driver-memory";
|
|
4208
4209
|
import {
|
|
4209
4210
|
asSignedHydratedBlockWithHashMeta,
|
|
4210
4211
|
asSignedHydratedBlockWithStorageMeta,
|
|
4211
|
-
asXL1BlockNumber as
|
|
4212
|
+
asXL1BlockNumber as asXL1BlockNumber9,
|
|
4213
|
+
asXL1BlockRange as asXL1BlockRange11,
|
|
4212
4214
|
BlockViewerMoniker as BlockViewerMoniker2,
|
|
4213
|
-
FinalizationViewerMoniker
|
|
4215
|
+
FinalizationViewerMoniker,
|
|
4216
|
+
stepSize as stepSize2,
|
|
4217
|
+
StepSizes as StepSizes14
|
|
4214
4218
|
} from "@xyo-network/xl1-protocol-lib";
|
|
4219
|
+
import { Semaphore as Semaphore2 } from "async-mutex";
|
|
4215
4220
|
|
|
4216
4221
|
// src/utils/HydratedCache.ts
|
|
4217
|
-
import { LRUCache as
|
|
4222
|
+
import { LRUCache as LRUCache2 } from "lru-cache";
|
|
4218
4223
|
var HydratedCache = class {
|
|
4219
4224
|
cache;
|
|
4220
4225
|
context;
|
|
@@ -4222,7 +4227,7 @@ var HydratedCache = class {
|
|
|
4222
4227
|
constructor(context, hydrateFunction, maxCount = 2e3, ttl = Number.MAX_SAFE_INTEGER) {
|
|
4223
4228
|
this.context = context;
|
|
4224
4229
|
this.hydrateFunction = hydrateFunction;
|
|
4225
|
-
this.cache = new
|
|
4230
|
+
this.cache = new LRUCache2({ max: maxCount, ttl });
|
|
4226
4231
|
}
|
|
4227
4232
|
async get(hash) {
|
|
4228
4233
|
const existing = this.cache.get(hash);
|
|
@@ -4251,8 +4256,10 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4251
4256
|
moniker = SimpleBlockViewer.defaultMoniker;
|
|
4252
4257
|
_store;
|
|
4253
4258
|
finalizationViewer;
|
|
4254
|
-
payloadCache = new
|
|
4255
|
-
signedHydratedBlockWithHashMetaCache = new
|
|
4259
|
+
payloadCache = new LruCacheMap2({ max: 1e4 });
|
|
4260
|
+
signedHydratedBlockWithHashMetaCache = new LruCacheMap2({ max: 2e3, ttl: 1e3 * 60 * 60 });
|
|
4261
|
+
_blockStepSemaphores = StepSizes14.map(() => new Semaphore2(20));
|
|
4262
|
+
_blocksSummaryMap;
|
|
4256
4263
|
_headPollHash;
|
|
4257
4264
|
_headPollInProgress = false;
|
|
4258
4265
|
_headPollTimer = null;
|
|
@@ -4260,6 +4267,10 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4260
4267
|
get finalizedArchivist() {
|
|
4261
4268
|
return this.params.finalizedArchivist;
|
|
4262
4269
|
}
|
|
4270
|
+
get blocksSummaryMap() {
|
|
4271
|
+
this._blocksSummaryMap ??= this.params.blocksSummaryMap ?? new LruCacheMap2({ max: 32 });
|
|
4272
|
+
return this._blocksSummaryMap;
|
|
4273
|
+
}
|
|
4263
4274
|
get headPollIntervalMs() {
|
|
4264
4275
|
return this.params.headPollIntervalMs;
|
|
4265
4276
|
}
|
|
@@ -4278,11 +4289,12 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4278
4289
|
static async paramsHandler(params) {
|
|
4279
4290
|
const headPollIntervalMs = params.headPollIntervalMs;
|
|
4280
4291
|
if (headPollIntervalMs !== void 0) {
|
|
4281
|
-
|
|
4292
|
+
assertEx34(headPollIntervalMs >= MIN_HEAD_POLL_INTERVAL_MS, () => `headPollIntervalMs must be at least ${MIN_HEAD_POLL_INTERVAL_MS}ms`);
|
|
4282
4293
|
}
|
|
4283
4294
|
return {
|
|
4284
4295
|
...await super.paramsHandler(params),
|
|
4285
|
-
|
|
4296
|
+
blocksSummaryMap: params.blocksSummaryMap,
|
|
4297
|
+
finalizedArchivist: assertEx34(params.finalizedArchivist, () => "finalizedArchivist is required"),
|
|
4286
4298
|
headPollIntervalMs
|
|
4287
4299
|
};
|
|
4288
4300
|
}
|
|
@@ -4311,8 +4323,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4311
4323
|
}
|
|
4312
4324
|
async blocksByHash(hash, limit = 50) {
|
|
4313
4325
|
return await this.spanAsync("blocksByHash", async () => {
|
|
4314
|
-
|
|
4315
|
-
|
|
4326
|
+
assertEx34(limit > 0, () => "limit must be greater than 0");
|
|
4327
|
+
assertEx34(limit <= 100, () => "limit must be less than 100");
|
|
4316
4328
|
const blocks = [];
|
|
4317
4329
|
let current = await this.blockByHash(hash);
|
|
4318
4330
|
while (current && blocks.length < limit) {
|
|
@@ -4326,8 +4338,8 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4326
4338
|
}
|
|
4327
4339
|
async blocksByNumber(blockNumber, limit = 50) {
|
|
4328
4340
|
return await this.spanAsync("blocksByNumber", async () => {
|
|
4329
|
-
|
|
4330
|
-
|
|
4341
|
+
assertEx34(limit > 0, () => "limit must be greater than 0");
|
|
4342
|
+
assertEx34(limit <= 100, () => "limit must be less than 100");
|
|
4331
4343
|
const chainContext = await this.getChainContextRead();
|
|
4332
4344
|
if (isUndefined8(chainContext.head)) {
|
|
4333
4345
|
return [];
|
|
@@ -4337,15 +4349,39 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4337
4349
|
while (current && blocks.length < limit) {
|
|
4338
4350
|
blocks.push(current);
|
|
4339
4351
|
if (current[0].block === 0) break;
|
|
4340
|
-
const previousNumber =
|
|
4352
|
+
const previousNumber = asXL1BlockNumber9(current[0].block - 1, true);
|
|
4341
4353
|
current = await this.blockByNumberWithContext(chainContext, previousNumber);
|
|
4342
4354
|
}
|
|
4343
4355
|
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true));
|
|
4344
4356
|
}, this.context);
|
|
4345
4357
|
}
|
|
4358
|
+
async blocksByStep(stepLevel, stepIndex) {
|
|
4359
|
+
return await this.spanAsync("blocksByStep", async () => {
|
|
4360
|
+
assertEx34(Number.isInteger(stepIndex) && stepIndex >= 0, () => "stepIndex must be a non-negative integer");
|
|
4361
|
+
const size = stepSize2(stepLevel);
|
|
4362
|
+
assertEx34(
|
|
4363
|
+
stepLevel <= blocksMaxStep,
|
|
4364
|
+
() => `blocksByStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`
|
|
4365
|
+
);
|
|
4366
|
+
const chainContext = await this.getChainContextRead();
|
|
4367
|
+
if (isUndefined8(chainContext.head)) {
|
|
4368
|
+
return [];
|
|
4369
|
+
}
|
|
4370
|
+
const start = stepIndex * size;
|
|
4371
|
+
const end = Math.min(start + size - 1, chainContext.head.block);
|
|
4372
|
+
if (end < start) {
|
|
4373
|
+
return [];
|
|
4374
|
+
}
|
|
4375
|
+
const range = asXL1BlockRange11([start, end], { name: "blocksByStep" });
|
|
4376
|
+
const frames = deepCalculateFramesFromRange(range, blocksMaxStep);
|
|
4377
|
+
const summaries = await Promise.all(frames.map((frame) => blocksStepSummaryFromRange(this.context, this._blockStepSemaphores, this, this.blocksSummaryMap, frame)));
|
|
4378
|
+
const blocks = summaries.flatMap((summary) => summary.blocks);
|
|
4379
|
+
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true)).toReversed();
|
|
4380
|
+
}, this.context);
|
|
4381
|
+
}
|
|
4346
4382
|
async chainId(blockNumber = "latest") {
|
|
4347
4383
|
return await this.spanAsync("chainId", async () => {
|
|
4348
|
-
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain :
|
|
4384
|
+
return blockNumber === "latest" ? (await this.finalizationViewer.headBlock()).chain : assertEx34(await this.blockByNumber(blockNumber), () => `Block not found [${blockNumber}]`)[0].chain;
|
|
4349
4385
|
}, this.context);
|
|
4350
4386
|
}
|
|
4351
4387
|
async createHandler() {
|
|
@@ -4373,9 +4409,9 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
4373
4409
|
remainingHashes = remainingHashes.filter((h) => !cachedHashes.has(h));
|
|
4374
4410
|
const finalizedPayloads = remainingHashes.length > 0 ? await this.finalizedArchivist.get(remainingHashes) : [];
|
|
4375
4411
|
const resultPayloads = [...cachedPayloads, ...finalizedPayloads.filter(exists4)];
|
|
4376
|
-
|
|
4412
|
+
for (const payload of resultPayloads) {
|
|
4377
4413
|
this.payloadCache.set(payload._hash, payload);
|
|
4378
|
-
}
|
|
4414
|
+
}
|
|
4379
4415
|
return resultPayloads;
|
|
4380
4416
|
}
|
|
4381
4417
|
async rate(range, timeUnit) {
|
|
@@ -4474,11 +4510,11 @@ SimpleBlockRewardViewer = __decorateClass([
|
|
|
4474
4510
|
], SimpleBlockRewardViewer);
|
|
4475
4511
|
|
|
4476
4512
|
// src/simple/blockValidation/SimpleBlockValidationViewer.ts
|
|
4477
|
-
import { assertEx as
|
|
4513
|
+
import { assertEx as assertEx35 } from "@xylabs/sdk-js";
|
|
4478
4514
|
import { PayloadBuilder as PayloadBuilder18 } from "@xyo-network/sdk-js";
|
|
4479
4515
|
import {
|
|
4480
4516
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker2,
|
|
4481
|
-
asXL1BlockRange as
|
|
4517
|
+
asXL1BlockRange as asXL1BlockRange12,
|
|
4482
4518
|
BlockValidationViewerMoniker,
|
|
4483
4519
|
BlockViewerMoniker as BlockViewerMoniker3,
|
|
4484
4520
|
ChainContractViewerMoniker,
|
|
@@ -4527,7 +4563,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4527
4563
|
head: void 0
|
|
4528
4564
|
};
|
|
4529
4565
|
const blocksWithMeta = await Promise.all(blocks.map((b) => Promise.all([PayloadBuilder18.addHashMeta(b[0]), PayloadBuilder18.addHashMeta(b[1])])));
|
|
4530
|
-
const head = isChainQualifiedHeadConfig5(config) ?
|
|
4566
|
+
const head = isChainQualifiedHeadConfig5(config) ? assertEx35(
|
|
4531
4567
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
4532
4568
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
4533
4569
|
) : void 0;
|
|
@@ -4535,7 +4571,7 @@ var SimpleBlockValidationViewer = class extends AbstractCreatableProvider {
|
|
|
4535
4571
|
const validateProtocol = value ? this.doValidateProtocol.bind(this) : void 0;
|
|
4536
4572
|
const validateState = state ? this.doValidateState.bind(this) : void 0;
|
|
4537
4573
|
const chainIdAtBlockNumber = (blockNumber) => this.chainContractViewer.chainIdAtBlockNumber(blockNumber);
|
|
4538
|
-
const qualification = { head: headBlock._hash, range:
|
|
4574
|
+
const qualification = { head: headBlock._hash, range: asXL1BlockRange12([0, headBlock.block], true) };
|
|
4539
4575
|
const [protocolResults, stateResults] = await Promise.all([
|
|
4540
4576
|
validateProtocol?.(blocksWithMeta, chainIdAtBlockNumber),
|
|
4541
4577
|
validateState?.(blocksWithMeta, chainIdAtBlockNumber)
|
|
@@ -4608,7 +4644,7 @@ SimpleBlockValidationViewer = __decorateClass([
|
|
|
4608
4644
|
], SimpleBlockValidationViewer);
|
|
4609
4645
|
|
|
4610
4646
|
// src/simple/chainContractViewer/SimpleChainContractViewer.ts
|
|
4611
|
-
import { assertEx as
|
|
4647
|
+
import { assertEx as assertEx36 } from "@xylabs/sdk-js";
|
|
4612
4648
|
import { ChainContractViewerMoniker as ChainContractViewerMoniker2, FinalizationViewerMoniker as FinalizationViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
4613
4649
|
var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
4614
4650
|
moniker = SimpleChainContractViewer.defaultMoniker;
|
|
@@ -4625,7 +4661,7 @@ var SimpleChainContractViewer = class extends AbstractCreatableProvider {
|
|
|
4625
4661
|
let contractViewer = this;
|
|
4626
4662
|
let forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4627
4663
|
while (forkedAtBlockNumber !== null && blockNumber <= forkedAtBlockNumber) {
|
|
4628
|
-
contractViewer =
|
|
4664
|
+
contractViewer = assertEx36(await contractViewer.forkedChainContractViewer());
|
|
4629
4665
|
forkedAtBlockNumber = await contractViewer.forkedAtBlockNumber();
|
|
4630
4666
|
chainId = await contractViewer.chainId();
|
|
4631
4667
|
}
|
|
@@ -4678,8 +4714,8 @@ var SimpleXyoClient = class {
|
|
|
4678
4714
|
};
|
|
4679
4715
|
|
|
4680
4716
|
// src/simple/datalake/RestDataLakeRunner.ts
|
|
4681
|
-
import { assertEx as
|
|
4682
|
-
import { isAnyPayload as
|
|
4717
|
+
import { assertEx as assertEx37, exists as exists6 } from "@xylabs/sdk-js";
|
|
4718
|
+
import { isAnyPayload as isAnyPayload8, PayloadZodLoose } from "@xyo-network/sdk-js";
|
|
4683
4719
|
import { DataLakeRunnerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
4684
4720
|
import { z as z29 } from "zod/mini";
|
|
4685
4721
|
|
|
@@ -4688,7 +4724,7 @@ import { FetchClientError, FetchJsonClient } from "@xylabs/sdk-js";
|
|
|
4688
4724
|
import {
|
|
4689
4725
|
exists as exists5
|
|
4690
4726
|
} from "@xylabs/sdk-js";
|
|
4691
|
-
import { asAnyPayload as asAnyPayload4, isAnyPayload as
|
|
4727
|
+
import { asAnyPayload as asAnyPayload4, isAnyPayload as isAnyPayload7 } from "@xyo-network/sdk-js";
|
|
4692
4728
|
var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
4693
4729
|
get allowedSchemas() {
|
|
4694
4730
|
return this.params.allowedSchemas;
|
|
@@ -4719,7 +4755,7 @@ var AbstractRestDataLake = class extends AbstractCreatableProvider {
|
|
|
4719
4755
|
}
|
|
4720
4756
|
}
|
|
4721
4757
|
isAllowed(value) {
|
|
4722
|
-
if (
|
|
4758
|
+
if (isAnyPayload7(value)) {
|
|
4723
4759
|
return this.isAllowedSchema(value.schema);
|
|
4724
4760
|
}
|
|
4725
4761
|
return false;
|
|
@@ -4746,8 +4782,8 @@ var RestDataLakeRunner = class extends AbstractRestDataLake {
|
|
|
4746
4782
|
}
|
|
4747
4783
|
async insert(items) {
|
|
4748
4784
|
const allowedItems = items.map((item) => {
|
|
4749
|
-
if (
|
|
4750
|
-
|
|
4785
|
+
if (isAnyPayload8(item) && this.isAllowed(item)) {
|
|
4786
|
+
assertEx37(typeof item === "object" && item !== null, () => "Data must be an object");
|
|
4751
4787
|
return item;
|
|
4752
4788
|
}
|
|
4753
4789
|
return null;
|
|
@@ -4781,11 +4817,11 @@ RestDataLakeViewer = __decorateClass([
|
|
|
4781
4817
|
|
|
4782
4818
|
// src/simple/datalake/SimpleDataLakeRunner.ts
|
|
4783
4819
|
import { exists as exists7 } from "@xylabs/sdk-js";
|
|
4784
|
-
import { isAnyPayload as
|
|
4820
|
+
import { isAnyPayload as isAnyPayload10, PayloadBuilder as PayloadBuilder19 } from "@xyo-network/sdk-js";
|
|
4785
4821
|
import { DataLakeRunnerMoniker as DataLakeRunnerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
4786
4822
|
|
|
4787
4823
|
// src/simple/datalake/AbstractSimpleDataLake.ts
|
|
4788
|
-
import { isAnyPayload as
|
|
4824
|
+
import { isAnyPayload as isAnyPayload9 } from "@xyo-network/sdk-js";
|
|
4789
4825
|
var AbstractSimpleDataLake = class extends AbstractCreatableProvider {
|
|
4790
4826
|
get allowedSchemas() {
|
|
4791
4827
|
return this.params.allowedSchemas;
|
|
@@ -4804,7 +4840,7 @@ var AbstractSimpleDataLake = class extends AbstractCreatableProvider {
|
|
|
4804
4840
|
throw new Error("Method not implemented.");
|
|
4805
4841
|
}
|
|
4806
4842
|
isAllowed(value) {
|
|
4807
|
-
if (
|
|
4843
|
+
if (isAnyPayload9(value)) {
|
|
4808
4844
|
return this.isAllowedSchema(value.schema);
|
|
4809
4845
|
}
|
|
4810
4846
|
return true;
|
|
@@ -4833,7 +4869,7 @@ var SimpleDataLakeRunner = class extends AbstractSimpleDataLake {
|
|
|
4833
4869
|
}))).filter(exists7);
|
|
4834
4870
|
}
|
|
4835
4871
|
async insert(items) {
|
|
4836
|
-
const payloads = items.filter(
|
|
4872
|
+
const payloads = items.filter(isAnyPayload10).filter((i) => this.isAllowed(i));
|
|
4837
4873
|
const hashPairs = await PayloadBuilder19.hashPairs(payloads);
|
|
4838
4874
|
for (const [payload, hash] of hashPairs) {
|
|
4839
4875
|
await this.map.set(hash, payload);
|
|
@@ -4890,7 +4926,7 @@ SimpleFinalizationRunner = __decorateClass([
|
|
|
4890
4926
|
], SimpleFinalizationRunner);
|
|
4891
4927
|
|
|
4892
4928
|
// src/simple/finalization/SimpleFinalizationViewer.ts
|
|
4893
|
-
import { assertEx as
|
|
4929
|
+
import { assertEx as assertEx38 } from "@xylabs/sdk-js";
|
|
4894
4930
|
import {
|
|
4895
4931
|
asSignedHydratedBlockWithStorageMeta as asSignedHydratedBlockWithStorageMeta2,
|
|
4896
4932
|
ChainContractViewerMoniker as ChainContractViewerMoniker3,
|
|
@@ -4919,7 +4955,7 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4919
4955
|
static async paramsHandler(params) {
|
|
4920
4956
|
return {
|
|
4921
4957
|
...await super.paramsHandler(params),
|
|
4922
|
-
finalizedArchivist:
|
|
4958
|
+
finalizedArchivist: assertEx38(params.finalizedArchivist, () => "finalizedArchivist is required")
|
|
4923
4959
|
};
|
|
4924
4960
|
}
|
|
4925
4961
|
chainId() {
|
|
@@ -4927,18 +4963,18 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4927
4963
|
}
|
|
4928
4964
|
async createHandler() {
|
|
4929
4965
|
await super.createHandler();
|
|
4930
|
-
this._chainId =
|
|
4966
|
+
this._chainId = assertEx38(this.config.chain.id ?? (await findMostRecentBlock(this.params.finalizedArchivist))?.chain, () => "chain.id is required if empty archivist");
|
|
4931
4967
|
this._store = { chainMap: this.params.finalizedArchivist };
|
|
4932
4968
|
}
|
|
4933
4969
|
async head() {
|
|
4934
4970
|
return await this.spanAsync("head", async () => {
|
|
4935
|
-
const currentHead =
|
|
4971
|
+
const currentHead = assertEx38(await this.getCurrentHead(), () => "Could not find most recent block [currentBlock]");
|
|
4936
4972
|
const cache = this.hydratedBlockCache;
|
|
4937
4973
|
const block = await cache.get(currentHead._hash);
|
|
4938
4974
|
if (!block) {
|
|
4939
4975
|
this.logger?.error(`Could not find current block with hash ${currentHead._hash}`);
|
|
4940
4976
|
}
|
|
4941
|
-
return
|
|
4977
|
+
return assertEx38(block, () => "Could not find current block");
|
|
4942
4978
|
}, this.context);
|
|
4943
4979
|
}
|
|
4944
4980
|
async headBlock() {
|
|
@@ -4964,8 +5000,8 @@ var SimpleFinalizationViewer = class extends AbstractCreatableProvider {
|
|
|
4964
5000
|
}
|
|
4965
5001
|
async getCurrentHead() {
|
|
4966
5002
|
const chainArchivist = this.finalizedArchivist;
|
|
4967
|
-
const result =
|
|
4968
|
-
|
|
5003
|
+
const result = assertEx38(await findMostRecentBlock(chainArchivist), () => "Could not find most recent block [getCurrentHead]");
|
|
5004
|
+
assertEx38(result?.chain === this._chainId, () => "Chain ID does not match head block chain ID");
|
|
4969
5005
|
return result;
|
|
4970
5006
|
}
|
|
4971
5007
|
};
|
|
@@ -4995,13 +5031,13 @@ var SimpleXyoGateway = class _SimpleXyoGateway extends AbstractCreatableProvider
|
|
|
4995
5031
|
|
|
4996
5032
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
4997
5033
|
import {
|
|
4998
|
-
assertEx as
|
|
5034
|
+
assertEx as assertEx39,
|
|
4999
5035
|
BigIntToJsonZod,
|
|
5000
|
-
isDefined as
|
|
5036
|
+
isDefined as isDefined17
|
|
5001
5037
|
} from "@xylabs/sdk-js";
|
|
5002
5038
|
import { PayloadBuilder as PayloadBuilder20 } from "@xyo-network/sdk-js";
|
|
5003
5039
|
import {
|
|
5004
|
-
asXL1BlockNumber as
|
|
5040
|
+
asXL1BlockNumber as asXL1BlockNumber10,
|
|
5005
5041
|
DataLakeRunnerMoniker as DataLakeRunnerMoniker3,
|
|
5006
5042
|
isSignedHydratedTransaction,
|
|
5007
5043
|
TransferSchema as TransferSchema3,
|
|
@@ -5028,23 +5064,23 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5028
5064
|
return this._signer;
|
|
5029
5065
|
}
|
|
5030
5066
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
5031
|
-
const viewer =
|
|
5067
|
+
const viewer = assertEx39(this.connection.viewer, () => "No viewer available on connection");
|
|
5032
5068
|
const {
|
|
5033
5069
|
nbf,
|
|
5034
5070
|
exp,
|
|
5035
5071
|
chain,
|
|
5036
5072
|
fees
|
|
5037
5073
|
} = options ?? {};
|
|
5038
|
-
const resolvedChainId =
|
|
5039
|
-
const resolvedNbf =
|
|
5040
|
-
const resolvedExp =
|
|
5074
|
+
const resolvedChainId = isDefined17(chain) ? chain : await viewer.chainId();
|
|
5075
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined17(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
5076
|
+
const resolvedExp = asXL1BlockNumber10(isDefined17(exp) ? exp : resolvedNbf + 10, true);
|
|
5041
5077
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
5042
5078
|
return await this.addTransactionToChain(tx, await PayloadBuilder20.addHashMeta(offChain));
|
|
5043
5079
|
}
|
|
5044
5080
|
async addTransactionToChain(tx, offChain = []) {
|
|
5045
5081
|
const connection = this.connection;
|
|
5046
5082
|
const signer = this.signer;
|
|
5047
|
-
const runner =
|
|
5083
|
+
const runner = assertEx39(connection.runner, () => "No runner available on connection");
|
|
5048
5084
|
let signedTx;
|
|
5049
5085
|
if (isSignedHydratedTransaction(tx)) {
|
|
5050
5086
|
const [bw, payloads] = tx;
|
|
@@ -5059,7 +5095,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5059
5095
|
}
|
|
5060
5096
|
async confirmSubmittedTransaction(txHash, options) {
|
|
5061
5097
|
return await confirmSubmittedTransaction(
|
|
5062
|
-
|
|
5098
|
+
assertEx39(this.connection.viewer, () => "Connection viewer is undefined"),
|
|
5063
5099
|
txHash,
|
|
5064
5100
|
options
|
|
5065
5101
|
);
|
|
@@ -5096,7 +5132,7 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
5096
5132
|
|
|
5097
5133
|
// src/simple/mempool/SimpleMempoolRunner.ts
|
|
5098
5134
|
import {
|
|
5099
|
-
assertEx as
|
|
5135
|
+
assertEx as assertEx40,
|
|
5100
5136
|
exists as exists8
|
|
5101
5137
|
} from "@xylabs/sdk-js";
|
|
5102
5138
|
import { isPayloadBundle, PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
@@ -5105,6 +5141,7 @@ import {
|
|
|
5105
5141
|
ChainContractViewerMoniker as ChainContractViewerMoniker4,
|
|
5106
5142
|
DeadLetterQueueRunnerMoniker,
|
|
5107
5143
|
DEFAULT_MAX_EXP_AHEAD,
|
|
5144
|
+
elevatedTransaction,
|
|
5108
5145
|
FinalizationViewerMoniker as FinalizationViewerMoniker4,
|
|
5109
5146
|
isSignedHydratedBlockWithHashMeta,
|
|
5110
5147
|
isSignedHydratedTransactionWithHashMeta,
|
|
@@ -5171,8 +5208,8 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5171
5208
|
static async paramsHandler(params) {
|
|
5172
5209
|
return {
|
|
5173
5210
|
...await super.paramsHandler(params),
|
|
5174
|
-
pendingBlocksArchivist:
|
|
5175
|
-
pendingTransactionsArchivist:
|
|
5211
|
+
pendingBlocksArchivist: assertEx40(params?.pendingBlocksArchivist, () => "pendingBlocksArchivist is required"),
|
|
5212
|
+
pendingTransactionsArchivist: assertEx40(params?.pendingTransactionsArchivist, () => "pendingTransactionsArchivist is required")
|
|
5176
5213
|
};
|
|
5177
5214
|
}
|
|
5178
5215
|
async createHandler() {
|
|
@@ -5210,7 +5247,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5210
5247
|
return b;
|
|
5211
5248
|
}
|
|
5212
5249
|
}).filter(exists8);
|
|
5213
|
-
|
|
5250
|
+
assertEx40(
|
|
5214
5251
|
remainingBlockMap.length === remainingBlocks.length,
|
|
5215
5252
|
() => `remainingBlockMap length should match remainingBlocks length [${remainingBlockMap.length}/${remainingBlocks.length}]`
|
|
5216
5253
|
);
|
|
@@ -5272,7 +5309,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5272
5309
|
return t;
|
|
5273
5310
|
}
|
|
5274
5311
|
}).filter(exists8);
|
|
5275
|
-
|
|
5312
|
+
assertEx40(
|
|
5276
5313
|
remainingTransactionMap.length === remainingTransactions.length,
|
|
5277
5314
|
() => `remainingTransactionMap length should match remainingTransactions length [${remainingTransactionMap.length}/${remainingTransactions.length}]`
|
|
5278
5315
|
);
|
|
@@ -5335,14 +5372,15 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5335
5372
|
await PayloadBuilder21.addHashMeta(payloads)
|
|
5336
5373
|
])
|
|
5337
5374
|
);
|
|
5375
|
+
const elevatedTransactions = hashedTransactions.map((tx) => elevatedTransaction(tx));
|
|
5338
5376
|
if (this.validateOnSubmit) {
|
|
5339
5377
|
const validationResults = await Promise.all(
|
|
5340
|
-
|
|
5378
|
+
elevatedTransactions.map(async (tx) => this.transactionValidationViewer.validateTransaction(tx, { value: true, state: true }))
|
|
5341
5379
|
);
|
|
5342
5380
|
const failures = [];
|
|
5343
5381
|
for (const [i, result] of validationResults.entries()) {
|
|
5344
5382
|
if (!isSignedHydratedTransactionWithHashMeta(result)) {
|
|
5345
|
-
failures.push({ tx:
|
|
5383
|
+
failures.push({ tx: elevatedTransactions[i], errors: result });
|
|
5346
5384
|
}
|
|
5347
5385
|
}
|
|
5348
5386
|
if (failures.length > 0) {
|
|
@@ -5351,7 +5389,7 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5351
5389
|
throw new Error(`SimpleMempoolRunner: rejected ${failures.length} transaction(s) at admission: ${detail}`);
|
|
5352
5390
|
}
|
|
5353
5391
|
}
|
|
5354
|
-
const bundles =
|
|
5392
|
+
const bundles = elevatedTransactions.map((tx) => hydratedTransactionToPayloadBundle(tx));
|
|
5355
5393
|
const inserted = await this.pendingTransactionsArchivist.insert(bundles);
|
|
5356
5394
|
await this.enforceCap();
|
|
5357
5395
|
return inserted.map((p) => p._hash);
|
|
@@ -5523,7 +5561,7 @@ SimpleMempoolRunner = __decorateClass([
|
|
|
5523
5561
|
// src/simple/mempool/SimpleMempoolViewer.ts
|
|
5524
5562
|
import {
|
|
5525
5563
|
exists as exists9,
|
|
5526
|
-
isDefined as
|
|
5564
|
+
isDefined as isDefined18,
|
|
5527
5565
|
isHash as isHash2
|
|
5528
5566
|
} from "@xylabs/sdk-js";
|
|
5529
5567
|
import { isHashMeta as isHashMeta2, isPayloadBundle as isPayloadBundle2 } from "@xyo-network/sdk-js";
|
|
@@ -5584,7 +5622,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5584
5622
|
let cursor = void 0;
|
|
5585
5623
|
if (isHash2(providedCursor)) {
|
|
5586
5624
|
const [p] = await this.pendingBlocksArchivist.get([providedCursor]);
|
|
5587
|
-
if (
|
|
5625
|
+
if (isDefined18(p)) {
|
|
5588
5626
|
cursor = p._sequence;
|
|
5589
5627
|
}
|
|
5590
5628
|
}
|
|
@@ -5603,7 +5641,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5603
5641
|
let cursor = void 0;
|
|
5604
5642
|
if (isHash2(providedCursor)) {
|
|
5605
5643
|
const [p] = await this.pendingTransactionsArchivist.get([providedCursor]);
|
|
5606
|
-
if (
|
|
5644
|
+
if (isDefined18(p)) {
|
|
5607
5645
|
cursor = p._sequence;
|
|
5608
5646
|
}
|
|
5609
5647
|
}
|
|
@@ -5618,7 +5656,7 @@ var SimpleMempoolViewer = class extends AbstractCreatableProvider {
|
|
|
5618
5656
|
const hydratedWithBundle = (await Promise.all(
|
|
5619
5657
|
filteredBundles.map(async (bundle3) => {
|
|
5620
5658
|
const tx = await bundledPayloadToHydratedTransaction(bundle3);
|
|
5621
|
-
return
|
|
5659
|
+
return isDefined18(tx) ? { bundle: bundle3, tx } : void 0;
|
|
5622
5660
|
})
|
|
5623
5661
|
)).filter(exists9);
|
|
5624
5662
|
const currentBlock = await this.windowedBlockViewer.currentBlock();
|
|
@@ -5811,7 +5849,7 @@ var SimpleXyoNetwork = class {
|
|
|
5811
5849
|
};
|
|
5812
5850
|
|
|
5813
5851
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
5814
|
-
import { assertEx as
|
|
5852
|
+
import { assertEx as assertEx41 } from "@xylabs/sdk-js";
|
|
5815
5853
|
var SimpleXyoPermissions = class {
|
|
5816
5854
|
invoker;
|
|
5817
5855
|
_store;
|
|
@@ -5820,7 +5858,7 @@ var SimpleXyoPermissions = class {
|
|
|
5820
5858
|
this.invoker = store.invoker;
|
|
5821
5859
|
}
|
|
5822
5860
|
get store() {
|
|
5823
|
-
return
|
|
5861
|
+
return assertEx41(this._store, () => "Store must be defined to get permissions");
|
|
5824
5862
|
}
|
|
5825
5863
|
async getPermissions() {
|
|
5826
5864
|
return await this.store.getPermissions();
|
|
@@ -5873,7 +5911,7 @@ var SimpleXyoPermissions = class {
|
|
|
5873
5911
|
};
|
|
5874
5912
|
|
|
5875
5913
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
5876
|
-
import { assertEx as
|
|
5914
|
+
import { assertEx as assertEx42 } from "@xylabs/sdk-js";
|
|
5877
5915
|
var MemoryPermissionsStore = class {
|
|
5878
5916
|
_invoker;
|
|
5879
5917
|
permissions = [];
|
|
@@ -5881,7 +5919,7 @@ var MemoryPermissionsStore = class {
|
|
|
5881
5919
|
this._invoker = invoker;
|
|
5882
5920
|
}
|
|
5883
5921
|
get invoker() {
|
|
5884
|
-
return
|
|
5922
|
+
return assertEx42(this._invoker, () => "Invoker must be defined to get permissions");
|
|
5885
5923
|
}
|
|
5886
5924
|
async getPermissions() {
|
|
5887
5925
|
await Promise.resolve();
|
|
@@ -5969,7 +6007,7 @@ var SimpleXyoSigner = class _SimpleXyoSigner extends AbstractCreatableProvider {
|
|
|
5969
6007
|
};
|
|
5970
6008
|
|
|
5971
6009
|
// src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts
|
|
5972
|
-
import { isDefined as
|
|
6010
|
+
import { isDefined as isDefined19 } from "@xylabs/sdk-js";
|
|
5973
6011
|
import { StakeEventsViewerMoniker } from "@xyo-network/xl1-protocol-lib";
|
|
5974
6012
|
var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
5975
6013
|
moniker = SimpleStakeEventsViewer.defaultMoniker;
|
|
@@ -5982,7 +6020,7 @@ var SimpleStakeEventsViewer = class extends AbstractCreatableProvider {
|
|
|
5982
6020
|
stakeEvents(range, { name } = {}) {
|
|
5983
6021
|
const positions = this.positionsFromRange(range);
|
|
5984
6022
|
const events = this.eventsFromPositions(positions);
|
|
5985
|
-
if (
|
|
6023
|
+
if (isDefined19(name)) {
|
|
5986
6024
|
return events.filter((event) => event.name === name);
|
|
5987
6025
|
}
|
|
5988
6026
|
return events;
|
|
@@ -6047,7 +6085,7 @@ SimpleStakeEventsViewer = __decorateClass([
|
|
|
6047
6085
|
], SimpleStakeEventsViewer);
|
|
6048
6086
|
|
|
6049
6087
|
// src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts
|
|
6050
|
-
import { assertEx as
|
|
6088
|
+
import { assertEx as assertEx43 } from "@xylabs/sdk-js";
|
|
6051
6089
|
import { asXyoAddress as asXyoAddress3 } from "@xyo-network/address";
|
|
6052
6090
|
import {
|
|
6053
6091
|
StakeTotalsViewerMoniker,
|
|
@@ -6091,7 +6129,7 @@ var SimpleStakeTotalsViewer = class extends AbstractCreatableProvider {
|
|
|
6091
6129
|
}
|
|
6092
6130
|
async createHandler() {
|
|
6093
6131
|
await super.createHandler();
|
|
6094
|
-
this._stakeViewer =
|
|
6132
|
+
this._stakeViewer = assertEx43(
|
|
6095
6133
|
await this.locateAndCreate(StakeViewerMoniker),
|
|
6096
6134
|
() => "Failed to create StakeViewer"
|
|
6097
6135
|
);
|
|
@@ -6145,14 +6183,14 @@ SimpleStakeTotalsViewer = __decorateClass([
|
|
|
6145
6183
|
], SimpleStakeTotalsViewer);
|
|
6146
6184
|
|
|
6147
6185
|
// src/simple/StakeViewer/SimpleStakeViewer.ts
|
|
6148
|
-
import { assertEx as
|
|
6186
|
+
import { assertEx as assertEx44, toAddress } from "@xylabs/sdk-js";
|
|
6149
6187
|
import { asXyoAddress as asXyoAddress4 } from "@xyo-network/address";
|
|
6150
6188
|
import { StakeEventsViewerMoniker as StakeEventsViewerMoniker2, StakeViewerMoniker as StakeViewerMoniker2 } from "@xyo-network/xl1-protocol-lib";
|
|
6151
6189
|
var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
6152
6190
|
moniker = SimpleStakeViewer.defaultMoniker;
|
|
6153
6191
|
_chainStakeEventsViewer;
|
|
6154
6192
|
get stakeEvents() {
|
|
6155
|
-
return
|
|
6193
|
+
return assertEx44(this._chainStakeEventsViewer, () => "Stake events viewer not set");
|
|
6156
6194
|
}
|
|
6157
6195
|
get positions() {
|
|
6158
6196
|
return this.params.positions;
|
|
@@ -6192,7 +6230,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6192
6230
|
}
|
|
6193
6231
|
async createHandler() {
|
|
6194
6232
|
await super.createHandler();
|
|
6195
|
-
this._chainStakeEventsViewer =
|
|
6233
|
+
this._chainStakeEventsViewer = assertEx44(
|
|
6196
6234
|
await this.locateAndCreate(StakeEventsViewerMoniker2),
|
|
6197
6235
|
() => "Failed to create StakeEventsViewer"
|
|
6198
6236
|
);
|
|
@@ -6227,7 +6265,7 @@ var SimpleStakeViewer = class extends AbstractCreatableProvider {
|
|
|
6227
6265
|
return toAddress(toAddress(1n));
|
|
6228
6266
|
}
|
|
6229
6267
|
stakeById(id) {
|
|
6230
|
-
return
|
|
6268
|
+
return assertEx44(this.positions[id], () => new Error(`Stake with id ${id} not found`));
|
|
6231
6269
|
}
|
|
6232
6270
|
stakeByStaker(staker, slot) {
|
|
6233
6271
|
return this.positions.filter((s) => asXyoAddress4(s.staker) === asXyoAddress4(staker))[slot];
|
|
@@ -6329,12 +6367,12 @@ RestSyncViewer = __decorateClass([
|
|
|
6329
6367
|
// src/simple/timeSync2/SimpleTimeSyncViewer.ts
|
|
6330
6368
|
import {
|
|
6331
6369
|
asHash as asHash5,
|
|
6332
|
-
assertEx as
|
|
6333
|
-
isDefined as
|
|
6370
|
+
assertEx as assertEx45,
|
|
6371
|
+
isDefined as isDefined20
|
|
6334
6372
|
} from "@xylabs/sdk-js";
|
|
6335
6373
|
import {
|
|
6336
6374
|
asTimePayload as asTimePayload2,
|
|
6337
|
-
asXL1BlockNumber as
|
|
6375
|
+
asXL1BlockNumber as asXL1BlockNumber11,
|
|
6338
6376
|
BlockViewerMoniker as BlockViewerMoniker4,
|
|
6339
6377
|
TimeSchema,
|
|
6340
6378
|
TimeSyncViewerMoniker
|
|
@@ -6351,10 +6389,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6351
6389
|
async convertTime(fromDomain, toDomain, from) {
|
|
6352
6390
|
switch (fromDomain) {
|
|
6353
6391
|
case "xl1": {
|
|
6354
|
-
const [block, payloads] =
|
|
6392
|
+
const [block, payloads] = assertEx45(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
6355
6393
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
6356
6394
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
6357
|
-
const timePayload = asTimePayload2(
|
|
6395
|
+
const timePayload = asTimePayload2(isDefined20(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
6358
6396
|
if (timePayload === void 0) return 0;
|
|
6359
6397
|
switch (toDomain) {
|
|
6360
6398
|
case "xl1": {
|
|
@@ -6406,10 +6444,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6406
6444
|
return [Date.now(), null];
|
|
6407
6445
|
}
|
|
6408
6446
|
case "ethereum": {
|
|
6409
|
-
const provider =
|
|
6447
|
+
const provider = assertEx45(this.ethProvider, () => "Ethereum provider not configured");
|
|
6410
6448
|
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
6411
6449
|
const block = await provider.getBlock(blockNumber);
|
|
6412
|
-
const blockHash = asHash5(
|
|
6450
|
+
const blockHash = asHash5(assertEx45(block?.hash, () => "Block hash not found"), true);
|
|
6413
6451
|
return [blockNumber, blockHash];
|
|
6414
6452
|
}
|
|
6415
6453
|
default: {
|
|
@@ -6424,10 +6462,10 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
6424
6462
|
// this is for the previous block
|
|
6425
6463
|
xl1,
|
|
6426
6464
|
// this is for the previous block
|
|
6427
|
-
xl1Hash:
|
|
6465
|
+
xl1Hash: assertEx45(xl1Hash, () => "No xl1 hash available from time sync service"),
|
|
6428
6466
|
epoch: Date.now()
|
|
6429
6467
|
};
|
|
6430
|
-
if (
|
|
6468
|
+
if (isDefined20(this.ethProvider)) {
|
|
6431
6469
|
const [ethereum, ethHashOrNull] = await this.currentTimeAndHash("ethereum");
|
|
6432
6470
|
const ethereumHash = asHash5(ethHashOrNull, () => "No ethereum hash available from time sync service");
|
|
6433
6471
|
timePayload.ethereum = ethereum;
|
|
@@ -6444,11 +6482,11 @@ SimpleTimeSyncViewer = __decorateClass([
|
|
|
6444
6482
|
], SimpleTimeSyncViewer);
|
|
6445
6483
|
|
|
6446
6484
|
// src/simple/transactionValidation/SimpleTransactionValidationViewer.ts
|
|
6447
|
-
import { assertEx as
|
|
6485
|
+
import { assertEx as assertEx46 } from "@xylabs/sdk-js";
|
|
6448
6486
|
import { PayloadBuilder as PayloadBuilder24 } from "@xyo-network/sdk-js";
|
|
6449
6487
|
import {
|
|
6450
6488
|
AccountBalanceViewerMoniker as AccountBalanceViewerMoniker3,
|
|
6451
|
-
asXL1BlockRange as
|
|
6489
|
+
asXL1BlockRange as asXL1BlockRange13,
|
|
6452
6490
|
BlockViewerMoniker as BlockViewerMoniker5,
|
|
6453
6491
|
ChainContractViewerMoniker as ChainContractViewerMoniker5,
|
|
6454
6492
|
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig6,
|
|
@@ -6495,7 +6533,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6495
6533
|
head: void 0
|
|
6496
6534
|
};
|
|
6497
6535
|
const transactionsWithMeta = await Promise.all(transactions.map((b) => Promise.all([PayloadBuilder24.addHashMeta(b[0]), PayloadBuilder24.addHashMeta(b[1])])));
|
|
6498
|
-
const head = isChainQualifiedHeadConfig6(config) ?
|
|
6536
|
+
const head = isChainQualifiedHeadConfig6(config) ? assertEx46(
|
|
6499
6537
|
(await this.blockViewer.blockByHash(config.head))?.[0],
|
|
6500
6538
|
() => `Specified a head that is not in the chain [${config.head}]`
|
|
6501
6539
|
) : void 0;
|
|
@@ -6503,7 +6541,7 @@ var SimpleTransactionValidationViewer = class extends AbstractCreatableProvider
|
|
|
6503
6541
|
const validateProtocol = value ? this.doValidateProtocol.bind(this) : void 0;
|
|
6504
6542
|
const validateState = state ? this.doValidateState.bind(this) : void 0;
|
|
6505
6543
|
const chainId = headBlock.chain;
|
|
6506
|
-
const qualification = { head: headBlock._hash, range:
|
|
6544
|
+
const qualification = { head: headBlock._hash, range: asXL1BlockRange13([0, headBlock.block], true) };
|
|
6507
6545
|
const [protocolResults, stateResults] = await Promise.all([
|
|
6508
6546
|
validateProtocol?.(transactionsWithMeta, chainId),
|
|
6509
6547
|
validateState?.(transactionsWithMeta, chainId)
|
|
@@ -6561,7 +6599,7 @@ SimpleTransactionValidationViewer = __decorateClass([
|
|
|
6561
6599
|
], SimpleTransactionValidationViewer);
|
|
6562
6600
|
|
|
6563
6601
|
// src/simple/TransactionViewer/SimpleTransactionViewer.ts
|
|
6564
|
-
import { assertEx as
|
|
6602
|
+
import { assertEx as assertEx47, exists as exists10 } from "@xylabs/sdk-js";
|
|
6565
6603
|
import { BoundWitnessSchema } from "@xyo-network/sdk-js";
|
|
6566
6604
|
import {
|
|
6567
6605
|
asSignedHydratedTransactionWithHashMeta,
|
|
@@ -6578,7 +6616,7 @@ var SimpleTransactionViewer = class extends AbstractCreatableProvider {
|
|
|
6578
6616
|
}
|
|
6579
6617
|
async byBlockHashAndIndex(blockHash, transactionIndex) {
|
|
6580
6618
|
return await this.spanAsync("byBlockHashAndIndex", async () => {
|
|
6581
|
-
|
|
6619
|
+
assertEx47(transactionIndex >= 0, () => "transactionIndex must be greater than or equal to 0");
|
|
6582
6620
|
try {
|
|
6583
6621
|
const block = await this.blockViewer.blockByHash(blockHash);
|
|
6584
6622
|
if (!block) return null;
|
|
@@ -6642,13 +6680,15 @@ SimpleTransactionViewer = __decorateClass([
|
|
|
6642
6680
|
|
|
6643
6681
|
// src/simple/windowedBlock/SimpleWindowedBlockViewer.ts
|
|
6644
6682
|
import {
|
|
6645
|
-
assertEx as
|
|
6683
|
+
assertEx as assertEx48,
|
|
6646
6684
|
exists as exists11,
|
|
6647
6685
|
isNull as isNull2
|
|
6648
6686
|
} from "@xylabs/sdk-js";
|
|
6687
|
+
import { MemoryMap as MemoryMap2 } from "@xyo-network/xl1-driver-memory";
|
|
6649
6688
|
import {
|
|
6650
|
-
asXL1BlockNumber as
|
|
6689
|
+
asXL1BlockNumber as asXL1BlockNumber12,
|
|
6651
6690
|
BlockViewerMoniker as BlockViewerMoniker7,
|
|
6691
|
+
stepSize as stepSize3,
|
|
6652
6692
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
6653
6693
|
} from "@xyo-network/xl1-protocol-lib";
|
|
6654
6694
|
import { Mutex as Mutex2 } from "async-mutex";
|
|
@@ -6700,11 +6740,20 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6700
6740
|
let block = this._blockNumberMap.get(blockNumber);
|
|
6701
6741
|
while (block && (limit === void 0 || result.length < limit)) {
|
|
6702
6742
|
result.unshift(block);
|
|
6703
|
-
const previousBlockNumber =
|
|
6743
|
+
const previousBlockNumber = asXL1BlockNumber12(block[0].block - 1, true);
|
|
6704
6744
|
block = previousBlockNumber >= 0 ? this._blockNumberMap.get(previousBlockNumber) : void 0;
|
|
6705
6745
|
}
|
|
6706
6746
|
return result;
|
|
6707
6747
|
}
|
|
6748
|
+
blocksByStep(stepLevel, stepIndex) {
|
|
6749
|
+
const size = stepSize3(stepLevel);
|
|
6750
|
+
const start = stepIndex * size;
|
|
6751
|
+
const end = start + size - 1;
|
|
6752
|
+
return this._chain.filter((block) => {
|
|
6753
|
+
const blockNumber = block[0].block;
|
|
6754
|
+
return blockNumber >= start && blockNumber <= end;
|
|
6755
|
+
}).toReversed();
|
|
6756
|
+
}
|
|
6708
6757
|
blocksByTransactionHashes(hashes) {
|
|
6709
6758
|
return hashes.map((hash) => this._transactionHashMap.get(hash)).filter(exists11);
|
|
6710
6759
|
}
|
|
@@ -6713,22 +6762,22 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
6713
6762
|
}
|
|
6714
6763
|
async createHandler() {
|
|
6715
6764
|
await super.createHandler();
|
|
6716
|
-
this._blockViewer =
|
|
6765
|
+
this._blockViewer = assertEx48(
|
|
6717
6766
|
this.params.blockViewer ?? await this.locator.getInstance(BlockViewerMoniker7),
|
|
6718
6767
|
() => "BlockViewer instance is required"
|
|
6719
6768
|
);
|
|
6720
|
-
this._blockHashMap = new
|
|
6721
|
-
this._blockNumberMap = new
|
|
6722
|
-
this._transactionHashMap = new
|
|
6769
|
+
this._blockHashMap = new MemoryMap2();
|
|
6770
|
+
this._blockNumberMap = new MemoryMap2();
|
|
6771
|
+
this._transactionHashMap = new MemoryMap2();
|
|
6723
6772
|
}
|
|
6724
6773
|
currentBlock() {
|
|
6725
|
-
return
|
|
6774
|
+
return assertEx48(this._chain.at(-1));
|
|
6726
6775
|
}
|
|
6727
6776
|
currentBlockHash() {
|
|
6728
|
-
return
|
|
6777
|
+
return assertEx48(this._chain.at(-1)?.[0]._hash);
|
|
6729
6778
|
}
|
|
6730
6779
|
currentBlockNumber() {
|
|
6731
|
-
return
|
|
6780
|
+
return assertEx48(this._chain.at(-1)?.[0].block);
|
|
6732
6781
|
}
|
|
6733
6782
|
async payloadByHash(hash) {
|
|
6734
6783
|
const payloads = await this.payloadsByHash([hash]);
|
|
@@ -6887,13 +6936,13 @@ var RuntimeStatusMonitor = class extends LoggerStatusReporter {
|
|
|
6887
6936
|
};
|
|
6888
6937
|
|
|
6889
6938
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
6890
|
-
import { assertEx as
|
|
6939
|
+
import { assertEx as assertEx49 } from "@xylabs/sdk-js";
|
|
6891
6940
|
import { asTimePayload as asTimePayload3, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol-lib";
|
|
6892
6941
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
6893
6942
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
6894
6943
|
const hydratedBlock = await hydrateBlock(context, blockHash);
|
|
6895
6944
|
const timePayload = asTimePayload3(hydratedBlock[1].find((p) => p.schema === TimeSchema2), { required: true });
|
|
6896
|
-
return
|
|
6945
|
+
return assertEx49(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
6897
6946
|
}
|
|
6898
6947
|
|
|
6899
6948
|
// src/validation/lib/isLocalhost.ts
|
|
@@ -6933,6 +6982,9 @@ var generateXyoBaseWalletFromPhrase = (walletPhrase) => {
|
|
|
6933
6982
|
const wallet = HDWallet.fromPhrase(walletPhrase, DEFAULT_WALLET_PATH);
|
|
6934
6983
|
return wallet;
|
|
6935
6984
|
};
|
|
6985
|
+
|
|
6986
|
+
// src/index.ts
|
|
6987
|
+
export * from "@xyo-network/xl1-driver-memory";
|
|
6936
6988
|
export {
|
|
6937
6989
|
ACCOUNT_TYPE,
|
|
6938
6990
|
ADDRESS_INDEX,
|
|
@@ -6945,6 +6997,7 @@ export {
|
|
|
6945
6997
|
BalancesStepSummarySchema,
|
|
6946
6998
|
BaseConfigContextZod,
|
|
6947
6999
|
BaseConfigZod,
|
|
7000
|
+
BlocksStepSummarySchema,
|
|
6948
7001
|
BoundWitnessHydrator,
|
|
6949
7002
|
BoundWitnessWithStorageMetaZod,
|
|
6950
7003
|
CHANGE_ADDRESS,
|
|
@@ -6972,8 +7025,6 @@ export {
|
|
|
6972
7025
|
HydratedCache,
|
|
6973
7026
|
JSONSchemaMetaSchema,
|
|
6974
7027
|
LoggerStatusReporter,
|
|
6975
|
-
LruCacheMap,
|
|
6976
|
-
MemoryMap,
|
|
6977
7028
|
MemoryPermissionsStore,
|
|
6978
7029
|
MissingCapabilityError,
|
|
6979
7030
|
MnemonicStringZod,
|
|
@@ -7053,6 +7104,8 @@ export {
|
|
|
7053
7104
|
asBalancesStepSummary,
|
|
7054
7105
|
asBalancesStepSummaryWithStorageMeta,
|
|
7055
7106
|
asBaseConfigContext,
|
|
7107
|
+
asBlocksStepSummary,
|
|
7108
|
+
asBlocksStepSummaryWithStorageMeta,
|
|
7056
7109
|
asBoundWitnessWithStorageMeta,
|
|
7057
7110
|
asChainIndexingServiceState,
|
|
7058
7111
|
asChainIndexingServiceStateWithStorageMeta,
|
|
@@ -7077,6 +7130,9 @@ export {
|
|
|
7077
7130
|
blockPayloadsFromHydratedBlock,
|
|
7078
7131
|
blockRangeSteps,
|
|
7079
7132
|
blockRate,
|
|
7133
|
+
blocksMaxStep,
|
|
7134
|
+
blocksStepSummaryFromRange,
|
|
7135
|
+
blocksStepSummaryKey,
|
|
7080
7136
|
buildTransaction,
|
|
7081
7137
|
buildUnsignedTransaction,
|
|
7082
7138
|
bundledPayloadToHydratedBlock,
|
|
@@ -7133,6 +7189,8 @@ export {
|
|
|
7133
7189
|
isBalancesStepSummary,
|
|
7134
7190
|
isBalancesStepSummaryWithStorageMeta,
|
|
7135
7191
|
isBaseConfigContext,
|
|
7192
|
+
isBlocksStepSummary,
|
|
7193
|
+
isBlocksStepSummaryWithStorageMeta,
|
|
7136
7194
|
isChainIndexingServiceState,
|
|
7137
7195
|
isChainIndexingServiceStateWithStorageMeta,
|
|
7138
7196
|
isCreatableProviderContext,
|