import { BigNumber } from 'ethers'; import { PaymentMethod, PurchaseParams, PurchaseResult } from '../types'; /** * Utility functions for payment processing */ export declare class PaymentUtils { /** * Validate payment parameters * @param params Purchase parameters * @returns Validation result with errors if any */ static validatePurchaseParams(params: PurchaseParams): { isValid: boolean; errors: string[]; }; /** * Check if address is valid Ethereum address * @param address Address to check * @returns True if address is valid */ static isValidAddress(address: string): boolean; /** * Format payment method for display * @param method Payment method * @returns Formatted string */ static formatPaymentMethod(method: PaymentMethod): string; /** * Get payment method icon/symbol * @param method Payment method * @returns Symbol string */ static getPaymentMethodSymbol(method: PaymentMethod): string; /** * Calculate total cost including gas estimate * @param price Content price * @param gasEstimate Estimated gas cost * @param paymentMethod Payment method * @returns Total cost breakdown */ static calculateTotalCost(price: BigNumber, gasEstimate: BigNumber, paymentMethod: PaymentMethod): { contentPrice: BigNumber; gasCost: BigNumber; total: BigNumber; isETHPayment: boolean; }; /** * Format purchase result for display * @param result Purchase result * @returns Formatted result object */ static formatPurchaseResult(result: PurchaseResult): { transactionHash: string; shortHash: string; contentId: number; purchaseTime: string; viewCount: number; validUntil: string; gasUsed?: string; }; /** * Shorten transaction hash for display * @param hash Full transaction hash * @returns Shortened hash */ static shortenHash(hash: string): string; /** * Format timestamp for display * @param timestamp BigNumber timestamp * @returns Formatted date string */ static formatTimestamp(timestamp: BigNumber): string; /** * Calculate percentage savings * @param originalPrice Original price * @param discountedPrice Discounted price * @returns Savings percentage */ static calculateSavings(originalPrice: BigNumber, discountedPrice: BigNumber): number; /** * Compare payment costs across different methods * @param costs Array of cost objects with method and price * @returns Sorted costs with savings information */ static comparePaymentCosts(costs: Array<{ method: PaymentMethod; price: BigNumber; gasEstimate?: BigNumber; tokenSymbol?: string; }>): Array<{ method: PaymentMethod; price: BigNumber; total: BigNumber; tokenSymbol?: string; savings?: number; isRecommended?: boolean; }>; /** * Generate payment summary text * @param params Purchase parameters * @param price Content price * @returns Summary text */ static generatePaymentSummary(params: PurchaseParams, price: BigNumber): string; /** * Estimate gas for purchase transaction * @param paymentMethod Payment method * @param hasApproval Whether token approval is needed (for ERC20) * @returns Estimated gas units */ static estimateGasUnits(paymentMethod: PaymentMethod, hasApproval?: boolean): number; /** * Check if sufficient balance for purchase * @param balance User's balance * @param requiredAmount Required amount * @param gasEstimate Gas cost estimate * @param paymentMethod Payment method * @returns Balance check result */ static checkSufficientBalance(balance: BigNumber, requiredAmount: BigNumber, gasEstimate: BigNumber, paymentMethod: PaymentMethod): { sufficient: boolean; shortage?: BigNumber; message: string; }; /** * Generate transaction receipt URL for block explorer * @param transactionHash Transaction hash * @param networkId Network ID * @returns Block explorer URL */ static generateExplorerUrl(transactionHash: string, networkId: number): string; /** * Parse error messages from failed transactions * @param error Error object * @returns User-friendly error message */ static parseTransactionError(error: any): string; } //# sourceMappingURL=payment-utils.d.ts.map