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.

191 lines (190 loc) 5.16 kB
import { type RetryOptions, type CircuitBreakerOptions } from '../errors/retry.js'; export interface RpcClientOptions { rpcUrl?: string; timeout?: number; retries?: number; retryOptions?: RetryOptions; circuitBreakerOptions?: CircuitBreakerOptions; } export declare class RpcClient { private rpcUrl; private timeout; private retries; private requestId; private retryManager; constructor(options?: RpcClientOptions); /** * Make a raw RPC request with proper error handling and retry logic */ request<T>(method: string, params?: any[]): Promise<T>; /** * Handle HTTP errors and convert to appropriate error types */ private handleHttpError; /** * Handle RPC-specific errors */ private handleRpcError; /** * Handle request-level errors (network, timeout, etc.) */ private handleRequestError; /** * Extract retry-after value from response */ private extractRetryAfter; /** * Get the current RPC endpoint */ getRpcUrl(): string; /** * Update the RPC endpoint */ setRpcUrl(url: string): void; /** * Get network information */ getHealth(): Promise<string>; /** * Get current slot */ getSlot(commitment?: string): Promise<number>; /** * Get current block height */ getBlockHeight(commitment?: string): Promise<number>; /** * Get version information */ getVersion(): Promise<{ 'solana-core': string; 'feature-set'?: number; }>; /** * Get latest blockhash */ getLatestBlockhash(commitment?: string): Promise<{ blockhash: string; lastValidBlockHeight: number; }>; /** * Get account information */ getAccountInfo(address: string, commitment?: string): Promise<{ lamports: number; owner: string; executable: boolean; rentEpoch: number; data: [string, string]; } | null>; /** * Get token account information */ getTokenAccountInfo(address: string, commitment?: string): Promise<{ mint: string; owner: string; tokenAmount: { amount: string; decimals: number; uiAmount: number; uiAmountString: string; }; } | null>; /** * Get mint account information */ getMintInfo(mintAddress: string, commitment?: string): Promise<{ supply: string; decimals: number; isInitialized: boolean; mintAuthority: string | null; freezeAuthority: string | null; } | null>; /** * Get token metadata account for NFTs */ getTokenMetadata(mintAddress: string, commitment?: string): Promise<{ name: string; symbol: string; uri: string; sellerFeeBasisPoints: number; creators: Array<{ address: string; verified: boolean; share: number; }>; collection?: { verified: boolean; key: string; }; } | null>; /** * Find metadata address for a given mint */ private findMetadataAddress; /** * Get multiple account information in a single request */ getMultipleAccounts(addresses: string[], commitment?: string): Promise<Array<{ lamports: number; owner: string; executable: boolean; rentEpoch: number; data: [string, string]; } | null>>; /** * Get token accounts owned by a specific address */ getTokenAccountsByOwner(ownerAddress: string, filter: { mint?: string; programId?: string; }, commitment?: string): Promise<Array<{ pubkey: string; account: { lamports: number; owner: string; executable: boolean; rentEpoch: number; data: [string, string]; }; }>>; /** * Check if a token is likely an NFT based on mint characteristics */ isNFT(mintAddress: string, commitment?: string): Promise<boolean>; /** * Extract Token-2022 metadata from mint account data */ private extractToken2022Metadata; /** * Get enhanced token information including NFT detection */ getTokenInfo(mintAddress: string, commitment?: string): Promise<{ mint: string; supply: string; decimals: number; isInitialized: boolean; mintAuthority: string | null; freezeAuthority: string | null; isNFT: boolean; metadata?: { name: string; symbol: string; uri: string; sellerFeeBasisPoints: number; creators: Array<{ address: string; verified: boolean; share: number; }>; }; } | null>; /** * Get transaction details by signature */ getTransaction(signature: string, options?: { encoding?: string; commitment?: string; maxSupportedTransactionVersion?: number; }): Promise<any>; }