UNPKG

@wuwei-labs/srsly

Version:
52 lines 1.6 kB
/** * @purpose Centralized RPC client creation for SRSLY SDK * * Provides a single point for creating Solana RPC clients, making it easier * to add environment-specific configurations or debugging in the future. */ import { createSolanaRpc } from '@solana/kit'; // Debug flag - can be set via setSdkConfig or environment let debugMode = false; /** * Enable or disable RPC debug mode * When enabled, logs RPC requests to console */ export function setRpcDebug(enabled) { debugMode = enabled; } /** * Check if RPC debug mode is enabled */ export function isRpcDebugEnabled() { return debugMode; } /** * Create a Solana RPC client * * This utility centralizes RPC client creation for the SDK. While it currently * uses the standard createSolanaRpc approach, having a single point of creation * makes it easier to: * - Add debugging/logging * - Handle environment-specific configurations * - Implement retry logic or custom transports * * @param rpcUrl - The RPC endpoint URL * @returns A configured Solana RPC client * * @example * ```typescript * const rpc = createRpc('https://api.devnet.solana.com'); * const account = await rpc.getAccountInfo(address).send(); * ``` */ export function createRpc(rpcUrl) { if (debugMode) { console.log('[SRSLY RPC Debug] Creating RPC client:', { url: rpcUrl, environment: typeof window !== 'undefined' ? 'browser' : 'node', userAgent: typeof navigator !== 'undefined' ? navigator.userAgent : 'N/A', }); } return createSolanaRpc(rpcUrl); } //# sourceMappingURL=rpc.js.map