import { Router } from 'express';
import { BalanceController } from '../controllers/balance.controller';
import { validateRequest } from '../middleware/validation.middleware';
import {
  walletNetworkBalanceParamsSchema,
  walletBalanceParamsSchema,
} from '../../application/dto';

/**
 * Balance routes mounted under `/api/v1`.
 *
 * Routes:
 *  - GET /wallets/:walletId/networks/:networkId/balances  Calculate token balances for a wallet on a specific network.
 *                                                            Params: { walletId: string (UUID), networkId: string (UUID) }
 *  - GET /wallets/:walletId/balances                        Calculate token balances across all networks.
 *                                                            Param: { walletId: string (UUID) }
 */
export const createBalanceRoutes = (controller: BalanceController): Router => {
  const router = Router();

  router.get(
    '/wallets/:walletId/networks/:networkId/balances',
    validateRequest({ params: walletNetworkBalanceParamsSchema }),
    controller.getForNetwork,
  );

  router.get(
    '/wallets/:walletId/balances',
    validateRequest({ params: walletBalanceParamsSchema }),
    controller.getAll,
  );

  return router;
};
