import { EVMTransactionHistoryItem } from "./evm/transactionParsing"; import { PriceResponse } from "./price.types"; import { SVMTransactionHistoryItem } from "./svm/transactionParsing"; import { Balance, ChainWalletConfig, NFTInfo, TokenInfo, TransactionResult, UserTokenBalance, NFT } from "./types"; export abstract class ChainAddress { config: ChainWalletConfig; address: AddressType; index: number | undefined connection: ConnectionType | undefined constructor(config: ChainWalletConfig, address: AddressType, index?: number) { this.config = config; this.address = address; this.index = index; } abstract getNativeBalance(): Promise; abstract getTokenBalance(tokenAddress: AddressType): Promise; abstract discoverToken(): Promise[]>; abstract discoverNFT(): Promise; abstract getTransactionHistory(): Promise<(SVMTransactionHistoryItem | EVMTransactionHistoryItem)[]>; abstract getPrices(tokenAddresses: string[]): Promise getAddress(): AddressType { return this.address; } getChainWalletConfig(): ChainWalletConfig { return this.config; } } export abstract class ChainWallet< AddressType, PrivateKeyType, ConnectionType > extends ChainAddress { protected privateKey: PrivateKeyType; /** * Protected constructor so wallets are created through factories */ constructor( config: ChainWalletConfig, address: AddressType, privateKey: PrivateKeyType, index?: number ) { super(config, address, index); this.privateKey = privateKey; } /** * Each chain must implement how an address is derived */ protected abstract generateAddress( privateKey: PrivateKeyType ): AddressType; /** * Transfer native coin (ETH, SOL, etc.) */ abstract transferNative( to: AddressType, amount: number ): Promise; /** * Transfer ERC20 / SPL token */ abstract transferToken( tokenAddress: TokenInfo, to: AddressType, amount: number ): Promise; /** * Swap tokens */ abstract swap( tokenAddress: TokenInfo, to: AddressType, amount: number, slippage?: number ): Promise; /** * Convert entropy/mnemonic → private key */ abstract convertFromEntropyToPrivateKey( entropy: string ): PrivateKeyType; /** * Expose private key only internally if needed */ protected getPrivateKey(): PrivateKeyType { return this.privateKey; } }