@canton-network/core-ledger-client 0.10.0 → 0.11.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/constants.d.ts +0 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +8 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ledger-api-utils.d.ts +14 -2
- package/dist/ledger-api-utils.d.ts.map +1 -1
- package/dist/ledger-api-utils.js +76 -5
- package/dist/ledger-client.d.ts +35 -1
- package/dist/ledger-client.d.ts.map +1 -1
- package/dist/ledger-client.js +146 -10
- package/dist/token-standard-service.d.ts +25 -9
- package/dist/token-standard-service.d.ts.map +1 -1
- package/dist/token-standard-service.js +256 -67
- package/dist/topology-write-service.d.ts +15 -3
- package/dist/topology-write-service.d.ts.map +1 -1
- package/dist/topology-write-service.js +28 -18
- package/dist/txparse/parser.d.ts +2 -1
- package/dist/txparse/parser.d.ts.map +1 -1
- package/dist/txparse/parser.js +22 -18
- package/dist/txparse/parser.test.js +3 -3
- package/package.json +6 -8
package/dist/constants.d.ts
CHANGED
|
@@ -5,9 +5,6 @@ export interface InterfaceIdParts {
|
|
|
5
5
|
}
|
|
6
6
|
export declare function splitInterfaceId(interfaceId: string): InterfaceIdParts | null;
|
|
7
7
|
export declare function matchInterfaceIds(a: string, b: string): boolean;
|
|
8
|
-
export declare const HoldingInterface = "#splice-api-token-holding-v1:Splice.Api.Token.HoldingV1:Holding";
|
|
9
|
-
export declare const TransferFactoryInterface = "#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferFactory";
|
|
10
|
-
export declare const TransferInstructionInterface = "#splice-api-token-transfer-instruction-v1:Splice.Api.Token.TransferInstructionV1:TransferInstruction";
|
|
11
8
|
export declare const TokenStandardTransactionInterfaces: string[];
|
|
12
9
|
export declare const TxKindMetaKey = "splice.lfdecentralizedtrust.org/tx-kind";
|
|
13
10
|
export declare const SenderMetaKey = "splice.lfdecentralizedtrust.org/sender";
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,gBAAgB;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAc7E;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAU/D;AAED,eAAO,MAAM,kCAAkC,UAQ9C,CAAA;AAGD,eAAO,MAAM,aAAa,4CAAkC,CAAA;AAC5D,eAAO,MAAM,aAAa,2CAAiC,CAAA;AAC3D,eAAO,MAAM,aAAa,2CAAiC,CAAA;AAC3D,eAAO,MAAM,aAAa,2CAAiC,CAAA;AAC3D,eAAO,MAAM,gBAAgB,UAK5B,CAAA"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { TRANSFER_INSTRUCTION_INTERFACE_ID, TRANSFER_FACTORY_INTERFACE_ID, HOLDING_INTERFACE_ID, } from '@canton-network/core-token-standard';
|
|
3
|
+
import { TRANSFER_INSTRUCTION_INTERFACE_ID, TRANSFER_FACTORY_INTERFACE_ID, ALLOCATION_FACTORY_INTERFACE_ID, ALLOCATION_INSTRUCTION_INTERFACE_ID, HOLDING_INTERFACE_ID, ALLOCATION_INTERFACE_ID, ALLOCATION_REQUEST_INTERFACE_ID, } from '@canton-network/core-token-standard';
|
|
4
4
|
export function splitInterfaceId(interfaceId) {
|
|
5
5
|
// Captures 3 groups: pkg, module and entity
|
|
6
6
|
// Note that prefix # is optional in regexp below,
|
|
@@ -25,14 +25,14 @@ export function matchInterfaceIds(a, b) {
|
|
|
25
25
|
aParts.moduleName === bParts.moduleName &&
|
|
26
26
|
aParts.entityName === bParts.entityName);
|
|
27
27
|
}
|
|
28
|
-
export const HoldingInterface = HOLDING_INTERFACE_ID;
|
|
29
|
-
export const TransferFactoryInterface = TRANSFER_FACTORY_INTERFACE_ID;
|
|
30
|
-
export const TransferInstructionInterface = TRANSFER_INSTRUCTION_INTERFACE_ID;
|
|
31
|
-
// TODO (#563): include allocations
|
|
32
28
|
export const TokenStandardTransactionInterfaces = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
HOLDING_INTERFACE_ID,
|
|
30
|
+
TRANSFER_FACTORY_INTERFACE_ID,
|
|
31
|
+
TRANSFER_INSTRUCTION_INTERFACE_ID,
|
|
32
|
+
ALLOCATION_FACTORY_INTERFACE_ID,
|
|
33
|
+
ALLOCATION_INSTRUCTION_INTERFACE_ID,
|
|
34
|
+
ALLOCATION_INTERFACE_ID,
|
|
35
|
+
ALLOCATION_REQUEST_INTERFACE_ID,
|
|
36
36
|
];
|
|
37
37
|
const SpliceMetaKeyPrefix = 'splice.lfdecentralizedtrust.org/';
|
|
38
38
|
export const TxKindMetaKey = `${SpliceMetaKeyPrefix}tx-kind`;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export * from './token-standard-service.js';
|
|
|
3
3
|
export * from './ledger-client.js';
|
|
4
4
|
export * from './generated-clients/openapi-3.3.0-SNAPSHOT.js';
|
|
5
5
|
export type { Transaction, TokenStandardEvent, Holding, HoldingLock, HoldingsChange, HoldingsChangeSummary, TransferInstructionView, TokenStandardChoice, PrettyTransactions, PrettyContract, ViewValue, Label, TransferIn, TransferOut, MergeSplit, Burn, Mint, Unlock, ExpireDust, RawArchive, RawCreate, } from './txparse/types.js';
|
|
6
|
-
export { awaitCompletion, promiseWithTimeout } from './ledger-api-utils.js';
|
|
6
|
+
export { awaitCompletion, promiseWithTimeout, isJsCantonError, } from './ledger-api-utils.js';
|
|
7
7
|
//# 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,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,+CAA+C,CAAA;AAE7D,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;AAE3B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,+CAA+C,CAAA;AAE7D,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;AAE3B,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,eAAe,GAClB,MAAM,uBAAuB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@ export * from './topology-write-service.js';
|
|
|
4
4
|
export * from './token-standard-service.js';
|
|
5
5
|
export * from './ledger-client.js';
|
|
6
6
|
export * from './generated-clients/openapi-3.3.0-SNAPSHOT.js';
|
|
7
|
-
export { awaitCompletion, promiseWithTimeout } from './ledger-api-utils.js';
|
|
7
|
+
export { awaitCompletion, promiseWithTimeout, isJsCantonError, } from './ledger-api-utils.js';
|
|
@@ -3,6 +3,7 @@ import { Holding, TransferInstructionView } from './txparse/types.js';
|
|
|
3
3
|
import { Types } from './ledger-client.js';
|
|
4
4
|
import { PartyId } from '@canton-network/core-types';
|
|
5
5
|
type TransactionFilter = Types['TransactionFilter'];
|
|
6
|
+
type EventFormat = Types['EventFormat'];
|
|
6
7
|
type CreatedEvent = Types['CreatedEvent'];
|
|
7
8
|
type ExercisedEvent = Types['ExercisedEvent'];
|
|
8
9
|
type ArchivedEvent = Types['ArchivedEvent'];
|
|
@@ -10,7 +11,17 @@ type ExerciseCommand = Types['ExerciseCommand'];
|
|
|
10
11
|
type JsInterfaceView = Types['JsInterfaceView'];
|
|
11
12
|
type DisclosedContract = Types['DisclosedContract'];
|
|
12
13
|
type Completion = Types['Completion']['value'];
|
|
13
|
-
export declare function
|
|
14
|
+
export declare function TransactionFilterBySetup(interfaceNames: string[] | string, options?: {
|
|
15
|
+
includeWildcard?: boolean;
|
|
16
|
+
isMasterUser?: boolean;
|
|
17
|
+
partyId?: PartyId | undefined;
|
|
18
|
+
}): TransactionFilter;
|
|
19
|
+
export declare function EventFilterBySetup(interfaceNames: string[] | string, options?: {
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
includeWildcard?: boolean;
|
|
22
|
+
isMasterUser?: boolean;
|
|
23
|
+
partyId?: PartyId | undefined;
|
|
24
|
+
}): EventFormat;
|
|
14
25
|
export declare function hasInterface(interfaceId: string, event: ExercisedEvent | ArchivedEvent): boolean;
|
|
15
26
|
export declare function getInterfaceView(createdEvent: CreatedEvent): JsInterfaceView | null;
|
|
16
27
|
export type KnownInterfaceView = {
|
|
@@ -31,7 +42,7 @@ type Meta = {
|
|
|
31
42
|
[key: string]: string;
|
|
32
43
|
};
|
|
33
44
|
} | undefined;
|
|
34
|
-
export declare function mergeMetas(event: ExercisedEvent): Meta;
|
|
45
|
+
export declare function mergeMetas(event: ExercisedEvent, extra?: Meta): Meta;
|
|
35
46
|
export declare function getMetaKeyValue(key: string, meta: Meta): string | null;
|
|
36
47
|
/**
|
|
37
48
|
* From the view of making it easy to build the display for the wallet,
|
|
@@ -47,5 +58,6 @@ export declare function submitExerciseCommand(ledgerClient: LedgerClient, exerci
|
|
|
47
58
|
*/
|
|
48
59
|
export declare function awaitCompletion(ledgerClient: LedgerClient, ledgerEnd: number, partyId: PartyId, userId: string, commandId?: string, submissionId?: string): Promise<Completion>;
|
|
49
60
|
export declare function promiseWithTimeout<T>(promise: Promise<T>, timeoutMs: number, errorMessage: string): Promise<T>;
|
|
61
|
+
export declare const isJsCantonError: (e: unknown) => e is Types["JsCantonError"];
|
|
50
62
|
export {};
|
|
51
63
|
//# sourceMappingURL=ledger-api-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-api-utils.d.ts","sourceRoot":"","sources":["../src/ledger-api-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ledger-api-utils.d.ts","sourceRoot":"","sources":["../src/ledger-api-utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAMpD,KAAK,iBAAiB,GAAG,KAAK,CAAC,mBAAmB,CAA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AAC,EACnB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACrB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAGD,eAAO,MAAM,eAAe,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAAK,CAAC,eAAe,CACS,CAAA"}
|
package/dist/ledger-api-utils.js
CHANGED
|
@@ -3,8 +3,43 @@
|
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
|
-
import { AllKnownMetaKeys,
|
|
7
|
-
|
|
6
|
+
import { AllKnownMetaKeys, matchInterfaceIds } from './constants.js';
|
|
7
|
+
import { HOLDING_INTERFACE_ID, TRANSFER_INSTRUCTION_INTERFACE_ID, } from '@canton-network/core-token-standard';
|
|
8
|
+
export function TransactionFilterBySetup(interfaceNames, options = { includeWildcard: false, isMasterUser: false }) {
|
|
9
|
+
const interfaceArrayed = Array.isArray(interfaceNames)
|
|
10
|
+
? interfaceNames
|
|
11
|
+
: [interfaceNames];
|
|
12
|
+
if (options.isMasterUser)
|
|
13
|
+
return {
|
|
14
|
+
filtersByParty: {},
|
|
15
|
+
filtersForAnyParty: filtersForAnyParty(interfaceArrayed, options.includeWildcard ?? false) ?? {},
|
|
16
|
+
};
|
|
17
|
+
else if (!options.partyId || options.partyId === undefined)
|
|
18
|
+
throw new Error('Party must be provided for non-master users');
|
|
19
|
+
else
|
|
20
|
+
return {
|
|
21
|
+
filtersByParty: filtersByParty(options.partyId, interfaceArrayed, options.includeWildcard ?? false) ?? {},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function EventFilterBySetup(interfaceNames, options = { includeWildcard: false, isMasterUser: false }) {
|
|
25
|
+
const interfaceArrayed = Array.isArray(interfaceNames)
|
|
26
|
+
? interfaceNames
|
|
27
|
+
: [interfaceNames];
|
|
28
|
+
if (options.isMasterUser)
|
|
29
|
+
return {
|
|
30
|
+
filtersByParty: {},
|
|
31
|
+
filtersForAnyParty: filtersForAnyParty(interfaceArrayed, options.includeWildcard ?? false) ?? {},
|
|
32
|
+
verbose: options.verbose ?? false,
|
|
33
|
+
};
|
|
34
|
+
else if (!options.partyId || options.partyId === undefined)
|
|
35
|
+
throw new Error('Party must be provided for non-master users');
|
|
36
|
+
else
|
|
37
|
+
return {
|
|
38
|
+
filtersByParty: filtersByParty(options.partyId, interfaceArrayed, options.includeWildcard ?? false) ?? {},
|
|
39
|
+
verbose: options.verbose ?? false,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function filtersByParty(party, interfaceNames, includeWildcard) {
|
|
8
43
|
const wildcardFilter = includeWildcard
|
|
9
44
|
? [
|
|
10
45
|
{
|
|
@@ -39,6 +74,39 @@ export function filtersByParty(party, interfaceNames, includeWildcard) {
|
|
|
39
74
|
},
|
|
40
75
|
};
|
|
41
76
|
}
|
|
77
|
+
function filtersForAnyParty(interfaceNames, includeWildcard) {
|
|
78
|
+
const wildcardFilter = includeWildcard
|
|
79
|
+
? [
|
|
80
|
+
{
|
|
81
|
+
identifierFilter: {
|
|
82
|
+
WildcardFilter: {
|
|
83
|
+
value: {
|
|
84
|
+
includeCreatedEventBlob: true,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
]
|
|
90
|
+
: [];
|
|
91
|
+
return {
|
|
92
|
+
cumulative: [
|
|
93
|
+
...interfaceNames.map((interfaceName) => {
|
|
94
|
+
return {
|
|
95
|
+
identifierFilter: {
|
|
96
|
+
InterfaceFilter: {
|
|
97
|
+
value: {
|
|
98
|
+
interfaceId: interfaceName,
|
|
99
|
+
includeInterfaceView: true,
|
|
100
|
+
includeCreatedEventBlob: true,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}),
|
|
106
|
+
...wildcardFilter,
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
}
|
|
42
110
|
export function hasInterface(interfaceId, event) {
|
|
43
111
|
return (event.implementedInterfaces || []).some((id) => matchInterfaceIds(id, interfaceId));
|
|
44
112
|
}
|
|
@@ -51,13 +119,13 @@ export function getKnownInterfaceView(createdEvent) {
|
|
|
51
119
|
if (!interfaceView) {
|
|
52
120
|
return null;
|
|
53
121
|
}
|
|
54
|
-
else if (matchInterfaceIds(
|
|
122
|
+
else if (matchInterfaceIds(HOLDING_INTERFACE_ID, interfaceView.interfaceId)) {
|
|
55
123
|
return {
|
|
56
124
|
type: 'Holding',
|
|
57
125
|
viewValue: interfaceView.viewValue,
|
|
58
126
|
};
|
|
59
127
|
}
|
|
60
|
-
else if (matchInterfaceIds(
|
|
128
|
+
else if (matchInterfaceIds(TRANSFER_INSTRUCTION_INTERFACE_ID, interfaceView.interfaceId)) {
|
|
61
129
|
return {
|
|
62
130
|
type: 'TransferInstruction',
|
|
63
131
|
viewValue: interfaceView.viewValue,
|
|
@@ -82,13 +150,14 @@ export function ensureInterfaceViewIsPresent(createdEvent, interfaceId) {
|
|
|
82
150
|
}
|
|
83
151
|
return interfaceView;
|
|
84
152
|
}
|
|
85
|
-
export function mergeMetas(event) {
|
|
153
|
+
export function mergeMetas(event, extra) {
|
|
86
154
|
// Add a type assertion to help TypeScript understand the shape of choiceArgument
|
|
87
155
|
const choiceArgument = event.choiceArgument;
|
|
88
156
|
const lastWriteWins = [
|
|
89
157
|
choiceArgument?.transfer?.meta,
|
|
90
158
|
choiceArgument?.extraArgs?.meta,
|
|
91
159
|
choiceArgument?.meta,
|
|
160
|
+
extra,
|
|
92
161
|
event.exerciseResult?.meta,
|
|
93
162
|
];
|
|
94
163
|
const result = {};
|
|
@@ -279,3 +348,5 @@ export async function promiseWithTimeout(promise, timeoutMs, errorMessage) {
|
|
|
279
348
|
}
|
|
280
349
|
}
|
|
281
350
|
}
|
|
351
|
+
// Helper for differentiating ledger errors from others and satisfying TS when checking error properties
|
|
352
|
+
export const isJsCantonError = (e) => typeof e === 'object' && e !== null && 'status' in e && 'errorCategory' in e;
|
package/dist/ledger-client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v3_3 from './generated-clients/openapi-3.3.0-SNAPSHOT.js';
|
|
2
2
|
import * as v3_4 from './generated-clients/openapi-3.4.0-SNAPSHOT.js';
|
|
3
|
+
import { FetchOptions } from 'openapi-fetch';
|
|
3
4
|
import { Logger } from 'pino';
|
|
4
5
|
import { PartyId } from '@canton-network/core-types';
|
|
5
6
|
export declare const supportedVersions: readonly ["3.3", "3.4"];
|
|
@@ -47,6 +48,11 @@ export type GetResponse<Path extends GetEndpoint> = paths[Path] extends {
|
|
|
47
48
|
};
|
|
48
49
|
};
|
|
49
50
|
} ? Res : never;
|
|
51
|
+
export type GenerateTransactionResponse = v3_3.components['schemas']['GenerateExternalPartyTopologyResponse'];
|
|
52
|
+
export type AllocateExternalPartyResponse = v3_3.components['schemas']['AllocateExternalPartyResponse'];
|
|
53
|
+
export type OnboardingTransactions = NonNullable<v3_3.components['schemas']['AllocateExternalPartyRequest']['onboardingTransactions']>;
|
|
54
|
+
export type MultiHashSignatures = NonNullable<v3_3.components['schemas']['AllocateExternalPartyRequest']['multiHashSignatures']>;
|
|
55
|
+
type ExtraPostOpts = Omit<FetchOptions<paths>, 'body' | 'params'>;
|
|
50
56
|
export declare class LedgerClient {
|
|
51
57
|
private readonly clients;
|
|
52
58
|
private clientVersion;
|
|
@@ -57,6 +63,30 @@ export declare class LedgerClient {
|
|
|
57
63
|
init(): Promise<void>;
|
|
58
64
|
getCurrentClientVersion(): SupportedVersions;
|
|
59
65
|
parseSupportedVersions(version: string | undefined): SupportedVersions;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a party exists
|
|
68
|
+
*
|
|
69
|
+
* @param partyId The ID of the party to look for
|
|
70
|
+
* @returns A promise to resolves to a boolean.
|
|
71
|
+
*/
|
|
72
|
+
checkIfPartyExists(partyId: PartyId): Promise<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* grant "Master User" rights to a user.
|
|
75
|
+
*
|
|
76
|
+
* this require running with an admin token.
|
|
77
|
+
*
|
|
78
|
+
* @param userId The ID of the user to grant rights to.
|
|
79
|
+
* @param canReadAsAnyParty define if the user can read as any party.
|
|
80
|
+
* @param canExecuteAsAnyParty define if the user can execute as any party.
|
|
81
|
+
*/
|
|
82
|
+
grantMasterUserRights(userId: string, canReadAsAnyParty: boolean, canExecuteAsAnyParty: boolean): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Create a new user.
|
|
85
|
+
*
|
|
86
|
+
* @param userId The ID of the user to create.
|
|
87
|
+
* @param primaryParty The primary party of the user.
|
|
88
|
+
*/
|
|
89
|
+
createUser(userId: string, primaryParty: PartyId): Promise<v3_3.components['schemas']['User']>;
|
|
60
90
|
/**
|
|
61
91
|
* Grants a user the right to act as a party, while ensuring the party exists.
|
|
62
92
|
*
|
|
@@ -65,10 +95,14 @@ export declare class LedgerClient {
|
|
|
65
95
|
* @returns A promise that resolves when the rights have been granted.
|
|
66
96
|
*/
|
|
67
97
|
grantUserRights(userId: string, partyId: PartyId): Promise<void>;
|
|
98
|
+
/** TODO: simplify once 3.4 snapshot contains this endpoint */
|
|
99
|
+
allocateExternalParty(synchronizerId: string, onboardingTransactions: OnboardingTransactions, multiHashSignatures: MultiHashSignatures): Promise<AllocateExternalPartyResponse>;
|
|
100
|
+
/** TODO: simplify once 3.4 snapshot contains this endpoint */
|
|
101
|
+
generateTopology(synchronizerId: string, publicKey: string, partyHint: string, localParticipantObservationOnly?: boolean, confirmationThreshold?: number, otherConfirmingParticipantUids?: string[]): Promise<GenerateTransactionResponse>;
|
|
68
102
|
post<Path extends PostEndpoint>(path: Path, body: PostRequest<Path>, params?: {
|
|
69
103
|
path?: Record<string, string>;
|
|
70
104
|
query?: Record<string, string>;
|
|
71
|
-
}): Promise<PostResponse<Path>>;
|
|
105
|
+
}, additionalOptions?: ExtraPostOpts): Promise<PostResponse<Path>>;
|
|
72
106
|
get<Path extends GetEndpoint>(path: Path, params?: {
|
|
73
107
|
path?: Record<string, string>;
|
|
74
108
|
query?: Record<string, string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-client.d.ts","sourceRoot":"","sources":["../src/ledger-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,+CAA+C,CAAA;AAErE,OAAO,KAAK,IAAI,MAAM,+CAA+C,CAAA;
|
|
1
|
+
{"version":3,"file":"ledger-client.d.ts","sourceRoot":"","sources":["../src/ledger-client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,+CAA+C,CAAA;AAErE,OAAO,KAAK,IAAI,MAAM,+CAA+C,CAAA;AACrE,OAAqB,EAAU,YAAY,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,eAAO,MAAM,iBAAiB,yBAA0B,CAAA;AAExD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAA;AAElE,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;AAE3E,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAIpC,KAAK,YAAY,GAAG;KACf,QAAQ,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS;QAC/C,IAAI,EAAE,OAAO,CAAA;KAChB,GACK,QAAQ,GACR,KAAK;CACd,CAAC,MAAM,KAAK,CAAC,CAAA;AAGd,MAAM,MAAM,WAAW,CAAC,IAAI,SAAS,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS;IACrE,IAAI,EAAE;QAAE,WAAW,EAAE;YAAE,OAAO,EAAE;gBAAE,kBAAk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AE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,+BAA+B,GAAE,OAAe,EAChD,qBAAqB,GAAE,MAAU,EACjC,8BAA8B,GAAE,MAAM,EAAO,GAC9C,OAAO,CAAC,2BAA2B,CAAC;IAkC1B,IAAI,CAAC,IAAI,SAAS,YAAY,EACvC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,EACvB,MAAM,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACjC,EAED,iBAAiB,CAAC,EAAE,aAAa,GAClC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAQjB,GAAG,CAAC,IAAI,SAAS,WAAW,EACrC,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACjC,GACF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAQf,YAAY;CAU7B"}
|
package/dist/ledger-client.js
CHANGED
|
@@ -60,6 +60,103 @@ export class LedgerClient {
|
|
|
60
60
|
}
|
|
61
61
|
return match;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if a party exists
|
|
65
|
+
*
|
|
66
|
+
* @param partyId The ID of the party to look for
|
|
67
|
+
* @returns A promise to resolves to a boolean.
|
|
68
|
+
*/
|
|
69
|
+
async checkIfPartyExists(partyId) {
|
|
70
|
+
try {
|
|
71
|
+
const party = await this.get('/v2/parties/{party}', {
|
|
72
|
+
path: { party: partyId },
|
|
73
|
+
});
|
|
74
|
+
return (party.partyDetails !== undefined &&
|
|
75
|
+
party.partyDetails[0].party === partyId);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* grant "Master User" rights to a user.
|
|
83
|
+
*
|
|
84
|
+
* this require running with an admin token.
|
|
85
|
+
*
|
|
86
|
+
* @param userId The ID of the user to grant rights to.
|
|
87
|
+
* @param canReadAsAnyParty define if the user can read as any party.
|
|
88
|
+
* @param canExecuteAsAnyParty define if the user can execute as any party.
|
|
89
|
+
*/
|
|
90
|
+
async grantMasterUserRights(userId, canReadAsAnyParty, canExecuteAsAnyParty) {
|
|
91
|
+
const rights = [];
|
|
92
|
+
if (canReadAsAnyParty) {
|
|
93
|
+
rights.push({
|
|
94
|
+
kind: {
|
|
95
|
+
CanReadAsAnyParty: { value: {} },
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (canExecuteAsAnyParty) {
|
|
100
|
+
rights.push({
|
|
101
|
+
kind: {
|
|
102
|
+
CanExecuteAsAnyParty: {
|
|
103
|
+
value: {},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const result = await this.post('/v2/users/{user-id}/rights', {
|
|
109
|
+
identityProviderId: '',
|
|
110
|
+
userId,
|
|
111
|
+
rights,
|
|
112
|
+
}, {
|
|
113
|
+
path: {
|
|
114
|
+
'user-id': userId,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (!result.newlyGrantedRights) {
|
|
118
|
+
throw new Error('Failed to grant user rights');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a new user.
|
|
123
|
+
*
|
|
124
|
+
* @param userId The ID of the user to create.
|
|
125
|
+
* @param primaryParty The primary party of the user.
|
|
126
|
+
*/
|
|
127
|
+
async createUser(userId, primaryParty) {
|
|
128
|
+
try {
|
|
129
|
+
const existing = await this.get('/v2/users/{user-id}', {
|
|
130
|
+
path: { 'user-id': userId },
|
|
131
|
+
});
|
|
132
|
+
if (existing && existing.user) {
|
|
133
|
+
return existing.user;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
//TODO: proper error handling based on daml code
|
|
138
|
+
// we continue if code is:
|
|
139
|
+
// code: 'USER_NOT_FOUND',
|
|
140
|
+
// cause: 'getting user failed for unknown user "master-user"',
|
|
141
|
+
}
|
|
142
|
+
return (await this.post('/v2/users', {
|
|
143
|
+
user: {
|
|
144
|
+
identityProviderId: '',
|
|
145
|
+
id: userId,
|
|
146
|
+
isDeactivated: false,
|
|
147
|
+
primaryParty: primaryParty,
|
|
148
|
+
},
|
|
149
|
+
rights: [
|
|
150
|
+
{
|
|
151
|
+
kind: {
|
|
152
|
+
ParticipantAdmin: {
|
|
153
|
+
value: {},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
})).user;
|
|
159
|
+
}
|
|
63
160
|
/**
|
|
64
161
|
* Grants a user the right to act as a party, while ensuring the party exists.
|
|
65
162
|
*
|
|
@@ -68,16 +165,14 @@ export class LedgerClient {
|
|
|
68
165
|
* @returns A promise that resolves when the rights have been granted.
|
|
69
166
|
*/
|
|
70
167
|
async grantUserRights(userId, partyId) {
|
|
71
|
-
this.init();
|
|
168
|
+
await this.init();
|
|
72
169
|
// Wait for party to appear on participant
|
|
73
170
|
let partyFound = false;
|
|
74
171
|
let tries = 0;
|
|
75
|
-
const maxTries =
|
|
172
|
+
const maxTries = 30;
|
|
76
173
|
while (!partyFound && tries < maxTries) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
parties.partyDetails?.some((party) => party.party === partyId) || false;
|
|
80
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
174
|
+
partyFound = await this.checkIfPartyExists(partyId);
|
|
175
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
81
176
|
tries++;
|
|
82
177
|
}
|
|
83
178
|
if (tries >= maxTries) {
|
|
@@ -108,15 +203,56 @@ export class LedgerClient {
|
|
|
108
203
|
}
|
|
109
204
|
return;
|
|
110
205
|
}
|
|
111
|
-
|
|
112
|
-
|
|
206
|
+
/** TODO: simplify once 3.4 snapshot contains this endpoint */
|
|
207
|
+
async allocateExternalParty(synchronizerId, onboardingTransactions, multiHashSignatures) {
|
|
208
|
+
await this.init();
|
|
209
|
+
if (this.clientVersion !== '3.3') {
|
|
210
|
+
throw new Error('allocateExternalParty is only supported on 3.3 clients');
|
|
211
|
+
}
|
|
212
|
+
const client = this.clients['3.3'];
|
|
213
|
+
const resp = await client.POST('/v2/parties/external/allocate', {
|
|
214
|
+
body: {
|
|
215
|
+
synchronizer: synchronizerId,
|
|
216
|
+
identityProviderId: '',
|
|
217
|
+
onboardingTransactions,
|
|
218
|
+
multiHashSignatures,
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
return this.valueOrError(resp);
|
|
222
|
+
}
|
|
223
|
+
/** TODO: simplify once 3.4 snapshot contains this endpoint */
|
|
224
|
+
async generateTopology(synchronizerId, publicKey, partyHint, localParticipantObservationOnly = false, confirmationThreshold = 1, otherConfirmingParticipantUids = []) {
|
|
225
|
+
await this.init();
|
|
226
|
+
if (this.clientVersion !== '3.3') {
|
|
227
|
+
throw new Error('allocateExternalParty is only supported on 3.3 clients');
|
|
228
|
+
}
|
|
229
|
+
const client = this.clients['3.3'];
|
|
230
|
+
const body = {
|
|
231
|
+
synchronizer: synchronizerId,
|
|
232
|
+
partyHint,
|
|
233
|
+
publicKey: {
|
|
234
|
+
format: 'CRYPTO_KEY_FORMAT_RAW',
|
|
235
|
+
keyData: publicKey,
|
|
236
|
+
keySpec: 'SIGNING_KEY_SPEC_EC_CURVE25519',
|
|
237
|
+
},
|
|
238
|
+
localParticipantObservationOnly,
|
|
239
|
+
confirmationThreshold,
|
|
240
|
+
otherConfirmingParticipantUids,
|
|
241
|
+
};
|
|
242
|
+
this.logger.debug(body, 'generateTopology request body');
|
|
243
|
+
const resp = await client.POST('/v2/parties/external/generate-topology', { body });
|
|
244
|
+
return this.valueOrError(resp);
|
|
245
|
+
}
|
|
246
|
+
async post(path, body, params,
|
|
247
|
+
// needed when posting to /packages, so content type and jsonification of bytes can be overriden
|
|
248
|
+
additionalOptions) {
|
|
113
249
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- (cant align this with openapi-fetch generics :shrug:)
|
|
114
|
-
const options = { body, params };
|
|
250
|
+
const options = { body, params, ...additionalOptions };
|
|
115
251
|
const resp = await this.currentClient.POST(path, options);
|
|
116
252
|
return this.valueOrError(resp);
|
|
117
253
|
}
|
|
118
254
|
async get(path, params) {
|
|
119
|
-
this.init();
|
|
255
|
+
await this.init();
|
|
120
256
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- (cant align this with openapi-fetch generics :shrug:)
|
|
121
257
|
const options = { params };
|
|
122
258
|
const resp = await this.currentClient.GET(path, options);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AllocationSpecification, AllocationContextValue } from '@canton-network/core-token-standard';
|
|
1
2
|
import { Logger, PartyId } from '@canton-network/core-types';
|
|
2
3
|
import { LedgerClient } from './ledger-client.js';
|
|
3
4
|
import { PrettyContract, ViewValue } from './txparse/types.js';
|
|
@@ -11,7 +12,8 @@ export declare class TokenStandardService {
|
|
|
11
12
|
private scanProxyClient;
|
|
12
13
|
private readonly logger;
|
|
13
14
|
private accessToken;
|
|
14
|
-
|
|
15
|
+
private readonly isMasterUser;
|
|
16
|
+
constructor(ledgerClient: LedgerClient, scanProxyClient: ScanProxyClient, logger: Logger, accessToken: string, isMasterUser: boolean);
|
|
15
17
|
private getTokenStandardClient;
|
|
16
18
|
getTransferPreApprovalByParty(partyId: PartyId): Promise<{
|
|
17
19
|
contract: import("@canton-network/core-splice-client/dist/generated-clients/scan-proxy.js").components["schemas"]["Contract"];
|
|
@@ -24,7 +26,7 @@ export declare class TokenStandardService {
|
|
|
24
26
|
created_event_blob: string;
|
|
25
27
|
created_at: string;
|
|
26
28
|
} | undefined>;
|
|
27
|
-
getInstrumentById(
|
|
29
|
+
getInstrumentById(registryUrl: string, instrumentId: string): Promise<{
|
|
28
30
|
id: string;
|
|
29
31
|
name: string;
|
|
30
32
|
symbol: string;
|
|
@@ -33,18 +35,32 @@ export declare class TokenStandardService {
|
|
|
33
35
|
decimals: number;
|
|
34
36
|
supportedApis: import("@canton-network/core-token-standard/dist/generated-clients/splice-api-token-metadata-v1/token-metadata-v1.js").components["schemas"]["SupportedApis"];
|
|
35
37
|
}>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
createRejectTransferInstruction(transferInstructionCid: string,
|
|
39
|
-
createWithdrawTransferInstruction(transferInstructionCid: string,
|
|
40
|
-
|
|
38
|
+
getInstrumentAdmin(registryUrl: string): Promise<string | undefined>;
|
|
39
|
+
createAcceptTransferInstruction(transferInstructionCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
40
|
+
createRejectTransferInstruction(transferInstructionCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
41
|
+
createWithdrawTransferInstruction(transferInstructionCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
42
|
+
createAllocationInstruction(allocationSpecification: AllocationSpecification, expectedAdmin: PartyId, registryUrl: string, inputUtxos?: string[], requestedAt?: string, extraContext?: AllocationContextValue): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
43
|
+
getAllocationExecuteTransferChoiceContext(allocationId: string, registryUrl: string): Promise<{
|
|
44
|
+
choiceContextData: Record<string, never>;
|
|
45
|
+
disclosedContracts: import("@canton-network/core-token-standard/dist/generated-clients/splice-api-token-allocation-v1/allocation-v1.js").components["schemas"]["DisclosedContract"][];
|
|
46
|
+
}>;
|
|
47
|
+
createExecuteTransferAllocation(allocationCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
48
|
+
createWithdrawAllocation(allocationCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
49
|
+
createCancelAllocation(allocationCid: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
50
|
+
createWithdrawAllocationInstruction(registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
51
|
+
createUpdateAllocationInstruction(allocationInstructionCid: string, extraActors?: PartyId[], extraArgsContext?: Record<string, unknown>, extraArgsMeta?: Record<string, unknown>): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
52
|
+
createRejectAllocationRequest(allocationRequestCid: string, actor: PartyId): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
53
|
+
createWithdrawAllocationRequest(allocationRequestCid: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
54
|
+
listContractsByInterface<T = ViewValue>(interfaceId: string, partyId?: PartyId): Promise<PrettyContract<T>[]>;
|
|
41
55
|
listHoldingTransactions(partyId: PartyId, afterOffset?: string, beforeOffset?: string): Promise<PrettyTransactions>;
|
|
42
56
|
getTransactionById(updateId: string, partyId: PartyId): Promise<Transaction>;
|
|
57
|
+
private getInputHoldingsCids;
|
|
43
58
|
createTransfer(sender: PartyId, receiver: PartyId, amount: string, instrumentAdmin: PartyId, // TODO (#907): replace with registry call
|
|
44
|
-
instrumentId: string,
|
|
59
|
+
instrumentId: string, registryUrl: string, inputUtxos?: string[], memo?: string, expiryDate?: Date, meta?: Record<string, unknown>): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
45
60
|
createTap(receiver: string, amount: string, instrumentAdmin: string, // TODO (#907): replace with registry call
|
|
46
|
-
instrumentId: string,
|
|
61
|
+
instrumentId: string, registryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
47
62
|
selfGrantFeatureAppRight(providerPartyId: PartyId, synchronizerId: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
63
|
+
private toPrettyTransactionsPerParty;
|
|
48
64
|
private toPrettyTransactions;
|
|
49
65
|
private toPrettyTransaction;
|
|
50
66
|
private toPrettyContract;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-standard-service.d.ts","sourceRoot":"","sources":["../src/token-standard-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token-standard-service.d.ts","sourceRoot":"","sources":["../src/token-standard-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAIH,uBAAuB,EACvB,sBAAsB,EAQzB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAQjD,OAAO,EACH,cAAc,EAEd,SAAS,EACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAIpE,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAA;AActD,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAA;AAU1D,qBAAa,oBAAoB;IAEzB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBAJrB,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACV,YAAY,EAAE,OAAO;IAG1C,OAAO,CAAC,sBAAsB;IAQxB,6BAA6B,CAAC,OAAO,EAAE,OAAO;kBAZ1B,uGACf;;;IAwBL,sBAAsB,CAAC,OAAO,EAAE,OAAO;;;;;;;IAavC,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,YAA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