@canton-network/core-ledger-client 0.27.2 → 0.27.3
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 +47 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -33
- package/dist/index.js.map +1 -1
- package/dist/ledger-client.d.ts.map +1 -1
- package/dist/token-standard-service.d.ts +3 -3
- package/dist/token-standard-service.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1135,14 +1135,17 @@ var CoreService = class _CoreService {
|
|
|
1135
1135
|
);
|
|
1136
1136
|
}
|
|
1137
1137
|
// TODO: probably needs a filter by instrument ID as well?
|
|
1138
|
-
async getInputHoldingsCids(sender, inputUtxos, amount) {
|
|
1138
|
+
async getInputHoldingsCids(sender, inputUtxos, amount, continueUntilCompletion) {
|
|
1139
1139
|
const now = /* @__PURE__ */ new Date();
|
|
1140
1140
|
if (inputUtxos && inputUtxos.length > 0) {
|
|
1141
1141
|
return inputUtxos;
|
|
1142
1142
|
}
|
|
1143
1143
|
const senderHoldings = await this.listContractsByInterface(
|
|
1144
1144
|
coreTokenStandard.HOLDING_INTERFACE_ID,
|
|
1145
|
-
sender
|
|
1145
|
+
sender,
|
|
1146
|
+
void 0,
|
|
1147
|
+
void 0,
|
|
1148
|
+
continueUntilCompletion
|
|
1146
1149
|
);
|
|
1147
1150
|
if (senderHoldings.length === 0) {
|
|
1148
1151
|
throw new Error(
|
|
@@ -1566,11 +1569,12 @@ var TransferService = class {
|
|
|
1566
1569
|
this.core = core;
|
|
1567
1570
|
this.logger = logger;
|
|
1568
1571
|
}
|
|
1569
|
-
async buildTransferChoiceArgs(sender, receiver, amount, instrumentAdmin, instrumentId, inputUtxos, memo, expiryDate, meta) {
|
|
1572
|
+
async buildTransferChoiceArgs(sender, receiver, amount, instrumentAdmin, instrumentId, inputUtxos, memo, expiryDate, meta, continueUntilCompletion) {
|
|
1570
1573
|
const inputHoldingCids = await this.core.getInputHoldingsCids(
|
|
1571
1574
|
sender,
|
|
1572
1575
|
inputUtxos,
|
|
1573
|
-
parseFloat(amount)
|
|
1576
|
+
parseFloat(amount),
|
|
1577
|
+
continueUntilCompletion
|
|
1574
1578
|
);
|
|
1575
1579
|
return {
|
|
1576
1580
|
expectedAdmin: instrumentAdmin,
|
|
@@ -1618,7 +1622,7 @@ var TransferService = class {
|
|
|
1618
1622
|
return [exercise, choiceContext.disclosedContracts];
|
|
1619
1623
|
}
|
|
1620
1624
|
// TODO: use named parameters
|
|
1621
|
-
async createTransfer(sender, receiver, amount, instrumentAdmin, instrumentId, registryUrl, inputUtxos, memo, expiryDate, meta, prefetchedRegistryChoiceContext) {
|
|
1625
|
+
async createTransfer(sender, receiver, amount, instrumentAdmin, instrumentId, registryUrl, inputUtxos, memo, expiryDate, meta, prefetchedRegistryChoiceContext, continueUntilCompletion) {
|
|
1622
1626
|
try {
|
|
1623
1627
|
const choiceArgs = await this.buildTransferChoiceArgs(
|
|
1624
1628
|
sender,
|
|
@@ -1629,7 +1633,8 @@ var TransferService = class {
|
|
|
1629
1633
|
inputUtxos,
|
|
1630
1634
|
memo,
|
|
1631
1635
|
expiryDate,
|
|
1632
|
-
meta
|
|
1636
|
+
meta,
|
|
1637
|
+
continueUntilCompletion
|
|
1633
1638
|
);
|
|
1634
1639
|
if (prefetchedRegistryChoiceContext) {
|
|
1635
1640
|
return this.createTransferFromContext(
|
|
@@ -3183,14 +3188,16 @@ var LedgerClient = class {
|
|
|
3183
3188
|
limit,
|
|
3184
3189
|
continueUntilCompletion
|
|
3185
3190
|
} = options;
|
|
3191
|
+
if (continueUntilCompletion) {
|
|
3192
|
+
const filter2 = this.buildActiveContractFilter(options);
|
|
3193
|
+
return await this.fetchActiveContractsUntilComplete(
|
|
3194
|
+
filter2,
|
|
3195
|
+
limit ?? 200
|
|
3196
|
+
);
|
|
3197
|
+
}
|
|
3186
3198
|
const hasLimit = typeof limit === "number";
|
|
3187
3199
|
if (hasLimit) {
|
|
3188
3200
|
const filter2 = this.buildActiveContractFilter(options);
|
|
3189
|
-
if (continueUntilCompletion)
|
|
3190
|
-
return await this.fetchActiveContractsUntilComplete(
|
|
3191
|
-
filter2,
|
|
3192
|
-
limit
|
|
3193
|
-
);
|
|
3194
3201
|
return await this.postWithRetry(
|
|
3195
3202
|
"/v2/state/active-contracts",
|
|
3196
3203
|
filter2,
|
|
@@ -3231,7 +3238,6 @@ var LedgerClient = class {
|
|
|
3231
3238
|
* @private
|
|
3232
3239
|
*/
|
|
3233
3240
|
async fetchActiveContractsUntilComplete(activeContractsArgs, limit) {
|
|
3234
|
-
const result = [];
|
|
3235
3241
|
const ledgerEnd = await this.getWithRetry("/v2/state/ledger-end");
|
|
3236
3242
|
const bodyRequest = {
|
|
3237
3243
|
beginExclusive: 0,
|
|
@@ -3241,9 +3247,11 @@ var LedgerClient = class {
|
|
|
3241
3247
|
if (activeContractsArgs.filter)
|
|
3242
3248
|
bodyRequest.filter = activeContractsArgs.filter;
|
|
3243
3249
|
let currentOffset = 0;
|
|
3250
|
+
const allContractsData = /* @__PURE__ */ new Map();
|
|
3251
|
+
const exercisedContracts = /* @__PURE__ */ new Set();
|
|
3244
3252
|
while (currentOffset < ledgerEnd.offset) {
|
|
3245
3253
|
bodyRequest.beginExclusive = currentOffset;
|
|
3246
|
-
const
|
|
3254
|
+
const results = (await this.postWithRetry(
|
|
3247
3255
|
"/v2/updates",
|
|
3248
3256
|
bodyRequest,
|
|
3249
3257
|
defaultRetryableOptions,
|
|
@@ -3256,30 +3264,36 @@ var LedgerClient = class {
|
|
|
3256
3264
|
}
|
|
3257
3265
|
throw new Error("Expected Transaction update");
|
|
3258
3266
|
}).map((data) => {
|
|
3259
|
-
const
|
|
3260
|
-
(event) =>
|
|
3267
|
+
const exercisedEvents = data.events?.filter((event) => "ExercisedEvent" in event).map(
|
|
3268
|
+
(event) => event.ExercisedEvent
|
|
3269
|
+
).filter((event) => event.consuming);
|
|
3270
|
+
const createdEvents = data.events?.filter((event) => "CreatedEvent" in event).map(
|
|
3271
|
+
(event) => event.CreatedEvent
|
|
3261
3272
|
);
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
reassignmentCounter: data.offset
|
|
3273
|
+
exercisedEvents?.forEach((event) => {
|
|
3274
|
+
exercisedContracts.add(event.contractId);
|
|
3275
|
+
});
|
|
3276
|
+
createdEvents?.forEach((event) => {
|
|
3277
|
+
allContractsData.set(event.contractId, {
|
|
3278
|
+
workflowId: data.workflowId,
|
|
3279
|
+
contractEntry: {
|
|
3280
|
+
JsActiveContract: {
|
|
3281
|
+
synchronizerId: data.synchronizerId,
|
|
3282
|
+
createdEvent: event,
|
|
3283
|
+
reassignmentCounter: data.offset
|
|
3284
|
+
}
|
|
3275
3285
|
}
|
|
3276
|
-
}
|
|
3277
|
-
};
|
|
3286
|
+
});
|
|
3287
|
+
});
|
|
3288
|
+
currentOffset = Math.max(currentOffset, data.offset);
|
|
3289
|
+
return true;
|
|
3278
3290
|
});
|
|
3279
|
-
|
|
3280
|
-
if (!newResults.length) currentOffset++;
|
|
3291
|
+
if (!results.length) currentOffset++;
|
|
3281
3292
|
}
|
|
3282
|
-
|
|
3293
|
+
exercisedContracts.forEach((cid) => {
|
|
3294
|
+
allContractsData.delete(cid);
|
|
3295
|
+
});
|
|
3296
|
+
return Array.from(allContractsData.values());
|
|
3283
3297
|
}
|
|
3284
3298
|
buildActiveContractFilter(options) {
|
|
3285
3299
|
const filter = {
|