/** * In-Memory Implementation: ILeagueWalletRepository * * Mock repository for testing and development */ import type { LeagueWallet } from '../../domain/entities/LeagueWallet'; import type { ILeagueWalletRepository } from '../../domain/repositories/ILeagueWalletRepository'; export class InMemoryLeagueWalletRepository implements ILeagueWalletRepository { private wallets: Map = new Map(); async findById(id: string): Promise { return this.wallets.get(id) ?? null; } async findByLeagueId(leagueId: string): Promise { for (const wallet of this.wallets.values()) { if (wallet.leagueId === leagueId) { return wallet; } } return null; } async create(wallet: LeagueWallet): Promise { if (this.wallets.has(wallet.id)) { throw new Error('LeagueWallet with this ID already exists'); } this.wallets.set(wallet.id, wallet); return wallet; } async update(wallet: LeagueWallet): Promise { if (!this.wallets.has(wallet.id)) { throw new Error('LeagueWallet not found'); } this.wallets.set(wallet.id, wallet); return wallet; } async delete(id: string): Promise { this.wallets.delete(id); } async exists(id: string): Promise { return this.wallets.has(id); } // Test helper clear(): void { this.wallets.clear(); } }