@canton-network/core-ledger-client 0.24.0 → 0.25.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/amulet-service.d.ts.map +1 -1
- package/dist/index.cjs +259 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +259 -100
- package/dist/index.js.map +1 -1
- package/dist/ledger-api-utils.d.ts +14 -7
- package/dist/ledger-api-utils.d.ts.map +1 -1
- package/dist/token-standard-service.d.ts.map +1 -1
- package/dist/txparse/parser.d.ts.map +1 -1
- package/dist/web-socket-client.d.ts +44 -0
- package/dist/web-socket-client.d.ts.map +1 -0
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export type { Transaction, TokenStandardEvent, Holding, HoldingLock, HoldingsCha
|
|
|
8
8
|
export { TransactionParser } from './txparse/parser.js';
|
|
9
9
|
export { TokenStandardTransactionInterfaces } from './constants.js';
|
|
10
10
|
export { awaitCompletion, promiseWithTimeout, isJsCantonError, asJsCantonError, JsCantonError, JSContractEntry, defaultRetryableOptions, } from './ledger-api-utils.js';
|
|
11
|
+
export * from './web-socket-client.js';
|
|
12
|
+
export { GetUpdatesRequest, JsGetUpdatesResponse, CompletionResponse, } from './generated-clients/asyncapi-3.4.7.js';
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,6BAA6B,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,cAAc,oBAAoB,CAAA;AAClC,cAAc,+CAA+C,CAAA;AAC7D,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,YAAY,EACR,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,KAAK,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,UAAU,EACV,UAAU,EACV,SAAS,GACZ,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,GAC1B,MAAM,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,6BAA6B,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,cAAc,oBAAoB,CAAA;AAClC,cAAc,+CAA+C,CAAA;AAC7D,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,YAAY,EACR,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,KAAK,EACL,UAAU,EACV,WAAW,EACX,UAAU,EACV,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,UAAU,EACV,UAAU,EACV,SAAS,GACZ,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAA;AAEnE,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,GAC1B,MAAM,uBAAuB,CAAA;AAE9B,cAAc,wBAAwB,CAAA;AACtC,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,kBAAkB,GACrB,MAAM,uCAAuC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -43,93 +43,131 @@ var AllKnownMetaKeys = [
|
|
|
43
43
|
ReasonMetaKey,
|
|
44
44
|
BurnedMetaKey
|
|
45
45
|
];
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
if (options.isMasterUser)
|
|
46
|
+
function createIdentiferFilter(type, id) {
|
|
47
|
+
if (type === "Template") {
|
|
49
48
|
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
identifierFilter: {
|
|
50
|
+
TemplateFilter: {
|
|
51
|
+
value: {
|
|
52
|
+
templateId: id,
|
|
53
|
+
includeCreatedEventBlob: true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
56
57
|
};
|
|
57
|
-
else
|
|
58
|
-
throw new Error("Party must be provided for non-master users");
|
|
59
|
-
else
|
|
58
|
+
} else {
|
|
60
59
|
return {
|
|
61
|
-
filtersByParty: filtersByParty(
|
|
62
|
-
options.partyId,
|
|
63
|
-
interfaceArrayed,
|
|
64
|
-
options.includeWildcard ?? false
|
|
65
|
-
) ?? {},
|
|
66
|
-
verbose: options.verbose ?? false
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function filtersByParty(party, interfaceNames, includeWildcard) {
|
|
70
|
-
const wildcardFilter = includeWildcard ? [
|
|
71
|
-
{
|
|
72
60
|
identifierFilter: {
|
|
73
|
-
|
|
61
|
+
InterfaceFilter: {
|
|
74
62
|
value: {
|
|
63
|
+
interfaceId: id,
|
|
64
|
+
includeInterfaceView: true,
|
|
75
65
|
includeCreatedEventBlob: true
|
|
76
66
|
}
|
|
77
67
|
}
|
|
78
68
|
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function createWildcardFilter() {
|
|
73
|
+
return {
|
|
74
|
+
identifierFilter: {
|
|
75
|
+
WildcardFilter: {
|
|
76
|
+
value: {
|
|
77
|
+
includeCreatedEventBlob: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function buildCumulativeFilters(templateIds, interfaceIds, includeWildcard) {
|
|
84
|
+
if (templateIds.length > 0) {
|
|
85
|
+
return [
|
|
86
|
+
...templateIds.map(
|
|
87
|
+
(templateId) => createIdentiferFilter("Template", templateId)
|
|
88
|
+
),
|
|
89
|
+
...includeWildcard ? [createWildcardFilter()] : []
|
|
90
|
+
];
|
|
91
|
+
} else {
|
|
92
|
+
return [
|
|
93
|
+
...interfaceIds.map(
|
|
94
|
+
(interfaceId) => createIdentiferFilter("Interface", interfaceId)
|
|
95
|
+
),
|
|
96
|
+
...includeWildcard ? [createWildcardFilter()] : []
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function buildFilter(templateIds, interfaceIds, options, additionalProps) {
|
|
101
|
+
const { isMasterUser = false, partyId, includeWildcard = false } = options;
|
|
102
|
+
if (isMasterUser) {
|
|
103
|
+
return {
|
|
104
|
+
filtersByParty: {},
|
|
105
|
+
filtersForAnyParty: filtersForAnyParty(
|
|
106
|
+
templateIds,
|
|
107
|
+
interfaceIds,
|
|
108
|
+
includeWildcard
|
|
109
|
+
),
|
|
110
|
+
...additionalProps
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
if (!partyId) {
|
|
114
|
+
throw new Error("Party must be provided for non-master users");
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
filtersByParty: filtersByParty(
|
|
118
|
+
partyId,
|
|
119
|
+
templateIds,
|
|
120
|
+
interfaceIds,
|
|
121
|
+
includeWildcard
|
|
122
|
+
),
|
|
123
|
+
...additionalProps
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function TransactionFilterBySetup(options) {
|
|
127
|
+
const { templateIds, interfaceIds, ...baseOptions } = options;
|
|
128
|
+
return buildFilter(
|
|
129
|
+
normalizeToArray(templateIds || []),
|
|
130
|
+
normalizeToArray(interfaceIds || []),
|
|
131
|
+
baseOptions
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
function EventFilterBySetup(options) {
|
|
135
|
+
const {
|
|
136
|
+
templateIds,
|
|
137
|
+
interfaceIds,
|
|
138
|
+
verbose = false,
|
|
139
|
+
...baseOptions
|
|
140
|
+
} = options;
|
|
141
|
+
return buildFilter(
|
|
142
|
+
normalizeToArray(templateIds || []),
|
|
143
|
+
normalizeToArray(interfaceIds || []),
|
|
144
|
+
baseOptions,
|
|
145
|
+
{ verbose }
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
function filtersByParty(party, templateIds, interfaceIds, includeWildcard) {
|
|
81
149
|
return {
|
|
82
150
|
[party]: {
|
|
83
|
-
cumulative:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value: {
|
|
89
|
-
interfaceId: interfaceName,
|
|
90
|
-
includeInterfaceView: true,
|
|
91
|
-
includeCreatedEventBlob: true
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}),
|
|
97
|
-
...wildcardFilter
|
|
98
|
-
]
|
|
151
|
+
cumulative: buildCumulativeFilters(
|
|
152
|
+
templateIds,
|
|
153
|
+
interfaceIds,
|
|
154
|
+
includeWildcard
|
|
155
|
+
)
|
|
99
156
|
}
|
|
100
157
|
};
|
|
101
158
|
}
|
|
102
|
-
function filtersForAnyParty(interfaceNames, includeWildcard) {
|
|
103
|
-
const wildcardFilter = includeWildcard ? [
|
|
104
|
-
{
|
|
105
|
-
identifierFilter: {
|
|
106
|
-
WildcardFilter: {
|
|
107
|
-
value: {
|
|
108
|
-
includeCreatedEventBlob: true
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
] : [];
|
|
159
|
+
function filtersForAnyParty(interfaceNames, templateIds, includeWildcard) {
|
|
114
160
|
return {
|
|
115
|
-
cumulative:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
value: {
|
|
121
|
-
interfaceId: interfaceName,
|
|
122
|
-
includeInterfaceView: true,
|
|
123
|
-
includeCreatedEventBlob: true
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}),
|
|
129
|
-
...wildcardFilter
|
|
130
|
-
]
|
|
161
|
+
cumulative: buildCumulativeFilters(
|
|
162
|
+
templateIds,
|
|
163
|
+
interfaceNames,
|
|
164
|
+
includeWildcard
|
|
165
|
+
)
|
|
131
166
|
};
|
|
132
167
|
}
|
|
168
|
+
function normalizeToArray(value) {
|
|
169
|
+
return Array.isArray(value) ? value : [value];
|
|
170
|
+
}
|
|
133
171
|
function hasInterface(interfaceId, event) {
|
|
134
172
|
return (event.implementedInterfaces || []).some(
|
|
135
173
|
(id) => matchInterfaceIds(id, interfaceId)
|
|
@@ -978,14 +1016,15 @@ var TransactionParser = class {
|
|
|
978
1016
|
}
|
|
979
1017
|
const basePayload = {
|
|
980
1018
|
contractId: archivedEvent.contractId,
|
|
981
|
-
eventFormat: EventFilterBySetup(
|
|
982
|
-
[
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1019
|
+
eventFormat: EventFilterBySetup({
|
|
1020
|
+
interfaceIds: [
|
|
1021
|
+
HOLDING_INTERFACE_ID,
|
|
1022
|
+
TRANSFER_INSTRUCTION_INTERFACE_ID
|
|
1023
|
+
],
|
|
1024
|
+
isMasterUser: this.isMasterUser,
|
|
1025
|
+
partyId: this.partyId,
|
|
1026
|
+
verbose: true
|
|
1027
|
+
})
|
|
989
1028
|
};
|
|
990
1029
|
const payload = this.ledgerClient.getCurrentClientVersion() === "3.3" ? { ...basePayload, requestingParties: [] } : basePayload;
|
|
991
1030
|
const events = await this.ledgerClient.postWithRetry("/v2/events/events-by-contract-id", payload).catch((err) => {
|
|
@@ -1479,7 +1518,9 @@ var AllocationService = class {
|
|
|
1479
1518
|
async fetchExecuteTransferChoiceContext(allocationId, registryUrl) {
|
|
1480
1519
|
return this.core.getTokenStandardClient(registryUrl).post(
|
|
1481
1520
|
"/registry/allocations/v1/{allocationId}/choice-contexts/execute-transfer",
|
|
1482
|
-
{
|
|
1521
|
+
{
|
|
1522
|
+
excludeDebugFields: true
|
|
1523
|
+
},
|
|
1483
1524
|
{
|
|
1484
1525
|
path: {
|
|
1485
1526
|
allocationId
|
|
@@ -1514,7 +1555,9 @@ var AllocationService = class {
|
|
|
1514
1555
|
async fetchWithdrawAllocationChoiceContext(allocationCid, registryUrl) {
|
|
1515
1556
|
return this.core.getTokenStandardClient(registryUrl).post(
|
|
1516
1557
|
"/registry/allocations/v1/{allocationId}/choice-contexts/withdraw",
|
|
1517
|
-
{
|
|
1558
|
+
{
|
|
1559
|
+
excludeDebugFields: true
|
|
1560
|
+
},
|
|
1518
1561
|
{ path: { allocationId: allocationCid } }
|
|
1519
1562
|
);
|
|
1520
1563
|
}
|
|
@@ -1545,7 +1588,9 @@ var AllocationService = class {
|
|
|
1545
1588
|
async fetchCancelAllocationChoiceContext(allocationCid, registryUrl) {
|
|
1546
1589
|
return this.core.getTokenStandardClient(registryUrl).post(
|
|
1547
1590
|
"/registry/allocations/v1/{allocationId}/choice-contexts/cancel",
|
|
1548
|
-
{
|
|
1591
|
+
{
|
|
1592
|
+
excludeDebugFields: true
|
|
1593
|
+
},
|
|
1549
1594
|
{ path: { allocationId: allocationCid } }
|
|
1550
1595
|
);
|
|
1551
1596
|
}
|
|
@@ -1727,7 +1772,9 @@ var TransferService = class {
|
|
|
1727
1772
|
const client = this.core.getTokenStandardClient(registryUrl);
|
|
1728
1773
|
const choiceContext = await client.post(
|
|
1729
1774
|
"/registry/transfer-instruction/v1/{transferInstructionId}/choice-contexts/accept",
|
|
1730
|
-
{
|
|
1775
|
+
{
|
|
1776
|
+
excludeDebugFields: true
|
|
1777
|
+
},
|
|
1731
1778
|
{
|
|
1732
1779
|
path: {
|
|
1733
1780
|
transferInstructionId: transferInstructionCid
|
|
@@ -1860,7 +1907,9 @@ var TransferService = class {
|
|
|
1860
1907
|
const client = this.core.getTokenStandardClient(registryUrl);
|
|
1861
1908
|
const choiceContext = await client.post(
|
|
1862
1909
|
"/registry/transfer-instruction/v1/{transferInstructionId}/choice-contexts/reject",
|
|
1863
|
-
{
|
|
1910
|
+
{
|
|
1911
|
+
excludeDebugFields: true
|
|
1912
|
+
},
|
|
1864
1913
|
{
|
|
1865
1914
|
path: {
|
|
1866
1915
|
transferInstructionId: transferInstructionCid
|
|
@@ -1917,7 +1966,9 @@ var TransferService = class {
|
|
|
1917
1966
|
const client = this.core.getTokenStandardClient(registryUrl);
|
|
1918
1967
|
const choiceContext = await client.post(
|
|
1919
1968
|
"/registry/transfer-instruction/v1/{transferInstructionId}/choice-contexts/withdraw",
|
|
1920
|
-
{
|
|
1969
|
+
{
|
|
1970
|
+
excludeDebugFields: true
|
|
1971
|
+
},
|
|
1921
1972
|
{
|
|
1922
1973
|
path: {
|
|
1923
1974
|
transferInstructionId: transferInstructionCid
|
|
@@ -2067,14 +2118,12 @@ var TokenStandardService = class {
|
|
|
2067
2118
|
const updatesResponse = await this.ledgerClient.postWithRetry("/v2/updates/flats", {
|
|
2068
2119
|
updateFormat: {
|
|
2069
2120
|
includeTransactions: {
|
|
2070
|
-
eventFormat: EventFilterBySetup(
|
|
2071
|
-
TokenStandardTransactionInterfaces,
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
}
|
|
2077
|
-
),
|
|
2121
|
+
eventFormat: EventFilterBySetup({
|
|
2122
|
+
interfaceIds: TokenStandardTransactionInterfaces,
|
|
2123
|
+
isMasterUser: this.isMasterUser,
|
|
2124
|
+
partyId,
|
|
2125
|
+
includeWildcard: true
|
|
2126
|
+
}),
|
|
2078
2127
|
transactionShape: "TRANSACTION_SHAPE_LEDGER_EFFECTS"
|
|
2079
2128
|
}
|
|
2080
2129
|
},
|
|
@@ -2094,14 +2143,12 @@ var TokenStandardService = class {
|
|
|
2094
2143
|
}
|
|
2095
2144
|
async getTransactionById(updateId, partyId) {
|
|
2096
2145
|
const transactionFormat = {
|
|
2097
|
-
eventFormat: EventFilterBySetup(
|
|
2098
|
-
TokenStandardTransactionInterfaces,
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
}
|
|
2104
|
-
),
|
|
2146
|
+
eventFormat: EventFilterBySetup({
|
|
2147
|
+
interfaceIds: TokenStandardTransactionInterfaces,
|
|
2148
|
+
isMasterUser: this.isMasterUser,
|
|
2149
|
+
partyId,
|
|
2150
|
+
includeWildcard: true
|
|
2151
|
+
}),
|
|
2105
2152
|
transactionShape: "TRANSACTION_SHAPE_LEDGER_EFFECTS"
|
|
2106
2153
|
};
|
|
2107
2154
|
const getTransactionResponse = await this.ledgerClient.postWithRetry(
|
|
@@ -3446,6 +3493,118 @@ var WSSupportWithBackOffSwitch = class {
|
|
|
3446
3493
|
}
|
|
3447
3494
|
};
|
|
3448
3495
|
|
|
3449
|
-
|
|
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
|
+
export { ACSContainer, ACS_UPDATE_CONFIG, AmuletService, CoreService, LedgerClient, TokenStandardService, TokenStandardTransactionInterfaces, TransactionParser, WSSupportWithBackOffSwitch, WebSocketClient, asJsCantonError, awaitCompletion, defaultRetryableOptions, isJsCantonError, promiseWithTimeout, supportedVersions };
|
|
3450
3609
|
//# sourceMappingURL=index.js.map
|
|
3451
3610
|
//# sourceMappingURL=index.js.map
|