ton-provider-system 0.1.1 → 0.1.2

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
@@ -2307,6 +2307,17 @@ var NodeAdapter = class {
2307
2307
  * Get TonClient instance
2308
2308
  *
2309
2309
  * Creates a new client if endpoint changed, otherwise returns cached.
2310
+ *
2311
+ * NOTE: Direct TonClient calls bypass rate limiting. For rate-limited operations,
2312
+ * use adapter methods (getAddressState, runGetMethod, etc.) or wrap your calls
2313
+ * with rate limit token acquisition.
2314
+ *
2315
+ * Example with rate limiting:
2316
+ * ```typescript
2317
+ * const endpoint = await adapter.manager.getEndpointWithRateLimit();
2318
+ * // Make your TonClient call
2319
+ * adapter.manager.reportSuccess(); // or reportError() on failure
2320
+ * ```
2310
2321
  */
2311
2322
  async getClient() {
2312
2323
  const endpoint = await this.manager.getEndpoint();
@@ -2332,6 +2343,19 @@ var NodeAdapter = class {
2332
2343
  this.logger.debug(`Created TonClient for ${network}`, { endpoint });
2333
2344
  return client;
2334
2345
  }
2346
+ /**
2347
+ * Get TonClient with rate limiting applied
2348
+ *
2349
+ * Acquires a rate limit token before returning the client.
2350
+ * Use this when you need to ensure rate limiting is respected.
2351
+ *
2352
+ * Note: This only acquires ONE token. For multiple operations,
2353
+ * you should acquire tokens before each operation or use adapter methods.
2354
+ */
2355
+ async getClientWithRateLimit(timeoutMs) {
2356
+ await this.manager.getEndpointWithRateLimit(timeoutMs);
2357
+ return this.getClient();
2358
+ }
2335
2359
  /**
2336
2360
  * Reset client cache (forces new client creation)
2337
2361
  */
@@ -2517,6 +2541,22 @@ async function getTonClient(manager) {
2517
2541
  const adapter = new NodeAdapter(manager);
2518
2542
  return adapter.getClient();
2519
2543
  }
2544
+ async function getTonClientWithRateLimit(manager) {
2545
+ const adapter = new NodeAdapter(manager);
2546
+ const client = await adapter.getClient();
2547
+ const withRateLimit = async (fn) => {
2548
+ await manager.getEndpointWithRateLimit();
2549
+ try {
2550
+ const result = await fn();
2551
+ manager.reportSuccess();
2552
+ return result;
2553
+ } catch (error) {
2554
+ manager.reportError(error);
2555
+ throw error;
2556
+ }
2557
+ };
2558
+ return { client, withRateLimit };
2559
+ }
2520
2560
  async function getTonClientForNetwork(network, configPath) {
2521
2561
  const manager = ProviderManager.getInstance({ configPath });
2522
2562
  if (!manager.isInitialized() || manager.getNetwork() !== network) {
@@ -2855,6 +2895,7 @@ exports.getProvidersForNetwork = getProvidersForNetwork;
2855
2895
  exports.getRateLimitForType = getRateLimitForType;
2856
2896
  exports.getTonClient = getTonClient;
2857
2897
  exports.getTonClientForNetwork = getTonClientForNetwork;
2898
+ exports.getTonClientWithRateLimit = getTonClientWithRateLimit;
2858
2899
  exports.isApiVersion = isApiVersion;
2859
2900
  exports.isChainstackUrl = isChainstackUrl;
2860
2901
  exports.isNetwork = isNetwork;