ton-provider-system 0.2.1 → 0.2.4

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.d.cts CHANGED
@@ -875,7 +875,10 @@ declare class TokenBucketRateLimiter {
875
875
  */
876
876
  release(): void;
877
877
  /**
878
- * Report a successful request (resets backoff)
878
+ * Report a successful request (gradually reduces backoff)
879
+ *
880
+ * Instead of immediately clearing backoff, we gradually reduce it to prevent
881
+ * immediately hitting the rate limit again after a single success.
879
882
  */
880
883
  reportSuccess(): void;
881
884
  /**
@@ -1004,6 +1007,7 @@ declare class HealthChecker {
1004
1007
  *
1005
1008
  * @param batchSize - Number of providers to test in parallel (default: 2)
1006
1009
  * @param batchDelayMs - Delay between batches in milliseconds (default: 500 to avoid rate limits)
1010
+ * If not provided, calculates delay based on lowest RPS in batch
1007
1011
  */
1008
1012
  testProviders(providers: ResolvedProvider[], batchSize?: number, batchDelayMs?: number): Promise<ProviderHealthResult[]>;
1009
1013
  /**
@@ -1084,6 +1088,8 @@ interface SelectionConfig {
1084
1088
  freshnessWeight: number;
1085
1089
  /** Minimum acceptable provider status */
1086
1090
  minStatus: ProviderStatus[];
1091
+ /** Cooldown period (ms) before retrying failed providers (default: 30000) */
1092
+ retryCooldownMs: number;
1087
1093
  }
1088
1094
  /**
1089
1095
  * Provider Selector
@@ -1196,6 +1202,22 @@ declare class ProviderSelector {
1196
1202
  * 2. Health check result browserCompatible flag (if health check was performed)
1197
1203
  */
1198
1204
  private filterBrowserCompatible;
1205
+ /**
1206
+ * Check if an error is retryable (temporary) or permanent
1207
+ *
1208
+ * Permanent errors (never retry):
1209
+ * - 404 (Not Found) - endpoint doesn't exist
1210
+ * - 401 (Unauthorized) - invalid API key
1211
+ * - Invalid API key errors
1212
+ *
1213
+ * Retryable errors (can retry after cooldown):
1214
+ * - 503 (Service Unavailable) - temporary server issue
1215
+ * - 502 (Bad Gateway) - temporary gateway issue
1216
+ * - Timeout errors - network issues
1217
+ * - Network errors - connection issues
1218
+ * - 429 (Rate Limit) - temporary rate limit (handled separately)
1219
+ */
1220
+ private isRetryableError;
1199
1221
  }
1200
1222
  /**
1201
1223
  * Create a provider selector
@@ -1554,18 +1576,26 @@ declare class BrowserAdapter {
1554
1576
  getEndpointWithRateLimit(timeoutMs?: number): Promise<string>;
1555
1577
  /**
1556
1578
  * Make a JSON-RPC call to the TON API
1579
+ *
1580
+ * Note: Uses rate limiting to prevent 429 errors.
1557
1581
  */
