@layerzerolabs/common-canton 0.2.102 → 0.2.103
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/.turbo/turbo-build.log +704 -699
- package/.turbo/turbo-test.log +19 -18
- package/dist/{KNUJUERI.js → 25GNLJIH.js} +3 -3
- package/dist/{KNUJUERI.js.map → 25GNLJIH.js.map} +1 -1
- package/dist/{SIXVG7DR.js → 2UWZKS5E.js} +3 -3
- package/dist/{SIXVG7DR.js.map → 2UWZKS5E.js.map} +1 -1
- package/dist/{JGMLJJM5.js → 37DZS34C.js} +3 -3
- package/dist/{JGMLJJM5.js.map → 37DZS34C.js.map} +1 -1
- package/dist/{ORO3GF7S.js → 3UD2GTXW.js} +3 -3
- package/dist/{ORO3GF7S.js.map → 3UD2GTXW.js.map} +1 -1
- package/dist/{XUUV67AB.js → 42XERBT4.js} +3 -3
- package/dist/{XUUV67AB.js.map → 42XERBT4.js.map} +1 -1
- package/dist/{WCCLV452.js → 4AKFOZFY.js} +5 -5
- package/dist/{WCCLV452.js.map → 4AKFOZFY.js.map} +1 -1
- package/dist/{QHLG5QK7.js → 4AM6UVPL.js} +3 -3
- package/dist/{QHLG5QK7.js.map → 4AM6UVPL.js.map} +1 -1
- package/dist/{ZPTSW4ST.js → 4UM5TVKI.js} +3 -3
- package/dist/{ZPTSW4ST.js.map → 4UM5TVKI.js.map} +1 -1
- package/dist/{B7EQ3SWK.js → 4VLNRPYZ.js} +3 -3
- package/dist/{B7EQ3SWK.js.map → 4VLNRPYZ.js.map} +1 -1
- package/dist/{G4PPJP65.js → 5N747JZQ.js} +3 -3
- package/dist/{G4PPJP65.js.map → 5N747JZQ.js.map} +1 -1
- package/dist/{PI2K7A3Q.js → 5RZS7DZN.js} +3 -3
- package/dist/{PI2K7A3Q.js.map → 5RZS7DZN.js.map} +1 -1
- package/dist/{C77Y3MIG.js → 6GAFSKMN.js} +3 -3
- package/dist/{C77Y3MIG.js.map → 6GAFSKMN.js.map} +1 -1
- package/dist/6VTJWUC7.js +35 -0
- package/dist/6VTJWUC7.js.map +1 -0
- package/dist/{CJEDJ6BA.js → 7G32CZXC.js} +14 -8
- package/dist/7G32CZXC.js.map +1 -0
- package/dist/{T5NCFR3W.js → 7NA23BJ3.js} +3 -3
- package/dist/{T5NCFR3W.js.map → 7NA23BJ3.js.map} +1 -1
- package/dist/{SWAXT3ZN.js → A7U4VVQK.js} +3 -3
- package/dist/{SWAXT3ZN.js.map → A7U4VVQK.js.map} +1 -1
- package/dist/{3GTU7DXV.js → AV2FN74T.js} +4 -4
- package/dist/{3GTU7DXV.js.map → AV2FN74T.js.map} +1 -1
- package/dist/{OZ5IUCBI.js → AYAFFPBV.js} +3 -3
- package/dist/{OZ5IUCBI.js.map → AYAFFPBV.js.map} +1 -1
- package/dist/{3EHEF6PF.js → BJXKGZ5Y.js} +4 -4
- package/dist/{3EHEF6PF.js.map → BJXKGZ5Y.js.map} +1 -1
- package/dist/{JEGCDOON.js → CLFKYN43.js} +4 -4
- package/dist/{JEGCDOON.js.map → CLFKYN43.js.map} +1 -1
- package/dist/{K4SNVOCJ.js → CXFHE5WB.js} +3 -3
- package/dist/{K4SNVOCJ.js.map → CXFHE5WB.js.map} +1 -1
- package/dist/{75QKYROD.js → CXNQT7WY.js} +2 -2
- package/dist/{75QKYROD.js.map → CXNQT7WY.js.map} +1 -1
- package/dist/{F46SX6MN.js → D3AV6J7R.js} +3 -3
- package/dist/{F46SX6MN.js.map → D3AV6J7R.js.map} +1 -1
- package/dist/{46Y2JCNE.js → EIXIZULE.js} +35 -35
- package/dist/{46Y2JCNE.js.map → EIXIZULE.js.map} +1 -1
- package/dist/{ZY3FX7W5.js → GMQEAD3I.js} +3 -3
- package/dist/{ZY3FX7W5.js.map → GMQEAD3I.js.map} +1 -1
- package/dist/{KBZ6YXX4.js → H7FW24YI.js} +3 -3
- package/dist/{KBZ6YXX4.js.map → H7FW24YI.js.map} +1 -1
- package/dist/{QSYGA6OS.js → ICTUC6FF.js} +3 -3
- package/dist/{QSYGA6OS.js.map → ICTUC6FF.js.map} +1 -1
- package/dist/{Y4LSYZDO.js → IOTRKLGP.js} +4 -4
- package/dist/{Y4LSYZDO.js.map → IOTRKLGP.js.map} +1 -1
- package/dist/{MVXDS4XR.js → JKQLMXRN.js} +3 -3
- package/dist/{MVXDS4XR.js.map → JKQLMXRN.js.map} +1 -1
- package/dist/{WDSUM647.js → JRFMLEIC.js} +3 -3
- package/dist/{WDSUM647.js.map → JRFMLEIC.js.map} +1 -1
- package/dist/{JTRUQM7V.js → JV2DWUBW.js} +74 -12
- package/dist/JV2DWUBW.js.map +1 -0
- package/dist/{YCJNLHFD.js → KCRFOKIB.js} +3 -3
- package/dist/{YCJNLHFD.js.map → KCRFOKIB.js.map} +1 -1
- package/dist/{TGWOYSYK.js → KJRFPBY4.js} +3 -3
- package/dist/{TGWOYSYK.js.map → KJRFPBY4.js.map} +1 -1
- package/dist/{4GYCD3G4.js → KK2NBQSG.js} +3 -3
- package/dist/{4GYCD3G4.js.map → KK2NBQSG.js.map} +1 -1
- package/dist/{3KJAGL4R.js → MDEOBKC3.js} +3 -3
- package/dist/{3KJAGL4R.js.map → MDEOBKC3.js.map} +1 -1
- package/dist/{ZOR226BV.js → MJCI4XZ2.js} +3 -3
- package/dist/{ZOR226BV.js.map → MJCI4XZ2.js.map} +1 -1
- package/dist/{YKFGZTXG.js → MZMRFQTR.js} +3 -3
- package/dist/{YKFGZTXG.js.map → MZMRFQTR.js.map} +1 -1
- package/dist/{JO5BWI3K.js → NLMU226B.js} +3 -3
- package/dist/{JO5BWI3K.js.map → NLMU226B.js.map} +1 -1
- package/dist/{TBC7IPN4.js → NWXHRFA3.js} +4 -4
- package/dist/{TBC7IPN4.js.map → NWXHRFA3.js.map} +1 -1
- package/dist/{WVIUQYTV.js → NX67V54F.js} +3 -3
- package/dist/{WVIUQYTV.js.map → NX67V54F.js.map} +1 -1
- package/dist/{A2K22XWL.js → OMRF3GH2.js} +3 -3
- package/dist/{A2K22XWL.js.map → OMRF3GH2.js.map} +1 -1
- package/dist/{U4Y3HOBO.js → OQ2FVATH.js} +3 -3
- package/dist/{U4Y3HOBO.js.map → OQ2FVATH.js.map} +1 -1
- package/dist/{OQKVGBIX.js → P3A2XIFY.js} +3 -3
- package/dist/{OQKVGBIX.js.map → P3A2XIFY.js.map} +1 -1
- package/dist/{KDGN5Z34.js → PHVMGN7T.js} +3 -3
- package/dist/{KDGN5Z34.js.map → PHVMGN7T.js.map} +1 -1
- package/dist/{NZJBYDXC.js → PVONQCBG.js} +3 -3
- package/dist/{NZJBYDXC.js.map → PVONQCBG.js.map} +1 -1
- package/dist/{73I7CBP3.js → QYQCAXCB.js} +3 -3
- package/dist/{73I7CBP3.js.map → QYQCAXCB.js.map} +1 -1
- package/dist/{ONXLINKX.js → R26MH4UH.js} +4 -4
- package/dist/{ONXLINKX.js.map → R26MH4UH.js.map} +1 -1
- package/dist/{35Q7BMW7.js → REC34FNU.js} +3 -3
- package/dist/{35Q7BMW7.js.map → REC34FNU.js.map} +1 -1
- package/dist/{HCFMCRFF.js → RQXQCK22.js} +3 -3
- package/dist/{HCFMCRFF.js.map → RQXQCK22.js.map} +1 -1
- package/dist/{VVBAHHOY.js → TL2NURGK.js} +4 -4
- package/dist/{VVBAHHOY.js.map → TL2NURGK.js.map} +1 -1
- package/dist/{AMLJTQWB.js → TWUSN2QY.js} +3 -3
- package/dist/{AMLJTQWB.js.map → TWUSN2QY.js.map} +1 -1
- package/dist/{NKXEPWZV.js → U7ISOK6B.js} +3 -3
- package/dist/{NKXEPWZV.js.map → U7ISOK6B.js.map} +1 -1
- package/dist/{6YYHHOJO.js → VVR6BIVE.js} +3 -3
- package/dist/{6YYHHOJO.js.map → VVR6BIVE.js.map} +1 -1
- package/dist/{5SIPGHZY.js → W53LLP7R.js} +3 -3
- package/dist/{5SIPGHZY.js.map → W53LLP7R.js.map} +1 -1
- package/dist/{ZLPED4Y2.js → WIQFSNER.js} +3 -3
- package/dist/{ZLPED4Y2.js.map → WIQFSNER.js.map} +1 -1
- package/dist/{CTDZ456O.js → WQTILDML.js} +10 -7
- package/dist/WQTILDML.js.map +1 -0
- package/dist/{STHJGYPG.js → WRPKZZ4E.js} +3 -3
- package/dist/{STHJGYPG.js.map → WRPKZZ4E.js.map} +1 -1
- package/dist/{Y53QRDCG.js → XSEEW6TB.js} +3 -3
- package/dist/{Y53QRDCG.js.map → XSEEW6TB.js.map} +1 -1
- package/dist/{DCGM3XRM.js → YAMAXOF4.js} +3 -3
- package/dist/{DCGM3XRM.js.map → YAMAXOF4.js.map} +1 -1
- package/dist/{OELP4BR2.js → YN7J2UOM.js} +3 -3
- package/dist/{OELP4BR2.js.map → YN7J2UOM.js.map} +1 -1
- package/dist/{KH7RP6Q4.js → ZF6ASBPX.js} +3 -3
- package/dist/{KH7RP6Q4.js.map → ZF6ASBPX.js.map} +1 -1
- package/dist/{EDQ6FYO4.js → ZN2CNFMH.js} +3 -3
- package/dist/{EDQ6FYO4.js.map → ZN2CNFMH.js.map} +1 -1
- package/dist/client/canton-client.d.ts +29 -1
- package/dist/client/canton-client.d.ts.map +1 -1
- package/dist/client/canton-client.js +90 -90
- package/dist/client/index.js +91 -91
- package/dist/client/interface.d.ts +15 -1
- package/dist/client/interface.d.ts.map +1 -1
- package/dist/events.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +99 -98
- package/dist/open-api/apis/DefaultApi.js +89 -89
- package/dist/open-api/apis/index.js +89 -89
- package/dist/open-api/index.js +89 -89
- package/dist/open-api/models/Command1.js +2 -2
- package/dist/open-api/models/Completion.js +1 -1
- package/dist/open-api/models/Completion1.js +1 -1
- package/dist/open-api/models/CompletionResponse.js +1 -1
- package/dist/open-api/models/CompletionResponseOneOf.js +1 -1
- package/dist/open-api/models/CompletionStreamResponse.js +1 -1
- package/dist/open-api/models/CreateUserRequest.js +5 -5
- package/dist/open-api/models/CumulativeFilter.js +3 -3
- package/dist/open-api/models/DeduplicationPeriod1.js +1 -1
- package/dist/open-api/models/DeduplicationPeriod2.js +2 -2
- package/dist/open-api/models/Event.js +2 -2
- package/dist/open-api/models/EventFormat.js +5 -5
- package/dist/open-api/models/ExperimentalFeatures.js +2 -2
- package/dist/open-api/models/FeaturesDescriptor.js +3 -3
- package/dist/open-api/models/Filters.js +4 -4
- package/dist/open-api/models/GetActiveContractsRequest.js +7 -7
- package/dist/open-api/models/GetEventsByContractIdRequest.js +6 -6
- package/dist/open-api/models/GetLedgerApiVersionResponse.js +4 -4
- package/dist/open-api/models/GetTransactionByIdRequest.js +7 -7
- package/dist/open-api/models/GetTransactionByOffsetRequest.js +7 -7
- package/dist/open-api/models/GetUpdateByIdRequest.js +8 -8
- package/dist/open-api/models/GetUpdateByOffsetRequest.js +8 -8
- package/dist/open-api/models/GetUpdatesRequest.js +9 -9
- package/dist/open-api/models/GrantUserRightsRequest.js +4 -4
- package/dist/open-api/models/GrantUserRightsResponse.js +4 -4
- package/dist/open-api/models/IdentifierFilter.js +2 -2
- package/dist/open-api/models/JsContractEntry.js +2 -2
- package/dist/open-api/models/JsExecuteSubmissionAndWaitForTransactionRequest.js +12 -12
- package/dist/open-api/models/JsExecuteSubmissionAndWaitForTransactionResponse.js +4 -4
- package/dist/open-api/models/JsExecuteSubmissionAndWaitRequest.js +6 -6
- package/dist/open-api/models/JsExecuteSubmissionRequest.js +6 -6
- package/dist/open-api/models/JsGetActiveContractsResponse.js +3 -3
- package/dist/open-api/models/JsGetTransactionResponse.js +4 -4
- package/dist/open-api/models/JsGetUpdateResponse.js +15 -15
- package/dist/open-api/models/JsGetUpdatesResponse.js +15 -15
- package/dist/open-api/models/JsPrepareSubmissionRequest.js +4 -4
- package/dist/open-api/models/JsSubmitAndWaitForTransactionRequest.js +11 -11
- package/dist/open-api/models/JsSubmitAndWaitForTransactionResponse.js +4 -4
- package/dist/open-api/models/JsTopologyTransaction.js +6 -6
- package/dist/open-api/models/JsTransaction.js +3 -3
- package/dist/open-api/models/Kind.js +2 -2
- package/dist/open-api/models/ListUserRightsResponse.js +4 -4
- package/dist/open-api/models/MinLedgerTime.js +3 -3
- package/dist/open-api/models/ReassignmentCommand.js +3 -3
- package/dist/open-api/models/ReassignmentCommands.js +4 -4
- package/dist/open-api/models/RevokeUserRightsRequest.js +4 -4
- package/dist/open-api/models/RevokeUserRightsResponse.js +4 -4
- package/dist/open-api/models/Right.js +3 -3
- package/dist/open-api/models/SubmitAndWaitForReassignmentRequest.js +10 -10
- package/dist/open-api/models/SubmitReassignmentRequest.js +5 -5
- package/dist/open-api/models/Time.js +2 -2
- package/dist/open-api/models/TopologyEvent.js +5 -5
- package/dist/open-api/models/TopologyEventEvent.js +4 -4
- package/dist/open-api/models/TopologyTransaction.js +7 -7
- package/dist/open-api/models/Transaction.js +4 -4
- package/dist/open-api/models/TransactionFilter.js +5 -5
- package/dist/open-api/models/TransactionFormat.js +6 -6
- package/dist/open-api/models/Update.js +14 -14
- package/dist/open-api/models/UpdateFormat.js +7 -7
- package/dist/open-api/models/UpdateOneOf2.js +8 -8
- package/dist/open-api/models/UpdateOneOf3.js +5 -5
- package/dist/open-api/models/UpdatePartyDetailsRequest.js +1 -1
- package/dist/open-api/models/UpdateUserRequest.js +1 -1
- package/dist/open-api/models/index.js +88 -88
- package/dist/provider.d.ts +4 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +93 -93
- package/dist/senderPlaceholder.d.ts +31 -0
- package/dist/senderPlaceholder.d.ts.map +1 -0
- package/dist/senderPlaceholder.js +4 -0
- package/dist/senderPlaceholder.js.map +1 -0
- package/dist/transaction.d.ts +10 -11
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +1 -1
- package/dist/types.d.ts +47 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +9 -9
- package/src/client/canton-client.ts +72 -6
- package/src/client/interface.ts +17 -0
- package/src/index.ts +3 -0
- package/src/provider.ts +16 -8
- package/src/senderPlaceholder.ts +92 -0
- package/src/transaction.ts +13 -8
- package/src/types.ts +33 -0
- package/dist/CJEDJ6BA.js.map +0 -1
- package/dist/CTDZ456O.js.map +0 -1
- package/dist/JTRUQM7V.js.map +0 -1
|
@@ -29,6 +29,7 @@ import type {
|
|
|
29
29
|
PreparedTransaction,
|
|
30
30
|
SubmitActors,
|
|
31
31
|
SubmitResult,
|
|
32
|
+
UserRight,
|
|
32
33
|
WaitOptions,
|
|
33
34
|
WaitResult,
|
|
34
35
|
} from '../types';
|
|
@@ -304,6 +305,49 @@ export class CantonClient implements ICantonClient {
|
|
|
304
305
|
};
|
|
305
306
|
}
|
|
306
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Return the rights granted to the current user (this.#userId).
|
|
310
|
+
*
|
|
311
|
+
* Bypasses the OpenAPI generator's typed `Kind` converter, which is
|
|
312
|
+
* broken: `instanceOfKindOneOf` checks lowercase `canActAs in value`, but
|
|
313
|
+
* `KindOneOfFromJSONTyped` reads uppercase `json['CanActAs']`, so the
|
|
314
|
+
* typed client returns every `kind` as `{}`. We parse the raw JSON
|
|
315
|
+
* ourselves to preserve the actual variant payload.
|
|
316
|
+
*/
|
|
317
|
+
async listUserRights(): Promise<UserRight[]> {
|
|
318
|
+
const apiResponse = await this.#api.getV2UsersUserIdRightsRaw({
|
|
319
|
+
userId: this.#userId,
|
|
320
|
+
});
|
|
321
|
+
const raw = (await apiResponse.raw.json()) as { rights?: UserRight[] };
|
|
322
|
+
return raw.rights ?? [];
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Return the parties the current user has CanActAs or CanReadAs rights
|
|
327
|
+
* for. Convenience wrapper over `listUserRights()` for the common case
|
|
328
|
+
* where the caller just needs party-scoped access (e.g. to query events
|
|
329
|
+
* or fetch transactions).
|
|
330
|
+
*
|
|
331
|
+
* Use this instead of `listParties()` when the caller only has scoped
|
|
332
|
+
* rights — `listParties()` returns *all* parties on the participant
|
|
333
|
+
* (including DSO, splice parties), and Canton returns 403 if you query
|
|
334
|
+
* as a party you can't read.
|
|
335
|
+
*/
|
|
336
|
+
async listUserParties(): Promise<string[]> {
|
|
337
|
+
const rights = await this.listUserRights();
|
|
338
|
+
const parties = new Set<string>();
|
|
339
|
+
for (const right of rights) {
|
|
340
|
+
// Only `CanActAs` / `CanReadAs` carry a party; the other four
|
|
341
|
+
// variants (ParticipantAdmin, IdentityProviderAdmin,
|
|
342
|
+
// CanReadAsAnyParty, CanExecuteAsAnyParty) have empty payloads.
|
|
343
|
+
const party = right.kind.CanActAs?.value.party ?? right.kind.CanReadAs?.value.party;
|
|
344
|
+
if (party !== undefined) {
|
|
345
|
+
parties.add(party);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return [...parties];
|
|
349
|
+
}
|
|
350
|
+
|
|
307
351
|
/**
|
|
308
352
|
* Allocate a new party on the participant node.
|
|
309
353
|
*
|
|
@@ -736,7 +780,12 @@ export class CantonClient implements ICantonClient {
|
|
|
736
780
|
},
|
|
737
781
|
};
|
|
738
782
|
|
|
739
|
-
|
|
783
|
+
let response;
|
|
784
|
+
try {
|
|
785
|
+
response = await this.#api.postV2InteractiveSubmissionPrepare(request);
|
|
786
|
+
} catch (error: unknown) {
|
|
787
|
+
throw await this.#throwApiError(error, 'Interactive submission prepare');
|
|
788
|
+
}
|
|
740
789
|
const validated = this.#validatePrepareResponse(response);
|
|
741
790
|
|
|
742
791
|
return {
|
|
@@ -788,7 +837,11 @@ export class CantonClient implements ICantonClient {
|
|
|
788
837
|
},
|
|
789
838
|
};
|
|
790
839
|
|
|
791
|
-
|
|
840
|
+
try {
|
|
841
|
+
await this.#api.postV2InteractiveSubmissionExecute(request);
|
|
842
|
+
} catch (error: unknown) {
|
|
843
|
+
throw await this.#throwApiError(error, 'Interactive submission execute');
|
|
844
|
+
}
|
|
792
845
|
|
|
793
846
|
return { commandId: prepared.commandId, completionOffset };
|
|
794
847
|
}
|
|
@@ -868,6 +921,12 @@ export class CantonClient implements ICantonClient {
|
|
|
868
921
|
/**
|
|
869
922
|
* Stream transactions from a given offset.
|
|
870
923
|
*
|
|
924
|
+
* Uses `updateFormat` with `TRANSACTION_SHAPE_LEDGER_EFFECTS` so consumers
|
|
925
|
+
* receive `ExercisedEvent`s (e.g. the request-poller depends on
|
|
926
|
+
* `Request_Create` exercise results). The deprecated legacy `filter`
|
|
927
|
+
* shape would default to `ACS_DELTA`, which only emits Created/Archived
|
|
928
|
+
* events and silently drops every exercise on the wire.
|
|
929
|
+
*
|
|
871
930
|
* @param party - Party to query as
|
|
872
931
|
* @param beginExclusive - Start offset (exclusive)
|
|
873
932
|
* @param endInclusive - End offset (inclusive)
|
|
@@ -880,16 +939,23 @@ export class CantonClient implements ICantonClient {
|
|
|
880
939
|
endInclusive: number,
|
|
881
940
|
opts?: { templateIds?: string[]; limit?: number },
|
|
882
941
|
): Promise<CantonUpdate[]> {
|
|
942
|
+
const eventFormat = {
|
|
943
|
+
filtersByParty: {
|
|
944
|
+
[party]: { cumulative: this.#buildCumulativeFilters(opts?.templateIds) },
|
|
945
|
+
},
|
|
946
|
+
verbose: false,
|
|
947
|
+
};
|
|
883
948
|
const rawResponse = await this.#api.postV2UpdatesRaw({
|
|
884
949
|
getUpdatesRequest: {
|
|
885
950
|
beginExclusive,
|
|
886
951
|
endInclusive,
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
952
|
+
verbose: false,
|
|
953
|
+
updateFormat: {
|
|
954
|
+
includeTransactions: {
|
|
955
|
+
eventFormat,
|
|
956
|
+
transactionShape: 'TRANSACTION_SHAPE_LEDGER_EFFECTS' as const,
|
|
890
957
|
},
|
|
891
958
|
},
|
|
892
|
-
verbose: true,
|
|
893
959
|
},
|
|
894
960
|
limit: opts?.limit,
|
|
895
961
|
});
|
package/src/client/interface.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type {
|
|
|
17
17
|
PreparedTransaction,
|
|
18
18
|
SubmitActors,
|
|
19
19
|
SubmitResult,
|
|
20
|
+
UserRight,
|
|
20
21
|
WaitOptions,
|
|
21
22
|
WaitResult,
|
|
22
23
|
} from '../types';
|
|
@@ -178,6 +179,22 @@ export interface ICantonClient {
|
|
|
178
179
|
pageToken?: string;
|
|
179
180
|
}): Promise<{ parties: string[]; nextPageToken: string }>;
|
|
180
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Return the rights granted to the current user (this user's userId in
|
|
184
|
+
* the underlying token).
|
|
185
|
+
*
|
|
186
|
+
* GET /v2/users/{userId}/rights
|
|
187
|
+
*/
|
|
188
|
+
listUserRights(): Promise<UserRight[]>;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Convenience wrapper over `listUserRights()` returning just the parties
|
|
192
|
+
* the current user has CanActAs / CanReadAs rights for. Use instead of
|
|
193
|
+
* `listParties()` when the call requires scoped read access (Canton
|
|
194
|
+
* returns 403 if you query as a party you can't read).
|
|
195
|
+
*/
|
|
196
|
+
listUserParties(): Promise<string[]>;
|
|
197
|
+
|
|
181
198
|
/**
|
|
182
199
|
* Allocate a new party on the participant node.
|
|
183
200
|
*
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './auth';
|
|
2
2
|
export * from './events';
|
|
3
3
|
export * from './provider';
|
|
4
|
+
export * from './senderPlaceholder';
|
|
4
5
|
export * from './transaction';
|
|
5
6
|
|
|
6
7
|
// Core types
|
|
@@ -13,6 +14,8 @@ export {
|
|
|
13
14
|
type SubmitActors,
|
|
14
15
|
type SubmitResult,
|
|
15
16
|
type TemplateId,
|
|
17
|
+
type UserRight,
|
|
18
|
+
type UserRightKind,
|
|
16
19
|
type WaitOptions,
|
|
17
20
|
type WaitResult,
|
|
18
21
|
} from './types';
|
package/src/provider.ts
CHANGED
|
@@ -24,6 +24,8 @@ export type CantonProvider = {
|
|
|
24
24
|
client: ICantonClient;
|
|
25
25
|
grpcClient: CantonGrpcClient;
|
|
26
26
|
tokenProvider: TokenProvider;
|
|
27
|
+
/** Validator wallet URL for scan-proxy CIP-56 endpoints. */
|
|
28
|
+
walletUrl?: string;
|
|
27
29
|
};
|
|
28
30
|
|
|
29
31
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -37,6 +39,8 @@ export type CantonUriParams = {
|
|
|
37
39
|
adminApiHost: string;
|
|
38
40
|
/** Ledger API user ID (default: "participant_admin") */
|
|
39
41
|
userId: string;
|
|
42
|
+
/** Validator wallet URL for scan-proxy CIP-56 endpoints (e.g. "http://localhost:7201") */
|
|
43
|
+
walletUrl?: string;
|
|
40
44
|
/** OAuth2 client credentials config — present only for non-local environments */
|
|
41
45
|
oauth2?: ClientCredentialsTokenProviderConfig;
|
|
42
46
|
};
|
|
@@ -54,25 +58,26 @@ export type CantonUriParams = {
|
|
|
54
58
|
export function parseCantonUri(uri: string): CantonUriParams {
|
|
55
59
|
const url = new URL(uri);
|
|
56
60
|
|
|
57
|
-
//
|
|
61
|
+
// `admin-api` is a gRPC `host:port` (no scheme), so it carries no TLS signal.
|
|
62
|
+
// TODO(CANTON): convey TLS for non-localhost (e.g. `&admin-api-tls=1` or `admin-api=grpcs://host:port`).
|
|
58
63
|
const adminApiHost = url.searchParams.get('admin-api');
|
|
59
64
|
if (!adminApiHost) {
|
|
60
65
|
throw new Error('Canton provider URI missing required "admin-api" query parameter');
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
const userId = url.searchParams.get('user-id') ?? 'participant_admin';
|
|
69
|
+
const walletUrl = url.searchParams.get('wallet-url') ?? undefined;
|
|
64
70
|
const tokenUrl = url.searchParams.get('token-url') ?? undefined;
|
|
65
71
|
const clientId = url.searchParams.get('client-id') ?? undefined;
|
|
66
72
|
const clientSecret = url.searchParams.get('client-secret') ?? undefined;
|
|
67
73
|
const scope = url.searchParams.get('scope') ?? undefined;
|
|
68
74
|
const audience = url.searchParams.get('audience') ?? undefined;
|
|
69
75
|
|
|
70
|
-
// Remove Canton params to get clean JSON API URL
|
|
71
76
|
for (const key of [
|
|
72
77
|
'admin-api',
|
|
73
78
|
'user-id',
|
|
79
|
+
'wallet-url',
|
|
74
80
|
'token-url',
|
|
75
|
-
// TODO: check if these are acceptable in our providers config, we do the same with api-keys currently.
|
|
76
81
|
'client-id',
|
|
77
82
|
'client-secret',
|
|
78
83
|
'scope',
|
|
@@ -81,7 +86,6 @@ export function parseCantonUri(uri: string): CantonUriParams {
|
|
|
81
86
|
url.searchParams.delete(key);
|
|
82
87
|
}
|
|
83
88
|
|
|
84
|
-
// Reconstruct clean base URL (origin + pathname, plus any remaining query params)
|
|
85
89
|
const jsonApiUrl = url.toString().replace(/\/$/, '');
|
|
86
90
|
|
|
87
91
|
const oauth2 =
|
|
@@ -89,7 +93,7 @@ export function parseCantonUri(uri: string): CantonUriParams {
|
|
|
89
93
|
? { tokenUrl, clientId, clientSecret, scope, audience }
|
|
90
94
|
: undefined;
|
|
91
95
|
|
|
92
|
-
return { jsonApiUrl, adminApiHost, userId, oauth2 };
|
|
96
|
+
return { jsonApiUrl, adminApiHost, userId, walletUrl, oauth2 };
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -131,7 +135,12 @@ export function createCantonProvider({
|
|
|
131
135
|
tokenProvider,
|
|
132
136
|
});
|
|
133
137
|
|
|
134
|
-
return {
|
|
138
|
+
return {
|
|
139
|
+
client,
|
|
140
|
+
grpcClient,
|
|
141
|
+
tokenProvider,
|
|
142
|
+
walletUrl: params.walletUrl,
|
|
143
|
+
};
|
|
135
144
|
}
|
|
136
145
|
|
|
137
146
|
function createTokenProvider(params: CantonUriParams, isLocal: boolean): TokenProvider {
|
|
@@ -143,8 +152,7 @@ function createTokenProvider(params: CantonUriParams, isLocal: boolean): TokenPr
|
|
|
143
152
|
});
|
|
144
153
|
}
|
|
145
154
|
|
|
146
|
-
// TODO: add other
|
|
147
|
-
// Non-local: require OAuth2 client credentials
|
|
155
|
+
// TODO(CANTON): add other prod auth methods (direct JWT passthrough, etc.).
|
|
148
156
|
if (!params.oauth2) {
|
|
149
157
|
throw new Error(
|
|
150
158
|
'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret) in the provider URI',
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { mapValues } from 'es-toolkit';
|
|
2
|
+
|
|
3
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
// Generic JSON-tree visitors
|
|
5
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Result of a leaf check: either the leaf has been replaced (with `value`),
|
|
9
|
+
* or `undefined` to leave it alone and recurse into its children.
|
|
10
|
+
*/
|
|
11
|
+
type LeafResult = { value: unknown } | undefined;
|
|
12
|
+
|
|
13
|
+
/** Walk a JSON value and rewrite leaves matched by `replace`; recursion stops at a swapped leaf. */
|
|
14
|
+
const visit = <T>(value: T, replace: (leaf: unknown) => LeafResult): T => {
|
|
15
|
+
const result = replace(value);
|
|
16
|
+
if (result) return result.value as T;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
return value.map((item) => visit(item, replace)) as T;
|
|
19
|
+
}
|
|
20
|
+
if (value !== null && typeof value === 'object') {
|
|
21
|
+
return mapValues(value as Record<string, unknown>, (item) => visit(item, replace)) as T;
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** True if `predicate` matches any leaf or sub-value in the tree. */
|
|
27
|
+
const containsLeaf = (value: unknown, predicate: (leaf: unknown) => boolean): boolean => {
|
|
28
|
+
if (predicate(value)) return true;
|
|
29
|
+
if (Array.isArray(value)) return value.some((item) => containsLeaf(item, predicate));
|
|
30
|
+
return (
|
|
31
|
+
value !== null &&
|
|
32
|
+
typeof value === 'object' &&
|
|
33
|
+
Object.values(value).some((item) => containsLeaf(item, predicate))
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
38
|
+
// Sender placeholder
|
|
39
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sentinel emitted in place of the sender `Party` when the sender is unknown at
|
|
43
|
+
* create time; substituted for the real party at sign time.
|
|
44
|
+
*/
|
|
45
|
+
export const CANTON_SENDER_PLACEHOLDER = '<<CANTON_SENDER_PLACEHOLDER>>';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns true if `value` is the Canton sender placeholder.
|
|
49
|
+
*/
|
|
50
|
+
export const isCantonSenderPlaceholder = (value: string): boolean =>
|
|
51
|
+
value === CANTON_SENDER_PLACEHOLDER;
|
|
52
|
+
|
|
53
|
+
/** Replace every {@link CANTON_SENDER_PLACEHOLDER} in a command tree with the actual sender party ID. */
|
|
54
|
+
export const replaceCantonSenderPlaceholders = <T>(value: T, senderParty: string): T =>
|
|
55
|
+
visit(value, (leaf) =>
|
|
56
|
+
leaf === CANTON_SENDER_PLACEHOLDER ? { value: senderParty } : undefined,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
/** Returns true if the command tree contains the sender placeholder anywhere. */
|
|
60
|
+
export const containsCantonSenderPlaceholder = (value: unknown): boolean =>
|
|
61
|
+
containsLeaf(value, (leaf) => leaf === CANTON_SENDER_PLACEHOLDER);
|
|
62
|
+
|
|
63
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
64
|
+
// AmuletCids placeholder
|
|
65
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Sentinel emitted as the sole element of the `amuletCids` array
|
|
69
|
+
* (`amuletCids: [CANTON_AMULET_CIDS_PLACEHOLDER]`); substituted for the resolved
|
|
70
|
+
* sender's Amulet contract IDs at sign time.
|
|
71
|
+
*/
|
|
72
|
+
export const CANTON_AMULET_CIDS_PLACEHOLDER = '<<CANTON_AMULET_CIDS_PLACEHOLDER>>';
|
|
73
|
+
|
|
74
|
+
const isAmuletCidsPlaceholderArray = (value: unknown): value is [string] =>
|
|
75
|
+
Array.isArray(value) && value.length === 1 && value[0] === CANTON_AMULET_CIDS_PLACEHOLDER;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if the command tree contains an amulet-cids placeholder array
|
|
79
|
+
* anywhere — i.e. an array `[CANTON_AMULET_CIDS_PLACEHOLDER]`.
|
|
80
|
+
*/
|
|
81
|
+
export const containsCantonAmuletCidsPlaceholder = (value: unknown): boolean =>
|
|
82
|
+
containsLeaf(value, isAmuletCidsPlaceholderArray);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Recursively walks a JSON-serializable value and replaces every
|
|
86
|
+
* `[CANTON_AMULET_CIDS_PLACEHOLDER]` array with the supplied list of resolved
|
|
87
|
+
* Amulet contract IDs.
|
|
88
|
+
*/
|
|
89
|
+
export const replaceCantonAmuletCidsPlaceholder = <T>(value: T, amuletCids: string[]): T =>
|
|
90
|
+
visit(value, (leaf) =>
|
|
91
|
+
isAmuletCidsPlaceholderArray(leaf) ? { value: amuletCids } : undefined,
|
|
92
|
+
);
|
package/src/transaction.ts
CHANGED
|
@@ -10,9 +10,8 @@ import type { PartialBy } from '@layerzerolabs/typescript-utils';
|
|
|
10
10
|
|
|
11
11
|
// === Component schemas ===
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// they carry arbitrary Daml values whose shape depends on the template.
|
|
13
|
+
// Payload fields (createArguments, choiceArgument, contractKey) are z.any() —
|
|
14
|
+
// arbitrary Daml values whose shape depends on the template.
|
|
16
15
|
|
|
17
16
|
const createCommandSchema = z.object({
|
|
18
17
|
templateId: z.string(),
|
|
@@ -55,7 +54,7 @@ export const cantonDisclosedContractSchema = z.object({
|
|
|
55
54
|
});
|
|
56
55
|
|
|
57
56
|
/** Output of prepareForSigning — needed by submitSigned to execute the transaction. */
|
|
58
|
-
const
|
|
57
|
+
const cantonInflightTransactionSchema = z.object({
|
|
59
58
|
/** The prepared transaction blob */
|
|
60
59
|
preparedTransaction: z.string(),
|
|
61
60
|
/** Hash of the prepared transaction (what was signed) */
|
|
@@ -67,6 +66,10 @@ const _cantonInflightTransactionSchema = z.object({
|
|
|
67
66
|
]),
|
|
68
67
|
/** Command ID for tracking */
|
|
69
68
|
commandId: z.string(),
|
|
69
|
+
/** Ledger offset at which the submission landed — used as `beginExclusive`
|
|
70
|
+
* for waitForCommand to avoid polling from the start of the ledger.
|
|
71
|
+
* Optional: only present after send(); absent for old/retry scenarios. */
|
|
72
|
+
completionOffset: z.number().optional(),
|
|
70
73
|
});
|
|
71
74
|
|
|
72
75
|
// === Lifecycle schemas ===
|
|
@@ -85,8 +88,10 @@ export const cantonTransactionSchema = transactionSchema.extend({
|
|
|
85
88
|
commands: z.array(cantonCommandSchema),
|
|
86
89
|
/** Disclosed contracts for contract/key lookups */
|
|
87
90
|
disclosedContracts: z.array(cantonDisclosedContractSchema),
|
|
88
|
-
/** Maps each actAs party ID → senderEntityName that controls its
|
|
89
|
-
|
|
91
|
+
/** Maps each `actAs` party ID → the senderEntityName that controls its
|
|
92
|
+
* signing key. Optional in the schema, but must be populated and cover
|
|
93
|
+
* every `actAs` party before the transaction can be signed. */
|
|
94
|
+
partyToSenderEntity: z.record(z.string(), z.string()).optional(),
|
|
90
95
|
}),
|
|
91
96
|
});
|
|
92
97
|
|
|
@@ -95,7 +100,7 @@ export const cantonTransactionSchema = transactionSchema.extend({
|
|
|
95
100
|
*/
|
|
96
101
|
export const cantonAssignedTransactionSchema = assignedTransactionSchema.extend({
|
|
97
102
|
...cantonTransactionSchema.shape,
|
|
98
|
-
inflightTransaction:
|
|
103
|
+
inflightTransaction: cantonInflightTransactionSchema.optional(),
|
|
99
104
|
});
|
|
100
105
|
|
|
101
106
|
/**
|
|
@@ -126,7 +131,7 @@ export const cantonSignedTransactionSchema = signedTransactionSchema.extend({
|
|
|
126
131
|
*/
|
|
127
132
|
export const cantonMinedTransactionSchema = minedTransactionSchema.extend({
|
|
128
133
|
...cantonSignedTransactionSchema.shape,
|
|
129
|
-
inflightTransaction:
|
|
134
|
+
inflightTransaction: cantonInflightTransactionSchema,
|
|
130
135
|
});
|
|
131
136
|
|
|
132
137
|
// === Types ===
|
package/src/types.ts
CHANGED
|
@@ -106,6 +106,39 @@ export type ExternalSignature = {
|
|
|
106
106
|
signingAlgorithmSpec: string;
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
/**
|
|
110
|
+
* A right granted to a Canton user, as returned by `/v2/users/{userId}/rights`.
|
|
111
|
+
*
|
|
112
|
+
* The `kind` is a discriminated union — only one variant is set per right:
|
|
113
|
+
* - `CanActAs.value.party`: user can submit transactions as that party
|
|
114
|
+
* - `CanReadAs.value.party`: user can read events visible to that party
|
|
115
|
+
* - `ParticipantAdmin`: user has admin rights on the participant
|
|
116
|
+
* - `IdentityProviderAdmin`: user can administer its identity provider
|
|
117
|
+
* - `CanReadAsAnyParty`: user can read as any party
|
|
118
|
+
* - `CanExecuteAsAnyParty`: user can submit as any party
|
|
119
|
+
*
|
|
120
|
+
* Hand-rolled because the OpenAPI generator's `Kind` converter is broken
|
|
121
|
+
* (`instanceOfKindOneOf` checks lowercase `canActAs`, but `KindOneOfFromJSON`
|
|
122
|
+
* reads uppercase `CanActAs`), so the typed client strips all party data.
|
|
123
|
+
*
|
|
124
|
+
* The four nullary variants carry `value: unknown` because Canton's wire
|
|
125
|
+
* format for them is literally `{ "value": {} }` (see
|
|
126
|
+
* https://docs.digitalasset.com/build/3.4/explanations/json-api/) and we
|
|
127
|
+
* never read into that payload — only the presence of the variant matters.
|
|
128
|
+
*/
|
|
129
|
+
export type UserRightKind = {
|
|
130
|
+
CanActAs?: { value: { party: string } };
|
|
131
|
+
CanReadAs?: { value: { party: string } };
|
|
132
|
+
ParticipantAdmin?: { value: unknown };
|
|
133
|
+
IdentityProviderAdmin?: { value: unknown };
|
|
134
|
+
CanReadAsAnyParty?: { value: unknown };
|
|
135
|
+
CanExecuteAsAnyParty?: { value: unknown };
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type UserRight = {
|
|
139
|
+
kind: UserRightKind;
|
|
140
|
+
};
|
|
141
|
+
|
|
109
142
|
/** Normalized active contract (flat shape derived from JsActiveContract). */
|
|
110
143
|
export type NormalizedActiveContract = {
|
|
111
144
|
contractId: string;
|
package/dist/CJEDJ6BA.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transaction.ts"],"names":["createCommandSchema","z","object","templateId","string","createArguments","any","exerciseCommandSchema","contractId","choice","choiceArgument","createAndExerciseCommandSchema","exerciseByKeyCommandSchema","contractKey","cantonCommandSchema","union","createCommand","exerciseCommand","createAndExerciseCommand","exerciseByKeyCommand","cantonDisclosedContractSchema","optional","createdEventBlob","synchronizerId","_cantonInflightTransactionSchema","preparedTransaction","preparedTransactionHash","hashingSchemeVersion","enum","commandId","cantonTransactionSchema","transactionSchema","extend","populatedTransaction","actAs","array","commands","disclosedContracts","partyToSenderEntity","record","cantonAssignedTransactionSchema","assignedTransactionSchema","shape","inflightTransaction","cantonSignedTransactionSchema","signedTransactionSchema","signedTransaction","signatures","party","format","signature","signedBy","signingAlgorithmSpec","cantonMinedTransactionSchema","minedTransactionSchema","buildCantonTransaction","chainName","tx","timestamps","created","Date","now"],"mappings":";;;;AAgBA,IAAMA,mBAAAA,GAAsBC,EAAEC,MAAAA,CAAO;AACjCC,EAAAA,UAAAA,EAAYF,EAAEG,MAAAA,EAAM;AACpBC,EAAAA,eAAAA,EAAiBJ,EAAEK,GAAAA;AACvB,CAAA,CAAA;AAEA,IAAMC,qBAAAA,GAAwBN,EAAEC,MAAAA,CAAO;AACnCC,EAAAA,UAAAA,EAAYF,EAAEG,MAAAA,EAAM;AACpBI,EAAAA,UAAAA,EAAYP,EAAEG,MAAAA,EAAM;AACpBK,EAAAA,MAAAA,EAAQR,EAAEG,MAAAA,EAAM;AAChBM,EAAAA,cAAAA,EAAgBT,EAAEK,GAAAA;AACtB,CAAA,CAAA;AAEA,IA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CAAEkC,KAAAA,CACVlC,CAAAA,CAAEC,MAAAA,CAAO;AACL+C,QAAAA,MAAAA,EAAQhD,EAAEG,MAAAA,EAAM;AAChB8C,QAAAA,SAAAA,EAAWjD,EAAEG,MAAAA,EAAM;AACnB+C,QAAAA,QAAAA,EAAUlD,EAAEG,MAAAA,EAAM;AAClBgD,QAAAA,oBAAAA,EAAsBnD,EAAEG,MAAAA;AAC5B,OAAA,CAAA;AAER,KAAA,CAAA;GAER;AACJ,CAAA;AAKO,IAAMiD,4BAAAA,GAA+BC,uBAAuBtB,MAAAA,CAAO;AACtE,EAAA,GAAGY,6BAAAA,CAA8BF,KAAAA;EACjCC,mBAAAA,EAAqBnB;AACzB,CAAA;AAaO,IAAM+B,sBAAAA,mBAAyB,MAAA,CAAA,OAClCC,SAAAA,EACAC,EAAAA,KAAAA;AAEA,EAAA,OAAO;IACH,GAAGA,EAAAA;AACHD,IAAAA,SAAAA;IACAE,UAAAA,EAAY;AACRC,MAAAA,OAAAA,EAASF,EAAAA,CAAGC,UAAAA,EAAYC,OAAAA,IAAWC,IAAAA,CAAKC,GAAAA;AAC5C;AACJ,GAAA;AACJ,CAAA,EAXsC,wBAAA","file":"CJEDJ6BA.js","sourcesContent":["import { z } from 'zod';\n\nimport {\n assignedTransactionSchema,\n minedTransactionSchema,\n signedTransactionSchema,\n transactionSchema,\n} from '@layerzerolabs/common-chain-model';\nimport type { PartialBy } from '@layerzerolabs/typescript-utils';\n\n// === Component schemas ===\n\n// Daml command schemas mirror the OpenAPI-generated Command union (Command = CommandOneOf | ... | CommandOneOf3).\n// Payload fields (createArguments, choiceArgument, contractKey) are z.any() because\n// they carry arbitrary Daml values whose shape depends on the template.\n\nconst createCommandSchema = z.object({\n templateId: z.string(),\n createArguments: z.any(),\n});\n\nconst exerciseCommandSchema = z.object({\n templateId: z.string(),\n contractId: z.string(),\n choice: z.string(),\n choiceArgument: z.any(),\n});\n\nconst createAndExerciseCommandSchema = z.object({\n templateId: z.string(),\n createArguments: z.any(),\n choice: z.string(),\n choiceArgument: z.any(),\n});\n\nconst exerciseByKeyCommandSchema = z.object({\n templateId: z.string(),\n contractKey: z.any(),\n choice: z.string(),\n choiceArgument: z.any(),\n});\n\nexport const cantonCommandSchema = z.union([\n z.object({ createCommand: createCommandSchema }),\n z.object({ exerciseCommand: exerciseCommandSchema }),\n z.object({ createAndExerciseCommand: createAndExerciseCommandSchema }),\n z.object({ exerciseByKeyCommand: exerciseByKeyCommandSchema }),\n]);\n\nexport const cantonDisclosedContractSchema = z.object({\n templateId: z.string().optional(),\n contractId: z.string(),\n createdEventBlob: z.string(),\n synchronizerId: z.string(),\n});\n\n/** Output of prepareForSigning — needed by submitSigned to execute the transaction. */\nconst _cantonInflightTransactionSchema = z.object({\n /** The prepared transaction blob */\n preparedTransaction: z.string(),\n /** Hash of the prepared transaction (what was signed) */\n preparedTransactionHash: z.string(),\n /** Hashing scheme version used */\n hashingSchemeVersion: z.enum([\n 'HASHING_SCHEME_VERSION_UNSPECIFIED',\n 'HASHING_SCHEME_VERSION_V2',\n ]),\n /** Command ID for tracking */\n commandId: z.string(),\n});\n\n// === Lifecycle schemas ===\n\n/**\n * Canton transaction schema for Daml Ledger API commands.\n *\n * Canton uses an interactive submission (prepare-sign-submit) flow for external party signing.\n * The populatedTransaction contains the commands to send to prepareForSigning.\n */\nexport const cantonTransactionSchema = transactionSchema.extend({\n populatedTransaction: z.object({\n /** Parties submitting the command (actAs) */\n actAs: z.array(z.string()),\n /** Daml commands to send to prepareForSigning */\n commands: z.array(cantonCommandSchema),\n /** Disclosed contracts for contract/key lookups */\n disclosedContracts: z.array(cantonDisclosedContractSchema),\n /** Maps each actAs party ID → senderEntityName that controls its signing key */\n partyToSenderEntity: z.record(z.string(), z.string()),\n }),\n});\n\n/**\n * Assigned transaction includes the inflight transaction data.\n */\nexport const cantonAssignedTransactionSchema = assignedTransactionSchema.extend({\n ...cantonTransactionSchema.shape,\n inflightTransaction: _cantonInflightTransactionSchema.optional(),\n});\n\n/**\n * Signed transaction includes the DER-encoded ECDSA signature.\n */\nexport const cantonSignedTransactionSchema = signedTransactionSchema.extend({\n ...cantonAssignedTransactionSchema.shape,\n signedTransaction: z.object({\n /** Per-party signatures in the format expected by Canton's submitSigned */\n signatures: z.array(\n z.object({\n party: z.string(),\n signatures: z.array(\n z.object({\n format: z.string(),\n signature: z.string(),\n signedBy: z.string(),\n signingAlgorithmSpec: z.string(),\n }),\n ),\n }),\n ),\n }),\n});\n\n/**\n * Mined transaction with confirmation result.\n */\nexport const cantonMinedTransactionSchema = minedTransactionSchema.extend({\n ...cantonSignedTransactionSchema.shape,\n inflightTransaction: _cantonInflightTransactionSchema,\n});\n\n// === Types ===\n\nexport type CantonTx = z.infer<typeof cantonTransactionSchema>;\nexport type CantonAssignedTx = z.infer<typeof cantonAssignedTransactionSchema>;\nexport type CantonSignedTx = z.infer<typeof cantonSignedTransactionSchema>;\nexport type CantonMinedTx = z.infer<typeof cantonMinedTransactionSchema>;\n\n// === Builder ===\n\nexport type BuildCantonTransactionInput = PartialBy<CantonTx, 'chainName' | 'timestamps'>;\n\nexport const buildCantonTransaction = async (\n chainName: string,\n tx: BuildCantonTransactionInput,\n): Promise<CantonTx> => {\n return {\n ...tx,\n chainName,\n timestamps: {\n created: tx.timestamps?.created ?? Date.now(),\n },\n };\n};\n"]}
|
package/dist/CTDZ456O.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"names":["parseCantonUri","uri","url","URL","adminApiHost","searchParams","get","Error","userId","tokenUrl","undefined","clientId","clientSecret","scope","audience","key","delete","jsonApiUrl","toString","replace","oauth2","createCantonProvider","isLocal","params","tokenProvider","createTokenProvider","configuration","Configuration","basePath","accessToken","getToken","client","CantonClient","grpcClient","CantonGrpcClient","host","LocalTokenProvider","actAs","admin","ClientCredentialsTokenProvider"],"mappings":";;;;;;;;AAqDO,SAASA,eAAeC,GAAAA,EAAW;AACtC,EAAA,MAAMC,GAAAA,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AAC1B5B,MAAAA,MAAAA,EAAQe,MAAAA,CAAOf,MAAAA;AACf6B,MAAAA,KAAAA,EAAO,EAAA;MACPC,KAAAA,EAAO;KACX,CAAA;AACJ,EAAA;AAIA,EAAA,IAAI,CAACf,OAAOH,MAAAA,EAAQ;AAChB,IAAA,MAAM,IAAIb,MACN,uGAAA,CAAA;AAER,EAAA;AAEA,EAAA,OAAO,IAAIgC,8BAAAA,CAA+BhB,MAAAA,CAAOH,MAAM,CAAA;AAC3D;AAlBSK,MAAAA,CAAAA,mBAAAA,EAAAA,qBAAAA,CAAAA","file":"CTDZ456O.js","sourcesContent":["import {\n ClientCredentialsTokenProvider,\n type ClientCredentialsTokenProviderConfig,\n} from './auth/client-credentials-token-provider';\nimport { LocalTokenProvider } from './auth/local-token-provider';\nimport type { TokenProvider } from './auth/token-provider';\nimport { CantonClient } from './client/canton-client';\nimport { CantonGrpcClient } from './client/grpc';\nimport type { ICantonClient } from './client/interface';\nimport { Configuration } from './open-api/runtime';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Type\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Composite provider for Canton — bundles both transport layers and shared auth.\n *\n * - {@link client} — JSON Ledger API (commands, queries, updates)\n * - {@link grpcClient} — gRPC Admin API (topology transactions, namespace queries)\n * - {@link tokenProvider} — Shared Bearer-token source used by both transports\n */\nexport type CantonProvider = {\n client: ICantonClient;\n grpcClient: CantonGrpcClient;\n tokenProvider: TokenProvider;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// URI Parsing\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CantonUriParams = {\n /** Base URL of the JSON Ledger API (e.g. \"http://localhost:5975\") */\n jsonApiUrl: string;\n /** Host:port of the gRPC Admin API (e.g. \"localhost:5076\") */\n adminApiHost: string;\n /** Ledger API user ID (default: \"participant_admin\") */\n userId: string;\n /** OAuth2 client credentials config — present only for non-local environments */\n oauth2?: ClientCredentialsTokenProviderConfig;\n};\n\n/**\n * Parse a Canton provider URI into its constituent parts.\n *\n * URI format:\n * `<json-api-base>?admin-api=<host:port>&user-id=<id>[&token-url=...&client-id=...&client-secret=...&scope=...&audience=...]`\n *\n * The base URL (everything before the query string) is the JSON Ledger API endpoint.\n * Canton-specific params are extracted and removed; any remaining query params are\n * preserved on the JSON API URL.\n */\nexport function parseCantonUri(uri: string): CantonUriParams {\n const url = new URL(uri);\n\n // Extract Canton-specific params\n const adminApiHost = url.searchParams.get('admin-api');\n if (!adminApiHost) {\n throw new Error('Canton provider URI missing required \"admin-api\" query parameter');\n }\n\n const userId = url.searchParams.get('user-id') ?? 'participant_admin';\n const tokenUrl = url.searchParams.get('token-url') ?? undefined;\n const clientId = url.searchParams.get('client-id') ?? undefined;\n const clientSecret = url.searchParams.get('client-secret') ?? undefined;\n const scope = url.searchParams.get('scope') ?? undefined;\n const audience = url.searchParams.get('audience') ?? undefined;\n\n // Remove Canton params to get clean JSON API URL\n for (const key of [\n 'admin-api',\n 'user-id',\n 'token-url',\n // TODO: check if these are acceptable in our providers config, we do the same with api-keys currently.\n 'client-id',\n 'client-secret',\n 'scope',\n 'audience',\n ]) {\n url.searchParams.delete(key);\n }\n\n // Reconstruct clean base URL (origin + pathname, plus any remaining query params)\n const jsonApiUrl = url.toString().replace(/\\/$/, '');\n\n const oauth2 =\n tokenUrl && clientId && clientSecret\n ? { tokenUrl, clientId, clientSecret, scope, audience }\n : undefined;\n\n return { jsonApiUrl, adminApiHost, userId, oauth2 };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Provider Factory\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type CreateCantonProviderOptions = {\n /** Raw provider URI (from provider config) */\n uri: string;\n /** When true, uses LocalTokenProvider (self-signed JWTs) instead of OAuth2 */\n isLocal: boolean;\n};\n\n/**\n * Create a {@link CantonProvider} from a provider URI.\n *\n * - **isLocal=true**: Uses {@link LocalTokenProvider} with admin-level access (self-signed JWTs).\n * - **isLocal=false**: Uses {@link ClientCredentialsTokenProvider} with OAuth2 client\n * credentials extracted from the URI query parameters.\n */\nexport function createCantonProvider({\n uri,\n isLocal,\n}: CreateCantonProviderOptions): CantonProvider {\n const params = parseCantonUri(uri);\n\n const tokenProvider = createTokenProvider(params, isLocal);\n\n // ── JSON Ledger API Client ──────────────────────────────────────────\n const configuration = new Configuration({\n basePath: params.jsonApiUrl,\n accessToken: () => tokenProvider.getToken(),\n });\n const client = new CantonClient(configuration, params.userId);\n\n // ── gRPC Admin API Client ───────────────────────────────────────────\n const grpcClient = new CantonGrpcClient({\n host: params.adminApiHost,\n tokenProvider,\n });\n\n return { client, grpcClient, tokenProvider };\n}\n\nfunction createTokenProvider(params: CantonUriParams, isLocal: boolean): TokenProvider {\n if (isLocal) {\n return new LocalTokenProvider({\n userId: params.userId,\n actAs: [],\n admin: true,\n });\n }\n\n // TODO: add other authentication methods for prod: such as direct jwt passthrough, oauth2 client credentials, etc.\n // Non-local: require OAuth2 client credentials\n if (!params.oauth2) {\n throw new Error(\n 'Canton provider requires OAuth2 credentials (token-url, client-id, client-secret) in the provider URI',\n );\n }\n\n return new ClientCredentialsTokenProvider(params.oauth2);\n}\n"]}
|