@xyo-network/xl1-protocol-sdk 2.0.1 → 2.0.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepCalculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/deepCalculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAKlE,oDAAoD;AACpD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"deepCalculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/deepCalculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAKlE,oDAAoD;AACpD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,aAAa,EAAE,YAAY,SAAI,GAA6B,aAAa,EAAE,CAuB9H"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -873,11 +873,11 @@ function calculateFramesFromRange(range, step) {
|
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
876
|
-
|
|
877
|
-
function deepCalculateFramesFromRange(range, startingStep = StepSizes2.length - 1) {
|
|
876
|
+
function deepCalculateFramesFromRange(range, startingStep = 4) {
|
|
878
877
|
const fitted = [];
|
|
879
878
|
let remaining = [range];
|
|
880
|
-
|
|
879
|
+
const actualStartingStep = Math.min(startingStep, 4);
|
|
880
|
+
for (let step = actualStartingStep; step >= 0; step--) {
|
|
881
881
|
const newRemaining = [];
|
|
882
882
|
for (const range2 of remaining) {
|
|
883
883
|
const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range2, step);
|
|
@@ -1501,11 +1501,11 @@ import { AddressZod as AddressZod2 } from "@xylabs/sdk-js";
|
|
|
1501
1501
|
import { globalRegistry as globalRegistry11, z as z15 } from "zod";
|
|
1502
1502
|
|
|
1503
1503
|
// src/primitives/block/range/blockRangeSteps.ts
|
|
1504
|
-
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as
|
|
1504
|
+
import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol-lib";
|
|
1505
1505
|
function blockRangeSteps(range, steps) {
|
|
1506
1506
|
const result = [];
|
|
1507
1507
|
for (const step of steps) {
|
|
1508
|
-
const stepSize2 =
|
|
1508
|
+
const stepSize2 = StepSizes2[step];
|
|
1509
1509
|
const startOfFirstStepCandidate = range[0] - range[0] % stepSize2 + stepSize2;
|
|
1510
1510
|
const startOfFirstStep = asXL1BlockNumber2(
|
|
1511
1511
|
startOfFirstStepCandidate,
|
|
@@ -1618,7 +1618,7 @@ import { assertEx as assertEx9 } from "@xylabs/sdk-js";
|
|
|
1618
1618
|
import {
|
|
1619
1619
|
asXL1BlockRange as asXL1BlockRange2,
|
|
1620
1620
|
isValidStep,
|
|
1621
|
-
StepSizes as
|
|
1621
|
+
StepSizes as StepSizes3
|
|
1622
1622
|
} from "@xyo-network/xl1-protocol-lib";
|
|
1623
1623
|
var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
1624
1624
|
const end = start + step * count;
|
|
@@ -1627,7 +1627,7 @@ var stepRate = async (viewer, start, step, count = 1, timeUnit) => {
|
|
|
1627
1627
|
};
|
|
1628
1628
|
var calculateStepSizeRate = async (viewer, start, stepIndex, count = 1, timeUnit) => {
|
|
1629
1629
|
assertEx9(isValidStep(stepIndex), () => `Invalid step index: ${stepIndex}`);
|
|
1630
|
-
const step =
|
|
1630
|
+
const step = StepSizes3[stepIndex];
|
|
1631
1631
|
return await stepRate(viewer, start, step, count, timeUnit);
|
|
1632
1632
|
};
|
|
1633
1633
|
|
|
@@ -1769,23 +1769,23 @@ function mergeTransfers(transfers) {
|
|
|
1769
1769
|
}
|
|
1770
1770
|
|
|
1771
1771
|
// src/primitives/step/stepBlockRange.ts
|
|
1772
|
-
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as
|
|
1772
|
+
import { asXL1BlockRange as asXL1BlockRange4, StepSizes as StepSizes4 } from "@xyo-network/xl1-protocol-lib";
|
|
1773
1773
|
function stepBlockRange({ block, step }) {
|
|
1774
|
-
const stepSize2 =
|
|
1774
|
+
const stepSize2 = StepSizes4[step];
|
|
1775
1775
|
const start = block - stepSize2;
|
|
1776
1776
|
return asXL1BlockRange4([start, start + stepSize2 - 1], { name: "stepBlockRange" });
|
|
1777
1777
|
}
|
|
1778
1778
|
|
|
1779
1779
|
// src/primitives/step/stepTransferIndex.ts
|
|
1780
1780
|
import { assertEx as assertEx12 } from "@xylabs/sdk-js";
|
|
1781
|
-
import { StepSizes as
|
|
1781
|
+
import { StepSizes as StepSizes5 } from "@xyo-network/xl1-protocol-lib";
|
|
1782
1782
|
function stepTransferIndex(block, step) {
|
|
1783
1783
|
let rewardTransferCount = 0;
|
|
1784
1784
|
let rewardTransferIndex = -1;
|
|
1785
|
-
for (let i = 3; i <
|
|
1786
|
-
const stepSize2 =
|
|
1785
|
+
for (let i = 3; i < StepSizes5.length; i++) {
|
|
1786
|
+
const stepSize2 = StepSizes5[i];
|
|
1787
1787
|
if (block % stepSize2 === 0) {
|
|
1788
|
-
if (stepSize2 ===
|
|
1788
|
+
if (stepSize2 === StepSizes5[step]) {
|
|
1789
1789
|
rewardTransferIndex = rewardTransferCount;
|
|
1790
1790
|
}
|
|
1791
1791
|
rewardTransferCount++;
|
|
@@ -1797,9 +1797,9 @@ function stepTransferIndex(block, step) {
|
|
|
1797
1797
|
|
|
1798
1798
|
// src/primitives/chain/step/stepRewardBlock.ts
|
|
1799
1799
|
import { assertEx as assertEx13 } from "@xylabs/sdk-js";
|
|
1800
|
-
import { StepSizes as
|
|
1800
|
+
import { StepSizes as StepSizes6 } from "@xyo-network/xl1-protocol-lib";
|
|
1801
1801
|
async function stepRewardBlock(context, blockViewer, { block, step }) {
|
|
1802
|
-
assertEx13(block %
|
|
1802
|
+
assertEx13(block % StepSizes6[step] === 0, () => `Block must be the first block of the step [${StepSizes6[step]}], got ${block}`);
|
|
1803
1803
|
return assertEx13(await blockViewer.blockByNumber(block), () => `Could not find block for block number ${block}`);
|
|
1804
1804
|
}
|
|
1805
1805
|
|
|
@@ -3609,7 +3609,7 @@ import {
|
|
|
3609
3609
|
BlockViewerMoniker,
|
|
3610
3610
|
isChainQualifiedHeadConfig as isChainQualifiedHeadConfig4,
|
|
3611
3611
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig4,
|
|
3612
|
-
StepSizes as
|
|
3612
|
+
StepSizes as StepSizes10,
|
|
3613
3613
|
TransferSchema as TransferSchema2
|
|
3614
3614
|
} from "@xyo-network/xl1-protocol-lib";
|
|
3615
3615
|
import { Semaphore } from "async-mutex";
|
|
@@ -3669,7 +3669,7 @@ var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersS
|
|
|
3669
3669
|
import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
|
|
3670
3670
|
import { assertEx as assertEx26 } from "@xylabs/sdk-js";
|
|
3671
3671
|
import { isAnyPayload as isAnyPayload3 } from "@xyo-network/sdk-js";
|
|
3672
|
-
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as
|
|
3672
|
+
import { asXL1BlockNumber as asXL1BlockNumber5, StepSizes as StepSizes7 } from "@xyo-network/xl1-protocol-lib";
|
|
3673
3673
|
async function balancesStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3674
3674
|
const cacheKey = `${range[0]}|${range[1]}`;
|
|
3675
3675
|
return await withContextCacheResponse(context, "balancesStepSummaryFromRange", cacheKey, async () => {
|
|
@@ -3690,8 +3690,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3690
3690
|
balances
|
|
3691
3691
|
};
|
|
3692
3692
|
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
3693
|
-
const step =
|
|
3694
|
-
assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${
|
|
3693
|
+
const step = StepSizes7.indexOf(asXL1BlockNumber5(frameSize, true));
|
|
3694
|
+
assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes7.join(", ")}`);
|
|
3695
3695
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3696
3696
|
if (isAnyPayload3(summaryResult)) {
|
|
3697
3697
|
return summaryResult;
|
|
@@ -3776,7 +3776,7 @@ import {
|
|
|
3776
3776
|
isHashMeta,
|
|
3777
3777
|
PayloadBuilder as PayloadBuilder17
|
|
3778
3778
|
} from "@xyo-network/sdk-js";
|
|
3779
|
-
import { StepSizes as
|
|
3779
|
+
import { StepSizes as StepSizes8 } from "@xyo-network/xl1-protocol-lib";
|
|
3780
3780
|
async function schemasStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3781
3781
|
const [frameHead] = assertEx28(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3782
3782
|
const frameSize = range[1] - range[0] + 1;
|
|
@@ -3798,8 +3798,8 @@ async function schemasStepSummaryFromRange(context, semaphores, blockViewer, sum
|
|
|
3798
3798
|
schemas
|
|
3799
3799
|
});
|
|
3800
3800
|
} else {
|
|
3801
|
-
const step =
|
|
3802
|
-
assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${
|
|
3801
|
+
const step = StepSizes8.indexOf(frameSize);
|
|
3802
|
+
assertEx28(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes8.join(", ")}`);
|
|
3803
3803
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
3804
3804
|
if (isAnyPayload4(summaryResult)) {
|
|
3805
3805
|
result = summaryResult;
|
|
@@ -3870,7 +3870,7 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3870
3870
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3871
3871
|
import { assertEx as assertEx30, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3872
3872
|
import { isAnyPayload as isAnyPayload5 } from "@xyo-network/sdk-js";
|
|
3873
|
-
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as
|
|
3873
|
+
import { asXL1BlockNumber as asXL1BlockNumber6, StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol-lib";
|
|
3874
3874
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
3875
3875
|
return `${frameHeadHash}|${frameSize}`;
|
|
3876
3876
|
}
|
|
@@ -3897,8 +3897,8 @@ async function transfersStepSummaryFromRange(context, semaphores, blockViewer, s
|
|
|
3897
3897
|
transfers
|
|
3898
3898
|
};
|
|
3899
3899
|
} else {
|
|
3900
|
-
const step =
|
|
3901
|
-
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${
|
|
3900
|
+
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
3901
|
+
assertEx30(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
3902
3902
|
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3903
3903
|
const summaryResult = await summaryMap.get(key);
|
|
3904
3904
|
if (isAnyPayload5(summaryResult)) {
|
|
@@ -3989,9 +3989,9 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3989
3989
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
3990
3990
|
var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
3991
3991
|
moniker = SimpleAccountBalanceViewer.defaultMoniker;
|
|
3992
|
-
_balanceStepSemaphores =
|
|
3992
|
+
_balanceStepSemaphores = StepSizes10.map(() => new Semaphore(20));
|
|
3993
3993
|
_blockViewer;
|
|
3994
|
-
_transferStepSemaphores =
|
|
3994
|
+
_transferStepSemaphores = StepSizes10.map(() => new Semaphore(20));
|
|
3995
3995
|
get balancesSummaryMap() {
|
|
3996
3996
|
return this.params.balancesSummaryMap;
|
|
3997
3997
|
}
|
|
@@ -4112,7 +4112,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4112
4112
|
}
|
|
4113
4113
|
async distillTransferHistory(address, range, max = 50) {
|
|
4114
4114
|
return await this.spanAsync("distillTransferHistory", async () => {
|
|
4115
|
-
if (range[1] - range[0] <=
|
|
4115
|
+
if (range[1] - range[0] <= StepSizes10[0] || max <= 1) {
|
|
4116
4116
|
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber7(n, true));
|
|
4117
4117
|
}
|
|
4118
4118
|
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true));
|
|
@@ -4127,7 +4127,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
4127
4127
|
});
|
|
4128
4128
|
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
4129
4129
|
for (const [frame] of sortedTransferSummaryPairs) {
|
|
4130
|
-
if (frame[1] - frame[0] + 1 >
|
|
4130
|
+
if (frame[1] - frame[0] + 1 > StepSizes10[0]) {
|
|
4131
4131
|
const values = await this.distillTransferHistory(address, asXL1BlockRange10([frame[0], frame[1] - 1], true), max - resultBlockNumbers.size);
|
|
4132
4132
|
for (const value of values) {
|
|
4133
4133
|
resultBlockNumbers.add(value);
|