ton-provider-system 0.1.13 → 0.2.1
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 +645 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +241 -19
- package/dist/index.d.ts +241 -19
- package/dist/index.js +636 -219
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1032,6 +1032,9 @@ declare class HealthChecker {
|
|
|
1032
1032
|
clearResults(): void;
|
|
1033
1033
|
/**
|
|
1034
1034
|
* Mark a provider as degraded (e.g., on 429 error)
|
|
1035
|
+
*
|
|
1036
|
+
* Providers marked as degraded have failed health checks (e.g., rate limit errors)
|
|
1037
|
+
* and should not be selected. The system will failover to the next available provider.
|
|
1035
1038
|
*/
|
|
1036
1039
|
markDegraded(providerId: string, network: Network, error?: string): void;
|
|
1037
1040
|
/**
|
|
@@ -1043,13 +1046,6 @@ declare class HealthChecker {
|
|
|
1043
1046
|
* Get endpoint URL for a provider (handles dynamic providers like Orbs)
|
|
1044
1047
|
*/
|
|
1045
1048
|
private getEndpoint;
|
|
1046
|
-
/**
|
|
1047
|
-
* Normalize endpoint for provider-specific requirements
|
|
1048
|
-
*
|
|
1049
|
-
* Note: normalizeV2Endpoint now handles all provider-specific cases correctly,
|
|
1050
|
-
* including Tatum (/jsonRPC), OnFinality (/public or /rpc), QuickNode, and GetBlock.
|
|
1051
|
-
*/
|
|
1052
|
-
private normalizeEndpointForProvider;
|
|
1053
1049
|
/**
|
|
1054
1050
|
* Call getMasterchainInfo API with provider-specific handling
|
|
1055
1051
|
*/
|
|
@@ -1630,20 +1626,16 @@ declare function createBrowserAdapterForNetwork(network: Network, configPath?: s
|
|
|
1630
1626
|
*
|
|
1631
1627
|
* URL normalization and manipulation for TON RPC endpoints.
|
|
1632
1628
|
*/
|
|
1629
|
+
|
|
1633
1630
|
/**
|
|
1634
|
-
* Normalize endpoint URL for TonClient v2 API.
|
|
1635
|
-
*
|
|
1631
|
+
* Normalize endpoint URL for TonClient v2 API using provider-specific implementation.
|
|
1632
|
+
* This is the preferred method when a ResolvedProvider is available.
|
|
1636
1633
|
*
|
|
1637
|
-
*
|
|
1638
|
-
* -
|
|
1639
|
-
*
|
|
1640
|
-
* - TON Access (orbs): Already returns correct JSON-RPC endpoint
|
|
1641
|
-
* - QuickNode: Needs /jsonRPC appended to base URL
|
|
1642
|
-
* - GetBlock: Needs /jsonRPC appended to base URL
|
|
1643
|
-
* - Tatum: Gateway URLs need /jsonRPC appended (gateway.tatum.io/jsonRPC)
|
|
1644
|
-
* - OnFinality: Uses /public or /rpc path with query params - preserve query params
|
|
1634
|
+
* @param endpoint - Endpoint URL to normalize
|
|
1635
|
+
* @param provider - Resolved provider configuration (optional)
|
|
1636
|
+
* @returns Normalized endpoint URL
|
|
1645
1637
|
*/
|
|
1646
|
-
declare function normalizeV2Endpoint(endpoint: string): string;
|
|
1638
|
+
declare function normalizeV2Endpoint(endpoint: string, provider?: ResolvedProvider): string;
|
|
1647
1639
|
/**
|
|
1648
1640
|
* Convert any endpoint to v2 base URL (without /jsonRPC suffix).
|
|
1649
1641
|
*/
|
|
@@ -1802,4 +1794,234 @@ declare function isTimeoutError(error: unknown): error is TimeoutError;
|
|
|
1802
1794
|
*/
|
|
1803
1795
|
declare function isRateLimitError(error: unknown): boolean;
|
|
1804
1796
|
|
|
1805
|
-
|
|
1797
|
+
/**
|
|
1798
|
+
* Unified Provider System - Base Provider
|
|
1799
|
+
*
|
|
1800
|
+
* Base class for provider-specific implementations.
|
|
1801
|
+
* All provider types extend this class to provide provider-specific behavior.
|
|
1802
|
+
*/
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Base provider class that all provider-specific implementations extend.
|
|
1806
|
+
* Provides common functionality and defines the interface for provider-specific behavior.
|
|
1807
|
+
*/
|
|
1808
|
+
declare abstract class BaseProvider {
|
|
1809
|
+
protected provider: ResolvedProvider;
|
|
1810
|
+
constructor(provider: ResolvedProvider);
|
|
1811
|
+
/**
|
|
1812
|
+
* Get the provider instance
|
|
1813
|
+
*/
|
|
1814
|
+
getProvider(): ResolvedProvider;
|
|
1815
|
+
/**
|
|
1816
|
+
* Normalize endpoint URL for this provider type.
|
|
1817
|
+
* Each provider may have different endpoint format requirements.
|
|
1818
|
+
*/
|
|
1819
|
+
abstract normalizeEndpoint(endpoint: string): string;
|
|
1820
|
+
/**
|
|
1821
|
+
* Build HTTP headers for requests to this provider.
|
|
1822
|
+
* Handles provider-specific authentication (API keys in headers, etc.)
|
|
1823
|
+
*/
|
|
1824
|
+
abstract buildHeaders(): Record<string, string>;
|
|
1825
|
+
/**
|
|
1826
|
+
* Build a JSON-RPC request body.
|
|
1827
|
+
* Most providers use standard JSON-RPC 2.0, but some may need modifications.
|
|
1828
|
+
*/
|
|
1829
|
+
buildRequest(method: string, params?: Record<string, unknown>): {
|
|
1830
|
+
id: string;
|
|
1831
|
+
jsonrpc: string;
|
|
1832
|
+
method: string;
|
|
1833
|
+
params: Record<string, unknown>;
|
|
1834
|
+
};
|
|
1835
|
+
/**
|
|
1836
|
+
* Parse response from provider.
|
|
1837
|
+
* Handles provider-specific response formats.
|
|
1838
|
+
*/
|
|
1839
|
+
parseResponse<T = unknown>(data: unknown): T;
|
|
1840
|
+
/**
|
|
1841
|
+
* Parse masterchain info from response.
|
|
1842
|
+
* Validates the response structure and extracts seqno.
|
|
1843
|
+
*/
|
|
1844
|
+
parseMasterchainInfo(data: unknown): MasterchainInfo;
|
|
1845
|
+
/**
|
|
1846
|
+
* Validate provider configuration.
|
|
1847
|
+
* Checks if required API keys are present, etc.
|
|
1848
|
+
*/
|
|
1849
|
+
validateConfig(): {
|
|
1850
|
+
valid: boolean;
|
|
1851
|
+
error?: string;
|
|
1852
|
+
};
|
|
1853
|
+
/**
|
|
1854
|
+
* Get the normalized endpoint for this provider.
|
|
1855
|
+
*/
|
|
1856
|
+
getNormalizedEndpoint(): string;
|
|
1857
|
+
/**
|
|
1858
|
+
* Check if this provider requires an API key.
|
|
1859
|
+
*/
|
|
1860
|
+
requiresApiKey(): boolean;
|
|
1861
|
+
/**
|
|
1862
|
+
* Check if API key is present (if required).
|
|
1863
|
+
*/
|
|
1864
|
+
hasApiKey(): boolean;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Unified Provider System - Chainstack Provider
|
|
1869
|
+
*
|
|
1870
|
+
* Chainstack-specific implementation.
|
|
1871
|
+
* Documentation: https://docs.chainstack.com/reference/getting-started-ton
|
|
1872
|
+
*
|
|
1873
|
+
* Endpoint format: https://ton-{network}.core.chainstack.com/{key}/api/v2/jsonRPC
|
|
1874
|
+
* API key: In URL path (not header)
|
|
1875
|
+
*/
|
|
1876
|
+
|
|
1877
|
+
declare class ChainstackProvider extends BaseProvider {
|
|
1878
|
+
constructor(provider: ResolvedProvider);
|
|
1879
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1880
|
+
buildHeaders(): Record<string, string>;
|
|
1881
|
+
validateConfig(): {
|
|
1882
|
+
valid: boolean;
|
|
1883
|
+
error?: string;
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
/**
|
|
1888
|
+
* Unified Provider System - Tatum Provider
|
|
1889
|
+
*
|
|
1890
|
+
* Tatum-specific implementation.
|
|
1891
|
+
* Documentation: https://docs.tatum.io/reference/rpc-ton
|
|
1892
|
+
*
|
|
1893
|
+
* Endpoint format: https://ton-{network}.gateway.tatum.io/jsonRPC
|
|
1894
|
+
* API key: Required in x-api-key header
|
|
1895
|
+
*/
|
|
1896
|
+
|
|
1897
|
+
declare class TatumProvider extends BaseProvider {
|
|
1898
|
+
constructor(provider: ResolvedProvider);
|
|
1899
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1900
|
+
buildHeaders(): Record<string, string>;
|
|
1901
|
+
requiresApiKey(): boolean;
|
|
1902
|
+
validateConfig(): {
|
|
1903
|
+
valid: boolean;
|
|
1904
|
+
error?: string;
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Unified Provider System - OnFinality Provider
|
|
1910
|
+
*
|
|
1911
|
+
* OnFinality-specific implementation.
|
|
1912
|
+
* Documentation: https://documentation.onfinality.io/support/ton
|
|
1913
|
+
*
|
|
1914
|
+
* Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
|
|
1915
|
+
* API key: Optional, in apikey header (preferred) or query params
|
|
1916
|
+
*/
|
|
1917
|
+
|
|
1918
|
+
declare class OnFinalityProvider extends BaseProvider {
|
|
1919
|
+
constructor(provider: ResolvedProvider);
|
|
1920
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1921
|
+
buildHeaders(): Record<string, string>;
|
|
1922
|
+
parseResponse<T = unknown>(data: unknown): T;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* Unified Provider System - QuickNode Provider
|
|
1927
|
+
*
|
|
1928
|
+
* QuickNode-specific implementation.
|
|
1929
|
+
* Documentation: https://quicknode.com/docs/ton
|
|
1930
|
+
*
|
|
1931
|
+
* Endpoint format: https://{key}.ton-{network}.quiknode.pro/jsonRPC
|
|
1932
|
+
* API key: In subdomain (not header)
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
declare class QuickNodeProvider extends BaseProvider {
|
|
1936
|
+
constructor(provider: ResolvedProvider);
|
|
1937
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1938
|
+
buildHeaders(): Record<string, string>;
|
|
1939
|
+
validateConfig(): {
|
|
1940
|
+
valid: boolean;
|
|
1941
|
+
error?: string;
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Unified Provider System - GetBlock Provider
|
|
1947
|
+
*
|
|
1948
|
+
* GetBlock-specific implementation.
|
|
1949
|
+
* Documentation: https://docs.getblock.io/api-reference/the-open-network-ton
|
|
1950
|
+
*
|
|
1951
|
+
* Endpoint format: https://go.getblock.io/{key}/jsonRPC
|
|
1952
|
+
* API key: Required in x-api-key header
|
|
1953
|
+
*/
|
|
1954
|
+
|
|
1955
|
+
declare class GetBlockProvider extends BaseProvider {
|
|
1956
|
+
constructor(provider: ResolvedProvider);
|
|
1957
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1958
|
+
buildHeaders(): Record<string, string>;
|
|
1959
|
+
requiresApiKey(): boolean;
|
|
1960
|
+
validateConfig(): {
|
|
1961
|
+
valid: boolean;
|
|
1962
|
+
error?: string;
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
/**
|
|
1967
|
+
* Unified Provider System - TON Center Provider
|
|
1968
|
+
*
|
|
1969
|
+
* TON Center-specific implementation.
|
|
1970
|
+
* Documentation: https://toncenter.com/api/v2/
|
|
1971
|
+
*
|
|
1972
|
+
* Endpoint format: https://{testnet.}toncenter.com/api/v2/jsonRPC
|
|
1973
|
+
* API key: Optional, passed to TonClient (not in header for HTTP requests)
|
|
1974
|
+
*/
|
|
1975
|
+
|
|
1976
|
+
declare class TonCenterProvider extends BaseProvider {
|
|
1977
|
+
constructor(provider: ResolvedProvider);
|
|
1978
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1979
|
+
buildHeaders(): Record<string, string>;
|
|
1980
|
+
requiresApiKey(): boolean;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* Unified Provider System - Orbs Provider
|
|
1985
|
+
*
|
|
1986
|
+
* Orbs (TON Access) specific implementation.
|
|
1987
|
+
* Documentation: https://github.com/orbs-network/ton-access
|
|
1988
|
+
*
|
|
1989
|
+
* Endpoint format: Dynamic discovery via @orbs-network/ton-access
|
|
1990
|
+
* API key: Not required (decentralized gateway)
|
|
1991
|
+
*/
|
|
1992
|
+
|
|
1993
|
+
declare class OrbsProvider extends BaseProvider {
|
|
1994
|
+
constructor(provider: ResolvedProvider);
|
|
1995
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1996
|
+
buildHeaders(): Record<string, string>;
|
|
1997
|
+
/**
|
|
1998
|
+
* Get dynamic endpoint from Orbs TON Access.
|
|
1999
|
+
* This should be called before making requests.
|
|
2000
|
+
*/
|
|
2001
|
+
getDynamicEndpoint(): Promise<string>;
|
|
2002
|
+
requiresApiKey(): boolean;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
* Unified Provider System - Provider Factory
|
|
2007
|
+
*
|
|
2008
|
+
* Factory for creating provider-specific implementations.
|
|
2009
|
+
*/
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Generic provider for unknown/custom provider types.
|
|
2013
|
+
* Uses default behavior from BaseProvider.
|
|
2014
|
+
*/
|
|
2015
|
+
declare class GenericProvider extends BaseProvider {
|
|
2016
|
+
normalizeEndpoint(endpoint: string): string;
|
|
2017
|
+
buildHeaders(): Record<string, string>;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Create a provider-specific implementation for the given provider.
|
|
2021
|
+
*
|
|
2022
|
+
* @param provider - Resolved provider configuration
|
|
2023
|
+
* @returns Provider-specific implementation instance
|
|
2024
|
+
*/
|
|
2025
|
+
declare function createProvider(provider: ResolvedProvider): BaseProvider;
|
|
2026
|
+
|
|
2027
|
+
export { type ApiVersion, ApiVersionSchema, BaseProvider, BrowserAdapter, CHAINSTACK_RATE_LIMIT, ChainstackProvider, ConfigError, DEFAULT_CONTRACT_TIMEOUT_MS, DEFAULT_HEALTH_CHECK_TIMEOUT_MS, DEFAULT_PROVIDERS, DEFAULT_PROVIDER_TIMEOUT_MS, DEFAULT_RATE_LIMIT, GenericProvider, GetBlockProvider, type HealthCheckConfig, HealthChecker, type Logger, type MasterchainInfo, type Network, type NetworkDefaults, NetworkSchema, NodeAdapter, ORBS_RATE_LIMIT, OnFinalityProvider, OrbsProvider, type ProviderConfig, ProviderConfigSchema, type ProviderEndpoints, ProviderError, type ProviderHealthResult, ProviderManager, type ProviderManagerOptions, type ProviderManagerState, ProviderRegistry, ProviderSelector, type ProviderState, type ProviderStatus, type ProviderType, ProviderTypeSchema, QUICKNODE_RATE_LIMIT, QuickNodeProvider, type RateLimitConfig, RateLimitError, type RateLimitState, RateLimiterManager, type ResolvedProvider, type RetryOptions, type RpcConfig, RpcConfigSchema, type SelectionConfig, type StateListener, TatumProvider, TimeoutError, TokenBucketRateLimiter, type TonApiResponse, TonCenterProvider, buildGetAddressBalanceUrl, buildGetAddressInfoUrl, buildGetAddressStateUrl, buildRestUrl, createBrowserAdapter, createBrowserAdapterForNetwork, createDefaultConfig, createDefaultRegistry, createEmptyConfig, createHealthChecker, createNodeAdapter, createProvider, createProviderManager, createRateLimiter, createRateLimiterManager, createRegistry, createRegistryFromData, createRegistryFromFile, createSelector, createTimeoutController, detectNetworkFromEndpoint, fetchWithTimeout, getBaseUrl, getDefaultProvidersForNetwork, getEnvVar, getProviderManager, getProvidersForNetwork, getRateLimitForType, getTonClient, getTonClientForNetwork, getTonClientWithRateLimit, isApiVersion, isChainstackUrl, isNetwork, isOrbsUrl, isProviderType, isQuickNodeUrl, isRateLimitError, isTimeoutError, isTonCenterUrl, isValidHttpUrl, isValidWsUrl, loadBuiltinConfig, loadConfig, loadConfigFromData, loadConfigFromUrl, mergeConfigs, mergeWithDefaults, normalizeV2Endpoint, parseProviderConfig, parseRpcConfig, resetNodeAdapter, resolveAllProviders, resolveEndpoints, resolveKeyPlaceholder, resolveProvider, sleep, toV2Base, toV3Base, withRetry, withTimeout, withTimeoutAndRetry, withTimeoutFn };
|
package/dist/index.d.ts
CHANGED
|
@@ -1032,6 +1032,9 @@ declare class HealthChecker {
|
|
|
1032
1032
|
clearResults(): void;
|
|
1033
1033
|
/**
|
|
1034
1034
|
* Mark a provider as degraded (e.g., on 429 error)
|
|
1035
|
+
*
|
|
1036
|
+
* Providers marked as degraded have failed health checks (e.g., rate limit errors)
|
|
1037
|
+
* and should not be selected. The system will failover to the next available provider.
|
|
1035
1038
|
*/
|
|
1036
1039
|
markDegraded(providerId: string, network: Network, error?: string): void;
|
|
1037
1040
|
/**
|
|
@@ -1043,13 +1046,6 @@ declare class HealthChecker {
|
|
|
1043
1046
|
* Get endpoint URL for a provider (handles dynamic providers like Orbs)
|
|
1044
1047
|
*/
|
|
1045
1048
|
private getEndpoint;
|
|
1046
|
-
/**
|
|
1047
|
-
* Normalize endpoint for provider-specific requirements
|
|
1048
|
-
*
|
|
1049
|
-
* Note: normalizeV2Endpoint now handles all provider-specific cases correctly,
|
|
1050
|
-
* including Tatum (/jsonRPC), OnFinality (/public or /rpc), QuickNode, and GetBlock.
|
|
1051
|
-
*/
|
|
1052
|
-
private normalizeEndpointForProvider;
|
|
1053
1049
|
/**
|
|
1054
1050
|
* Call getMasterchainInfo API with provider-specific handling
|
|
1055
1051
|
*/
|
|
@@ -1630,20 +1626,16 @@ declare function createBrowserAdapterForNetwork(network: Network, configPath?: s
|
|
|
1630
1626
|
*
|
|
1631
1627
|
* URL normalization and manipulation for TON RPC endpoints.
|
|
1632
1628
|
*/
|
|
1629
|
+
|
|
1633
1630
|
/**
|
|
1634
|
-
* Normalize endpoint URL for TonClient v2 API.
|
|
1635
|
-
*
|
|
1631
|
+
* Normalize endpoint URL for TonClient v2 API using provider-specific implementation.
|
|
1632
|
+
* This is the preferred method when a ResolvedProvider is available.
|
|
1636
1633
|
*
|
|
1637
|
-
*
|
|
1638
|
-
* -
|
|
1639
|
-
*
|
|
1640
|
-
* - TON Access (orbs): Already returns correct JSON-RPC endpoint
|
|
1641
|
-
* - QuickNode: Needs /jsonRPC appended to base URL
|
|
1642
|
-
* - GetBlock: Needs /jsonRPC appended to base URL
|
|
1643
|
-
* - Tatum: Gateway URLs need /jsonRPC appended (gateway.tatum.io/jsonRPC)
|
|
1644
|
-
* - OnFinality: Uses /public or /rpc path with query params - preserve query params
|
|
1634
|
+
* @param endpoint - Endpoint URL to normalize
|
|
1635
|
+
* @param provider - Resolved provider configuration (optional)
|
|
1636
|
+
* @returns Normalized endpoint URL
|
|
1645
1637
|
*/
|
|
1646
|
-
declare function normalizeV2Endpoint(endpoint: string): string;
|
|
1638
|
+
declare function normalizeV2Endpoint(endpoint: string, provider?: ResolvedProvider): string;
|
|
1647
1639
|
/**
|
|
1648
1640
|
* Convert any endpoint to v2 base URL (without /jsonRPC suffix).
|
|
1649
1641
|
*/
|
|
@@ -1802,4 +1794,234 @@ declare function isTimeoutError(error: unknown): error is TimeoutError;
|
|
|
1802
1794
|
*/
|
|
1803
1795
|
declare function isRateLimitError(error: unknown): boolean;
|
|
1804
1796
|
|
|
1805
|
-
|
|
1797
|
+
/**
|
|
1798
|
+
* Unified Provider System - Base Provider
|
|
1799
|
+
*
|
|
1800
|
+
* Base class for provider-specific implementations.
|
|
1801
|
+
* All provider types extend this class to provide provider-specific behavior.
|
|
1802
|
+
*/
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* Base provider class that all provider-specific implementations extend.
|
|
1806
|
+
* Provides common functionality and defines the interface for provider-specific behavior.
|
|
1807
|
+
*/
|
|
1808
|
+
declare abstract class BaseProvider {
|
|
1809
|
+
protected provider: ResolvedProvider;
|
|
1810
|
+
constructor(provider: ResolvedProvider);
|
|
1811
|
+
/**
|
|
1812
|
+
* Get the provider instance
|
|
1813
|
+
*/
|
|
1814
|
+
getProvider(): ResolvedProvider;
|
|
1815
|
+
/**
|
|
1816
|
+
* Normalize endpoint URL for this provider type.
|
|
1817
|
+
* Each provider may have different endpoint format requirements.
|
|
1818
|
+
*/
|
|
1819
|
+
abstract normalizeEndpoint(endpoint: string): string;
|
|
1820
|
+
/**
|
|
1821
|
+
* Build HTTP headers for requests to this provider.
|
|
1822
|
+
* Handles provider-specific authentication (API keys in headers, etc.)
|
|
1823
|
+
*/
|
|
1824
|
+
abstract buildHeaders(): Record<string, string>;
|
|
1825
|
+
/**
|
|
1826
|
+
* Build a JSON-RPC request body.
|
|
1827
|
+
* Most providers use standard JSON-RPC 2.0, but some may need modifications.
|
|
1828
|
+
*/
|
|
1829
|
+
buildRequest(method: string, params?: Record<string, unknown>): {
|
|
1830
|
+
id: string;
|
|
1831
|
+
jsonrpc: string;
|
|
1832
|
+
method: string;
|
|
1833
|
+
params: Record<string, unknown>;
|
|
1834
|
+
};
|
|
1835
|
+
/**
|
|
1836
|
+
* Parse response from provider.
|
|
1837
|
+
* Handles provider-specific response formats.
|
|
1838
|
+
*/
|
|
1839
|
+
parseResponse<T = unknown>(data: unknown): T;
|
|
1840
|
+
/**
|
|
1841
|
+
* Parse masterchain info from response.
|
|
1842
|
+
* Validates the response structure and extracts seqno.
|
|
1843
|
+
*/
|
|
1844
|
+
parseMasterchainInfo(data: unknown): MasterchainInfo;
|
|
1845
|
+
/**
|
|
1846
|
+
* Validate provider configuration.
|
|
1847
|
+
* Checks if required API keys are present, etc.
|
|
1848
|
+
*/
|
|
1849
|
+
validateConfig(): {
|
|
1850
|
+
valid: boolean;
|
|
1851
|
+
error?: string;
|
|
1852
|
+
};
|
|
1853
|
+
/**
|
|
1854
|
+
* Get the normalized endpoint for this provider.
|
|
1855
|
+
*/
|
|
1856
|
+
getNormalizedEndpoint(): string;
|
|
1857
|
+
/**
|
|
1858
|
+
* Check if this provider requires an API key.
|
|
1859
|
+
*/
|
|
1860
|
+
requiresApiKey(): boolean;
|
|
1861
|
+
/**
|
|
1862
|
+
* Check if API key is present (if required).
|
|
1863
|
+
*/
|
|
1864
|
+
hasApiKey(): boolean;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
/**
|
|
1868
|
+
* Unified Provider System - Chainstack Provider
|
|
1869
|
+
*
|
|
1870
|
+
* Chainstack-specific implementation.
|
|
1871
|
+
* Documentation: https://docs.chainstack.com/reference/getting-started-ton
|
|
1872
|
+
*
|
|
1873
|
+
* Endpoint format: https://ton-{network}.core.chainstack.com/{key}/api/v2/jsonRPC
|
|
1874
|
+
* API key: In URL path (not header)
|
|
1875
|
+
*/
|
|
1876
|
+
|
|
1877
|
+
declare class ChainstackProvider extends BaseProvider {
|
|
1878
|
+
constructor(provider: ResolvedProvider);
|
|
1879
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1880
|
+
buildHeaders(): Record<string, string>;
|
|
1881
|
+
validateConfig(): {
|
|
1882
|
+
valid: boolean;
|
|
1883
|
+
error?: string;
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
/**
|
|
1888
|
+
* Unified Provider System - Tatum Provider
|
|
1889
|
+
*
|
|
1890
|
+
* Tatum-specific implementation.
|
|
1891
|
+
* Documentation: https://docs.tatum.io/reference/rpc-ton
|
|
1892
|
+
*
|
|
1893
|
+
* Endpoint format: https://ton-{network}.gateway.tatum.io/jsonRPC
|
|
1894
|
+
* API key: Required in x-api-key header
|
|
1895
|
+
*/
|
|
1896
|
+
|
|
1897
|
+
declare class TatumProvider extends BaseProvider {
|
|
1898
|
+
constructor(provider: ResolvedProvider);
|
|
1899
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1900
|
+
buildHeaders(): Record<string, string>;
|
|
1901
|
+
requiresApiKey(): boolean;
|
|
1902
|
+
validateConfig(): {
|
|
1903
|
+
valid: boolean;
|
|
1904
|
+
error?: string;
|
|
1905
|
+
};
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
/**
|
|
1909
|
+
* Unified Provider System - OnFinality Provider
|
|
1910
|
+
*
|
|
1911
|
+
* OnFinality-specific implementation.
|
|
1912
|
+
* Documentation: https://documentation.onfinality.io/support/ton
|
|
1913
|
+
*
|
|
1914
|
+
* Endpoint format: https://ton-{network}.api.onfinality.io/public or /rpc
|
|
1915
|
+
* API key: Optional, in apikey header (preferred) or query params
|
|
1916
|
+
*/
|
|
1917
|
+
|
|
1918
|
+
declare class OnFinalityProvider extends BaseProvider {
|
|
1919
|
+
constructor(provider: ResolvedProvider);
|
|
1920
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1921
|
+
buildHeaders(): Record<string, string>;
|
|
1922
|
+
parseResponse<T = unknown>(data: unknown): T;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
/**
|
|
1926
|
+
* Unified Provider System - QuickNode Provider
|
|
1927
|
+
*
|
|
1928
|
+
* QuickNode-specific implementation.
|
|
1929
|
+
* Documentation: https://quicknode.com/docs/ton
|
|
1930
|
+
*
|
|
1931
|
+
* Endpoint format: https://{key}.ton-{network}.quiknode.pro/jsonRPC
|
|
1932
|
+
* API key: In subdomain (not header)
|
|
1933
|
+
*/
|
|
1934
|
+
|
|
1935
|
+
declare class QuickNodeProvider extends BaseProvider {
|
|
1936
|
+
constructor(provider: ResolvedProvider);
|
|
1937
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1938
|
+
buildHeaders(): Record<string, string>;
|
|
1939
|
+
validateConfig(): {
|
|
1940
|
+
valid: boolean;
|
|
1941
|
+
error?: string;
|
|
1942
|
+
};
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/**
|
|
1946
|
+
* Unified Provider System - GetBlock Provider
|
|
1947
|
+
*
|
|
1948
|
+
* GetBlock-specific implementation.
|
|
1949
|
+
* Documentation: https://docs.getblock.io/api-reference/the-open-network-ton
|
|
1950
|
+
*
|
|
1951
|
+
* Endpoint format: https://go.getblock.io/{key}/jsonRPC
|
|
1952
|
+
* API key: Required in x-api-key header
|
|
1953
|
+
*/
|
|
1954
|
+
|
|
1955
|
+
declare class GetBlockProvider extends BaseProvider {
|
|
1956
|
+
constructor(provider: ResolvedProvider);
|
|
1957
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1958
|
+
buildHeaders(): Record<string, string>;
|
|
1959
|
+
requiresApiKey(): boolean;
|
|
1960
|
+
validateConfig(): {
|
|
1961
|
+
valid: boolean;
|
|
1962
|
+
error?: string;
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
/**
|
|
1967
|
+
* Unified Provider System - TON Center Provider
|
|
1968
|
+
*
|
|
1969
|
+
* TON Center-specific implementation.
|
|
1970
|
+
* Documentation: https://toncenter.com/api/v2/
|
|
1971
|
+
*
|
|
1972
|
+
* Endpoint format: https://{testnet.}toncenter.com/api/v2/jsonRPC
|
|
1973
|
+
* API key: Optional, passed to TonClient (not in header for HTTP requests)
|
|
1974
|
+
*/
|
|
1975
|
+
|
|
1976
|
+
declare class TonCenterProvider extends BaseProvider {
|
|
1977
|
+
constructor(provider: ResolvedProvider);
|
|
1978
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1979
|
+
buildHeaders(): Record<string, string>;
|
|
1980
|
+
requiresApiKey(): boolean;
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
/**
|
|
1984
|
+
* Unified Provider System - Orbs Provider
|
|
1985
|
+
*
|
|
1986
|
+
* Orbs (TON Access) specific implementation.
|
|
1987
|
+
* Documentation: https://github.com/orbs-network/ton-access
|
|
1988
|
+
*
|
|
1989
|
+
* Endpoint format: Dynamic discovery via @orbs-network/ton-access
|
|
1990
|
+
* API key: Not required (decentralized gateway)
|
|
1991
|
+
*/
|
|
1992
|
+
|
|
1993
|
+
declare class OrbsProvider extends BaseProvider {
|
|
1994
|
+
constructor(provider: ResolvedProvider);
|
|
1995
|
+
normalizeEndpoint(endpoint: string): string;
|
|
1996
|
+
buildHeaders(): Record<string, string>;
|
|
1997
|
+
/**
|
|
1998
|
+
* Get dynamic endpoint from Orbs TON Access.
|
|
1999
|
+
* This should be called before making requests.
|
|
2000
|
+
*/
|
|
2001
|
+
getDynamicEndpoint(): Promise<string>;
|
|
2002
|
+
requiresApiKey(): boolean;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
* Unified Provider System - Provider Factory
|
|
2007
|
+
*
|
|
2008
|
+
* Factory for creating provider-specific implementations.
|
|
2009
|
+
*/
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Generic provider for unknown/custom provider types.
|
|
2013
|
+
* Uses default behavior from BaseProvider.
|
|
2014
|
+
*/
|
|
2015
|
+
declare class GenericProvider extends BaseProvider {
|
|
2016
|
+
normalizeEndpoint(endpoint: string): string;
|
|
2017
|
+
buildHeaders(): Record<string, string>;
|
|
2018
|
+
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Create a provider-specific implementation for the given provider.
|
|
2021
|
+
*
|
|
2022
|
+
* @param provider - Resolved provider configuration
|
|
2023
|
+
* @returns Provider-specific implementation instance
|
|
2024
|
+
*/
|
|
2025
|
+
declare function createProvider(provider: ResolvedProvider): BaseProvider;
|
|
2026
|
+
|
|
2027
|
+
export { type ApiVersion, ApiVersionSchema, BaseProvider, BrowserAdapter, CHAINSTACK_RATE_LIMIT, ChainstackProvider, ConfigError, DEFAULT_CONTRACT_TIMEOUT_MS, DEFAULT_HEALTH_CHECK_TIMEOUT_MS, DEFAULT_PROVIDERS, DEFAULT_PROVIDER_TIMEOUT_MS, DEFAULT_RATE_LIMIT, GenericProvider, GetBlockProvider, type HealthCheckConfig, HealthChecker, type Logger, type MasterchainInfo, type Network, type NetworkDefaults, NetworkSchema, NodeAdapter, ORBS_RATE_LIMIT, OnFinalityProvider, OrbsProvider, type ProviderConfig, ProviderConfigSchema, type ProviderEndpoints, ProviderError, type ProviderHealthResult, ProviderManager, type ProviderManagerOptions, type ProviderManagerState, ProviderRegistry, ProviderSelector, type ProviderState, type ProviderStatus, type ProviderType, ProviderTypeSchema, QUICKNODE_RATE_LIMIT, QuickNodeProvider, type RateLimitConfig, RateLimitError, type RateLimitState, RateLimiterManager, type ResolvedProvider, type RetryOptions, type RpcConfig, RpcConfigSchema, type SelectionConfig, type StateListener, TatumProvider, TimeoutError, TokenBucketRateLimiter, type TonApiResponse, TonCenterProvider, buildGetAddressBalanceUrl, buildGetAddressInfoUrl, buildGetAddressStateUrl, buildRestUrl, createBrowserAdapter, createBrowserAdapterForNetwork, createDefaultConfig, createDefaultRegistry, createEmptyConfig, createHealthChecker, createNodeAdapter, createProvider, createProviderManager, createRateLimiter, createRateLimiterManager, createRegistry, createRegistryFromData, createRegistryFromFile, createSelector, createTimeoutController, detectNetworkFromEndpoint, fetchWithTimeout, getBaseUrl, getDefaultProvidersForNetwork, getEnvVar, getProviderManager, getProvidersForNetwork, getRateLimitForType, getTonClient, getTonClientForNetwork, getTonClientWithRateLimit, isApiVersion, isChainstackUrl, isNetwork, isOrbsUrl, isProviderType, isQuickNodeUrl, isRateLimitError, isTimeoutError, isTonCenterUrl, isValidHttpUrl, isValidWsUrl, loadBuiltinConfig, loadConfig, loadConfigFromData, loadConfigFromUrl, mergeConfigs, mergeWithDefaults, normalizeV2Endpoint, parseProviderConfig, parseRpcConfig, resetNodeAdapter, resolveAllProviders, resolveEndpoints, resolveKeyPlaceholder, resolveProvider, sleep, toV2Base, toV3Base, withRetry, withTimeout, withTimeoutAndRetry, withTimeoutFn };
|