/** * In-Memory Implementation: InMemoryWalletRepository */ import type { Transaction, Wallet } from '@core/payments/domain/entities/Wallet'; import type { WalletRepository } from '@core/payments/domain/repositories/WalletRepository'; import type { Logger } from '@core/shared/domain/Logger'; const wallets: Map = new Map(); const transactions: Map = new Map(); export class InMemoryWalletRepository implements WalletRepository { constructor(private readonly logger: Logger) {} async findById(id: string): Promise { this.logger.debug('[InMemoryWalletRepository] findById', { id }); return wallets.get(id) || null; } async findByLeagueId(leagueId: string): Promise { this.logger.debug('[InMemoryWalletRepository] findByLeagueId', { leagueId }); return Array.from(wallets.values()).find(w => w.leagueId === leagueId) || null; } async create(wallet: Wallet): Promise { this.logger.debug('[InMemoryWalletRepository] create', { wallet }); wallets.set(wallet.id, wallet); return wallet; } async update(wallet: Wallet): Promise { this.logger.debug('[InMemoryWalletRepository] update', { wallet }); wallets.set(wallet.id, wallet); return wallet; } } export class InMemoryTransactionRepository implements TransactionRepository { constructor(private readonly logger: Logger) {} async findById(id: string): Promise { this.logger.debug('[InMemoryTransactionRepository] findById', { id }); return transactions.get(id) || null; } async findByWalletId(walletId: string): Promise { this.logger.debug('[InMemoryTransactionRepository] findByWalletId', { walletId }); return Array.from(transactions.values()).filter(t => t.walletId === walletId); } async create(transaction: Transaction): Promise { this.logger.debug('[InMemoryTransactionRepository] create', { transaction }); transactions.set(transaction.id, transaction); return transaction; } }