code quality
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped

This commit is contained in:
2026-01-26 17:22:01 +01:00
parent cfc30c79a8
commit 9ac74f5046
305 changed files with 1192 additions and 607 deletions

View File

@@ -4,36 +4,33 @@
import type { WalletRepository, TransactionRepository } from '@core/payments/domain/repositories/WalletRepository';
import type { Logger } from '@core/shared/domain/Logger';
import type { LeagueWalletRepository } from '@core/racing/domain/repositories/LeagueWalletRepository';
import type { Wallet } from '@core/payments/domain/entities/Wallet';
import type { LeagueWallet } from '@core/racing/domain/entities/league-wallet/LeagueWallet';
import type { Transaction } from '@core/payments/domain/entities/league-wallet/Transaction';
import type { Wallet, Transaction } from '@core/payments/domain/entities/Wallet';
const wallets: Map<string, Wallet | LeagueWallet> = new Map();
const wallets: Map<string, Wallet> = new Map();
const transactions: Map<string, Transaction> = new Map();
export class InMemoryWalletRepository implements WalletRepository, LeagueWalletRepository {
export class InMemoryWalletRepository implements WalletRepository {
constructor(private readonly logger: Logger) {}
async findById(id: string): Promise<Wallet | LeagueWallet | null> {
async findById(id: string): Promise<Wallet | null> {
this.logger.debug('[InMemoryWalletRepository] findById', { id });
return wallets.get(id) || null;
}
async findByLeagueId(leagueId: string): Promise<LeagueWallet | null> {
async findByLeagueId(leagueId: string): Promise<Wallet | null> {
this.logger.debug('[InMemoryWalletRepository] findByLeagueId', { leagueId });
return (Array.from(wallets.values()).find(w => (w as LeagueWallet).leagueId.toString() === leagueId) as LeagueWallet) || null;
return Array.from(wallets.values()).find(w => w.leagueId === leagueId) || null;
}
async create(wallet: Wallet | LeagueWallet): Promise<Wallet | LeagueWallet> {
async create(wallet: Wallet): Promise<Wallet> {
this.logger.debug('[InMemoryWalletRepository] create', { wallet });
wallets.set(wallet.id.toString(), wallet);
wallets.set(wallet.id, wallet);
return wallet;
}
async update(wallet: Wallet | LeagueWallet): Promise<Wallet | LeagueWallet> {
async update(wallet: Wallet): Promise<Wallet> {
this.logger.debug('[InMemoryWalletRepository] update', { wallet });
wallets.set(wallet.id.toString(), wallet);
wallets.set(wallet.id, wallet);
return wallet;
}
@@ -53,24 +50,24 @@ export class InMemoryWalletRepository implements WalletRepository, LeagueWalletR
export class InMemoryTransactionRepository implements TransactionRepository {
constructor(private readonly logger: Logger) {}
async findById(id: string): Promise<any | null> {
async findById(id: string): Promise<Transaction | null> {
this.logger.debug('[InMemoryTransactionRepository] findById', { id });
return transactions.get(id) || null;
}
async findByWalletId(walletId: string): Promise<any[]> {
async findByWalletId(walletId: string): Promise<Transaction[]> {
this.logger.debug('[InMemoryTransactionRepository] findByWalletId', { walletId });
return Array.from(transactions.values()).filter(t => t.walletId.toString() === walletId);
return Array.from(transactions.values()).filter(t => t.walletId === walletId);
}
async create(transaction: any): Promise<any> {
async create(transaction: Transaction): Promise<Transaction> {
this.logger.debug('[InMemoryTransactionRepository] create', { transaction });
transactions.set(transaction.id.toString(), transaction);
transactions.set(transaction.id, transaction);
return transaction;
}
async update(transaction: any): Promise<any> {
transactions.set(transaction.id.toString(), transaction);
async update(transaction: Transaction): Promise<Transaction> {
transactions.set(transaction.id, transaction);
return transaction;
}
@@ -82,7 +79,7 @@ export class InMemoryTransactionRepository implements TransactionRepository {
return transactions.has(id);
}
findByType(type: any): Promise<any[]> {
findByType(type: any): Promise<Transaction[]> {
return Promise.resolve(Array.from(transactions.values()).filter(t => t.type === type));
}