@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.js CHANGED
@@ -1196,9 +1196,11 @@ var CoreService = class _CoreService {
1196
1196
  offset: ledgerEnd,
1197
1197
  interfaceIds: [interfaceId],
1198
1198
  parties: [partyId],
1199
- filterByParty: true,
1200
- limit: limit ?? 100
1199
+ filterByParty: true
1201
1200
  };
1201
+ if (limit !== void 0) {
1202
+ options.limit = limit;
1203
+ }
1202
1204
  const acsResponses = await this.ledgerClient.activeContracts(options);
1203
1205
  const isActiveContractEntry = (acsResponse) => "JsActiveContract" in acsResponse.contractEntry && !!acsResponse.contractEntry.JsActiveContract?.createdEvent;
1204
1206
  const activeContractEntries = acsResponses.filter(
@@ -1590,6 +1592,7 @@ var TransferService = class {
1590
1592
  };
1591
1593
  return [exercise, choiceContext.disclosedContracts];
1592
1594
  }
1595
+ // TODO: use named parameters
1593
1596
  async createTransfer(sender, receiver, amount, instrumentAdmin, instrumentId, registryUrl, inputUtxos, memo, expiryDate, meta, prefetchedRegistryChoiceContext) {
1594
1597
  try {
1595
1598
  const choiceArgs = await this.buildTransferChoiceArgs(
@@ -3123,8 +3126,26 @@ var LedgerClient = class {
3123
3126
  return this.valueOrError(resp);
3124
3127
  }
3125
3128
  }
3129
+ /*
3130
+ if limit is provided, this function performs a one-time query
3131
+ if limit is omitted, results may be served from the ACS cache
3132
+ current cache design doesn't support limiting queries because updates/deltas for the acs at offset x will be incorrect
3133
+ TODO: expose query mode vs subscribe mode to call queryActiveContracts vs subscribeActiveContracts
3134
+ */
3126
3135
  async activeContracts(options) {
3127
3136
  const { offset, templateIds, parties, interfaceIds, limit } = options;
3137
+ const hasLimit = typeof limit === "number";
3138
+ if (hasLimit) {
3139
+ const filter2 = this.buildActiveContractFilter(options);
3140
+ return await this.postWithRetry(
3141
+ "/v2/state/active-contracts",
3142
+ filter2,
3143
+ defaultRetryableOptions,
3144
+ {
3145
+ query: limit ? { limit: limit.toString() } : {}
3146
+ }
3147
+ );
3148
+ }
3128
3149
  this.logger.debug(options, "options for active contracts");
3129
3150
  const hasParties = Array.isArray(parties) && parties.length > 0;
3130
3151
  if (templateIds?.length && hasParties) {
@@ -3146,10 +3167,7 @@ var LedgerClient = class {
3146
3167
  return await this.postWithRetry(
3147
3168
  "/v2/state/active-contracts",
3148
3169
  filter,
3149
- defaultRetryableOptions,
3150
- {
3151
- query: limit ? { limit: limit.toString() } : {}
3152
- }
3170
+ defaultRetryableOptions
3153
3171
  );
3154
3172
  }
3155
3173
  buildActiveContractFilter(options) {