@nosana/kit
Version:
Nosana KIT
51 lines (50 loc) • 1.85 kB
TypeScript
import { AxiosRequestConfig } from 'axios';
import { ReadonlyUint8Array } from 'gill';
import type { IpfsConfig } from '../config/types.js';
/**
* Class to interact with Pinata Cloud
* https://www.pinata.cloud/
*/
export declare class IPFS {
private api;
config: IpfsConfig;
constructor(config: IpfsConfig);
/**
* Convert the ipfs bytes from a solana job to a CID
* It prepends the 0x1220 (18,32) to make it 34 bytes and Base58 encodes it.
* This result is IPFS addressable.
*/
static solHashToIpfsHash(hashArray: ReadonlyUint8Array | Array<number>): string | null;
/**
* Converts IPFS hash to byte array needed to submit results
* @param hash IPFS hash
* @returns Array<number>
*/
static IpfsHashToByteArray(hash: string): Array<number>;
/**
* Retrieve data from IPFS using the configured gateway
* @param hash IPFS hash string or byte array
* @param options Additional axios request options
* @returns The retrieved data
*/
retrieve(hash: string | Array<number>, options?: AxiosRequestConfig): Promise<any>;
/**
* Function to pin data into Pinata Cloud
* @param data Object to pin into IPFS as JSON
* @returns The IPFS hash of the pinned data
*/
pin(data: object): Promise<string>;
/**
* Function to pin a file into Pinata Cloud
* @param filePath Path to the file to pin
* @returns The IPFS hash of the pinned file
*/
pinFile(filePath: string): Promise<string>;
/**
* Function to pin a file from buffer/blob into Pinata Cloud
* @param fileBuffer Buffer or Blob containing the file data
* @param fileName Name of the file
* @returns The IPFS hash of the pinned file
*/
pinFileFromBuffer(fileBuffer: Buffer | Blob, fileName: string): Promise<string>;
}