UNPKG

@wuwei-labs/srsly

Version:
57 lines 1.77 kB
"use strict"; /** * @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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.setRpcDebug = setRpcDebug; exports.isRpcDebugEnabled = isRpcDebugEnabled; exports.createRpc = createRpc; const kit_1 = require("@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 */ function setRpcDebug(enabled) { debugMode = enabled; } /** * Check if RPC debug mode is enabled */ 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(); * ``` */ 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 (0, kit_1.createSolanaRpc)(rpcUrl); } //# sourceMappingURL=rpc.js.map