import { get } from '../utils/request';

export interface WalletBalance {
  total: number;
  available: number;
  frozen: number;
}

export interface TransactionRecord {
  id: string;
  type: string; // 'buy' | 'sell' | 'deposit' | 'withdraw' | 'transfer' | 'redeem'
  amount: number;
  description: string;
  status: string;
  createdAt: string;
}

export interface PaginatedTransactions {
  items: TransactionRecord[];
  total: number;
}

/** 获取钱包余额 */
export function getBalance() {
  return get<WalletBalance>('/api/v1/wallet');
}

/** 获取交易记录 */
export function getTransactions(params?: { type?: string; page?: number; limit?: number }) {
  return get<PaginatedTransactions>('/api/v1/wallet/transactions', {
    type: params?.type,
    page: params?.page ?? 1,
    limit: params?.limit ?? 20,
  });
}
