games_app/backend/dist/repositories/transactionRepository.d.ts
2026-06-29 15:01:23 +02:00

68 lines
3.2 KiB
TypeScript

import { Transaction } from '../models';
/**
* Repository for blockchain transaction records.
* Persists deposits, withdrawals, and transfers with status and confirmation tracking.
*/
/**
* Inserts a new transaction record.
* @param data - Transaction fields to persist.
* @param data.userId - ID of the user who owns the transaction.
* @param data.walletTypeId - Wallet type for this transaction.
* @param data.type - Transaction kind: deposit, withdrawal, or transfer.
* @param data.amount - Amount in the smallest currency unit.
* @param data.fee - Optional fee amount (defaults to 0).
* @param data.status - Current transaction status.
* @param data.blockchainTxId - Optional on-chain transaction hash or ID.
* @param data.fromAddress - Optional sender address.
* @param data.toAddress - Optional recipient address.
* @param data.confirmations - Optional current confirmation count.
* @param data.requiredConfirmations - Optional confirmations required before completion.
* @param data.metadata - Optional additional context as key-value pairs.
* @returns The newly created transaction record.
*/
export declare function create(data: {
userId: string;
walletTypeId: number;
type: 'deposit' | 'withdrawal' | 'transfer' | 'game_stake' | 'game_payout' | 'game_refund' | 'bonus' | 'admin_adjustment';
amount: bigint;
fee?: bigint;
status: string;
blockchainTxId?: string | null;
fromAddress?: string | null;
toAddress?: string | null;
confirmations?: number | null;
requiredConfirmations?: number | null;
metadata?: Record<string, unknown> | null;
}): Promise<Transaction>;
/**
* Updates a transaction's status and optionally its confirmations or blockchain TX ID.
* @param id - ID of the transaction to update.
* @param status - New status value.
* @param confirmations - Optional confirmation count (existing value kept if omitted).
* @param blockchainTxId - Optional blockchain TX ID (existing value kept if omitted).
* @returns Resolves when the row has been updated.
*/
export declare function updateStatus(id: string, status: string, confirmations?: number, blockchainTxId?: string): Promise<void>;
/**
* Finds a transaction by its on-chain transaction ID.
* @param blockchainTxId - Blockchain transaction hash or ID.
* @returns The matching transaction, or null if not found.
*/
export declare function findByBlockchainTxId(blockchainTxId: string): Promise<Transaction | null>;
/**
* Finds a transaction by its primary key.
* @param id - Transaction UUID.
* @returns The matching transaction, or null if not found.
*/
export declare function findById(id: string): Promise<Transaction | null>;
/**
* Lists a user's transactions ordered by creation time (newest first).
* @param userId - ID of the user whose transactions to fetch.
* @param limit - Maximum number of rows to return (default 50).
* @param offset - Number of rows to skip for pagination (default 0).
* @returns Array of transaction records.
*/
export declare function listByUserId(userId: string, limit?: number, offset?: number): Promise<Transaction[]>;
/** Total transaction count for a user (pagination). */
export declare function countByUserId(userId: string): Promise<number>;
//# sourceMappingURL=transactionRepository.d.ts.map