@canton-network/core-ledger-client 0.16.0 → 0.17.0

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/index.js CHANGED
@@ -1485,22 +1485,6 @@ var CoreService = class {
1485
1485
  ).viewValue
1486
1486
  };
1487
1487
  }
1488
- async getActiveOpenMiningRound() {
1489
- const openMiningRounds = await this.scanProxyClient.getOpenMiningRounds();
1490
- if (!(Array.isArray(openMiningRounds) && openMiningRounds.length)) {
1491
- throw new Error("OpenMiningRound contract not found");
1492
- }
1493
- const nowForOpenMiningRounds = Date.now();
1494
- const latestOpenMiningRound = openMiningRounds.findLast(
1495
- (openMiningRound) => {
1496
- const { opensAt, targetClosesAt } = openMiningRound.payload;
1497
- const opensAtMs = Number(new Date(opensAt));
1498
- const targetClosesAtMs = Number(new Date(targetClosesAt));
1499
- return opensAtMs <= nowForOpenMiningRounds && targetClosesAtMs > nowForOpenMiningRounds;
1500
- }
1501
- );
1502
- return latestOpenMiningRound ?? null;
1503
- }
1504
1488
  };
1505
1489
  var AllocationService = class {
1506
1490
  constructor(core, logger) {
@@ -2287,7 +2271,7 @@ var TokenStandardService = class {
2287
2271
  if (!amuletRules) {
2288
2272
  throw new Error("AmuletRules contract not found");
2289
2273
  }
2290
- const latestOpenMiningRound = await this.core.getActiveOpenMiningRound();
2274
+ const latestOpenMiningRound = await this.scanProxyClient.getActiveOpenMiningRound();
2291
2275
  if (!latestOpenMiningRound) {
2292
2276
  throw new Error(
2293
2277
  "OpenMiningRound active at current moment not found"
@@ -2338,7 +2322,7 @@ var TokenStandardService = class {
2338
2322
  }
2339
2323
  async renewTransferPreapproval(contractId, templateId, provider, synchronizerId, newExpiresAt, inputUtxos) {
2340
2324
  const amuletRules = await this.scanProxyClient.getAmuletRules();
2341
- const activeRound = await this.core.getActiveOpenMiningRound();
2325
+ const activeRound = await this.scanProxyClient.getActiveOpenMiningRound();
2342
2326
  if (!amuletRules) {
2343
2327
  throw new Error("AmuletRules contract not found");
2344
2328
  }
@@ -2436,13 +2420,15 @@ if (typeof window !== "undefined") {
2436
2420
  window["ACS_UPDATE_CONFIG"] = ACS_UPDATE_CONFIG;
2437
2421
  }
2438
2422
  var ACSContainer = class _ACSContainer {
2439
- constructor(orginalContainer = null) {
2423
+ constructor(orginalContainer = null, settings = { includeCreatedEventBlob: true }) {
2440
2424
  __publicField(this, "acsSet", null);
2425
+ __publicField(this, "settings");
2441
2426
  this.acsSet = orginalContainer ? orginalContainer.acsSet : null;
2427
+ this.settings = settings;
2442
2428
  }
2443
2429
  async update(offset, key, api, wsSupport) {
2444
2430
  if (this.acsSet === null) {
2445
- const acs = await _ACSContainer.readACS(offset, key, api, wsSupport);
2431
+ const acs = await this.readACS(offset, key, api, wsSupport);
2446
2432
  this.acsSet = acs;
2447
2433
  return _ACSContainer.calculateAt(acs, offset);
2448
2434
  }
@@ -2456,7 +2442,7 @@ var ACSContainer = class _ACSContainer {
2456
2442
  const updates = await _ACSContainer.updateContracts(
2457
2443
  this.acsSet.lastUpdateOffset,
2458
2444
  offset,
2459
- _ACSContainer.createEventFormat(key),
2445
+ this.createEventFormat(key),
2460
2446
  api
2461
2447
  );
2462
2448
  const [newEvents, newOffset] = _ACSContainer.extractEvents(
@@ -2607,19 +2593,17 @@ var ACSContainer = class _ACSContainer {
2607
2593
  }
2608
2594
  return acs;
2609
2595
  }
2610
- static async readACS(offset, key, api, wsSupport) {
2596
+ async readACS(offset, key, api, wsSupport) {
2611
2597
  if (wsSupport && wsSupport.enabled()) {
2612
- return _ACSContainer.readACSUsingWs(offset, key, wsSupport).catch(
2613
- () => {
2614
- console.log("Falling back to HTTP for ACS read");
2615
- return _ACSContainer.readHttpACS(offset, key, api);
2616
- }
2617
- );
2598
+ return this.readACSUsingWs(offset, key, wsSupport).catch(() => {
2599
+ console.log("Falling back to HTTP for ACS read");
2600
+ return this.readHttpACS(offset, key, api);
2601
+ });
2618
2602
  }
2619
- return _ACSContainer.readHttpACS(offset, key, api);
2603
+ return this.readHttpACS(offset, key, api);
2620
2604
  }
2621
- static async readHttpACS(offset, key, api) {
2622
- const format = _ACSContainer.createEventFormat(key);
2605
+ async readHttpACS(offset, key, api) {
2606
+ const format = this.createEventFormat(key);
2623
2607
  const acs = await api.postWithRetry("/v2/state/active-contracts", {
2624
2608
  activeAtOffset: offset,
2625
2609
  verbose: false,
@@ -2632,9 +2616,9 @@ var ACSContainer = class _ACSContainer {
2632
2616
  updates: []
2633
2617
  };
2634
2618
  }
2635
- static readACSUsingWs(offset, key, wsSupport) {
2619
+ readACSUsingWs(offset, key, wsSupport) {
2636
2620
  const wsACSURL = `${wsSupport.baseUrl}/v2/state/active-contracts`;
2637
- const format = _ACSContainer.createEventFormat(key);
2621
+ const format = this.createEventFormat(key);
2638
2622
  const request = {
2639
2623
  activeAtOffset: offset,
2640
2624
  verbose: false,
@@ -2687,7 +2671,7 @@ var ACSContainer = class _ACSContainer {
2687
2671
  };
2688
2672
  });
2689
2673
  }
2690
- static createInterfaceFilter(interfaceId) {
2674
+ createInterfaceFilter(interfaceId) {
2691
2675
  return {
2692
2676
  cumulative: [
2693
2677
  {
@@ -2696,7 +2680,7 @@ var ACSContainer = class _ACSContainer {
2696
2680
  value: {
2697
2681
  interfaceId,
2698
2682
  includeInterfaceView: true,
2699
- includeCreatedEventBlob: false
2683
+ includeCreatedEventBlob: this.settings.includeCreatedEventBlob
2700
2684
  }
2701
2685
  }
2702
2686
  }
@@ -2704,7 +2688,7 @@ var ACSContainer = class _ACSContainer {
2704
2688
  ]
2705
2689
  };
2706
2690
  }
2707
- static createTemplateFilter(templateId) {
2691
+ createTemplateFilter(templateId) {
2708
2692
  return {
2709
2693
  cumulative: [
2710
2694
  {
@@ -2712,7 +2696,7 @@ var ACSContainer = class _ACSContainer {
2712
2696
  TemplateFilter: {
2713
2697
  value: {
2714
2698
  templateId,
2715
- includeCreatedEventBlob: false
2699
+ includeCreatedEventBlob: this.settings.includeCreatedEventBlob
2716
2700
  }
2717
2701
  }
2718
2702
  }
@@ -2720,8 +2704,8 @@ var ACSContainer = class _ACSContainer {
2720
2704
  ]
2721
2705
  };
2722
2706
  }
2723
- static createEventFormat(key) {
2724
- const cumulativeFilter = key.templateId ? _ACSContainer.createTemplateFilter(key.templateId) : _ACSContainer.createInterfaceFilter(key.interfaceId ?? "");
2707
+ createEventFormat(key) {
2708
+ const cumulativeFilter = key.templateId ? this.createTemplateFilter(key.templateId) : this.createInterfaceFilter(key.interfaceId ?? "");
2725
2709
  const baseFormat = {
2726
2710
  filtersByParty: {},
2727
2711
  verbose: false
@@ -2750,6 +2734,7 @@ var ACSHelper = class _ACSHelper {
2750
2734
  __publicField(this, "apiInstance");
2751
2735
  __publicField(this, "wsSupport");
2752
2736
  __publicField(this, "logger");
2737
+ __publicField(this, "includeCreatedEventBlob");
2753
2738
  __publicField(this, "hits", 0);
2754
2739
  __publicField(this, "misses", 0);
2755
2740
  __publicField(this, "evictions", 0);
@@ -2769,6 +2754,7 @@ var ACSHelper = class _ACSHelper {
2769
2754
  this.apiInstance = apiInstance;
2770
2755
  this.wsSupport = options?.wsSupport;
2771
2756
  this.logger = _logger.child({ component: "ACSHelper" });
2757
+ this.includeCreatedEventBlob = options?.includeCreatedEventBlob ?? true;
2772
2758
  }
2773
2759
  getCacheStats() {
2774
2760
  const totalCalls = this.hits + this.misses;
@@ -2804,7 +2790,9 @@ var ACSHelper = class _ACSHelper {
2804
2790
  }
2805
2791
  this.logger.debug("cache miss");
2806
2792
  this.misses++;
2807
- const newContainer = new ACSContainer();
2793
+ const newContainer = new ACSContainer(void 0, {
2794
+ includeCreatedEventBlob: this.includeCreatedEventBlob
2795
+ });
2808
2796
  this.contractsSet.set(keyStr, newContainer);
2809
2797
  return newContainer;
2810
2798
  }
@@ -3116,7 +3104,7 @@ var LedgerClient = class {
3116
3104
  return this.valueOrError(resp);
3117
3105
  }
3118
3106
  /** TODO: simplify once 3.4 snapshot contains this endpoint */
3119
- async generateTopology(synchronizerId, publicKey, partyHint, localParticipantObservationOnly = false, confirmationThreshold = 1, otherConfirmingParticipantUids = []) {
3107
+ async generateTopology(synchronizerId, publicKey, partyHint, localParticipantObservationOnly = false, confirmationThreshold = 1, otherConfirmingParticipantUids = [], observingParticipantUids = []) {
3120
3108
  await this.init();
3121
3109
  if (this.clientVersion !== "3.3") {
3122
3110
  throw new Error(
@@ -3134,7 +3122,8 @@ var LedgerClient = class {
3134
3122
  },
3135
3123
  localParticipantObservationOnly,
3136
3124
  confirmationThreshold,
3137
- otherConfirmingParticipantUids
3125
+ otherConfirmingParticipantUids,
3126
+ observingParticipantUids
3138
3127
  };
3139
3128
  this.logger.debug(body, "generateTopology request body");
3140
3129
  const resp = await client.POST(