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

83 lines 2.71 kB
import { Logger } from "../../types"; import { MetadataClient, UploadResult } from "./base"; export interface IrysConfig { privateKey: string; network?: 'mainnet-beta' | 'devnet' | 'testnet'; minBalanceSol?: number; timeout?: number; retries?: number; logger?: Logger; } export interface IrysUploadResult extends UploadResult { } export interface IrysCostResult { cost: number; dataSize: number; } export declare class IrysClient implements MetadataClient { private static readonly DEFAULT_TIMEOUT; private static readonly DEFAULT_RETRIES; private static readonly DEFAULT_MIN_BALANCE_SOL; private static readonly VERIFICATION_RETRIES; private static readonly VERIFICATION_DELAY; private readonly config; private readonly logger?; private requestId; constructor(config: IrysConfig); /** * Upload metadata to Arweave using Irys * @param metadata - The metadata object to upload * @returns Promise<IrysUploadResult> */ uploadMetadata(metadata: any): Promise<IrysUploadResult>; /** * Upload image to Arweave using Irys * @param imageBuffer - The image buffer to upload * @param mimeType - The MIME type of the image (e.g., "image/png", "image/jpeg") * @returns Promise<IrysUploadResult> */ uploadImage(imageBuffer: Buffer, mimeType?: string): Promise<IrysUploadResult>; /** * Get the cost estimate for uploading data to Arweave via Irys * @param dataSize - Size of data in bytes * @returns Promise<IrysCostResult> */ getUploadCost(dataSize: number): Promise<IrysCostResult>; /** * Create an Irys uploader instance * @returns Promise<any> - The Irys uploader */ private createIrysUploader; /** * Fund the Irys account if needed * @param irys - The Irys uploader instance */ private fundIrysIfNeeded; /** * Verify that an Arweave upload is accessible * @param uri - The Arweave URI to verify * @returns Promise<boolean> */ private verifyUpload; /** * 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<IrysConfig>, 'logger' | 'privateKey'> & { logger?: Logger; privateKey: string; }>; } //# sourceMappingURL=irys.d.ts.map