UNPKG

@gala-chain/launchpad-sdk

Version:

TypeScript SDK for Gala Launchpad Backend API - Production-ready DeFi token launchpad integration with wallet-based authentication, GalaChain trading, and comprehensive user operations. 100% tested (22/22 endpoints working).

145 lines 4.29 kB
/** * Common types used throughout the Launchpad SDK */ /** * Available environment types for SDK configuration */ export type Environment = 'PROD' | 'STAGE'; /** * Standard API response wrapper from the backend */ export interface ApiResponse<T = unknown> { /** Response data - structure varies by endpoint */ data?: T; /** Error message if request failed */ message?: string; /** Success status */ success: boolean; /** HTTP status code */ statusCode?: number; /** Additional metadata - use type guards when accessing unknown properties */ [key: string]: unknown; } /** * Pagination parameters for list endpoints * Note: Backend expects these as strings, but SDK accepts numbers for convenience */ export interface PaginationParams { /** Page number (1-based) */ page: number; /** Number of items per page */ limit: number; } /** * Backend pagination response structure */ export interface PaginatedResponse<T = unknown> { /** Array of items */ data: T[]; /** Current page number */ page: number; /** Items per page */ limit: number; /** Total number of items */ total: number; /** Total number of pages */ totalPages: number; /** Whether there are more pages */ hasNextPage: boolean; /** Whether there is a previous page */ hasPrevPage: boolean; } /** * Configuration options for the SDK */ export interface SDKConfig { /** Environment preset (automatically configures all URLs) */ env?: Environment; /** Base URL for the API (defaults to STAGE environment) */ baseUrl?: string; /** Request timeout in milliseconds */ timeout?: number; /** Additional headers to include with requests */ headers?: Record<string, string>; /** Whether to enable debug logging */ debug?: boolean; /** Optional MySQL connection string for price history (Node.js only) */ mysqlConnectionString?: string; } /** * Standard error response from the backend */ export interface ErrorResponse { /** Error message */ message: string; /** Error code */ error?: string; /** HTTP status code */ statusCode: number; /** Detailed error information - use type guards for safe access */ details?: unknown; /** Request timestamp */ timestamp?: string; /** Request path */ path?: string; } /** * Address format used by the backend * Format: eth|{40-hex-characters} */ export type AddressFormat = `eth|${string}`; /** * Utility type for ensuring address format */ export type EthereumAddress = string; /** * HTTP methods supported by the API */ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; /** * Request configuration for HTTP client */ export interface RequestConfig { /** HTTP method */ method: HttpMethod; /** Request URL (relative to base URL) */ url: string; /** Request data for POST/PUT/PATCH - use specific types when possible */ data?: unknown; /** Query parameters */ params?: Record<string, unknown> | undefined; /** Additional headers */ headers?: Record<string, string> | undefined; /** Request timeout override */ timeout?: number | undefined; } /** * Token class identifier (no instance field) * Used for identifying a token type without specifying instance */ export interface TokenClassKey { /** Token collection (e.g., "Token", "GALA") */ collection: string; /** Token category (e.g., "Unit") */ category: string; /** Token type/symbol (e.g., "UNI", "none") */ type: string; /** Additional key (e.g., "eth:address", "none") */ additionalKey: string; } /** * Token instance identifier (includes instance field) * Used for identifying a specific instance of a token */ export interface TokenInstanceKey extends TokenClassKey { /** Token instance (e.g., "0") */ instance: string; } /** * Flexible token identifier that accepts multiple formats: * - String: "collection|category|type|additionalKey" or "collection|category|type|additionalKey|instance" * - TokenClassKey: Object without instance field * - TokenInstanceKey: Object with instance field */ export type TokenId = string | TokenClassKey | TokenInstanceKey; //# sourceMappingURL=common.d.ts.map