UNPKG

@gorbchain-xyz/chaindecode

Version:

GorbchainSDK V1.3+ - Complete Solana development toolkit with advanced cryptography, messaging, and collaboration features. Build secure applications with blockchain, DeFi, and end-to-end encryption.

156 lines (155 loc) 4.43 kB
/** * Enhanced RPC Client for Gorbchain SDK v2 * Provides network-aware token operations and custom program support */ import { NetworkConfig } from '../config/networks.js'; export interface ProgramAccountFilter { memcmp?: { offset: number; bytes: string; }; dataSize?: number; } export interface ProgramAccount { pubkey: string; account: { data: [string, string]; executable: boolean; lamports: number; owner: string; rentEpoch: number; space: number; }; } export interface ParsedTokenAccount { mint: string; owner: string; amount: string; decimals: number; uiAmount: number; isInitialized: boolean; } export interface ParsedMintAccount { mintAuthority: string | null; supply: string; decimals: number; isInitialized: boolean; freezeAuthority: string | null; } export interface TokenHolding { mint: string; tokenAccount: string; balance: { raw: string; decimal: number; formatted: string; }; decimals: number; isNFT: boolean; metadata?: { name?: string; symbol?: string; uri?: string; }; mintInfo?: { supply?: string; mintAuthority?: string; freezeAuthority?: string; isInitialized?: boolean; }; } export interface TokenConfig { /** Custom token programs to scan */ customPrograms?: string[]; /** Whether to include standard SPL tokens */ includeStandardTokens?: boolean; /** Whether to include Token-2022 */ includeToken2022?: boolean; /** Maximum concurrent requests */ maxConcurrentRequests?: number; } /** * Enhanced RPC Client with network-aware capabilities */ export declare class EnhancedRpcClient { private rpcEndpoint; private networkConfig; private baseRpcClient; constructor(rpcEndpoint: string, baseRpcClient: any); /** * Get program accounts with filters */ getProgramAccounts(programId: string, filters?: ProgramAccountFilter[]): Promise<ProgramAccount[]>; /** * Apply filters manually to account results */ private applyFiltersManually; /** * Convert address string to bytes for comparison */ private addressToBytes; /** * Get token accounts by program for a specific wallet */ getTokenAccountsByProgram(walletAddress: string, programId: string): Promise<ProgramAccount[]>; /** * Validate if an address is in correct format */ private isValidAddress; /** * Filter accounts by owner manually */ private filterAccountsByOwner; /** * Get custom token holdings for a wallet */ getCustomTokenHoldings(walletAddress: string, config?: TokenConfig): Promise<TokenHolding[]>; /** * Parse token account data from buffer */ parseTokenAccount(data: Buffer): ParsedTokenAccount; /** * Parse mint account data from buffer */ parseMintAccount(data: Buffer): ParsedMintAccount; /** * Get mint account information */ getMintAccountInfo(mintAddress: string): Promise<ParsedMintAccount | null>; /** * Check if a specific RPC method is supported */ isMethodSupported(method: string): Promise<boolean>; /** * Get list of supported RPC methods */ getSupportedMethods(): Promise<string[]>; /** * Get network configuration */ getNetworkConfig(): NetworkConfig | null; /** * Set network configuration manually */ setNetworkConfig(config: NetworkConfig): void; /** * Determine which token programs to scan based on config and network */ private getProgramsToScan; /** * Make RPC call to the endpoint */ private makeRpcCall; /** * Convert buffer to base58 string */ private bufferToBase58; getBalance(publicKey: string): Promise<number>; getSlot(): Promise<number>; getAccountInfo(publicKey: string, encoding?: string): Promise<any>; getSignaturesForAddress(address: string, options?: any): Promise<any[]>; getTransaction(signature: string, options?: any): Promise<any>; getTokenAccountsByOwner(walletAddress: string, filter: any, commitment?: string): Promise<any[]>; getTokenAccountInfo(tokenAccount: string, commitment?: string): Promise<any>; getTokenInfo(mintAddress: string): Promise<any>; }