UNPKG

@keypo/synapse-storage-sdk

Version:
147 lines 5.28 kB
/** * SDK constants and magic numbers * All hardcoded values should be centralized here for better maintainability */ export declare const FILE_SIZE: { /** Bytes per kilobyte */ readonly BYTES_PER_KB: 1024; /** Bytes per megabyte */ readonly BYTES_PER_MB: number; /** Bytes per gigabyte */ readonly BYTES_PER_GB: number; }; export declare const STORAGE_DEFAULTS: { /** Default storage capacity in GB */ readonly CAPACITY_GB: 10; /** Default persistence period in days */ readonly PERSISTENCE_DAYS: 30; /** Minimum days threshold */ readonly MIN_DAYS_THRESHOLD: 10; /** Default CDN enabled state */ readonly WITH_CDN: true; }; export declare const TOKEN_DECIMALS: { /** USDFC token decimal places */ readonly USDFC: 6; /** FIL token decimal places */ readonly FIL: 18; }; export declare const TOKEN_AMOUNTS: { /** Minimum allowance threshold (1 USDFC in smallest units) */ readonly MIN_ALLOWANCE: 1000000n; /** Minimum Synapse balance threshold (0.1 USDFC in smallest units) */ readonly MIN_SYNAPSE_BALANCE: 100000n; /** Default deposit amount (1 USDFC in smallest units) */ readonly DEFAULT_DEPOSIT: 1000000n; /** Minimum wallet balance threshold for warnings (in formatted units) */ readonly MIN_WALLET_BALANCE: 0.1; /** Minimum balance required for uploads (in formatted units) */ readonly UPLOAD_MIN_BALANCE: 1; /** Rate calculation divisor for storage pricing */ readonly RATE_DIVISOR: 1000n; /** Dataset creation fee (0.1 USDFC in wei) */ readonly DATA_SET_CREATION_FEE: bigint; }; export declare const BALANCE_THRESHOLDS: { /** Low balance warning threshold (formatted USDFC) */ readonly LOW_BALANCE_WARNING: 0.1; /** Minimum balance for deposit suggestions (formatted USDFC) */ readonly DEPOSIT_SUGGESTION_MIN: 1; /** Minimum balance required for uploads (formatted USDFC) */ readonly UPLOAD_MIN_BALANCE: 1; }; export declare const CHAIN_IDS: { /** Filecoin Calibration testnet chain ID */ readonly CALIBRATION: 314159; /** Filecoin mainnet chain ID (for reference) */ readonly MAINNET: 314; }; export declare const NETWORK_NAMES: { readonly CALIBRATION: "calibration"; readonly MAINNET: "mainnet"; }; export declare const TIME: { /** Milliseconds in one second */ readonly SECOND_MS: 1000; /** Milliseconds in one minute */ readonly MINUTE_MS: number; /** Milliseconds in one hour */ readonly HOUR_MS: number; /** Milliseconds in one day */ readonly DAY_MS: number; /** Timestamp conversion factor (seconds to milliseconds) */ readonly TIMESTAMP_TO_MS: 1000; }; export declare const AUTH_EXPIRATION: { /** Default auth expiration time (24 hours in milliseconds) */ readonly DEFAULT_MS: number; }; export declare const RETRY_CONFIG: { /** Default number of retry attempts for smart contract operations */ readonly DEFAULT_ATTEMPTS: 10; /** Base retry delay in milliseconds */ readonly BASE_DELAY_MS: 1000; /** Maximum retry delay in milliseconds */ readonly MAX_DELAY_MS: 5000; /** Exponential backoff multiplier */ readonly BACKOFF_MULTIPLIER: 2; }; export declare const TIMEOUT_CONFIG: { /** Default operation timeout in milliseconds */ readonly DEFAULT_MS: 30000; /** User operation timeout in milliseconds */ readonly USER_OPERATION_MS: 60000; /** Network request timeout in milliseconds */ readonly NETWORK_REQUEST_MS: 15000; }; export declare const LIT_PROTOCOL: { /** Auth manager app name */ readonly APP_NAME: "synapse-storage-sdk"; /** Network name for Lit Protocol */ readonly NETWORK_NAME: "naga-local"; /** Storage path for auth context */ readonly STORAGE_PATH: "./lit-auth-local"; /** Auth domain */ readonly AUTH_DOMAIN: "localhost"; /** Auth statement */ readonly AUTH_STATEMENT: "Decrypt test data"; }; export declare const FORMATTING: { /** Decimal places for file size display */ readonly FILE_SIZE_DECIMALS: 2; /** Decimal places for time display */ readonly TIME_DECIMALS: 2; /** Decimal places for balance display */ readonly BALANCE_DECIMALS: 2; }; export declare const VALIDATION: { /** Valid network values */ readonly VALID_NETWORKS: readonly ["mainnet", "calibration"]; /** Maximum file size for upload warnings (in bytes) */ readonly MAX_FILE_SIZE_WARNING: number; }; /** * Convert bytes to megabytes with proper decimals */ export declare const bytesToMB: (bytes: number) => string; /** * Convert USDFC smallest units to formatted units */ export declare const formatUSDFC: (amount: bigint | number) => number; /** * Convert formatted USDFC to smallest units */ export declare const parseUSDFC: (amount: string | number) => bigint; /** * Convert timestamp to milliseconds for Date constructor */ export declare const timestampToMs: (timestamp: number) => number; /** * Calculate exponential backoff delay */ export declare const calculateBackoffDelay: (attempt: number, baseDelay?: number) => number; /** * Convert storage capacity from GB to bytes */ export declare const storageCapacityToBytes: (capacityGB: number) => bigint; //# sourceMappingURL=index.d.ts.map