@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.
291 lines (290 loc) • 9.72 kB
TypeScript
/**
* GorbchainSDK V1 - Main SDK Class
*
* Specialized in rich Solana operations for rapid application development.
* Focuses on wallet integration, enhanced transaction analysis, and portfolio management.
*
* @example
* ```typescript
* const sdk = new GorbchainSDK({
* rpcEndpoint: 'https://rpc.gorbchain.xyz',
* network: 'gorbchain'
* });
*
* // Rich token portfolio analysis
* const portfolio = await sdk.getRichTokenAccounts(address);
*
* // Enhanced transaction analysis
* const transaction = await sdk.getRichTransaction(signature);
*
* // Universal wallet integration
* const walletManager = sdk.createWalletManager();
* ```
*
* @version 1.0.0
* @author Gorbchain Team
*/
import { RpcClient } from '../rpc/client.js';
import { EnhancedRpcClient } from '../rpc/enhancedClient.js';
import { AdvancedTokenHoldings } from '../tokens/advancedHoldings.js';
import { NetworkConfig } from '../config/networks.js';
import { DecoderRegistry } from '../decoders/registry.js';
import { UniversalWalletManager } from '../rich/walletIntegration.js';
import type { GorbchainSDKConfig } from './types.js';
/**
* GorbchainSDK V1 - Rich Solana Operations
*
* Main SDK class providing enhanced Solana operations for rapid dApp development.
* Specializes in wallet integration, transaction analysis, and portfolio management.
*
* @public
*/
export declare class GorbchainSDK {
config: GorbchainSDKConfig;
private rpcClient;
private enhancedRpcClient;
private tokenAnalyzer;
private networkConfig;
decoders: DecoderRegistry;
constructor(config?: GorbchainSDKConfig);
/**
* Initialize network configuration from config
*/
private initializeNetworkConfig;
/**
* Get the standard RPC client (v1 compatibility)
*/
getRpcClient(): RpcClient;
/**
* Get the enhanced RPC client with v2 features
*/
getEnhancedRpcClient(): EnhancedRpcClient;
/**
* Get the token analyzer
*/
getTokenAnalyzer(): AdvancedTokenHoldings;
/**
* Get network configuration
*/
getNetworkConfig(): NetworkConfig | null;
/**
* Set custom network configuration
*/
setNetworkConfig(config: NetworkConfig): void;
/**
* Create custom network configuration
*/
createCustomNetwork(config: Partial<NetworkConfig> & {
name: string;
rpcEndpoint: string;
}): NetworkConfig;
/**
* Check if current network supports a feature
*/
supportsFeature(feature: string): boolean;
/**
* Check if current network supports an RPC method
*/
supportsMethod(method: string): boolean;
/**
* Get network health status
*/
getNetworkHealth(): Promise<{
status: 'healthy' | 'degraded' | 'unhealthy';
currentSlot: number;
responseTime: number;
networkName: string;
blockHeight?: number;
rpcEndpoint?: string;
}>;
/**
* Get comprehensive token holdings (v2 enhanced method)
*/
getAllTokenHoldings(walletAddress: string, options?: {
includeStandardTokens?: boolean;
includeCustomTokens?: boolean;
includeNFTs?: boolean;
customPrograms?: string[];
}): Promise<import("../tokens/advancedHoldings.js").TokenPortfolio>;
/**
* Get tokens from specific program
*/
getCustomProgramTokens(walletAddress: string, programId: string): Promise<import("../rpc/enhancedClient.js").TokenHolding[]>;
/**
* Analyze portfolio for insights
*/
analyzePortfolio(walletAddress: string): Promise<import("../tokens/advancedHoldings.js").PortfolioAnalysis>;
/**
* Get tokens by category
*/
getTokensByCategory(walletAddress: string): Promise<{
nfts: import("../rpc/enhancedClient.js").TokenHolding[];
fungibleTokens: import("../rpc/enhancedClient.js").TokenHolding[];
}>;
/**
* Get top holdings by balance
*/
getTopHoldings(walletAddress: string, limit?: number): Promise<import("../rpc/enhancedClient.js").TokenHolding[]>;
/**
* Compare two portfolios
*/
comparePortfolios(walletAddress1: string, walletAddress2: string): Promise<{
commonTokens: import("../rpc/enhancedClient.js").TokenHolding[];
uniqueToWallet1: import("../rpc/enhancedClient.js").TokenHolding[];
uniqueToWallet2: import("../rpc/enhancedClient.js").TokenHolding[];
similarity: number;
}>;
/**
* Batch analyze multiple wallets
*/
batchAnalyzeWallets(walletAddresses: string[], options?: {
maxConcurrentRequests?: number;
customPrograms?: string[];
}): Promise<import("../tokens/advancedHoldings.js").TokenPortfolio[]>;
/**
* Get and decode transaction (enhanced with network-aware decoding)
*/
getAndDecodeTransaction(signature: string, options?: {
richDecoding?: boolean;
includeTokenMetadata?: boolean;
maxRetries?: number;
}): Promise<{
decoded: import("../decoders/registry.js").DecodedInstruction[];
meta: unknown;
}>;
/**
* Get supported programs for current network
*/
getSupportedPrograms(): string[];
/**
* Get network capabilities
*/
getNetworkCapabilities(): {
supportedMethods: string[];
features: Record<string, boolean>;
tokenPrograms: string[];
};
/**
* Detect network capabilities dynamically
*/
detectNetworkCapabilities(): Promise<{
supportedMethods: string[];
detectedFeatures: Record<string, boolean>;
}>;
/**
* Get network statistics
*/
getNetworkStats(): Promise<{
currentSlot: number;
epochInfo: any;
version: any;
identity: string;
}>;
/**
* Direct access to underlying RPC client for advanced usage
*/
get rpc(): RpcClient;
/**
* Direct access to enhanced RPC client for enhanced features
*/
get enhancedRpc(): EnhancedRpcClient;
/**
* Rich Functions - Enhanced operations with comprehensive metadata
*/
/**
* Get rich token accounts with complete metadata and market data
*
* @param ownerAddress - Wallet address to analyze
* @param options - Configuration options for metadata fetching
* @returns Promise resolving to rich token accounts with portfolio summary
*/
getRichTokenAccounts(ownerAddress: string, options?: {
includeMetadata?: boolean;
includeMarketData?: boolean;
includeNFTs?: boolean;
includeZeroBalance?: boolean;
maxConcurrentRequests?: number;
customPrograms?: string[];
}): Promise<import("../rich/tokenOperations.js").RichTokenAccountsResponse>;
/**
* Get rich transaction with decoded instructions and token metadata
*
* @param signature - Transaction signature to analyze
* @param options - Configuration options for analysis
* @returns Promise resolving to rich transaction with complete context
*/
getRichTransaction(signature: string, options?: {
includeTokenMetadata?: boolean;
includeBalanceChanges?: boolean;
resolveAddressLabels?: boolean;
maxRetries?: number;
commitment?: 'processed' | 'confirmed' | 'finalized';
}): Promise<import("../rich/transactionOperations.js").RichTransaction>;
/**
* Create universal wallet manager for comprehensive wallet integration
*
* @returns UniversalWalletManager instance for wallet operations
*/
createWalletManager(): UniversalWalletManager;
/**
* Direct access to decoder registry for custom decoder management
*/
get decoderRegistry(): DecoderRegistry;
/**
* Register a decoder for a program (v1 compatibility method)
* @deprecated Use sdk.decoderRegistry.register() instead
*/
registerDecoder(programName: string, programId: string, decoder: any): void;
/**
* Decode a single instruction (v1 compatibility method)
* @deprecated Use sdk.decoderRegistry.decode() instead
*/
decodeInstruction(instruction: any): any;
/**
* Decode multiple instructions (v1 compatibility method)
* @deprecated Use instructions.map(ix => sdk.decoderRegistry.decode(ix)) instead
*/
decodeInstructions(instructions: any[]): any[];
/**
* Get current slot (v1 compatibility method)
* @deprecated Use sdk.rpc.getSlot() instead
*/
getCurrentSlot(): Promise<number>;
/**
* Get block height (v1 compatibility method)
* @deprecated Use sdk.rpc.getBlockHeight() instead
*/
getBlockHeight(): Promise<number>;
/**
* Get basic balance (v1 compatibility method)
* @deprecated Use sdk.rpc.getAccountInfo(address).lamports instead
*/
getBalance(address: string): Promise<number>;
/**
* Get detailed balance information (v1 compatibility method)
*/
getBalanceDetailed(address: string): Promise<{
lamports: number;
sol: number;
formatted: string;
}>;
/**
* Get account info (v1 compatibility method)
* @deprecated Use sdk.rpc.getAccountInfo() instead
*/
getAccountInfo(address: string): Promise<any>;
/**
* Set RPC endpoint (v1 compatibility method)
* @deprecated Create a new SDK instance with the desired endpoint instead
*/
setRpcEndpoint(endpoint: string): void;
/**
* Test RPC performance (v1 compatibility method)
*/
testRpcPerformance(iterations?: number): Promise<{
averageResponseTime: number;
successRate: number;
minResponseTime: number;
maxResponseTime: number;
}>;
}