UNPKG

filecoin-pin

Version:

Bridge IPFS content to Filecoin Onchain Cloud using familiar tools

87 lines 3.17 kB
/** * Common upload flow shared between import and add commands * * This module provides reusable functions for the Synapse upload workflow * including payment validation, storage context creation, and result display. */ import type { Synapse } from '@filoz/synapse-sdk'; import type { CID } from 'multiformats/cid'; import type { Logger } from 'pino'; import { type SynapseService } from '../core/synapse/index.js'; import { type SynapseUploadResult } from '../core/upload/index.js'; import type { Spinner } from '../utils/cli-helpers.js'; export interface UploadFlowOptions { /** * Context identifier for logging (e.g., 'import', 'add') */ contextType: string; /** * Size of the file being uploaded in bytes */ fileSize: number; /** * Logger instance */ logger: Logger; /** * Optional spinner for progress updates */ spinner?: Spinner; /** * Optional metadata attached to the upload request */ pieceMetadata?: Record<string, string>; } export interface UploadFlowResult extends SynapseUploadResult { network: string; transactionHash?: string | undefined; } /** * Perform auto-funding if requested * Automatically ensures a minimum of 30 days of runway based on current usage + new file requirements * * @param synapse - Initialized Synapse instance * @param fileSize - Size of file being uploaded (in bytes) * @param spinner - Optional spinner for progress */ export declare function performAutoFunding(synapse: Synapse, fileSize: number, spinner?: Spinner): Promise<void>; /** * Validate payment setup and capacity for upload * * @param synapse - Initialized Synapse instance * @param fileSize - Size of file to upload in bytes (use 0 for minimum setup check) * @param spinner - Optional spinner for progress * @param options - Optional configuration * @param options.suppressSuggestions - If true, don't display suggestion warnings * @returns true if validation passes, exits process if not */ export declare function validatePaymentSetup(synapse: Synapse, fileSize: number, spinner?: Spinner, options?: { suppressSuggestions?: boolean; }): Promise<void>; /** * Upload CAR data to Synapse with progress tracking * * @param synapseService - Initialized Synapse service with storage context * @param carData - CAR file data as Uint8Array * @param rootCid - Root CID of the content * @param options - Upload flow options * @returns Upload result with transaction hash */ export declare function performUpload(synapseService: SynapseService, carData: Uint8Array, rootCid: CID, options: UploadFlowOptions): Promise<UploadFlowResult>; /** * Display results for import or add command * * @param result - Result data to display * @param operation - Operation name ('Import' or 'Add') */ export declare function displayUploadResults(result: { filePath: string; fileSize: number; rootCid: string; pieceCid: string; pieceId?: number | undefined; dataSetId: string; providerInfo: any; transactionHash?: string | undefined; }, operation: string, network: string): void; //# sourceMappingURL=upload-flow.d.ts.map