@stoar/sdk
Version:
JavaScript/TypeScript SDK for STOAR - Decentralized file storage on Arweave
79 lines • 2.19 kB
TypeScript
/**
* Cost breakdown for operations
*/
export interface CostBreakdown {
operation: string;
costAR: string;
costUSD: string;
}
/**
* Total cost estimation
*/
export interface CostEstimate {
breakdown: CostBreakdown[];
totalAR: string;
totalUSD: string;
warning?: string;
}
/**
* Calculates costs for Arweave storage operations
*/
export declare class CostCalculator {
private static readonly BASE_TX_SIZE;
private static readonly MANIFEST_OVERHEAD;
private static readonly WARNING_THRESHOLD_USD;
private arPriceCache;
private readonly CACHE_DURATION;
/**
* Get current AR price in USD
*/
getARPrice(): Promise<number>;
/**
* Calculate storage cost for data size in bytes
*/
calculateStorageCost(bytes: number): Promise<number>;
/**
* Estimate cost for a single operation
*/
estimateOperationCost(operation: string, sizeInBytes: number): Promise<CostBreakdown>;
/**
* Estimate costs for multiple operations
*/
estimateCost(operations: Array<{
type: 'putObject' | 'createBucket' | 'updateManifest';
size?: number;
}>): Promise<CostEstimate>;
/**
* Estimate cost for manifest update with multiple file changes
*/
estimateManifestUpdateCost(currentManifestSize: number, fileOperations: Array<{
operation: 'add' | 'update' | 'remove';
key: string;
size?: number;
}>): Promise<CostEstimate>;
/**
* Format AR amount for display
*/
formatAR(amount: number | string): string;
/**
* Format USD amount for display
*/
formatUSD(amount: number | string): string;
/**
* Calculate cost savings for batch operations
*/
calculateBatchSavings(individualCosts: CostBreakdown[], batchCost: CostBreakdown): {
savingsAR: string;
savingsUSD: string;
savingsPercent: number;
};
/**
* Get cost estimate message for user
*/
getCostMessage(estimate: CostEstimate): string;
/**
* Clear price cache (useful for testing or manual refresh)
*/
clearPriceCache(): void;
}
//# sourceMappingURL=cost-calculator.d.ts.map