@canton-network/core-ledger-client 0.27.0 → 0.27.2
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/acs/acs-helper.d.ts +4 -4
- package/dist/acs/acs-helper.d.ts.map +1 -1
- package/dist/amulet-service.d.ts.map +1 -1
- package/dist/index.cjs +90 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -247
- package/dist/index.js.map +1 -1
- package/dist/ledger-api-utils.d.ts +0 -20
- package/dist/ledger-api-utils.d.ts.map +1 -1
- package/dist/ledger-client.d.ts +12 -2
- 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/dist/txparse/parser.d.ts +2 -2
- package/dist/txparse/parser.d.ts.map +1 -1
- package/dist/txparse/types.d.ts +3 -3
- package/dist/txparse/types.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/generated-clients/asyncapi-3.4.7.d.ts +0 -994
- package/dist/generated-clients/asyncapi-3.4.7.d.ts.map +0 -1
- package/dist/generated-clients/openapi-3.3.0-SNAPSHOT.d.ts +0 -6114
- package/dist/generated-clients/openapi-3.3.0-SNAPSHOT.d.ts.map +0 -1
- package/dist/generated-clients/openapi-3.4.7.d.ts +0 -7143
- package/dist/generated-clients/openapi-3.4.7.d.ts.map +0 -1
- package/dist/web-socket-client.d.ts +0 -44
- package/dist/web-socket-client.d.ts.map +0 -1
package/dist/acs/acs-helper.d.ts
CHANGED
|
@@ -34,17 +34,17 @@ export declare class ACSHelper {
|
|
|
34
34
|
private findACSContainer;
|
|
35
35
|
updateSingleKey(offset: number, key: ACSKey): Promise<({
|
|
36
36
|
workflowId: string;
|
|
37
|
-
contractEntry: import("
|
|
37
|
+
contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.3.0-SNAPSHOT").components["schemas"]["JsContractEntry"];
|
|
38
38
|
} | {
|
|
39
39
|
workflowId: string;
|
|
40
|
-
contractEntry: import("
|
|
40
|
+
contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.4.11").components["schemas"]["JsContractEntry"];
|
|
41
41
|
})[]>;
|
|
42
42
|
queryAcsByKeys(offset: number, keys: ACSKey[]): Promise<({
|
|
43
43
|
workflowId: string;
|
|
44
|
-
contractEntry: import("
|
|
44
|
+
contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.3.0-SNAPSHOT").components["schemas"]["JsContractEntry"];
|
|
45
45
|
} | {
|
|
46
46
|
workflowId: string;
|
|
47
|
-
contractEntry: import("
|
|
47
|
+
contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.4.11").components["schemas"]["JsContractEntry"];
|
|
48
48
|
})[]>;
|
|
49
49
|
activeContractsForTemplates(offset: number, parties: PartyId[], templateIds: string[]): Promise<JsGetActiveContractsResponse[]>;
|
|
50
50
|
activeContractsForInterfaces(offset: number, parties: PartyId[], interfaceIds: string[]): Promise<JsGetActiveContractsResponse[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acs-helper.d.ts","sourceRoot":"","sources":["../../src/acs/acs-helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAMzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AAEzD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,YAAY,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GACnB,OAAO,CAAC,4BAA4B,EAAE,CAAC;IAOpC,2BAA2B,CAC7B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,OAAO,GAAG,SAAS,EAChC,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;CAMlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amulet-service.d.ts","sourceRoot":"","sources":["../src/amulet-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACvB,MAAM,6BAA6B,CAAA;AAMpC;;;;;;GAMG;AACH,qBAAa,aAAa;IAElB,QAAQ,CAAC,aAAa,EAAE,oBAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFlB,aAAa,EAAE,oBAAoB,EAC3B,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,GAAG,SAAS;IAGjD,6BAA6B,CAAC,OAAO,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"amulet-service.d.ts","sourceRoot":"","sources":["../src/amulet-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAChF,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACvB,MAAM,6BAA6B,CAAA;AAMpC;;;;;;GAMG;AACH,qBAAa,aAAa;IAElB,QAAQ,CAAC,aAAa,EAAE,oBAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;gBAFlB,aAAa,EAAE,oBAAoB,EA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B,EAAE,CAAC,CAAC;CA2DrD"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var coreTokenStandard = require('@canton-network/core-token-standard');
|
|
4
|
+
var coreLedgerClientTypes = require('@canton-network/core-ledger-client-types');
|
|
4
5
|
var coreLedgerProto = require('@canton-network/core-ledger-proto');
|
|
5
6
|
var BigNumber = require('bignumber.js');
|
|
6
7
|
var createClient = require('openapi-fetch');
|
|
@@ -50,131 +51,6 @@ var AllKnownMetaKeys = [
|
|
|
50
51
|
ReasonMetaKey,
|
|
51
52
|
BurnedMetaKey
|
|
52
53
|
];
|
|
53
|
-
function createIdentiferFilter(type, id) {
|
|
54
|
-
if (type === "Template") {
|
|
55
|
-
return {
|
|
56
|
-
identifierFilter: {
|
|
57
|
-
TemplateFilter: {
|
|
58
|
-
value: {
|
|
59
|
-
templateId: id,
|
|
60
|
-
includeCreatedEventBlob: true
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
} else {
|
|
66
|
-
return {
|
|
67
|
-
identifierFilter: {
|
|
68
|
-
InterfaceFilter: {
|
|
69
|
-
value: {
|
|
70
|
-
interfaceId: id,
|
|
71
|
-
includeInterfaceView: true,
|
|
72
|
-
includeCreatedEventBlob: true
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function createWildcardFilter() {
|
|
80
|
-
return {
|
|
81
|
-
identifierFilter: {
|
|
82
|
-
WildcardFilter: {
|
|
83
|
-
value: {
|
|
84
|
-
includeCreatedEventBlob: true
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function buildCumulativeFilters(templateIds, interfaceIds, includeWildcard) {
|
|
91
|
-
if (templateIds.length > 0) {
|
|
92
|
-
return [
|
|
93
|
-
...templateIds.map(
|
|
94
|
-
(templateId) => createIdentiferFilter("Template", templateId)
|
|
95
|
-
),
|
|
96
|
-
...includeWildcard ? [createWildcardFilter()] : []
|
|
97
|
-
];
|
|
98
|
-
} else {
|
|
99
|
-
return [
|
|
100
|
-
...interfaceIds.map(
|
|
101
|
-
(interfaceId) => createIdentiferFilter("Interface", interfaceId)
|
|
102
|
-
),
|
|
103
|
-
...includeWildcard ? [createWildcardFilter()] : []
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function buildFilter(templateIds, interfaceIds, options, additionalProps) {
|
|
108
|
-
const { isMasterUser = false, partyId, includeWildcard = false } = options;
|
|
109
|
-
if (isMasterUser) {
|
|
110
|
-
return {
|
|
111
|
-
filtersByParty: {},
|
|
112
|
-
filtersForAnyParty: filtersForAnyParty(
|
|
113
|
-
templateIds,
|
|
114
|
-
interfaceIds,
|
|
115
|
-
includeWildcard
|
|
116
|
-
),
|
|
117
|
-
...additionalProps
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (!partyId) {
|
|
121
|
-
throw new Error("Party must be provided for non-master users");
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
filtersByParty: filtersByParty(
|
|
125
|
-
partyId,
|
|
126
|
-
templateIds,
|
|
127
|
-
interfaceIds,
|
|
128
|
-
includeWildcard
|
|
129
|
-
),
|
|
130
|
-
...additionalProps
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function TransactionFilterBySetup(options) {
|
|
134
|
-
const { templateIds, interfaceIds, ...baseOptions } = options;
|
|
135
|
-
return buildFilter(
|
|
136
|
-
normalizeToArray(templateIds || []),
|
|
137
|
-
normalizeToArray(interfaceIds || []),
|
|
138
|
-
baseOptions
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
function EventFilterBySetup(options) {
|
|
142
|
-
const {
|
|
143
|
-
templateIds,
|
|
144
|
-
interfaceIds,
|
|
145
|
-
verbose = false,
|
|
146
|
-
...baseOptions
|
|
147
|
-
} = options;
|
|
148
|
-
return buildFilter(
|
|
149
|
-
normalizeToArray(templateIds || []),
|
|
150
|
-
normalizeToArray(interfaceIds || []),
|
|
151
|
-
baseOptions,
|
|
152
|
-
{ verbose }
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
function filtersByParty(party, templateIds, interfaceIds, includeWildcard) {
|
|
156
|
-
return {
|
|
157
|
-
[party]: {
|
|
158
|
-
cumulative: buildCumulativeFilters(
|
|
159
|
-
templateIds,
|
|
160
|
-
interfaceIds,
|
|
161
|
-
includeWildcard
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function filtersForAnyParty(interfaceNames, templateIds, includeWildcard) {
|
|
167
|
-
return {
|
|
168
|
-
cumulative: buildCumulativeFilters(
|
|
169
|
-
templateIds,
|
|
170
|
-
interfaceNames,
|
|
171
|
-
includeWildcard
|
|
172
|
-
)
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function normalizeToArray(value) {
|
|
176
|
-
return Array.isArray(value) ? value : [value];
|
|
177
|
-
}
|
|
178
54
|
function hasInterface(interfaceId, event) {
|
|
179
55
|
return (event.implementedInterfaces || []).some(
|
|
180
56
|
(id) => matchInterfaceIds(id, interfaceId)
|
|
@@ -1023,7 +899,7 @@ var TransactionParser = class {
|
|
|
1023
899
|
}
|
|
1024
900
|
const basePayload = {
|
|
1025
901
|
contractId: archivedEvent.contractId,
|
|
1026
|
-
eventFormat: EventFilterBySetup({
|
|
902
|
+
eventFormat: coreLedgerClientTypes.EventFilterBySetup({
|
|
1027
903
|
interfaceIds: [
|
|
1028
904
|
coreTokenStandard.HOLDING_INTERFACE_ID,
|
|
1029
905
|
coreTokenStandard.TRANSFER_INSTRUCTION_INTERFACE_ID
|
|
@@ -1331,14 +1207,15 @@ var CoreService = class _CoreService {
|
|
|
1331
1207
|
}
|
|
1332
1208
|
return cIds;
|
|
1333
1209
|
}
|
|
1334
|
-
async listContractsByInterface(interfaceId, partyId, limit, offset) {
|
|
1210
|
+
async listContractsByInterface(interfaceId, partyId, limit, offset, continueUntilCompletion) {
|
|
1335
1211
|
try {
|
|
1336
1212
|
const ledgerEnd = offset ?? (await this.ledgerClient.getWithRetry("/v2/state/ledger-end")).offset;
|
|
1337
1213
|
const options = {
|
|
1338
1214
|
offset: ledgerEnd,
|
|
1339
1215
|
interfaceIds: [interfaceId],
|
|
1340
1216
|
parties: [partyId],
|
|
1341
|
-
filterByParty: true
|
|
1217
|
+
filterByParty: true,
|
|
1218
|
+
continueUntilCompletion: Boolean(continueUntilCompletion)
|
|
1342
1219
|
};
|
|
1343
1220
|
if (limit !== void 0) {
|
|
1344
1221
|
options.limit = limit;
|
|
@@ -2106,12 +1983,13 @@ var TokenStandardService = class {
|
|
|
2106
1983
|
}
|
|
2107
1984
|
// <T> is shape of viewValue related to queried interface.
|
|
2108
1985
|
// i.e. when querying by TransferInstruction interfaceId, <T> would be TransferInstructionView from daml codegen
|
|
2109
|
-
async listContractsByInterface(interfaceId, partyId, limit, offset) {
|
|
1986
|
+
async listContractsByInterface(interfaceId, partyId, limit, offset, continueUntilCompletion) {
|
|
2110
1987
|
return this.core.listContractsByInterface(
|
|
2111
1988
|
interfaceId,
|
|
2112
1989
|
partyId,
|
|
2113
1990
|
limit,
|
|
2114
|
-
offset
|
|
1991
|
+
offset,
|
|
1992
|
+
continueUntilCompletion
|
|
2115
1993
|
);
|
|
2116
1994
|
}
|
|
2117
1995
|
async listHoldingTransactions(partyId, afterOffset, beforeOffset) {
|
|
@@ -2125,7 +2003,7 @@ var TokenStandardService = class {
|
|
|
2125
2003
|
const updatesResponse = await this.ledgerClient.postWithRetry("/v2/updates/flats", {
|
|
2126
2004
|
updateFormat: {
|
|
2127
2005
|
includeTransactions: {
|
|
2128
|
-
eventFormat: EventFilterBySetup({
|
|
2006
|
+
eventFormat: coreLedgerClientTypes.EventFilterBySetup({
|
|
2129
2007
|
interfaceIds: TokenStandardTransactionInterfaces,
|
|
2130
2008
|
isMasterUser: this.isMasterUser,
|
|
2131
2009
|
partyId,
|
|
@@ -2150,7 +2028,7 @@ var TokenStandardService = class {
|
|
|
2150
2028
|
}
|
|
2151
2029
|
async getTransactionById(updateId, partyId) {
|
|
2152
2030
|
const transactionFormat = {
|
|
2153
|
-
eventFormat: EventFilterBySetup({
|
|
2031
|
+
eventFormat: coreLedgerClientTypes.EventFilterBySetup({
|
|
2154
2032
|
interfaceIds: TokenStandardTransactionInterfaces,
|
|
2155
2033
|
isMasterUser: this.isMasterUser,
|
|
2156
2034
|
partyId,
|
|
@@ -3291,23 +3169,33 @@ var LedgerClient = class {
|
|
|
3291
3169
|
}
|
|
3292
3170
|
}
|
|
3293
3171
|
/*
|
|
3294
|
-
if limit is provided, this function performs a one-time query
|
|
3172
|
+
if limit is provided, this function performs a one-time query. Automatically splits into multiple `/v2/updates` calls with `continueUntilCompletion` on.
|
|
3295
3173
|
if limit is omitted, results may be served from the ACS cache
|
|
3296
3174
|
current cache design doesn't support limiting queries because updates/deltas for the acs at offset x will be incorrect
|
|
3297
3175
|
TODO: expose query mode vs subscribe mode to call queryActiveContracts vs subscribeActiveContracts
|
|
3298
3176
|
*/
|
|
3299
3177
|
async activeContracts(options) {
|
|
3300
|
-
const {
|
|
3178
|
+
const {
|
|
3179
|
+
offset,
|
|
3180
|
+
templateIds,
|
|
3181
|
+
parties,
|
|
3182
|
+
interfaceIds,
|
|
3183
|
+
limit,
|
|
3184
|
+
continueUntilCompletion
|
|
3185
|
+
} = options;
|
|
3301
3186
|
const hasLimit = typeof limit === "number";
|
|
3302
3187
|
if (hasLimit) {
|
|
3303
3188
|
const filter2 = this.buildActiveContractFilter(options);
|
|
3189
|
+
if (continueUntilCompletion)
|
|
3190
|
+
return await this.fetchActiveContractsUntilComplete(
|
|
3191
|
+
filter2,
|
|
3192
|
+
limit
|
|
3193
|
+
);
|
|
3304
3194
|
return await this.postWithRetry(
|
|
3305
3195
|
"/v2/state/active-contracts",
|
|
3306
3196
|
filter2,
|
|
3307
3197
|
defaultRetryableOptions,
|
|
3308
|
-
{
|
|
3309
|
-
query: limit ? { limit: limit.toString() } : {}
|
|
3310
|
-
}
|
|
3198
|
+
{ query: { limit: limit.toString() } }
|
|
3311
3199
|
);
|
|
3312
3200
|
}
|
|
3313
3201
|
this.logger.debug(options, "options for active contracts");
|
|
@@ -3334,6 +3222,65 @@ var LedgerClient = class {
|
|
|
3334
3222
|
defaultRetryableOptions
|
|
3335
3223
|
);
|
|
3336
3224
|
}
|
|
3225
|
+
/**
|
|
3226
|
+
* Fetches active contracts by splitting requests into multiple `/v2/updates` calls.
|
|
3227
|
+
* Should only be used when the number of contracts exceeds http-list-max-elements-limit (200 by default).
|
|
3228
|
+
* For limits at or below http-list-max-elements-limit, use a single `/v2/state/active-contracts` call instead.
|
|
3229
|
+
* @param activeContractsArgs The request parameters for active contracts query
|
|
3230
|
+
* @returns A promise that resolves to an array of active contract responses
|
|
3231
|
+
* @private
|
|
3232
|
+
*/
|
|
3233
|
+
async fetchActiveContractsUntilComplete(activeContractsArgs, limit) {
|
|
3234
|
+
const result = [];
|
|
3235
|
+
const ledgerEnd = await this.getWithRetry("/v2/state/ledger-end");
|
|
3236
|
+
const bodyRequest = {
|
|
3237
|
+
beginExclusive: 0,
|
|
3238
|
+
endInclusive: ledgerEnd.offset,
|
|
3239
|
+
verbose: false
|
|
3240
|
+
};
|
|
3241
|
+
if (activeContractsArgs.filter)
|
|
3242
|
+
bodyRequest.filter = activeContractsArgs.filter;
|
|
3243
|
+
let currentOffset = 0;
|
|
3244
|
+
while (currentOffset < ledgerEnd.offset) {
|
|
3245
|
+
bodyRequest.beginExclusive = currentOffset;
|
|
3246
|
+
const newResults = (await this.postWithRetry(
|
|
3247
|
+
"/v2/updates",
|
|
3248
|
+
bodyRequest,
|
|
3249
|
+
defaultRetryableOptions,
|
|
3250
|
+
{
|
|
3251
|
+
query: { limit: limit.toString() }
|
|
3252
|
+
}
|
|
3253
|
+
)).filter(({ update }) => "Transaction" in update).map(({ update }) => {
|
|
3254
|
+
if ("Transaction" in update) {
|
|
3255
|
+
return update.Transaction.value;
|
|
3256
|
+
}
|
|
3257
|
+
throw new Error("Expected Transaction update");
|
|
3258
|
+
}).map((data) => {
|
|
3259
|
+
const createdEvent = data.events?.find(
|
|
3260
|
+
(event) => typeof event === "object" && event !== null && "CreatedEvent" in event
|
|
3261
|
+
);
|
|
3262
|
+
if (!createdEvent || !("CreatedEvent" in createdEvent)) {
|
|
3263
|
+
throw new Error(
|
|
3264
|
+
"CreatedEvent not found in transaction events"
|
|
3265
|
+
);
|
|
3266
|
+
}
|
|
3267
|
+
currentOffset = Math.max(currentOffset, data.offset);
|
|
3268
|
+
return {
|
|
3269
|
+
workflowId: data.workflowId,
|
|
3270
|
+
contractEntry: {
|
|
3271
|
+
JsActiveContract: {
|
|
3272
|
+
synchronizerId: data.synchronizerId,
|
|
3273
|
+
createdEvent: createdEvent.CreatedEvent,
|
|
3274
|
+
reassignmentCounter: data.offset
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
};
|
|
3278
|
+
});
|
|
3279
|
+
result.push(...newResults);
|
|
3280
|
+
if (!newResults.length) currentOffset++;
|
|
3281
|
+
}
|
|
3282
|
+
return result;
|
|
3283
|
+
}
|
|
3337
3284
|
buildActiveContractFilter(options) {
|
|
3338
3285
|
const filter = {
|
|
3339
3286
|
filter: {
|
|
@@ -3493,118 +3440,6 @@ var WSSupportWithBackOffSwitch = class {
|
|
|
3493
3440
|
}
|
|
3494
3441
|
};
|
|
3495
3442
|
|
|
3496
|
-
// src/generated-clients/asyncapi-3.4.7.ts
|
|
3497
|
-
var CHANNELS = {
|
|
3498
|
-
v2_commands_completions: "/v2/commands/completions",
|
|
3499
|
-
v2_updates: "/v2/updates"};
|
|
3500
|
-
|
|
3501
|
-
// src/web-socket-client.ts
|
|
3502
|
-
var WebSocketClient = class {
|
|
3503
|
-
constructor({
|
|
3504
|
-
baseUrl,
|
|
3505
|
-
isAdmin,
|
|
3506
|
-
accessTokenProvider,
|
|
3507
|
-
logger,
|
|
3508
|
-
wsSupportBackOff
|
|
3509
|
-
}) {
|
|
3510
|
-
__publicField(this, "ws", null);
|
|
3511
|
-
__publicField(this, "baseUrl");
|
|
3512
|
-
__publicField(this, "token", "");
|
|
3513
|
-
__publicField(this, "isAdmin");
|
|
3514
|
-
__publicField(this, "protocol", []);
|
|
3515
|
-
__publicField(this, "logger");
|
|
3516
|
-
__publicField(this, "wsSupportBackOff");
|
|
3517
|
-
__publicField(this, "accessTokenProvider");
|
|
3518
|
-
this.logger = logger.child({ component: "WebSocketClient" });
|
|
3519
|
-
this.baseUrl = baseUrl;
|
|
3520
|
-
this.wsSupportBackOff = wsSupportBackOff;
|
|
3521
|
-
this.accessTokenProvider = accessTokenProvider;
|
|
3522
|
-
this.isAdmin = isAdmin ?? false;
|
|
3523
|
-
}
|
|
3524
|
-
async init() {
|
|
3525
|
-
this.token = this.isAdmin ? await this.accessTokenProvider.getAdminAccessToken() : await this.accessTokenProvider.getUserAccessToken();
|
|
3526
|
-
this.protocol = [`jwt.token.${this.token}`, "daml.ws.auth"];
|
|
3527
|
-
this.logger.info(
|
|
3528
|
-
`initializing websocket client with ${this.protocol.length} protocols`
|
|
3529
|
-
);
|
|
3530
|
-
}
|
|
3531
|
-
generate(wsUrl, request) {
|
|
3532
|
-
const messageQueue = [];
|
|
3533
|
-
let resolveNext = null;
|
|
3534
|
-
let isClosed = false;
|
|
3535
|
-
let streamError = null;
|
|
3536
|
-
const generator = async function* () {
|
|
3537
|
-
await this.init();
|
|
3538
|
-
this.logger.debug(request);
|
|
3539
|
-
const ws = new WebSocket(wsUrl, this.protocol);
|
|
3540
|
-
ws.onopen = () => {
|
|
3541
|
-
ws.send(JSON.stringify(request));
|
|
3542
|
-
};
|
|
3543
|
-
ws.onmessage = (event) => {
|
|
3544
|
-
messageQueue.push(JSON.parse(event.data));
|
|
3545
|
-
this.logger.debug(event.data, `Received event`);
|
|
3546
|
-
resolveNext?.();
|
|
3547
|
-
};
|
|
3548
|
-
ws.onerror = () => {
|
|
3549
|
-
streamError = new Error("WebSocket Handshake/Connection failed");
|
|
3550
|
-
this.logger.error(`Encountered ws.onError`);
|
|
3551
|
-
isClosed = true;
|
|
3552
|
-
resolveNext?.();
|
|
3553
|
-
};
|
|
3554
|
-
ws.onclose = (event) => {
|
|
3555
|
-
this.logger.debug(
|
|
3556
|
-
`CLOSING WEBSOCKET CONNECTION code: ${event.code}, reason: ${event.reason}`
|
|
3557
|
-
);
|
|
3558
|
-
isClosed = true;
|
|
3559
|
-
resolveNext?.();
|
|
3560
|
-
};
|
|
3561
|
-
try {
|
|
3562
|
-
while (true) {
|
|
3563
|
-
if (messageQueue.length === 0) {
|
|
3564
|
-
if (isClosed) break;
|
|
3565
|
-
await new Promise((r) => resolveNext = r);
|
|
3566
|
-
}
|
|
3567
|
-
if (streamError) throw streamError;
|
|
3568
|
-
while (messageQueue.length > 0) {
|
|
3569
|
-
yield messageQueue.shift();
|
|
3570
|
-
}
|
|
3571
|
-
if (isClosed && messageQueue.length === 0) break;
|
|
3572
|
-
}
|
|
3573
|
-
} finally {
|
|
3574
|
-
if (ws.readyState === WebSocket.OPEN) ws.close();
|
|
3575
|
-
this.logger.info("Generator cleanup: WebSocket closed.");
|
|
3576
|
-
}
|
|
3577
|
-
};
|
|
3578
|
-
return generator.call(this);
|
|
3579
|
-
}
|
|
3580
|
-
streamUpdates(options) {
|
|
3581
|
-
const wsUpdatesUrl = `${this.baseUrl}${CHANNELS.v2_updates}`;
|
|
3582
|
-
const filter = options.templateIds ? TransactionFilterBySetup({
|
|
3583
|
-
templateIds: options.templateIds,
|
|
3584
|
-
partyId: options.partyId
|
|
3585
|
-
}) : TransactionFilterBySetup({
|
|
3586
|
-
interfaceIds: options.interfaceIds,
|
|
3587
|
-
partyId: options.partyId
|
|
3588
|
-
});
|
|
3589
|
-
const request = {
|
|
3590
|
-
beginExclusive: options.beginExclusive,
|
|
3591
|
-
endInclusive: options.endInclusive,
|
|
3592
|
-
verbose: options.verbose ?? true,
|
|
3593
|
-
filter
|
|
3594
|
-
};
|
|
3595
|
-
return this.generate(wsUpdatesUrl, request);
|
|
3596
|
-
}
|
|
3597
|
-
streamCompletions(options) {
|
|
3598
|
-
const wsCompletionsUrl = `${this.baseUrl}${CHANNELS.v2_commands_completions}`;
|
|
3599
|
-
const request = {
|
|
3600
|
-
beginExclusive: options.beginExclusive,
|
|
3601
|
-
userId: options.userId,
|
|
3602
|
-
parties: options.parties
|
|
3603
|
-
};
|
|
3604
|
-
return this.generate(wsCompletionsUrl, request);
|
|
3605
|
-
}
|
|
3606
|
-
};
|
|
3607
|
-
|
|
3608
3443
|
exports.ACSContainer = ACSContainer;
|
|
3609
3444
|
exports.ACS_UPDATE_CONFIG = ACS_UPDATE_CONFIG;
|
|
3610
3445
|
exports.AmuletService = AmuletService;
|
|
@@ -3614,12 +3449,17 @@ exports.TokenStandardService = TokenStandardService;
|
|
|
3614
3449
|
exports.TokenStandardTransactionInterfaces = TokenStandardTransactionInterfaces;
|
|
3615
3450
|
exports.TransactionParser = TransactionParser;
|
|
3616
3451
|
exports.WSSupportWithBackOffSwitch = WSSupportWithBackOffSwitch;
|
|
3617
|
-
exports.WebSocketClient = WebSocketClient;
|
|
3618
3452
|
exports.asJsCantonError = asJsCantonError;
|
|
3619
3453
|
exports.awaitCompletion = awaitCompletion;
|
|
3620
3454
|
exports.defaultRetryableOptions = defaultRetryableOptions;
|
|
3621
3455
|
exports.isJsCantonError = isJsCantonError;
|
|
3622
3456
|
exports.promiseWithTimeout = promiseWithTimeout;
|
|
3623
3457
|
exports.supportedVersions = supportedVersions;
|
|
3458
|
+
Object.keys(coreLedgerClientTypes).forEach(function (k) {
|
|
3459
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
3460
|
+
enumerable: true,
|
|
3461
|
+
get: function () { return coreLedgerClientTypes[k]; }
|
|
3462
|
+
});
|
|
3463
|
+
});
|
|
3624
3464
|
//# sourceMappingURL=index.cjs.map
|
|
3625
3465
|
//# sourceMappingURL=index.cjs.map
|