@xyo-network/xl1-protocol-sdk 1.25.13 → 1.25.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +85 -79
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +3 -3
- package/src/summary/primitives/balances/balancesSummary.ts +1 -1
- package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +66 -63
- package/src/summary/primitives/transfers/transfersSummary.ts +1 -1
package/dist/neutral/index.mjs
CHANGED
|
@@ -2876,7 +2876,7 @@ import {
|
|
|
2876
2876
|
import {
|
|
2877
2877
|
AccountBalanceViewerMoniker,
|
|
2878
2878
|
asRange,
|
|
2879
|
-
asXL1BlockNumber as
|
|
2879
|
+
asXL1BlockNumber as asXL1BlockNumber8,
|
|
2880
2880
|
asXL1BlockRange as asXL1BlockRange10,
|
|
2881
2881
|
AttoXL1 as AttoXL12,
|
|
2882
2882
|
BlockViewerMoniker,
|
|
@@ -2962,7 +2962,7 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
2962
2962
|
stepSize: -1,
|
|
2963
2963
|
balances
|
|
2964
2964
|
});
|
|
2965
|
-
}, context) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
2965
|
+
}, { ...context, timeBudgetLimit: 500 }) : await spanRootAsync2(`balancesStepSummaryFromRange.frameSize>1[${key}]`, async () => {
|
|
2966
2966
|
const step = StepSizes9.indexOf(asXL1BlockNumber6(frameSize, true));
|
|
2967
2967
|
assertEx25(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
|
|
2968
2968
|
const summaryResult = await summaryMap.get(`${frameHead._hash}|${frameSize}`);
|
|
@@ -3002,8 +3002,8 @@ async function balancesStepSummaryFromRange(context, semaphores, blockViewer, su
|
|
|
3002
3002
|
semaphores[step].release();
|
|
3003
3003
|
}
|
|
3004
3004
|
}
|
|
3005
|
-
}, context);
|
|
3006
|
-
}, context);
|
|
3005
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3006
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3007
3007
|
}, { max: 1e5 });
|
|
3008
3008
|
}
|
|
3009
3009
|
|
|
@@ -3038,7 +3038,7 @@ async function balancesSummary(context, semaphores, blockViewer, summaryMap, con
|
|
|
3038
3038
|
}
|
|
3039
3039
|
}
|
|
3040
3040
|
return [balances, { range, head: headHash }];
|
|
3041
|
-
}, context);
|
|
3041
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3042
3042
|
}
|
|
3043
3043
|
|
|
3044
3044
|
// src/summary/primitives/schemas/schemasStepSummaryFromRange.ts
|
|
@@ -3141,86 +3141,92 @@ async function schemasSummary(context, semaphores, blockViewer, summaryMap, conf
|
|
|
3141
3141
|
}
|
|
3142
3142
|
|
|
3143
3143
|
// src/summary/primitives/transfers/transfersStepSummaryFromRange.ts
|
|
3144
|
-
import { assertEx as assertEx29 } from "@xylabs/sdk-js";
|
|
3145
|
-
import {
|
|
3146
|
-
|
|
3144
|
+
import { assertEx as assertEx29, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
|
|
3145
|
+
import {
|
|
3146
|
+
asHashMeta,
|
|
3147
|
+
isAnyPayload as isAnyPayload4,
|
|
3148
|
+
PayloadBuilder as PayloadBuilder18
|
|
3149
|
+
} from "@xyo-network/sdk-js";
|
|
3150
|
+
import { asXL1BlockNumber as asXL1BlockNumber7, StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol";
|
|
3147
3151
|
function transfersSummaryKey(frameHeadHash, frameSize) {
|
|
3148
3152
|
return `${frameHeadHash}|${frameSize}`;
|
|
3149
3153
|
}
|
|
3150
3154
|
async function transfersStepSummaryFromRange(context, semaphores, blockViewer, summaryMap, range) {
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3155
|
+
return await spanRootAsync5("transfersStepSummaryFromRange", async () => {
|
|
3156
|
+
const [frameHead] = assertEx29(await blockViewer.blockByNumber(range[1]), () => `Block not found for number: ${range[1]}`);
|
|
3157
|
+
const frameSize = range[1] - range[0] + 1;
|
|
3158
|
+
let result;
|
|
3159
|
+
if (frameSize === 1) {
|
|
3160
|
+
const [, payloads] = assertEx29(await blockViewer.blockByNumber(range[0]), () => `Block not found for number: ${range[0]}`);
|
|
3161
|
+
const transfers = {};
|
|
3162
|
+
for (const [from, toMap] of Object.entries(netTransfersForPayloads(payloads))) {
|
|
3163
|
+
transfers[from] = transfers[from] ?? {};
|
|
3164
|
+
for (const [to, amount] of Object.entries(toMap)) {
|
|
3165
|
+
transfers[from][to] = toSignedBigInt(amount);
|
|
3166
|
+
}
|
|
3161
3167
|
}
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
});
|
|
3169
|
-
} else {
|
|
3170
|
-
const step = StepSizes11.indexOf(frameSize);
|
|
3171
|
-
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
3172
|
-
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3173
|
-
const summaryResult = await summaryMap.get(key);
|
|
3174
|
-
if (isAnyPayload4(summaryResult)) {
|
|
3175
|
-
result = summaryResult;
|
|
3168
|
+
result = await PayloadBuilder18.addHashMeta({
|
|
3169
|
+
schema: TransfersStepSummarySchema,
|
|
3170
|
+
hash: frameHead._hash,
|
|
3171
|
+
stepSize: -1,
|
|
3172
|
+
transfers
|
|
3173
|
+
});
|
|
3176
3174
|
} else {
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3175
|
+
const step = StepSizes11.indexOf(asXL1BlockNumber7(frameSize, true));
|
|
3176
|
+
assertEx29(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
|
|
3177
|
+
const key = transfersSummaryKey(frameHead._hash, frameSize);
|
|
3178
|
+
const summaryResult = await summaryMap.get(key);
|
|
3179
|
+
if (isAnyPayload4(summaryResult)) {
|
|
3180
|
+
result = asHashMeta(asTransfersStepSummary(summaryResult, { required: true }), true);
|
|
3181
|
+
} else {
|
|
3182
|
+
await semaphores[step].acquire();
|
|
3183
|
+
try {
|
|
3184
|
+
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
3185
|
+
const promises = subRanges.map((subRange) => transfersStepSummaryFromRange(
|
|
3186
|
+
context,
|
|
3187
|
+
semaphores,
|
|
3188
|
+
blockViewer,
|
|
3189
|
+
summaryMap,
|
|
3190
|
+
subRange
|
|
3191
|
+
));
|
|
3192
|
+
const subResults = await Promise.all(promises);
|
|
3193
|
+
const bigIntBalances = {};
|
|
3194
|
+
for (const subResult of subResults) {
|
|
3195
|
+
for (const [from, toMap] of Object.entries(subResult.transfers)) {
|
|
3196
|
+
bigIntBalances[from] = bigIntBalances[from] ?? {};
|
|
3197
|
+
for (const [to, transfer] of Object.entries(toMap)) {
|
|
3198
|
+
bigIntBalances[from][to] = (bigIntBalances[from][to] ?? 0n) + parseSignedBigInt(transfer);
|
|
3199
|
+
}
|
|
3194
3200
|
}
|
|
3195
3201
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
+
const transfers = {};
|
|
3203
|
+
for (const [from, toMap] of Object.entries(bigIntBalances)) {
|
|
3204
|
+
transfers[from] = transfers[from] ?? {};
|
|
3205
|
+
for (const [to, transfer] of Object.entries(toMap)) {
|
|
3206
|
+
transfers[from][to] = toSignedBigInt(transfer);
|
|
3207
|
+
}
|
|
3202
3208
|
}
|
|
3209
|
+
result = await PayloadBuilder18.addHashMeta({
|
|
3210
|
+
schema: TransfersStepSummarySchema,
|
|
3211
|
+
hash: frameHead._hash,
|
|
3212
|
+
stepSize: frameSize,
|
|
3213
|
+
transfers
|
|
3214
|
+
});
|
|
3215
|
+
await summaryMap.set(key, result);
|
|
3216
|
+
} finally {
|
|
3217
|
+
semaphores[step].release();
|
|
3203
3218
|
}
|
|
3204
|
-
result = await PayloadBuilder18.addHashMeta({
|
|
3205
|
-
schema: TransfersStepSummarySchema,
|
|
3206
|
-
hash: frameHead._hash,
|
|
3207
|
-
stepSize: frameSize,
|
|
3208
|
-
transfers
|
|
3209
|
-
});
|
|
3210
|
-
await summaryMap.set(key, result);
|
|
3211
|
-
} finally {
|
|
3212
|
-
semaphores[step].release();
|
|
3213
3219
|
}
|
|
3214
3220
|
}
|
|
3215
|
-
|
|
3216
|
-
|
|
3221
|
+
return result;
|
|
3222
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3217
3223
|
}
|
|
3218
3224
|
|
|
3219
3225
|
// src/summary/primitives/transfers/transfersSummary.ts
|
|
3220
3226
|
import {
|
|
3221
3227
|
asAddress as asAddress3,
|
|
3222
3228
|
assertEx as assertEx30,
|
|
3223
|
-
spanRootAsync as
|
|
3229
|
+
spanRootAsync as spanRootAsync6
|
|
3224
3230
|
} from "@xylabs/sdk-js";
|
|
3225
3231
|
import {
|
|
3226
3232
|
asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4,
|
|
@@ -3229,7 +3235,7 @@ import {
|
|
|
3229
3235
|
isChainQualifiedRangeConfig as isChainQualifiedRangeConfig3
|
|
3230
3236
|
} from "@xyo-network/xl1-protocol";
|
|
3231
3237
|
async function transfersSummary(context, semaphores, blockViewer, summaryMap, config) {
|
|
3232
|
-
return await
|
|
3238
|
+
return await spanRootAsync6("transferSummary", async () => {
|
|
3233
3239
|
const headHash = isChainQualifiedHeadConfig3(config) ? config.head : await blockViewer.currentBlockHash();
|
|
3234
3240
|
const [head] = assertEx30(await blockViewer.blockByHash(headHash), () => `Block not found for hash: ${headHash}`);
|
|
3235
3241
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(head, () => `Found Block not a BlockWithHashMeta: ${headHash}`);
|
|
@@ -3251,7 +3257,7 @@ async function transfersSummary(context, semaphores, blockViewer, summaryMap, co
|
|
|
3251
3257
|
}
|
|
3252
3258
|
}
|
|
3253
3259
|
return [transfers, { range, head: headHash }];
|
|
3254
|
-
}, context);
|
|
3260
|
+
}, { ...context, timeBudgetLimit: 500 });
|
|
3255
3261
|
}
|
|
3256
3262
|
|
|
3257
3263
|
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
@@ -3381,7 +3387,7 @@ var SimpleAccountBalanceViewer = class extends AbstractCreatableProvider {
|
|
|
3381
3387
|
async distillTransferHistory(address, range, max = 50) {
|
|
3382
3388
|
return await this.spanAsync("distillTransferHistory", async () => {
|
|
3383
3389
|
if (range[1] - range[0] <= StepSizes12[0] || max <= 1) {
|
|
3384
|
-
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) =>
|
|
3390
|
+
return Array.from({ length: range[1] - range[0] + 1 }, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber8(n, true));
|
|
3385
3391
|
}
|
|
3386
3392
|
const frames = deepCalculateFramesFromRange(asXL1BlockRange10(range, true));
|
|
3387
3393
|
const transferSummaryPairs = await Promise.all(frames.map(
|
|
@@ -3463,7 +3469,7 @@ import {
|
|
|
3463
3469
|
import {
|
|
3464
3470
|
asSignedHydratedBlockWithHashMeta,
|
|
3465
3471
|
asSignedHydratedBlockWithStorageMeta,
|
|
3466
|
-
asXL1BlockNumber as
|
|
3472
|
+
asXL1BlockNumber as asXL1BlockNumber9,
|
|
3467
3473
|
BlockViewerMoniker as BlockViewerMoniker2,
|
|
3468
3474
|
DataLakeViewerMoniker,
|
|
3469
3475
|
FinalizationViewerMoniker
|
|
@@ -3581,7 +3587,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
|
|
|
3581
3587
|
while (current && blocks.length < limit) {
|
|
3582
3588
|
blocks.push(current);
|
|
3583
3589
|
if (current[0].block === 0) break;
|
|
3584
|
-
const previousNumber =
|
|
3590
|
+
const previousNumber = asXL1BlockNumber9(current[0].block - 1, true);
|
|
3585
3591
|
current = await this.blockByNumber(previousNumber);
|
|
3586
3592
|
}
|
|
3587
3593
|
return blocks.map((b) => asSignedHydratedBlockWithHashMeta(b, true));
|
|
@@ -4208,7 +4214,7 @@ import {
|
|
|
4208
4214
|
} from "@xylabs/sdk-js";
|
|
4209
4215
|
import { PayloadBuilder as PayloadBuilder21 } from "@xyo-network/sdk-js";
|
|
4210
4216
|
import {
|
|
4211
|
-
asXL1BlockNumber as
|
|
4217
|
+
asXL1BlockNumber as asXL1BlockNumber10,
|
|
4212
4218
|
DataLakeRunnerMoniker as DataLakeRunnerMoniker3,
|
|
4213
4219
|
isSignedHydratedTransaction,
|
|
4214
4220
|
TransferSchema as TransferSchema3,
|
|
@@ -4243,8 +4249,8 @@ var SimpleXyoGatewayRunner = class _SimpleXyoGatewayRunner extends AbstractCreat
|
|
|
4243
4249
|
fees
|
|
4244
4250
|
} = options ?? {};
|
|
4245
4251
|
const resolvedChainId = isDefined18(chain) ? chain : await viewer.chainId();
|
|
4246
|
-
const resolvedNbf =
|
|
4247
|
-
const resolvedExp =
|
|
4252
|
+
const resolvedNbf = asXL1BlockNumber10(isDefined18(nbf) ? nbf : await viewer.currentBlockNumber(), true);
|
|
4253
|
+
const resolvedExp = asXL1BlockNumber10(isDefined18(exp) ? exp : resolvedNbf + 10, true);
|
|
4248
4254
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await this.signer.address(), fees);
|
|
4249
4255
|
return await this.addTransactionToChain(tx, await PayloadBuilder21.addHashMeta(offChain));
|
|
4250
4256
|
}
|
|
@@ -5237,7 +5243,7 @@ import {
|
|
|
5237
5243
|
} from "@xylabs/sdk-js";
|
|
5238
5244
|
import {
|
|
5239
5245
|
asTimePayload as asTimePayload2,
|
|
5240
|
-
asXL1BlockNumber as
|
|
5246
|
+
asXL1BlockNumber as asXL1BlockNumber11,
|
|
5241
5247
|
BlockViewerMoniker as BlockViewerMoniker4,
|
|
5242
5248
|
TimeSchema,
|
|
5243
5249
|
TimeSyncViewerMoniker
|
|
@@ -5254,7 +5260,7 @@ var SimpleTimeSyncViewer = class extends AbstractCreatableProvider {
|
|
|
5254
5260
|
async convertTime(fromDomain, toDomain, from) {
|
|
5255
5261
|
switch (fromDomain) {
|
|
5256
5262
|
case "xl1": {
|
|
5257
|
-
const [block, payloads] = assertEx43(await this.blockViewer.blockByNumber(
|
|
5263
|
+
const [block, payloads] = assertEx43(await this.blockViewer.blockByNumber(asXL1BlockNumber11(from, true)), () => "Block not found");
|
|
5258
5264
|
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
5259
5265
|
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
5260
5266
|
const timePayload = asTimePayload2(isDefined21(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
@@ -5436,7 +5442,7 @@ import {
|
|
|
5436
5442
|
isNull as isNull2
|
|
5437
5443
|
} from "@xylabs/sdk-js";
|
|
5438
5444
|
import {
|
|
5439
|
-
asXL1BlockNumber as
|
|
5445
|
+
asXL1BlockNumber as asXL1BlockNumber12,
|
|
5440
5446
|
BlockViewerMoniker as BlockViewerMoniker6,
|
|
5441
5447
|
WindowedBlockViewerMoniker as WindowedBlockViewerMoniker2
|
|
5442
5448
|
} from "@xyo-network/xl1-protocol";
|
|
@@ -5489,7 +5495,7 @@ var SimpleWindowedBlockViewer = class extends AbstractCreatableProvider {
|
|
|
5489
5495
|
let block = this._blockNumberMap.get(blockNumber);
|
|
5490
5496
|
while (block && (limit === void 0 || result.length < limit)) {
|
|
5491
5497
|
result.unshift(block);
|
|
5492
|
-
const previousBlockNumber =
|
|
5498
|
+
const previousBlockNumber = asXL1BlockNumber12(block[0].block - 1, true);
|
|
5493
5499
|
block = previousBlockNumber >= 0 ? this._blockNumberMap.get(previousBlockNumber) : void 0;
|
|
5494
5500
|
}
|
|
5495
5501
|
return result;
|