UNPKG

delegate-framework

Version:

A TypeScript framework for building robust, production-ready blockchain workflows with comprehensive error handling, logging, and testing. Maintained by delegate.fun

300 lines 12.2 kB
import { Transaction as SolanaTransaction, PublicKey, Keypair } from "@solana/web3.js"; import { HeliusConfig, SendTransactionOptions, Logger, GetLatestBlockhashOptions, GetTransactionsOptions, Transaction, GetAccountInfoOptions } from "../types"; export declare class HeliusClient { private static readonly DEFAULT_TIMEOUT; private static readonly DEFAULT_RETRIES; private static readonly DEFAULT_RPC_URL; private static readonly DEFAULT_ENHANCED_API_URL; private static readonly METAPLEX_METADATA_PROGRAM_ID; private readonly config; private readonly logger?; private requestId; private rateLimitInfo; constructor(config: HeliusConfig); /** * Send a transaction to the Solana network * @param transaction - The transaction to send * @param options - Optional configuration for the transaction * @returns Transaction signature */ sendTransaction(transaction: SolanaTransaction, options?: SendTransactionOptions): Promise<string>; /** * Send native SOL transfer * @param from - Source wallet keypair * @param to - Destination wallet public key * @param amount - Amount in lamports * @param options - Optional transaction options * @returns Transaction signature */ sendNativeTransfer(from: Keypair, to: PublicKey, amount: number, options?: SendTransactionOptions): Promise<string>; /** * Send SPL token transfer * @param to - Destination token account public key * @param owner - Owner keypair of the source token account * @param amount - Amount to transfer * @param mint - Token mint address * @param options - Optional transaction options * @returns Transaction signature */ sendTokenTransfer(to: PublicKey, owner: Keypair, amount: number, mint: PublicKey, options?: SendTransactionOptions): Promise<string>; /** * Get the balance of a public key * @param publicKey - The public key to check balance for * @returns Balance in lamports */ getBalance(publicKey: PublicKey): Promise<any>; /** * Get account information with enhanced Metaplex metadata parsing * @param publicKey - The public key to get account info for * @param encodingOrOptions - Optional encoding or configuration options * @returns Account information with optional parsed Metaplex metadata */ getAccountInfo(publicKey: PublicKey, encodingOrOptions?: 'base64' | 'base58' | GetAccountInfoOptions): Promise<any>; /** * Get transaction details * @param signature - Transaction signature * @param commitment - Optional commitment level * @returns Transaction details */ getTransaction(signature: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<any>; /** * Get transactions for a public key * @param publicKey - The public key to get transactions for * @param options - Optional configuration for transaction retrieval * @returns Array of Transaction objects */ getTransactions(publicKey: PublicKey, options?: GetTransactionsOptions): Promise<Transaction[]>; /** * Validate pagination parameter combinations * @param options - The pagination options to validate * @private */ private validatePaginationParameters; /** * Get all transactions for a public key with automatic pagination * @param publicKey - The public key to get all transactions for * @param options - Optional configuration for transaction retrieval (supports all pagination parameters) * @returns Array of all Transaction objects */ getAllTransactions(publicKey: PublicKey, options?: GetTransactionsOptions): Promise<Transaction[]>; /** * Get a specific number of transactions for a public key with automatic pagination * @param publicKey - The public key to get transactions for * @param totalLimit - Total number of transactions to fetch * @param options - Optional configuration for transaction retrieval (supports all pagination parameters) * @param batchSize - Number of transactions to fetch per API call (default: 10, max: 100) * @returns Array of Transaction objects up to the specified limit */ getTransactionsWithLimit(publicKey: PublicKey, totalLimit: number, options?: GetTransactionsOptions, batchSize?: number): Promise<Transaction[]>; /** * Get transactions with limit using a more robust pagination strategy * This method attempts to handle potential gaps in transaction history by using * a combination of 'before' and 'until' parameters and retry logic * @param publicKey - The public key to get transactions for * @param totalLimit - Total number of transactions to fetch * @param options - Optional configuration for transaction retrieval * @param batchSize - Number of transactions to fetch per API call (default: 50, max: 100) * @returns Array of Transaction objects up to the specified limit */ getTransactionsWithLimitRobust(publicKey: PublicKey, totalLimit: number, options?: GetTransactionsOptions, batchSize?: number): Promise<Transaction[]>; /** * Diagnostic method to analyze transaction pagination behavior * This method helps identify gaps and understand the pagination patterns * @param publicKey - The public key to analyze * @param sampleSize - Number of transactions to analyze (default: 1000) * @param batchSize - Batch size for analysis (default: 100) * @returns Analysis results including gap detection and pagination statistics */ analyzeTransactionPagination(publicKey: PublicKey, sampleSize?: number, batchSize?: number): Promise<{ totalTransactions: number; batches: number; gaps: Array<{ before: string; after: string; estimatedGapSize: number; }>; averageBatchSize: number; paginationIssues: string[]; recommendations: string[]; }>; /** * Get slot information * @param commitment - Optional commitment level * @returns Current slot */ getSlot(commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<number>; /** * Get token account * @param publicKey - The public key to get token account from * @param mint - contract address of the token * @returns Token account */ getTokenAccount(publicKey: PublicKey, mint: PublicKey): Promise<any>; /** * Get token accounts by owner * @param publicKey - The public key to get token accounts from * @returns Token accounts */ getTokenAccounts(publicKey: PublicKey): Promise<any>; /** * Get token account balance * @param publicKey - The token account public key to get balance for * @returns Token account balance */ getTokenAccountBalance(publicKey: PublicKey): Promise<any>; /** * Get cluster nodes * @returns Information about cluster nodes */ getClusterNodes(): Promise<any[]>; /** * Get version information * @returns Solana version information */ getVersion(): Promise<any>; /** * Get latest blockhash * @returns Latest blockhash information */ getLatestBlockhash(options?: GetLatestBlockhashOptions): Promise<any>; /** * Get latest blockhash with retry mechanism * @param options - Optional configuration for blockhash retrieval * @param maxAttempts - Maximum number of retry attempts (default: 3) * @returns Latest blockhash information */ getLatestBlockhashWithRetry(options?: GetLatestBlockhashOptions, maxAttempts?: number): Promise<any>; /** * Get top token holders * @param tokenAddress - The token mint address * @returns Top token holders information */ getTopHolders(tokenAddress: string): Promise<any>; /** * Get token account owner * @param tokenAccount - The token account address * @returns Token account owner address */ getTokenAccountOwner(tokenAccount: string): Promise<string>; /** * Get token supply information * @param tokenAddress - The token mint address * @returns Token supply information including decimals */ getTokenSupply(tokenAddress: string): Promise<any>; /** * Get token info (decimals) from supply * @param tokenAddress - The token mint address * @returns Token info with decimals, or null if not found */ getTokenInfo(tokenAddress: string): Promise<{ decimals: number; } | null>; /** * Get comprehensive asset data for any Solana NFT or digital asset * @param assetId - The asset ID (mint address) * @returns Comprehensive asset data including metadata, ownership, and other details */ getAsset(assetId: string): Promise<any>; /** * Get comprehensive token account data for a wallet * @param walletAddress - The wallet public key * @returns Token account data including SOL balance and all token accounts */ getWalletTokenData(walletAddress: string): Promise<any>; /** * Simulate a transaction * @param transaction - The transaction to simulate * @returns Simulation result */ simulateTransaction(transaction: SolanaTransaction): Promise<any>; /** * Wait for confirmation of a transaction * @param signature - Transaction signature * @param commitment - Optional commitment level * @returns Transaction confirmation information */ waitForConfirmation(signature: string, commitment?: 'processed' | 'confirmed' | 'finalized'): Promise<any>; /** * Make a raw RPC request * @param method - RPC method name * @param params - RPC parameters * @param baseUrl - Optional base URL (defaults to rpcUrl) * @returns RPC response result */ private makeRequest; /** * Extract and log rate limit information from response headers * @param response - The fetch response * @param requestId - The request ID for logging * @private */ private extractAndLogRateLimitInfo; /** * Get current rate limit information * @returns Current rate limit status */ getRateLimitInfo(): { remaining: number; limit: number; reset: number; lastUpdate: number; usagePercentage: number; timeUntilReset?: number; }; /** * Debug logging helper that falls back to console when no logger is provided * @param message - The message to log * @param data - Optional data to log * @private */ private debugLog; /** * Utility method for delays * @param ms - Milliseconds to delay */ private delay; /** * Get the current configuration * @returns Current client configuration */ getConfig(): Readonly<Omit<Required<HeliusConfig>, 'logger'> & { logger?: Logger; }>; /** * Make a REST API request (for non-JSON-RPC endpoints) * @param url - Full URL to request * @returns Response data */ private makeRestRequest; /** * Make a REST API POST request (for non-JSON-RPC endpoints that require POST with body) * @param url - Full URL to request * @param body - Request body to send * @returns Response data */ private makeRestPostRequest; /** * Derive the Metaplex metadata account PDA for a given mint * @param mint - The mint public key * @returns The metadata account public key * @private */ private deriveMetaplexMetadataAccount; /** * Get the Metaplex metadata account for a given mint * @param mint - The mint public key * @returns Metadata account info or null if not found * @private */ private getMetaplexMetadataAccount; /** * Parse Metaplex metadata from account data * @param accountInfo - The account info response * @param includeOffChainMetadata - Whether to include off-chain metadata * @returns Parsed metadata structure * @private */ private parseMetaplexMetadata; } //# sourceMappingURL=helius.d.ts.map