UNPKG

delegate-framework

Version:

A TypeScript framework for building robust, production-ready blockchain workflows with comprehensive error handling, logging, and testing. Maintained by delegate.fun

111 lines 3.68 kB
import { Logger } from "../../types"; import { MetadataClient } from "./base"; export interface ArweaveConfig { privateKey: string; network?: 'mainnet-beta' | 'devnet' | 'testnet'; bundlrUrl?: string; rpcUrl?: string; timeout?: number; retries?: number; logger?: Logger; } export interface ArweaveUploadResult { success: boolean; uri?: string; error?: string; txId?: string; } export interface ArweaveCostResult { cost: number; dataSize: number; } export declare class ArweaveClient implements MetadataClient { private static readonly DEFAULT_TIMEOUT; private static readonly DEFAULT_RETRIES; private static readonly DEFAULT_BUNDLR_URL; private static readonly FALLBACK_BUNDLR_URL; private static readonly VERIFICATION_RETRIES; private static readonly VERIFICATION_DELAY; private static readonly FUNDING_RETRIES; private static readonly FUNDING_DELAY; private static readonly FUNDING_BUFFER; private readonly config; private readonly logger?; private requestId; constructor(config: ArweaveConfig); /** * Upload metadata to Arweave using Bundlr Network * @param metadata - The metadata object to upload * @returns Promise<ArweaveUploadResult> */ uploadMetadata(metadata: any): Promise<ArweaveUploadResult>; /** * Upload image to Arweave using Bundlr Network * @param imageBuffer - The image buffer to upload * @param mimeType - The MIME type of the image (e.g., "image/png", "image/jpeg") * @returns Promise<ArweaveUploadResult> */ uploadImage(imageBuffer: Buffer, mimeType?: string): Promise<ArweaveUploadResult>; /** * Get the cost estimate for uploading data to Arweave * @param dataSize - Size of data in bytes * @returns Promise<ArweaveCostResult> */ getUploadCost(dataSize: number): Promise<ArweaveCostResult>; /** * Perform the actual upload with retry logic * @param data - Data to upload * @param options - Upload options * @param type - Type of upload for logging * @returns Promise<ArweaveUploadResult> */ private performUpload; /** * Try upload to a specific Bundlr node * @param data - Data to upload * @param options - Upload options * @param type - Type of upload for logging * @param bundlrUrl - Bundlr node URL * @returns Promise<ArweaveUploadResult> */ private tryUpload; /** * Create a Bundlr client instance * @param bundlrUrl - Optional custom Bundlr URL * @returns Promise<Bundlr> */ private createBundlrClient; /** * Verify that an Arweave upload is accessible * @param uri - The Arweave URI to verify * @returns Promise<boolean> */ private verifyUpload; /** * Fund the Bundlr account and wait for confirmation * @param bundlr - The Bundlr client instance * @param requiredAmount - The total amount required for the upload */ private fundAndConfirm; /** * Make a request with retry logic and error handling * @param operation - The operation to perform * @param operationName - Name of the operation for logging * @returns Result of the operation */ private makeRequest; /** * Utility method for delays * @param ms - Milliseconds to delay */ private delay; /** * Get the current configuration * @returns Current client configuration */ getConfig(): Readonly<Omit<Required<ArweaveConfig>, 'logger' | 'privateKey'> & { logger?: Logger; privateKey: string; }>; } //# sourceMappingURL=arweave.d.ts.map