@xyo-network/xl1-protocol-sdk 1.18.21 → 1.18.22

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.
@@ -3104,74 +3104,76 @@ var isTransfersStepSummaryWithStorageMeta = (value) => {
3104
3104
  var asTransfersStepSummaryWithStorageMeta = AsObjectFactory7.create(isTransfersStepSummaryWithStorageMeta);
3105
3105
 
3106
3106
  // src/summary/primitives/balances/balancesStepSummaryFromRange.ts
3107
+ import { spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
3107
3108
  import { assertEx as assertEx25 } from "@xylabs/sdk-js";
3108
3109
  import { PayloadBuilder as PayloadBuilder14 } from "@xyo-network/payload-builder";
3109
3110
  import { isAnyPayload } from "@xyo-network/payload-model";
3110
3111
  import { StepSizes as StepSizes9 } from "@xyo-network/xl1-protocol";
3111
3112
  async function balancesStepSummaryFromRange(context, range) {
3112
- const frameHeadHash = await hashFromBlockNumber(context, range[1]);
3113
- const frameSize = range[1] - range[0] + 1;
3114
- const [headHash] = await context.head();
3115
- let result = void 0;
3116
- if (frameSize === 1) {
3117
- const hash = await hashFromBlockNumber(context, range[0]);
3118
- const [, payloads] = await hydrateBlock(context.store, hash);
3119
- const balances = {};
3120
- for (const [address, balance] of Object.entries(netBalancesForPayloads(payloads))) {
3121
- balances[address] = toSignedBigInt(balance);
3122
- }
3123
- result = {
3124
- schema: BalancesStepSummarySchema,
3125
- hash: headHash,
3126
- stepSize: -1,
3127
- balances
3128
- };
3129
- } else {
3130
- const step = StepSizes9.indexOf(frameSize);
3131
- assertEx25(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
3132
- const summaryResult = await context.summaryMap.get(`${frameHeadHash}|${frameSize}`);
3133
- if (isAnyPayload(summaryResult)) {
3134
- result = summaryResult;
3113
+ return await spanRootAsync2("balancesStepSummaryFromRange", async () => {
3114
+ const frameHeadHash = await hashFromBlockNumber(context, range[1]);
3115
+ const frameSize = range[1] - range[0] + 1;
3116
+ const [headHash] = await context.head();
3117
+ let result;
3118
+ if (frameSize === 1) {
3119
+ const hash = await hashFromBlockNumber(context, range[0]);
3120
+ const [, payloads] = await hydrateBlock(context.store, hash);
3121
+ const balances = {};
3122
+ for (const [address, balance] of Object.entries(netBalancesForPayloads(payloads))) {
3123
+ balances[address] = toSignedBigInt(balance);
3124
+ }
3125
+ result = await PayloadBuilder14.addHashMeta({
3126
+ schema: BalancesStepSummarySchema,
3127
+ hash: headHash,
3128
+ stepSize: -1,
3129
+ balances
3130
+ });
3135
3131
  } else {
3136
- await context.stepSemaphores[step].acquire();
3137
- try {
3138
- const subRanges = deepCalculateFramesFromRange(range, step - 1);
3139
- const promises = subRanges.map((subRange) => balancesStepSummaryFromRange(
3140
- context,
3141
- subRange
3142
- ));
3143
- const subResults = await Promise.all(promises);
3144
- const bigIntBalances = {};
3145
- for (const subResult of subResults) {
3146
- for (const [address, balance] of Object.entries(subResult.balances)) {
3147
- bigIntBalances[address] = (bigIntBalances[address] ?? 0n) + parseSignedBigInt(balance);
3132
+ const step = StepSizes9.indexOf(frameSize);
3133
+ assertEx25(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes9.join(", ")}`);
3134
+ const summaryResult = await context.summaryMap.get(`${frameHeadHash}|${frameSize}`);
3135
+ if (isAnyPayload(summaryResult)) {
3136
+ result = summaryResult;
3137
+ } else {
3138
+ await context.stepSemaphores[step].acquire();
3139
+ try {
3140
+ const subRanges = deepCalculateFramesFromRange(range, step - 1);
3141
+ const promises = subRanges.map((subRange) => balancesStepSummaryFromRange(
3142
+ context,
3143
+ subRange
3144
+ ));
3145
+ const subResults = await Promise.all(promises);
3146
+ const bigIntBalances = {};
3147
+ for (const subResult of subResults) {
3148
+ for (const [address, balance] of Object.entries(subResult.balances)) {
3149
+ bigIntBalances[address] = (bigIntBalances[address] ?? 0n) + parseSignedBigInt(balance);
3150
+ }
3148
3151
  }
3152
+ const balances = {};
3153
+ for (const [address, balance] of Object.entries(bigIntBalances)) {
3154
+ balances[address] = toSignedBigInt(balance);
3155
+ }
3156
+ result = await PayloadBuilder14.addHashMeta({
3157
+ schema: BalancesStepSummarySchema,
3158
+ hash: frameHeadHash,
3159
+ stepSize: frameSize,
3160
+ balances
3161
+ });
3162
+ await context.summaryMap.set(`${frameHeadHash}|${frameSize}`, result);
3163
+ } finally {
3164
+ context.stepSemaphores[step].release();
3149
3165
  }
3150
- const balances = {};
3151
- for (const [address, balance] of Object.entries(bigIntBalances)) {
3152
- balances[address] = toSignedBigInt(balance);
3153
- }
3154
- result = {
3155
- schema: BalancesStepSummarySchema,
3156
- hash: frameHeadHash,
3157
- stepSize: frameSize,
3158
- balances
3159
- };
3160
- await context.summaryMap.set(`${frameHeadHash}|${frameSize}`, result);
3161
- } finally {
3162
- context.stepSemaphores[step].release();
3163
3166
  }
3164
3167
  }
3165
- }
3166
- const finalResult = await PayloadBuilder14.addStorageMeta(result);
3167
- return finalResult;
3168
+ return result;
3169
+ }, { timeBudgetLimit: 500 });
3168
3170
  }
3169
3171
 
3170
3172
  // src/summary/primitives/balances/balancesSummary.ts
3171
- import { asAddress as asAddress3, spanRootAsync as spanRootAsync2 } from "@xylabs/sdk-js";
3173
+ import { asAddress as asAddress3, spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
3172
3174
  import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2, asXL1BlockRange as asXL1BlockRange7 } from "@xyo-network/xl1-protocol";
3173
3175
  async function balancesSummary(context, config) {
3174
- return await spanRootAsync2("balancesSummary", async () => {
3176
+ return await spanRootAsync3("balancesSummary", async () => {
3175
3177
  const [headHash] = isChainQualifiedHeadConfig(config) ? [config.head] : await context.head();
3176
3178
  const headResult = await context.store.chainMap.get(headHash);
3177
3179
  const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${headHash}`);
@@ -3214,12 +3216,12 @@ async function schemasStepSummaryFromRange(context, range) {
3214
3216
  schemas[schema] = (schemas[schema] ?? 0) + 1;
3215
3217
  }
3216
3218
  }
3217
- result = {
3219
+ result = await PayloadBuilder15.addHashMeta({
3218
3220
  schema: SchemasStepSummarySchema,
3219
3221
  hash: headHash,
3220
3222
  stepSize: -1,
3221
3223
  schemas
3222
- };
3224
+ });
3223
3225
  } else {
3224
3226
  const step = StepSizes10.indexOf(frameSize);
3225
3227
  assertEx26(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes10.join(", ")}`);
@@ -3241,12 +3243,12 @@ async function schemasStepSummaryFromRange(context, range) {
3241
3243
  schemas[schema] = (schemas[schema] ?? 0) + count;
3242
3244
  }
3243
3245
  }
3244
- result = {
3246
+ result = await PayloadBuilder15.addHashMeta({
3245
3247
  schema: SchemasStepSummarySchema,
3246
3248
  hash: frameHeadHash,
3247
3249
  stepSize: frameSize,
3248
3250
  schemas
3249
- };
3251
+ });
3250
3252
  await context.summaryMap.set(`${frameHeadHash}|${frameSize}`, result);
3251
3253
  } finally {
3252
3254
  context.stepSemaphores[step].release();
@@ -3257,10 +3259,10 @@ async function schemasStepSummaryFromRange(context, range) {
3257
3259
  }
3258
3260
 
3259
3261
  // src/summary/primitives/schemas/schemasSummary.ts
3260
- import { spanRootAsync as spanRootAsync3 } from "@xylabs/sdk-js";
3262
+ import { spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
3261
3263
  import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3, asXL1BlockRange as asXL1BlockRange8 } from "@xyo-network/xl1-protocol";
3262
3264
  async function schemasSummary(context, config) {
3263
- return await spanRootAsync3("schemasSummary", async () => {
3265
+ return await spanRootAsync4("schemasSummary", async () => {
3264
3266
  const [headHash] = isChainQualifiedHeadConfig(config) ? [config.head] : await context.head();
3265
3267
  const headResult = await context.store.chainMap.get(headHash);
3266
3268
  const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${headHash}`);
@@ -3287,10 +3289,10 @@ import { isAnyPayload as isAnyPayload3 } from "@xyo-network/payload-model";
3287
3289
  import { StepSizes as StepSizes11 } from "@xyo-network/xl1-protocol";
3288
3290
 
3289
3291
  // src/summary/primitives/transfers/transfersSummary.ts
3290
- import { asAddress as asAddress4, spanRootAsync as spanRootAsync4 } from "@xylabs/sdk-js";
3292
+ import { asAddress as asAddress4, spanRootAsync as spanRootAsync5 } from "@xylabs/sdk-js";
3291
3293
  import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta4, asXL1BlockRange as asXL1BlockRange9 } from "@xyo-network/xl1-protocol";
3292
3294
  async function transfersSummary(context, config) {
3293
- return await spanRootAsync4("transferSummary", async () => {
3295
+ return await spanRootAsync5("transferSummary", async () => {
3294
3296
  const [headHash] = isChainQualifiedHeadConfig(config) ? [config.head] : await context.head();
3295
3297
  const headResult = await context.store.chainMap.get(headHash);
3296
3298
  const headBoundWitness = asBlockBoundWitnessWithStorageMeta4(headResult, () => `Head block not found for hash: ${headHash}`);
@@ -3334,12 +3336,12 @@ async function transfersStepSummaryFromRange(context, range) {
3334
3336
  transfers[from][to] = toSignedBigInt(amount);
3335
3337
  }
3336
3338
  }
3337
- result = {
3339
+ result = await PayloadBuilder16.addHashMeta({
3338
3340
  schema: TransfersStepSummarySchema,
3339
3341
  hash: headHash,
3340
3342
  stepSize: -1,
3341
3343
  transfers
3342
- };
3344
+ });
3343
3345
  } else {
3344
3346
  const step = StepSizes11.indexOf(frameSize);
3345
3347
  assertEx27(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes11.join(", ")}`);
@@ -3372,20 +3374,19 @@ async function transfersStepSummaryFromRange(context, range) {
3372
3374
  transfers[from][to] = toSignedBigInt(transfer);
3373
3375
  }
3374
3376
  }
3375
- result = {
3377
+ result = await PayloadBuilder16.addHashMeta({
3376
3378
  schema: TransfersStepSummarySchema,
3377
3379
  hash: frameHeadHash,
3378
3380
  stepSize: frameSize,
3379
3381
  transfers
3380
- };
3382
+ });
3381
3383
  await context.summaryMap.set(key, result);
3382
3384
  } finally {
3383
3385
  context.stepSemaphores[step].release();
3384
3386
  }
3385
3387
  }
3386
3388
  }
3387
- const finalResult = await PayloadBuilder16.addStorageMeta(result);
3388
- return finalResult;
3389
+ return result;
3389
3390
  }
3390
3391
 
3391
3392
  // src/viewers/AccountBalance.ts