filecoin-pin
Version:
Bridge IPFS content to Filecoin Onchain Cloud using familiar tools
125 lines • 5.53 kB
TypeScript
/**
* Payment setup utilities and display functions
*
* This module provides UI utilities and display functions for payment setup,
* building on the core payment operations from synapse/payments.
*/
import { calculateActualCapacity, calculateStorageAllowances, calculateStorageFromUSDFC, checkFILBalance, checkUSDFCBalance, depositUSDFC, getPaymentStatus, setServiceApprovals, withdrawUSDFC } from '../synapse/payments.js';
export { calculateActualCapacity, calculateStorageAllowances, calculateStorageFromUSDFC, checkFILBalance, checkUSDFCBalance, depositUSDFC, withdrawUSDFC, getPaymentStatus, setServiceApprovals, };
/**
* Parse storage allowance string
*
* Parses different storage allowance formats:
* - "1TiB/month" or "500GiB/month" - Human-friendly storage units
* - "0.0000565" - Direct USDFC per epoch (returns null, needs price lookup)
*
* @param input - Storage allowance string
* @returns Parsed TiB per month or null if it's a direct USDFC amount
*/
export declare function parseStorageAllowance(input: string): number | null;
/**
* Format USDFC amount for display
*
* @param amount - Amount in wei (18 decimals)
* @param decimals - Number of decimal places to show
* @returns Formatted string
*/
export declare function formatUSDFC(amount: bigint, decimals?: number): string;
/**
* Display the payment status summary
*
* Shows three sections: Wallet, Filecoin Pay Deposit, and WarmStorage Service Permissions
*
* @param network - Network name
* @param filBalance - FIL balance in wei
* @param isCalibnet - Whether this is calibnet testnet
* @param usdfcBalance - USDFC balance in wei
* @param depositedAmount - Amount deposited in Filecoin Pay
* @param rateAllowance - Maximum rate per epoch
* @param lockupAllowance - Maximum lockup amount
* @param pricePerTiBPerEpoch - Current storage price
*/
export declare function displayPaymentSummary(network: string, filBalance: bigint, isCalibnet: boolean, usdfcBalance: bigint, depositedAmount: bigint, rateAllowance: bigint, lockupAllowance: bigint, pricePerTiBPerEpoch: bigint): void;
/**
* Display account and balance information
*
* @param address - Wallet address
* @param network - Network name (mainnet/calibration)
* @param filBalance - FIL balance in wei
* @param isCalibnet - Whether on calibration testnet
* @param hasSufficientGas - Whether wallet has enough FIL for gas
* @param usdfcBalance - USDFC balance in wei
* @param depositedAmount - Amount deposited to Filecoin Pay
*/
export declare function displayAccountInfo(address: string, network: string, filBalance: bigint, isCalibnet: boolean, _hasSufficientGas: boolean, usdfcBalance: bigint, depositedAmount: bigint): void;
/**
* Validation result with error messages
*/
export interface PaymentValidationResult {
isValid: boolean;
errorMessage?: string;
helpMessage?: string;
}
/**
* Validate payment requirements and return structured result
*
* This function validates both FIL and USDFC balances and returns
* structured error messages that can be displayed by the caller.
*
* @param hasSufficientGas - Whether wallet has enough FIL for gas
* @param usdfcBalance - USDFC balance in wei
* @param isCalibnet - Whether on calibration testnet
* @returns Validation result with error messages
*/
export declare function validatePaymentRequirements(hasSufficientGas: boolean, usdfcBalance: bigint, isCalibnet: boolean): PaymentValidationResult;
/**
* Display deposit warning if balance is too low for active storage
*
* Warns when the available deposit (total deposit minus locked amount)
* is insufficient to maintain active storage operations.
*
* @param depositedAmount - Current deposit balance
* @param lockupUsed - Amount currently locked for active storage
*/
export declare function displayDepositWarning(depositedAmount: bigint, lockupUsed: bigint): void;
/**
* Calculate actual capacity with deposit limitations
*/
declare function calculateActualCapacityWithDeposit(depositedAmount: bigint, rateAllowance: bigint, lockupAllowance: bigint, pricePerTiBPerEpoch: bigint): {
actualGiB: number;
potentialGiB: number;
isDepositLimited: boolean;
additionalDepositNeeded: bigint;
};
/**
* Display capacity information based on deposit and limits
*
* @param capacity - Calculated capacity information
*/
export declare function displayCapacity(capacity: ReturnType<typeof calculateActualCapacityWithDeposit>): void;
/**
* Display current pricing information
*
* @param pricePerGiBPerMonth - Price per GiB per month
* @param pricePerTiBPerMonth - Price per TiB per month
*/
export declare function displayPricing(pricePerGiBPerMonth: bigint, pricePerTiBPerMonth: bigint): void;
/**
* Display WarmStorage service permissions with capacity information
*
* @param title - Section title to display
* @param monthlyRate - Rate allowance in USDFC per month
* @param lockupAmount - Lockup allowance amount
* @param depositAmount - Total deposited amount
* @param pricePerTiBPerEpoch - Current pricing per TiB per epoch
*/
export declare function displayServicePermissions(title: string, monthlyRate: bigint, lockupAmount: bigint, depositAmount: bigint, pricePerTiBPerEpoch: bigint, shouldFlush?: boolean): void;
/**
* Format FIL amount for display
*
* @param amount - Amount in attoFIL
* @param isTestnet - Whether this is tFIL (testnet)
* @returns Formatted string with unit
*/
export declare function formatFIL(amount: bigint, isTestnet: boolean): string;
//# sourceMappingURL=setup.d.ts.map