@canton-network/core-ledger-client 0.31.1 → 0.32.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.
@@ -32,20 +32,14 @@ export declare class ACSHelper {
32
32
  private static createKey;
33
33
  private static keyToString;
34
34
  private findACSContainer;
35
- updateSingleKey(offset: number, key: ACSKey): Promise<({
36
- workflowId: string;
37
- contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.3.0-SNAPSHOT").components["schemas"]["JsContractEntry"];
38
- } | {
35
+ updateSingleKey(offset: number, key: ACSKey): Promise<{
39
36
  workflowId: string;
40
37
  contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.4.12").components["schemas"]["JsContractEntry"];
41
- })[]>;
42
- queryAcsByKeys(offset: number, keys: ACSKey[]): Promise<({
43
- workflowId: string;
44
- contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.3.0-SNAPSHOT").components["schemas"]["JsContractEntry"];
45
- } | {
38
+ }[]>;
39
+ queryAcsByKeys(offset: number, keys: ACSKey[]): Promise<{
46
40
  workflowId: string;
47
41
  contractEntry: import("../../../ledger-client-types/dist/generated-clients/openapi-3.4.12").components["schemas"]["JsContractEntry"];
48
- })[]>;
42
+ }[]>;
49
43
  activeContractsForTemplates(offset: number, parties: PartyId[], templateIds: string[]): Promise<JsGetActiveContractsResponse[]>;
50
44
  activeContractsForInterfaces(offset: number, parties: PartyId[], interfaceIds: string[]): Promise<JsGetActiveContractsResponse[]>;
51
45
  activeContractsForTemplate(offset: number, partyFilter: PartyId, templateId: string): Promise<JsGetActiveContractsResponse[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"acs-helper.d.ts","sourceRoot":"","sources":["../../src/acs/acs-helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,YAAY,E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function awaitCompletion(ledgerClient, ledgerEnd, partyId, userId, command
30
30
  }
31
31
  );
32
32
  const completions = responses.filter(
33
- (r) => "Completion" in r.completionResponse
33
+ (r) => r.completionResponse && "Completion" in r.completionResponse
34
34
  );
35
35
  const wantedCompletion = responses.find((r) => {
36
- if ("Completion" in r.completionResponse) {
36
+ if (r.completionResponse && "Completion" in r.completionResponse) {
37
37
  const completion = r.completionResponse.Completion.value;
38
38
  return completion.userId === userId && (completion.commandId === commandIdOrSubmissionId || completion.submissionId === commandIdOrSubmissionId);
39
39
  }
40
40
  return false;
41
41
  });
42
- if (wantedCompletion && "Completion" in wantedCompletion.completionResponse) {
42
+ if (wantedCompletion?.completionResponse && "Completion" in wantedCompletion.completionResponse) {
43
43
  const completion = wantedCompletion.completionResponse.Completion.value;
44
44
  const status = completion.status;
45
45
  if (status && status.code !== 0) {
@@ -48,7 +48,7 @@ async function awaitCompletion(ledgerClient, ledgerEnd, partyId, userId, command
48
48
  return completion;
49
49
  } else {
50
50
  const lastCompletion = completions[completions.length - 1];
51
- const newLedgerEnd = lastCompletion && "Completion" in lastCompletion.completionResponse ? lastCompletion.completionResponse.Completion.value.offset : void 0;
51
+ const newLedgerEnd = lastCompletion?.completionResponse && "Completion" in lastCompletion.completionResponse ? lastCompletion.completionResponse.Completion.value.offset : void 0;
52
52
  return awaitCompletion(
53
53
  ledgerClient,
54
54
  newLedgerEnd || ledgerEnd,
@@ -601,7 +601,7 @@ var ACSHelper = class _ACSHelper {
601
601
  };
602
602
 
603
603
  // src/ledger-client.ts
604
- var supportedVersions = ["3.3", "3.4"];
604
+ var supportedVersions = ["3.4"];
605
605
  var LedgerClient = class {
606
606
  constructor({
607
607
  baseUrl,
@@ -614,7 +614,6 @@ var LedgerClient = class {
614
614
  // privately manage the active connected version and associated client codegen
615
615
  __publicField(this, "clients");
616
616
  __publicField(this, "clientVersion", "3.4");
617
- // default to 3.4 if not provided
618
617
  __publicField(this, "currentClient");
619
618
  __publicField(this, "initialized", false);
620
619
  __publicField(this, "accessTokenProvider");
@@ -636,10 +635,6 @@ var LedgerClient = class {
636
635
  });
637
636
  };
638
637
  this.clients = {
639
- "3.3": createClient__default.default({
640
- baseUrl: baseUrl.href,
641
- fetch: authenticatedFetch
642
- }),
643
638
  "3.4": createClient__default.default({
644
639
  baseUrl: baseUrl.href,
645
640
  fetch: authenticatedFetch
@@ -866,79 +861,42 @@ var LedgerClient = class {
866
861
  }
867
862
  return result;
868
863
  }
869
- /** TODO: simplify once 3.4 snapshot contains this endpoint */
870
864
  async allocateExternalParty(synchronizerId, onboardingTransactions, multiHashSignatures) {
871
865
  await this.init();
872
- if (this.clientVersion == "3.3") {
873
- const client = this.clients["3.3"];
874
- const resp = await client.POST("/v2/parties/external/allocate", {
875
- body: {
876
- synchronizer: synchronizerId,
877
- identityProviderId: "",
878
- onboardingTransactions,
879
- multiHashSignatures
880
- }
881
- });
882
- return this.valueOrError(resp);
883
- } else {
884
- const client = this.clients["3.4"];
885
- const resp = await client.POST("/v2/parties/external/allocate", {
866
+ const resp = await this.currentClient.POST(
867
+ "/v2/parties/external/allocate",
868
+ {
886
869
  body: {
887
870
  synchronizer: synchronizerId,
888
871
  identityProviderId: "",
889
872
  onboardingTransactions,
890
873
  multiHashSignatures
891
874
  }
892
- });
893
- return this.valueOrError(resp);
894
- }
875
+ }
876
+ );
877
+ return this.valueOrError(resp);
895
878
  }
896
- /** TODO: simplify once 3.4 snapshot contains this endpoint */
897
879
  async generateTopology(synchronizerId, publicKey, partyHint, localParticipantObservationOnly = false, confirmationThreshold = 1, otherConfirmingParticipantUids = [], observingParticipantUids = []) {
898
880
  await this.init();
899
- if (this.clientVersion == "3.3") {
900
- const client = this.clients["3.3"];
901
- const body = {
902
- synchronizer: synchronizerId,
903
- partyHint,
904
- publicKey: {
905
- format: "CRYPTO_KEY_FORMAT_RAW",
906
- keyData: publicKey,
907
- keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
908
- },
909
- localParticipantObservationOnly,
910
- confirmationThreshold,
911
- otherConfirmingParticipantUids,
912
- observingParticipantUids
913
- };
914
- this.logger.debug(body, "generateTopology request body");
915
- const resp = await client.POST(
916
- "/v2/parties/external/generate-topology",
917
- { body }
918
- );
919
- return this.valueOrError(resp);
920
- } else {
921
- const client = this.clients["3.4"];
922
- const body = {
923
- synchronizer: synchronizerId,
924
- partyHint,
925
- publicKey: {
926
- format: "CRYPTO_KEY_FORMAT_RAW",
927
- keyData: publicKey,
928
- keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
929
- },
930
- localParticipantObservationOnly,
931
- confirmationThreshold,
932
- otherConfirmingParticipantUids,
933
- observingParticipantUids
934
- };
935
- this.logger.debug(body, "generateTopology request body");
936
- const resp = await client.POST(
937
- "/v2/parties/external/generate-topology",
938
- { body }
939
- );
940
- return this.valueOrError(resp);
941
- }
881
+ const body = {
882
+ synchronizer: synchronizerId,
883
+ partyHint,
884
+ publicKey: {
885
+ format: "CRYPTO_KEY_FORMAT_RAW",
886
+ keyData: publicKey,
887
+ keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
888
+ },
889
+ localParticipantObservationOnly,
890
+ confirmationThreshold,
891
+ otherConfirmingParticipantUids,
892
+ observingParticipantUids
893
+ };
894
+ this.logger.debug(body, "generateTopology request body");
895
+ const resp = await this.currentClient.POST(
896
+ "/v2/parties/external/generate-topology",
897
+ { body }
898
+ );
899
+ return this.valueOrError(resp);
942
900
  }
943
901
  /*
944
902
  if limit is provided, this function performs a one-time query. Automatically splits into multiple `/v2/updates` calls with `continueUntilCompletion` on.
@@ -1009,9 +967,10 @@ var LedgerClient = class {
1009
967
  const bodyRequest = {
1010
968
  beginExclusive: 0,
1011
969
  endInclusive: ledgerEnd.offset,
1012
- verbose: false
970
+ verbose: false,
971
+ updateFormat: {}
1013
972
  };
1014
- if (activeContractsArgs.filter)
973
+ if (!activeContractsArgs.filter)
1015
974
  bodyRequest.filter = activeContractsArgs.filter;
1016
975
  let currentOffset = 0;
1017
976
  const allContractsData = /* @__PURE__ */ new Map();
@@ -1025,8 +984,8 @@ var LedgerClient = class {
1025
984
  {
1026
985
  query: { limit: limit.toString() }
1027
986
  }
1028
- )).filter(({ update }) => "Transaction" in update).map(({ update }) => {
1029
- if ("Transaction" in update) {
987
+ )).filter(({ update }) => update && "Transaction" in update).map(({ update }) => {
988
+ if (update && "Transaction" in update) {
1030
989
  return update.Transaction.value;
1031
990
  }
1032
991
  throw new Error("Expected Transaction update");