@canton-network/core-ledger-client 0.21.0 → 0.22.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.cjs CHANGED
@@ -1203,9 +1203,11 @@ var CoreService = class _CoreService {
1203
1203
  offset: ledgerEnd,
1204
1204
  interfaceIds: [interfaceId],
1205
1205
  parties: [partyId],
1206
- filterByParty: true,
1207
- limit: limit ?? 100
1206
+ filterByParty: true
1208
1207
  };
1208
+ if (limit !== void 0) {
1209
+ options.limit = limit;
1210
+ }
1209
1211
  const acsResponses = await this.ledgerClient.activeContracts(options);
1210
1212
  const isActiveContractEntry = (acsResponse) => "JsActiveContract" in acsResponse.contractEntry && !!acsResponse.contractEntry.JsActiveContract?.createdEvent;
1211
1213
  const activeContractEntries = acsResponses.filter(
@@ -1597,6 +1599,7 @@ var TransferService = class {
1597
1599
  };
1598
1600
  return [exercise, choiceContext.disclosedContracts];
1599
1601
  }
1602
+ // TODO: use named parameters
1600
1603
  async createTransfer(sender, receiver, amount, instrumentAdmin, instrumentId, registryUrl, inputUtxos, memo, expiryDate, meta, prefetchedRegistryChoiceContext) {
1601
1604
  try {
1602
1605
  const choiceArgs = await this.buildTransferChoiceArgs(
@@ -3130,8 +3133,26 @@ var LedgerClient = class {
3130
3133
  return this.valueOrError(resp);
3131
3134
  }
3132
3135
  }
3136
+ /*
3137
+ if limit is provided, this function performs a one-time query
3138
+ if limit is omitted, results may be served from the ACS cache
3139
+ current cache design doesn't support limiting queries because updates/deltas for the acs at offset x will be incorrect
3140
+ TODO: expose query mode vs subscribe mode to call queryActiveContracts vs subscribeActiveContracts
3141
+ */
3133
3142
  async activeContracts(options) {
3134
3143
  const { offset, templateIds, parties, interfaceIds, limit } = options;
3144
+ const hasLimit = typeof limit === "number";
3145
+ if (hasLimit) {
3146
+ const filter2 = this.buildActiveContractFilter(options);
3147
+ return await this.postWithRetry(
3148
+ "/v2/state/active-contracts",
3149
+ filter2,
3150
+ defaultRetryableOptions,
3151
+ {
3152
+ query: limit ? { limit: limit.toString() } : {}
3153
+ }
3154
+ );
3155
+ }
3135
3156
  this.logger.debug(options, "options for active contracts");
3136
3157
  const hasParties = Array.isArray(parties) && parties.length > 0;
3137
3158
  if (templateIds?.length && hasParties) {
@@ -3153,10 +3174,7 @@ var LedgerClient = class {
3153
3174
  return await this.postWithRetry(
3154
3175
  "/v2/state/active-contracts",
3155
3176
  filter,
3156
- defaultRetryableOptions,
3157
- {
3158
- query: limit ? { limit: limit.toString() } : {}
3159
- }
3177
+ defaultRetryableOptions
3160
3178
  );
3161
3179
  }
3162
3180
  buildActiveContractFilter(options) {