games_app/backend/dist/repositories/walletRepository.d.ts

63 lines
2.6 KiB
TypeScript

import { UserWallet, WalletType } from '../models';
/**
* Repository for wallet types and per-user deposit addresses.
* Manages wallet type catalog, user wallet assignment, and address lookup.
*/
/**
* Returns all configured wallet types ordered by ID.
* @returns Array of wallet type records.
*/
export declare function getWalletTypes(): Promise<WalletType[]>;
/**
* Finds a wallet type by its unique code.
* @param code - Wallet type code (e.g. USDT_TRC20).
* @returns The matching wallet type, or null if not found.
*/
export declare function getWalletTypeByCode(code: string): Promise<WalletType | null>;
export declare function getWalletTypeById(id: number): Promise<WalletType | null>;
/**
* Retrieves a user's wallet for a specific wallet type.
* @param userId - ID of the user.
* @param walletTypeId - Wallet type to look up.
* @returns The user wallet record, or null if none exists.
*/
export declare function getUserWallet(userId: string, walletTypeId: number): Promise<UserWallet | null>;
/**
* Creates or updates a user wallet (upsert on user_id + wallet_type_id).
* @param data - User wallet fields to persist.
* @param data.userId - ID of the owning user.
* @param data.walletTypeId - Wallet type for this address.
* @param data.address - On-chain deposit address.
* @param data.derivationIndex - HD derivation index used to generate the address.
* @returns The created or updated user wallet record.
*/
export declare function createUserWallet(data: {
userId: string;
walletTypeId: number;
address: string;
derivationIndex: number;
}): Promise<UserWallet>;
/**
* Returns the next available HD derivation index for a wallet type.
* @param walletTypeId - Wallet type to allocate an index for.
* @returns Next derivation index (max existing index + 1, or 0 if none exist).
*/
export declare function getNextDerivationIndex(walletTypeId: number): Promise<number>;
/**
* Lists all wallets belonging to a user.
* @param userId - ID of the user.
* @returns Array of user wallet records.
*/
export declare function getUserWalletsByUserId(userId: string): Promise<UserWallet[]>;
/**
* Finds the user and wallet type associated with a deposit address.
* @param address - On-chain address to look up (case-insensitive).
* @returns User ID and wallet type ID, or null if the address is unknown.
*/
export declare function findUserByDepositAddress(address: string): Promise<{
user_id: string;
wallet_type_id: number;
} | null>;
/** Full user_wallets row for an on-chain deposit address (case-insensitive). */
export declare function findUserWalletByAddress(address: string): Promise<UserWallet | null>;
//# sourceMappingURL=walletRepository.d.ts.map