four-flap-meme-sdk
Version:
SDK for Flap bonding curve and four.meme TokenManager
41 lines (40 loc) • 1.45 kB
TypeScript
export type PinataConfig = {
jwt: string;
gateway?: string;
};
export declare class PinataClient {
private client;
private ready;
constructor(cfg: PinataConfig);
uploadFile(file: File): Promise<{
cid: string;
id: string;
}>;
uploadJSON(obj: unknown, name?: string): Promise<{
cid: string;
id: string;
}>;
get(cid: string): Promise<any>;
url(cid: string): Promise<any>;
}
export type PinataPinResp = {
cid: string;
size?: number;
timestamp?: string;
raw?: any;
};
/**
* 使用 Pinata JWT 直接上传文件(Node 环境)
* @param jwt Pinata JWT(以 Bearer 形式传入)
* @param filePath 本地文件绝对/相对路径(优先)
* @param data 可选:内存 Buffer(当未提供 filePath 时使用)
* @param fileName 可选:内存数据的文件名
*/
export declare function pinFileToIPFSWithJWT(jwt: string, filePath?: string, data?: any, fileName?: string): Promise<PinataPinResp>;
/**
* 便捷方法:上传本地图片路径(返回 CID)
*/
export declare function pinImageByPath(jwt: string, filePath: string): Promise<string>;
export declare function pinFileToIPFSWithJWTWeb(jwt: string, file: Blob, fileName?: string): Promise<PinataPinResp>;
export declare function dataURLToBlob(dataUrl: string): Blob;
export declare function pinDataURLWithJWTWeb(jwt: string, dataUrl: string, fileName?: string): Promise<PinataPinResp>;