delegate-framework
Version:
A TypeScript framework for building robust, production-ready blockchain workflows with comprehensive error handling, logging, and testing. Maintained by delegate.fun
69 lines • 2.3 kB
TypeScript
import { Logger } from "../../types";
import { MetadataClient } from "./base";
export interface PinataConfig {
jwt: string;
gateway?: string;
timeout?: number;
retries?: number;
logger?: Logger;
}
export interface PinataUploadResult {
success: boolean;
uri?: string;
error?: string;
cid?: string;
}
export declare class PinataClient implements MetadataClient {
private static readonly DEFAULT_TIMEOUT;
private static readonly DEFAULT_RETRIES;
private static readonly DEFAULT_GATEWAY;
private static readonly UPLOAD_URL;
private readonly config;
private readonly logger?;
private requestId;
constructor(config: PinataConfig);
/**
* Upload metadata to IPFS using Pinata
* @param metadata - The metadata object to upload
* @param fileName - Optional filename for the metadata
* @returns Promise<PinataUploadResult>
*/
uploadMetadata(metadata: any, fileName?: string): Promise<PinataUploadResult>;
/**
* Upload image to IPFS using Pinata
* @param imageBuffer - The image buffer to upload
* @param mimeType - The MIME type of the image (e.g., "image/png", "image/jpeg")
* @param fileName - Optional filename for the image
* @returns Promise<PinataUploadResult>
*/
uploadImage(imageBuffer: Buffer, mimeType?: string, fileName?: string): Promise<PinataUploadResult>;
/**
* Perform the actual upload with retry logic
* @param blob - Blob to upload
* @param fileName - Filename for the upload
* @param type - Type of upload for logging
* @returns Promise<PinataUploadResult>
*/
private performUpload;
/**
* 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<PinataConfig>, 'logger' | 'jwt'> & {
logger?: Logger;
jwt: string;
}>;
}
//# sourceMappingURL=pinata.d.ts.map