1558
1582
  jsonRpc<T = unknown>(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
1559
1583
  /**
1560
1584
  * Get address state
1585
+ *
1586
+ * Note: Uses rate limiting to prevent 429 errors.
1561
1587
  */
1562
1588
  getAddressState(address: string, timeoutMs?: number): Promise<'uninit' | 'active' | 'frozen'>;
1563
1589
  /**
1564
1590
  * Get address balance
1591
+ *
1592
+ * Note: Uses rate limiting to prevent 429 errors.
1565
1593
  */
1566
1594
  getAddressBalance(address: string, timeoutMs?: number): Promise<bigint>;
1567
1595
  /**
1568
1596
  * Get address information
1597
+ *
1598
+ * Note: Uses rate limiting to prevent 429 errors.
1569
1599
  */
1570
1600
  getAddressInfo(address: string, timeoutMs?: number): Promise<{
1571
1601
  state: 'uninit' | 'active' | 'frozen';
@@ -1575,6 +1605,8 @@ declare class BrowserAdapter {
1575
1605
  }>;
1576
1606
  /**
1577
1607
  * Run get method
1608
+ *
1609
+ * Note: Uses rate limiting to prevent 429 errors.
1578
1610
  */
1579
1611
  runGetMethod(address: string, method: string, stack?: unknown[], timeoutMs?: number): Promise<{
1580
1612
  exit_code: number;
@@ -1912,7 +1944,10 @@ declare class TatumProvider extends BaseProvider {
1912
1944
  * Documentation: https://documentation.onfinality.io/support/ton
1913
1945
  *
1914
1946
  * Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
1915
- * API key: Optional, in apikey header (preferred) or query params
1947
+ * API key: Required for /rpc endpoint, passed as query parameter ?apikey=YOUR_API_KEY
1948
+ *
1949
+ * IMPORTANT: OnFinality uses query parameters for API key authentication, NOT headers.
1950
+ * The API key must be included in the URL as ?apikey=YOUR_API_KEY
1916
1951
  */
1917
1952
 
1918
1953
  declare class OnFinalityProvider extends BaseProvider {
package/dist/index.d.ts CHANGED
@@ -875,7 +875,10 @@ declare class TokenBucketRateLimiter {
875
875
  */
876
876
  release(): void;
877
877
  /**
878
- * Report a successful request (resets backoff)
878
+ * Report a successful request (gradually reduces backoff)
879
+ *
880
+ * Instead of immediately clearing backoff, we gradually reduce it to prevent
881
+ * immediately hitting the rate limit again after a single success.
879
882
  */
880
883
  reportSuccess(): void;
881
884
  /**
@@ -1004,6 +1007,7 @@ declare class HealthChecker {
1004
1007
  *
1005
1008
  * @param batchSize - Number of providers to test in parallel (default: 2)
1006
1009
  * @param batchDelayMs - Delay between batches in milliseconds (default: 500 to avoid rate limits)
1010
+ * If not provided, calculates delay based on lowest RPS in batch
1007
1011
  */
1008
1012
  testProviders(providers: ResolvedProvider[], batchSize?: number, batchDelayMs?: number): Promise<ProviderHealthResult[]>;
1009
1013
  /**
@@ -1084,6 +1088,8 @@ interface SelectionConfig {
1084
1088
  freshnessWeight: number;
1085
1089
  /** Minimum acceptable provider status */
1086
1090
  minStatus: ProviderStatus[];
1091
+ /** Cooldown period (ms) before retrying failed providers (default: 30000) */
1092
+ retryCooldownMs: number;
1087
1093
  }
1088
1094
  /**
1089
1095
  * Provider Selector
@@ -1196,6 +1202,22 @@ declare class ProviderSelector {
1196
1202
  * 2. Health check result browserCompatible flag (if health check was performed)
1197
1203
  */
1198
1204
  private filterBrowserCompatible;
1205
+ /**
1206
+ * Check if an error is retryable (temporary) or permanent
1207
+ *
1208
+ * Permanent errors (never retry):
1209
+ * - 404 (Not Found) - endpoint doesn't exist
1210
+ * - 401 (Unauthorized) - invalid API key
1211
+ * - Invalid API key errors
1212
+ *
1213
+ * Retryable errors (can retry after cooldown):
1214
+ * - 503 (Service Unavailable) - temporary server issue
1215
+ * - 502 (Bad Gateway) - temporary gateway issue
1216
+ * - Timeout errors - network issues
1217
+ * - Network errors - connection issues
1218
+ * - 429 (Rate Limit) - temporary rate limit (handled separately)
1219
+ */
1220
+ private isRetryableError;
1199
1221
  }
1200
1222
  /**
1201
1223
  * Create a provider selector
@@ -1554,18 +1576,26 @@ declare class BrowserAdapter {
1554
1576
  getEndpointWithRateLimit(timeoutMs?: number): Promise<string>;
1555
1577
  /**
1556
1578
  * Make a JSON-RPC call to the TON API
1579
+ *
1580
+ * Note: Uses rate limiting to prevent 429 errors.
1557
1581
  */
1558
1582
  jsonRpc<T = unknown>(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
1559
1583
  /**
1560
1584
  * Get address state
1585
+ *
1586
+ * Note: Uses rate limiting to prevent 429 errors.
1561
1587
  */
1562
1588
  getAddressState(address: string, timeoutMs?: number): Promise<'uninit' | 'active' | 'frozen'>;
1563
1589
  /**
1564
1590
  * Get address balance
1591
+ *
1592
+ * Note: Uses rate limiting to prevent 429 errors.
1565
1593
  */
1566
1594
  getAddressBalance(address: string, timeoutMs?: number): Promise<bigint>;
1567
1595
  /**
1568
1596
  * Get address information
1597
+ *
1598
+ * Note: Uses rate limiting to prevent 429 errors.
1569
1599
  */
1570
1600
  getAddressInfo(address: string, timeoutMs?: number): Promise<{
1571
1601
  state: 'uninit' | 'active' | 'frozen';
@@ -1575,6 +1605,8 @@ declare class BrowserAdapter {
1575
1605
  }>;
1576
1606
  /**
1577
1607
  * Run get method
1608
+ *
1609
+ * Note: Uses rate limiting to prevent 429 errors.
1578
1610
  */
1579
1611
  runGetMethod(address: string, method: string, stack?: unknown[], timeoutMs?: number): Promise<{
1580
1612
  exit_code: number;
@@ -1912,7 +1944,10 @@ declare class TatumProvider extends BaseProvider {
1912
1944
  * Documentation: https://documentation.onfinality.io/support/ton
1913
1945
  *
1914
1946
  * Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
1915
- * API key: Optional, in apikey header (preferred) or query params
1947
+ * API key: Required for /rpc endpoint, passed as query parameter ?apikey=YOUR_API_KEY
1948
+ *
1949
+ * IMPORTANT: OnFinality uses query parameters for API key authentication, NOT headers.
1950
+ * The API key must be included in the URL as ?apikey=YOUR_API_KEY
1916
1951
  */
1917
1952
 
1918
1953
  declare class OnFinalityProvider extends BaseProvider {