UNPKG

@iota-big3/sdk-blockchain

Version:

Comprehensive blockchain integration platform with multi-chain support, smart contracts, DeFi protocols, NFT infrastructure, Bitcoin support, and seamless SDK ecosystem integration for IOTA Big3

301 lines 7.49 kB
/** * @iota-big3/sdk-blockchain - Clean Types * Core blockchain type definitions */ import { EventEmitter } from 'events'; import type { ContractABI } from './types/blockchain.types'; export interface EventBusLike { emit(event: any): Promise<void>; on(eventType: string, handler: (event: any) => void): void; off(eventType: string, handler: (event: any) => void): void; } export interface DatabaseConfigLike { type: 'postgres' | 'mysql' | 'sqlite' | 'mssql'; host?: string; port?: number; database?: string; user?: string; password?: string; connectionString?: string; } export interface PerformanceConfigLike { cache?: { ttl?: number; maxSize?: number; }; } export interface BlockchainConfig { defaultChain: ChainId; supportedChains: ChainId[]; rpcEndpoints: Record<ChainId, string>; web3Auth?: Web3AuthConfig; contracts?: ContractConfig[]; eventBus?: EventBusLike; database?: DatabaseConfigLike; performance?: PerformanceConfigLike; features?: { eventIntegration?: boolean; databaseIntegration?: boolean; cacheIntegration?: boolean; }; } export interface Web3AuthConfig { enabled: boolean; clientId?: string; network?: 'mainnet' | 'testnet'; chainConfig?: ChainConfig; } export interface ChainConfig { chainId: ChainId; chainName: string; nativeCurrency: { name: string; symbol: string; decimals: number; }; rpcUrls: string[]; blockExplorerUrls?: string[]; } export type ChainId = 1 | 3 | 4 | 5 | 56 | 97 | 137 | 80001 | 43114 | 43113 | 250 | 4002; export interface ContractConfig { name: string; address: string; chainId: ChainId; abi: ContractABI; } export interface SmartContract { address: string; abi: ContractABI; chainId: ChainId; deploymentBlock?: number; deploymentTransaction?: string; verified?: boolean; transactionHash?: string; status?: boolean; } export interface ContractDeployment { abi: ContractABI; bytecode: string; constructorArgs?: unknown[]; gasLimit?: bigint; value?: bigint; } export interface EventFilter { fromBlock?: number | string; toBlock?: number | string; args?: unknown[]; } export interface Event { address: string; blockNumber: number; transactionHash: string; transactionIndex: number; blockHash: string; logIndex: number; removed: boolean; id: string; returnValues: Record<string, unknown>; event: string; signature: string; raw: { data: string; topics: string[]; }; } export interface EventListener { contract?: SmartContract; eventName: string; filter?: EventFilter; callback?: (event: Event) => void | Promise<void>; } export interface BlockchainHealth { status: 'healthy' | 'disabled' | 'error'; lastCheck: Date; details: { initialized: boolean; contractsDeployed: number; activeListeners: number; }; } export interface BlockchainHealthResult { isHealthy: boolean; connectedChains: number; activeContracts: number; lastBlockNumber?: number; rpcLatency?: number; } export interface TransactionLog { address: string; topics: string[]; data: string; blockNumber: number; transactionHash: string; logIndex: number; } export interface TransactionParams { to: string; from?: string; value?: string; data?: string; gasLimit?: number; gasPrice?: string; nonce?: number; } export interface TransactionReceipt { transactionHash: string; blockNumber: number; blockHash: string; from: string; to?: string; gasUsed: string; effectiveGasPrice: string; status: boolean; logs: TransactionLog[]; contractAddress?: string; } export interface SwapParams { tokenIn: string; tokenOut: string; amountIn: string; slippage: number; recipient: string; } export interface LiquidityParams { tokenA: string; tokenB: string; amountA: string; amountB: string; recipient: string; } export interface SwapResult { transactionHash: string; amountOut: string; gasUsed: string; status: boolean; } export interface LiquidityResult { transactionHash: string; liquidityTokens: string; gasUsed: string; status: boolean; } export interface DeFiProtocol { name: string; version: string; chainId: ChainId; contractAddress: string; tvl: string; apy: number; supportedTokens?: string[]; fees: { swap: number; withdrawal: number; }; isActive: boolean; } export interface NFTCollection { id: string; address: string; chainId: ChainId; name: string; symbol: string; description: string; contractAddress: string; owner: string; totalSupply: number; mintedSupply: number; royaltyPercentage: number; createdAt: Date; isActive: boolean; standard: 'ERC721' | 'ERC1155'; baseTokenURI?: string; } export interface NFT { tokenId: string; collectionId: string; contractAddress?: string; chainId: ChainId; owner: string; metadata: NFTMetadata; mintedAt: Date; isListed: boolean; listingPrice?: string; } export interface NFTMetadata { name: string; description: string; image: string; attributes?: Array<{ trait_type: string; value: string | number; }>; } export type NFTToken = NFT; export interface MarketplaceListing { id: string; nft: NFT; seller: string; price: string; currency: string; status: 'active' | 'sold' | 'cancelled'; createdAt: Date; expiresAt?: Date; } export interface AuctionParams { nft: NFT; startingPrice: string; reservePrice?: string; duration: number; } export interface Bid { bidder: string; amount: string; timestamp: Date; } export interface Web3Session { address: string; chainId: ChainId; provider: unknown; signer: unknown; isConnected: boolean; } export type WalletProvider = 'metamask' | 'walletconnect' | 'coinbase' | 'web3auth'; export interface WalletConnection { address: string; chainId: ChainId; provider: WalletProvider; isConnected: boolean; balance?: string; } export type ContractInstance = SmartContract; export type BlockchainEventType = 'wallet_connected' | 'wallet_disconnected' | 'chain_changed' | 'transaction_sent' | 'transaction_confirmed' | 'contract_deployed' | 'nft_minted' | 'nft_transferred' | 'swap_executed' | 'liquidity_added'; export interface BlockchainEvent { type: BlockchainEventType; data: unknown; timestamp: Date; chainId?: ChainId; transactionHash?: string; } export interface BlockchainHealthResult { isHealthy: boolean; connectedChains: number; activeContracts: number; lastBlockNumber?: number; rpcLatency?: number; } export interface BlockchainMetrics { totalTransactions: number; successfulTransactions: number; failedTransactions: number; averageGasUsed: string; totalValueTransferred: string; activeWallets: number; } export interface IBlockchainManager extends EventEmitter { isEnabled: boolean; initialize(): Promise<void>; shutdown(): Promise<void>; getHealth(): Promise<BlockchainHealthResult>; getMetrics(): BlockchainMetrics; } //# sourceMappingURL=types.d.ts.map