@canton-network/core-ledger-client 0.19.0 → 0.20.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.cjs CHANGED
@@ -1582,6 +1582,10 @@ var CoreService = class _CoreService {
1582
1582
  fetchedAtOffset: offset
1583
1583
  };
1584
1584
  }
1585
+ toQualifiedMemberId(memberId) {
1586
+ if (!memberId) throw new Error("memberId is required");
1587
+ return /^(PAR|MED)::/.test(memberId) ? memberId : `PAR::${memberId}`;
1588
+ }
1585
1589
  };
1586
1590
  var AllocationService = class {
1587
1591
  constructor(core, logger) {
@@ -2162,12 +2166,13 @@ var TransferService = class {
2162
2166
  }
2163
2167
  };
2164
2168
  var TokenStandardService = class {
2165
- constructor(ledgerClient, scanProxyClient, logger, accessTokenProvider, isMasterUser) {
2169
+ constructor(ledgerClient, scanProxyClient, logger, accessTokenProvider, isMasterUser, scanClient) {
2166
2170
  this.ledgerClient = ledgerClient;
2167
2171
  this.scanProxyClient = scanProxyClient;
2168
2172
  this.logger = logger;
2169
2173
  this.accessTokenProvider = accessTokenProvider;
2170
2174
  this.isMasterUser = isMasterUser;
2175
+ this.scanClient = scanClient;
2171
2176
  __publicField(this, "core");
2172
2177
  __publicField(this, "allocation");
2173
2178
  __publicField(this, "transfer");
@@ -2176,7 +2181,9 @@ var TokenStandardService = class {
2176
2181
  scanProxyClient,
2177
2182
  logger,
2178
2183
  accessTokenProvider,
2179
- isMasterUser
2184
+ isMasterUser,
2185
+ void 0,
2186
+ void 0
2180
2187
  );
2181
2188
  this.allocation = new AllocationService(this.core, this.logger);
2182
2189
  this.transfer = new TransferService(this.core, this.logger);
@@ -2265,7 +2272,7 @@ var TokenStandardService = class {
2265
2272
  value: cid
2266
2273
  })),
2267
2274
  provider,
2268
- memberId,
2275
+ memberId: this.core.toQualifiedMemberId(memberId),
2269
2276
  synchronizerId,
2270
2277
  migrationId,
2271
2278
  trafficAmount,
@@ -2279,6 +2286,20 @@ var TokenStandardService = class {
2279
2286
  };
2280
2287
  return [exercise, disclosed];
2281
2288
  }
2289
+ async getMemberTrafficStatus(domainId, memberId) {
2290
+ if (!this.scanClient) {
2291
+ throw new Error("Scan API URL was not provided");
2292
+ }
2293
+ return this.scanClient.get(
2294
+ "/v0/domains/{domain_id}/members/{member_id}/traffic-status",
2295
+ {
2296
+ path: {
2297
+ domain_id: domainId,
2298
+ member_id: this.core.toQualifiedMemberId(memberId)
2299
+ }
2300
+ }
2301
+ );
2302
+ }
2282
2303
  async getInstrumentAdmin(registryUrl) {
2283
2304
  const client = this.core.getTokenStandardClient(registryUrl);
2284
2305
  const info = await client.get("/registry/metadata/v1/info");
@@ -3023,6 +3044,7 @@ var LedgerClient = class {
3023
3044
  __publicField(this, "accessTokenProvider");
3024
3045
  __publicField(this, "acsHelper");
3025
3046
  __publicField(this, "logger");
3047
+ __publicField(this, "synchronizerId");
3026
3048
  __publicField(this, "baseUrl");
3027
3049
  this.logger = _logger.child({ component: "LedgerClient" });
3028
3050
  this.accessTokenProvider = accessTokenProvider;
@@ -3461,6 +3483,25 @@ var LedgerClient = class {
3461
3483
  }
3462
3484
  return filter;
3463
3485
  }
3486
+ // Retrieve an (arbitrary) synchronizer id from the validator.
3487
+ // This synchronizer id is cached for the remainder of this object's life.
3488
+ async getSynchronizerId() {
3489
+ if (this.synchronizerId) return this.synchronizerId;
3490
+ const response = await this.getWithRetry(
3491
+ "/v2/state/connected-synchronizers"
3492
+ );
3493
+ if (!response.connectedSynchronizers?.[0]) {
3494
+ throw new Error("No connected synchronizers found");
3495
+ }
3496
+ const synchronizerId = response.connectedSynchronizers[0].synchronizerId;
3497
+ if (response.connectedSynchronizers.length > 1) {
3498
+ this.logger.warn(
3499
+ `Found ${response.connectedSynchronizers.length} synchronizers, defaulting to ${synchronizerId}`
3500
+ );
3501
+ }
3502
+ this.synchronizerId = synchronizerId;
3503
+ return synchronizerId;
3504
+ }
3464
3505
  async postWithRetry(path, body, retryOptions = defaultRetryableOptions, params, additionalOptions) {
3465
3506
  return await retryable(
3466
3507
  () => this.post(path, body, params, additionalOptions),