UNPKG

irys-complete-toolkit

Version:

Complete Irys SDK toolkit supporting all chains, tokens, and features

176 lines (175 loc) 4.73 kB
/** * Irys Toolkit Utilities * Collection of utility functions and helpers */ import { IrysTag, NFTMetadata, OnchainFolder, ManifestData, DataInput } from '../types'; /** * Format utilities for Irys data */ export declare class IrysFormatter { /** * Convert bytes to human readable format */ static formatBytes(bytes: number, decimals?: number): string; /** * Format timestamp to human readable date */ static formatTimestamp(timestamp: number): string; /** * Format token amount from atomic units */ static formatTokenAmount(atomicAmount: string, decimals?: number): string; /** * Parse token amount to atomic units */ static parseTokenAmount(amount: string | number, decimals?: number): string; /** * Format Irys URL */ static formatGatewayUrl(txId: string, gateway?: string): string; /** * Format mutable reference URL */ static formatMutableUrl(txId: string, gateway?: string): string; } /** * Validation utilities */ export declare class IrysValidator { /** * Validate transaction ID format */ static isValidTxId(txId: string): boolean; /** * Validate Ethereum address */ static isValidEthereumAddress(address: string): boolean; /** * Validate Solana address */ static isValidSolanaAddress(address: string): boolean; /** * Validate Aptos address */ static isValidAptosAddress(address: string): boolean; /** * Validate address based on token type */ static isValidAddress(address: string, token: string): boolean; /** * Validate tags array */ static isValidTags(tags: IrysTag[]): boolean; /** * Validate supported token */ static isValidToken(token: string): boolean; } /** * Data processing utilities */ export declare class IrysDataProcessor { /** * Format bytes to human readable format */ static formatBytes(bytes: number, decimals?: number): string; /** * Get data size in bytes */ static getDataSize(data: DataInput): number; /** * Convert data to Buffer (Node.js) */ static toBuffer(data: DataInput): Buffer; /** * Convert data to Uint8Array (Browser) */ static toUint8Array(data: DataInput): Promise<Uint8Array>; /** * Create manifest data for onchain folders */ static createManifest(folder: OnchainFolder, version?: string): ManifestData; /** * Extract file extension from filename */ static getFileExtension(filename: string): string; /** * Guess content type from file extension */ static guessContentType(filename: string): string; } /** * NFT utilities */ export declare class IrysNFTUtils { /** * Create standard NFT metadata */ static createNFTMetadata(name: string, description: string, imageUrl: string, options?: { animationUrl?: string; externalUrl?: string; attributes?: Array<{ trait_type: string; value: string | number; }>; collection?: { name: string; family?: string; }; properties?: any; }): NFTMetadata; /** * Validate NFT metadata */ static validateNFTMetadata(metadata: any): boolean; /** * Generate common NFT tags */ static generateNFTTags(metadata: NFTMetadata, additionalTags?: IrysTag[]): IrysTag[]; } /** * URL and path utilities */ export declare class IrysUrlUtils { /** * Build gateway URL with optional path */ static buildGatewayUrl(txId: string, path?: string, gateway?: string): string; /** * Parse Irys URL to extract transaction ID and path */ static parseIrysUrl(url: string): { txId: string; path?: string; gateway: string; } | null; /** * Check if URL is an Irys gateway URL */ static isIrysUrl(url: string): boolean; /** * Convert relative path to manifest path format */ static normalizeManifestPath(path: string): string; } /** * Crypto and encoding utilities */ export declare class IrysCryptoUtils { /** * Generate random anchor for data items */ static generateAnchor(length?: number): string; /** * Base64 URL encode */ static base64UrlEncode(data: string | Uint8Array): string; /** * Base64 URL decode */ static base64UrlDecode(data: string): Uint8Array; } /** * Export all utilities */ export { IrysFormatter as Formatter, IrysValidator as Validator, IrysDataProcessor as DataProcessor, IrysNFTUtils as NFTUtils, IrysUrlUtils as UrlUtils, IrysCryptoUtils as CryptoUtils, };