p-sdk-wallet
Version:
A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.
79 lines (78 loc) • 4.04 kB
TypeScript
import { Vault } from '../Vault';
import { ChainService } from '../chain/ChainService';
import { SolanaChainService } from '../chain/SolanaChainService';
import { Recipient, MultiTransferOptions, MultiTransferResult } from '../types/multiTransfer';
import { ChainId } from '../config/chains';
/**
* Service for handling multi-transfer operations across different blockchain networks.
* Supports both native tokens and ERC-20/SPL tokens with batch processing and progress tracking.
*/
export declare class MultiTransferService {
private vault;
private chainService;
private chainId;
/**
* Creates a new MultiTransferService instance.
* @param vault - The vault instance containing the accounts
* @param chainService - The chain service for the target blockchain
* @param chainId - The chain ID for all operations
*/
constructor(vault: Vault, chainService: ChainService | SolanaChainService, chainId: ChainId);
/**
* Transfers native tokens to multiple recipients.
* @param fromAddress - The sender's address
* @param recipients - Array of recipients with addresses and amounts
* @param chainId - The chain ID for the transfer
* @param options - Optional configuration for the transfer operation
* @returns Promise resolving to the multi-transfer result
* @throws Error if validation fails or insufficient balance
*/
transferNativeTokens(fromAddress: string, recipients: Recipient[], chainId: ChainId, options?: MultiTransferOptions): Promise<MultiTransferResult>;
/**
* Transfers ERC-20/SPL tokens to multiple recipients.
* @param fromAddress - The sender's address
* @param tokenAddress - The token contract address
* @param recipients - Array of recipients with addresses and amounts
* @param chainId - The chain ID for the transfer
* @param options - Optional configuration for the transfer operation
* @returns Promise resolving to the multi-transfer result
* @throws Error if validation fails or insufficient balance
*/
transferTokens(fromAddress: string, tokenAddress: string, recipients: Recipient[], chainId: ChainId, options?: MultiTransferOptions): Promise<MultiTransferResult>;
/**
* Validates transfer inputs including recipients and amounts.
* @param fromAddress - The sender's address
* @param recipients - Array of recipients to validate
* @param options - Transfer options
* @returns Validation result with errors and total amount
*/
private validateTransferInputs;
/**
* Checks if the account has sufficient balance for the transfer.
* @param address - The account address to check
* @param amount - The amount to transfer
* @param isNative - Whether checking native token balance
* @param tokenAddress - Token address (for non-native tokens)
* @param chainId - The chain ID for the check
* @throws Error if insufficient balance
*/
private checkBalance;
/**
* Estimates gas cost for a multi-transfer operation.
* @param recipients - Array of recipients to estimate gas for
* @param chainId - The chain ID for the estimation
* @param isNative - Whether estimating for native tokens (default: true)
* @param tokenAddress - Token contract address (required for non-native tokens)
* @returns Promise resolving to estimated gas cost in wei
*/
estimateGasCost(recipients: Recipient[], chainId: ChainId, isNative?: boolean, tokenAddress?: string): Promise<bigint>;
/**
* Factory method: Create MultiTransferService from vault, fromAddress, and chainId.
* Handles private key and chainService creation internally for simplicity.
* @param vault - The vault instance
* @param fromAddress - The sender's address
* @param chainId - The chain ID
* @returns Promise resolving to a MultiTransferService instance
*/
static fromVault(vault: Vault, fromAddress: string, chainId: ChainId): Promise<MultiTransferService>;
}