@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.
package/dist/index.js CHANGED
@@ -24,16 +24,16 @@ async function awaitCompletion(ledgerClient, ledgerEnd, partyId, userId, command
24
24
  }
25
25
  );
26
26
  const completions = responses.filter(
27
- (r) => "Completion" in r.completionResponse
27
+ (r) => r.completionResponse && "Completion" in r.completionResponse
28
28
  );
29
29
  const wantedCompletion = responses.find((r) => {
30
- if ("Completion" in r.completionResponse) {
30
+ if (r.completionResponse && "Completion" in r.completionResponse) {
31
31
  const completion = r.completionResponse.Completion.value;
32
32
  return completion.userId === userId && (completion.commandId === commandIdOrSubmissionId || completion.submissionId === commandIdOrSubmissionId);
33
33
  }
34
34
  return false;
35
35
  });
36
- if (wantedCompletion && "Completion" in wantedCompletion.completionResponse) {
36
+ if (wantedCompletion?.completionResponse && "Completion" in wantedCompletion.completionResponse) {
37
37
  const completion = wantedCompletion.completionResponse.Completion.value;
38
38
  const status = completion.status;
39
39
  if (status && status.code !== 0) {
@@ -42,7 +42,7 @@ async function awaitCompletion(ledgerClient, ledgerEnd, partyId, userId, command
42
42
  return completion;
43
43
  } else {
44
44
  const lastCompletion = completions[completions.length - 1];
45
- const newLedgerEnd = lastCompletion && "Completion" in lastCompletion.completionResponse ? lastCompletion.completionResponse.Completion.value.offset : void 0;
45
+ const newLedgerEnd = lastCompletion?.completionResponse && "Completion" in lastCompletion.completionResponse ? lastCompletion.completionResponse.Completion.value.offset : void 0;
46
46
  return awaitCompletion(
47
47
  ledgerClient,
48
48
  newLedgerEnd || ledgerEnd,
@@ -595,7 +595,7 @@ var ACSHelper = class _ACSHelper {
595
595
  };
596
596
 
597
597
  // src/ledger-client.ts
598
- var supportedVersions = ["3.3", "3.4"];
598
+ var supportedVersions = ["3.4"];
599
599
  var LedgerClient = class {
600
600
  constructor({
601
601
  baseUrl,
@@ -608,7 +608,6 @@ var LedgerClient = class {
608
608
  // privately manage the active connected version and associated client codegen
609
609
  __publicField(this, "clients");
610
610
  __publicField(this, "clientVersion", "3.4");
611
- // default to 3.4 if not provided
612
611
  __publicField(this, "currentClient");
613
612
  __publicField(this, "initialized", false);
614
613
  __publicField(this, "accessTokenProvider");
@@ -630,10 +629,6 @@ var LedgerClient = class {
630
629
  });
631
630
  };
632
631
  this.clients = {
633
- "3.3": createClient({
634
- baseUrl: baseUrl.href,
635
- fetch: authenticatedFetch
636
- }),
637
632
  "3.4": createClient({
638
633
  baseUrl: baseUrl.href,
639
634
  fetch: authenticatedFetch
@@ -860,79 +855,42 @@ var LedgerClient = class {
860
855
  }
861
856
  return result;
862
857
  }
863
- /** TODO: simplify once 3.4 snapshot contains this endpoint */
864
858
  async allocateExternalParty(synchronizerId, onboardingTransactions, multiHashSignatures) {
865
859
  await this.init();
866
- if (this.clientVersion == "3.3") {
867
- const client = this.clients["3.3"];
868
- const resp = await client.POST("/v2/parties/external/allocate", {
869
- body: {
870
- synchronizer: synchronizerId,
871
- identityProviderId: "",
872
- onboardingTransactions,
873
- multiHashSignatures
874
- }
875
- });
876
- return this.valueOrError(resp);
877
- } else {
878
- const client = this.clients["3.4"];
879
- const resp = await client.POST("/v2/parties/external/allocate", {
860
+ const resp = await this.currentClient.POST(
861
+ "/v2/parties/external/allocate",
862
+ {
880
863
  body: {
881
864
  synchronizer: synchronizerId,
882
865
  identityProviderId: "",
883
866
  onboardingTransactions,
884
867
  multiHashSignatures
885
868
  }
886
- });
887
- return this.valueOrError(resp);
888
- }
869
+ }
870
+ );
871
+ return this.valueOrError(resp);
889
872
  }
890
- /** TODO: simplify once 3.4 snapshot contains this endpoint */
891
873
  async generateTopology(synchronizerId, publicKey, partyHint, localParticipantObservationOnly = false, confirmationThreshold = 1, otherConfirmingParticipantUids = [], observingParticipantUids = []) {
892
874
  await this.init();
893
- if (this.clientVersion == "3.3") {
894
- const client = this.clients["3.3"];
895
- const body = {
896
- synchronizer: synchronizerId,
897
- partyHint,
898
- publicKey: {
899
- format: "CRYPTO_KEY_FORMAT_RAW",
900
- keyData: publicKey,
901
- keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
902
- },
903
- localParticipantObservationOnly,
904
- confirmationThreshold,
905
- otherConfirmingParticipantUids,
906
- observingParticipantUids
907
- };
908
- this.logger.debug(body, "generateTopology request body");
909
- const resp = await client.POST(
910
- "/v2/parties/external/generate-topology",
911
- { body }
912
- );
913
- return this.valueOrError(resp);
914
- } else {
915
- const client = this.clients["3.4"];
916
- const body = {
917
- synchronizer: synchronizerId,
918
- partyHint,
919
- publicKey: {
920
- format: "CRYPTO_KEY_FORMAT_RAW",
921
- keyData: publicKey,
922
- keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
923
- },
924
- localParticipantObservationOnly,
925
- confirmationThreshold,
926
- otherConfirmingParticipantUids,
927
- observingParticipantUids
928
- };
929
- this.logger.debug(body, "generateTopology request body");
930
- const resp = await client.POST(
931
- "/v2/parties/external/generate-topology",
932
- { body }
933
- );
934
- return this.valueOrError(resp);
935
- }
875
+ const body = {
876
+ synchronizer: synchronizerId,
877
+ partyHint,
878
+ publicKey: {
879
+ format: "CRYPTO_KEY_FORMAT_RAW",
880
+ keyData: publicKey,
881
+ keySpec: "SIGNING_KEY_SPEC_EC_CURVE25519"
882
+ },
883
+ localParticipantObservationOnly,
884
+ confirmationThreshold,
885
+ otherConfirmingParticipantUids,
886
+ observingParticipantUids
887
+ };
888
+ this.logger.debug(body, "generateTopology request body");
889
+ const resp = await this.currentClient.POST(
890
+ "/v2/parties/external/generate-topology",
891
+ { body }
892
+ );
893
+ return this.valueOrError(resp);
936
894
  }
937
895
  /*
938
896
  if limit is provided, this function performs a one-time query. Automatically splits into multiple `/v2/updates` calls with `continueUntilCompletion` on.
@@ -1003,9 +961,10 @@ var LedgerClient = class {
1003
961
  const bodyRequest = {
1004
962
  beginExclusive: 0,
1005
963
  endInclusive: ledgerEnd.offset,
1006
- verbose: false
964
+ verbose: false,
965
+ updateFormat: {}
1007
966
  };
1008
- if (activeContractsArgs.filter)
967
+ if (!activeContractsArgs.filter)
1009
968
  bodyRequest.filter = activeContractsArgs.filter;
1010
969
  let currentOffset = 0;
1011
970
  const allContractsData = /* @__PURE__ */ new Map();
@@ -1019,8 +978,8 @@ var LedgerClient = class {
1019
978
  {
1020
979
  query: { limit: limit.toString() }
1021
980
  }
1022
- )).filter(({ update }) => "Transaction" in update).map(({ update }) => {
1023
- if ("Transaction" in update) {
981
+ )).filter(({ update }) => update && "Transaction" in update).map(({ update }) => {
982
+ if (update && "Transaction" in update) {
1024
983
  return update.Transaction.value;
1025
984
  }
1026
985
  throw new Error("Expected Transaction update");