UNPKG

@gotake/gotake-sdk

Version:

SDK for interacting with GoTake blockchain contracts

174 lines 5.92 kB
import { ethers } from 'ethers'; import { Provider } from '@ethersproject/providers'; import { NetworkId, GoTakeSDKOptions } from './utils'; import { AccountApi, IPNFTApi, VideoApi, VideoPaymentApi } from './api'; import { VideoMetadata, StatusCallback, Subscription, MintResult, PollController, TransactionOptions } from './types'; interface ExtendedGoTakeSDKOptions extends GoTakeSDKOptions { apiEndpoint?: string; apiKey?: string; } /** * GoTake SDK - Main SDK class for interacting with GoTake contracts and services */ export declare class GoTakeSDK { private _provider; private _signer; private _networkId; private _networkConfig; private _apiConfig; private _statusTracker; readonly account: AccountApi; readonly ipnft: IPNFTApi; readonly video: VideoApi; readonly videoPayment: VideoPaymentApi; /** * Create SDK instance * @param options Initialization options */ constructor(options?: ExtendedGoTakeSDKOptions); /** * Get current network ID */ get networkId(): NetworkId; /** * Get Provider */ get provider(): Provider; /** * Get Signer */ get signer(): ethers.Signer; /** * Get current user address */ getAddress(): Promise<string>; /** * Check if user has a TBA and create one if not exists * @param options Transaction options * @returns Promise resolving to TBA address and whether it was newly created */ checkAndCreateTBA(options?: TransactionOptions): Promise<{ tbaAddress: string; isNew: boolean; }>; /** * Upload video to the platform * @param file Video file to upload * @param metadata Video metadata * @returns Promise resolving to video ID */ uploadVideo(file: File, metadata: VideoMetadata): Promise<string>; /** * Get video status * @param videoId Video ID * @returns Promise resolving to video status information */ getVideoStatus(videoId: string): Promise<any>; /** * Subscribe to video status updates * @param videoId Video ID * @param callback Function to be called when status updates * @returns Subscription object */ subscribeToVideoStatus(videoId: string, callback: StatusCallback): Subscription; /** * Poll video status at regular intervals * @param videoId Video ID * @param options Poll options * @returns Poll controller */ pollVideoStatus(videoId: string, options: { interval?: number; stopCondition?: (status: any) => boolean; callback: StatusCallback; }): PollController; /** * Mint IP NFT for a video * @param videoId Video ID * @param options Transaction options * @returns Promise resolving to mint result */ mintIPNFT(videoId: string, options?: TransactionOptions): Promise<MintResult>; /** * Upload video and mint NFT when ready * @param file Video file to upload * @param metadata Video metadata * @param options Options including status callback and auto-mint flag * @returns Promise resolving to video ID */ uploadAndMintWhenReady(file: File, metadata: VideoMetadata, options?: { statusCallback?: StatusCallback; autoMint?: boolean; transactionOptions?: TransactionOptions; }): Promise<string>; /** * Purchase content with simplified interface * @param contentId Content ID to purchase * @param paymentMethod Payment method (ETH or ERC20) * @param tokenAddress Token address (required for ERC20 payments) * @param options Transaction options * @returns Purchase result */ purchaseContent(contentId: number, paymentMethod: 'ETH' | 'ERC20', tokenAddress?: string, options?: TransactionOptions): Promise<any>; /** * Check if current user has view permission for content * @param contentId Content ID * @returns True if user has valid view permission */ hasViewPermission(contentId: number): Promise<boolean>; /** * Get current user's permission details for content * @param contentId Content ID * @returns View permission details */ getMyPermissions(contentId: number): Promise<any>; /** * Get content information including pricing * @param contentId Content ID * @returns Content information */ getContentInfo(contentId: number): Promise<any>; /** * Switch network * @param network Network ID or name */ switchNetwork(network: NetworkId | string): Promise<void>; /** * Resolve network configuration * @param network Network ID or name * @returns Network configuration */ private _resolveNetwork; /** * Resolve Provider * @param provider Provider or RPC URL * @param networkConfig Network configuration * @returns Provider instance */ private _resolveProvider; /** * Resolve Signer * @param signer Signer, private key, or environment variable name * @returns Signer instance */ private _resolveSigner; /** * Get current gas price recommendations * @param options Optional configuration * @returns Gas price data including maxFeePerGas and maxPriorityFeePerGas */ getGasPrice(options?: { multiplier?: number; priorityMultiplier?: number; }): Promise<{ baseFeePerGas?: ethers.BigNumber; maxFeePerGas: ethers.BigNumber; maxPriorityFeePerGas?: ethers.BigNumber; gasPrice?: ethers.BigNumber; }>; } export { NetworkId, getNetworkById, getNetworkByName } from './utils'; export { GasConfig, VideoStatus, VideoStatusInfo, VideoMetadata, StatusCallback, Subscription, MintResult, PollController, TransactionOptions } from './types'; export * from './api'; export * from './wrappers'; //# sourceMappingURL=index.d.ts.map