p-sdk-wallet
Version:
A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.
95 lines (94 loc) • 3.89 kB
TypeScript
import { type ChainConfig } from '../config/chains';
/**
* Interface representing Solana transaction response.
* Similar to EVM transaction response but adapted for Solana's transaction structure.
*/
export interface SolanaTransactionResponse {
/** The transaction signature/hash */
hash: string;
/** The sender's public key address */
from: string;
/** The recipient's public key address */
to: string;
/** The block number (optional, not always available on Solana) */
blockNumber?: number;
}
/**
* Interface representing Solana SPL token metadata.
* Extends the basic token interface with Solana-specific fields.
*/
export interface SolanaToken {
/** The token's mint address */
address: string;
/** The human-readable name of the token */
name: string;
/** The token's symbol/ticker */
symbol: string;
/** The number of decimal places for the token */
decimals: number;
/** The total supply of the token (optional) */
totalSupply?: string;
}
/**
* Service for interacting with Solana blockchain.
* Provides methods for SOL balance checking, SPL token operations, and transaction sending.
*/
export declare class SolanaChainService {
private connection;
private keypair;
/**
* Creates a new SolanaChainService instance for the specified Solana network.
* @param privateKey - The private key to use for signing transactions (hex string)
* @param chainConfig - The chain configuration to use
* @throws Error if the chain is not a Solana chain
*/
constructor(privateKey: string, chainConfig: ChainConfig);
/**
* Gets the native SOL balance for the wallet.
* @returns Promise resolving to the balance as a bigint in lamports
* @throws Error if the balance query fails
*/
getNativeBalance(): Promise<bigint>;
/**
* Sends native SOL to another address.
* @param to - The recipient's public key address
* @param amount - The amount of SOL to send as a string (e.g., "1.5")
* @returns Promise resolving to the transaction response with signature and details
* @throws Error if the transaction fails or recipient address is invalid
*/
sendTransaction(to: string, amount: string): Promise<SolanaTransactionResponse>;
/**
* Gets the balance of a specific SPL token for the wallet.
* @param tokenAddress - The token's mint address
* @returns Promise resolving to the token balance as a bigint
* @throws Error if the balance query fails (returns 0 if token account doesn't exist)
*/
getTokenBalance(tokenAddress: string): Promise<bigint>;
/**
* Gets metadata information about an SPL token.
* @param tokenAddress - The token's mint address
* @returns Promise resolving to token metadata including supply information
* @throws Error if the token info query fails
*/
getTokenInfo(tokenAddress: string): Promise<SolanaToken>;
/**
* Sends SPL tokens to another address.
* @param tokenAddress - The token's mint address to send
* @param to - The recipient's public key address
* @param amount - The amount of tokens to send as a string
* @returns Promise resolving to the transaction response with signature and details
* @throws Error if the transaction fails, insufficient balance, or addresses are invalid
*/
sendToken(tokenAddress: string, to: string, amount: string): Promise<SolanaTransactionResponse>;
/**
* Gets the public key address of the wallet.
* @returns The public key address as a string
*/
getAddress(): string;
/**
* Estimates the transaction fee for a typical transaction.
* @returns Promise resolving to the estimated fee as a bigint in lamports
* @throws Error if the fee estimation fails
*/
estimateTransactionFee(): Promise<bigint>;
}