"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTransactionRoutes = void 0;
const express_1 = require("express");
const validation_middleware_1 = require("../middleware/validation.middleware");
const dto_1 = require("../../application/dto");
/**
 * Transaction routes mounted under `/api/v1`.
 *
 * Routes:
 *  - POST  /transactions              Create a transaction record.
 *                                         Body: { hash, status, block?, networkId, timestamp, from?, to?, interactedWith?, value,
 *                                                 fee?, gasPrice?, gasLimit?, method, data? }
 *                                                 For layer-1 transfers: interactedWith = null, value = amount, data = [].
 *                                                 from/to may be an address record id (UUID) or a raw blockchain address; raw
 *                                                 addresses are resolved to the matching internal address record when possible.
 *                                                 For smart-contract token transfers: interactedWith = tokenId, value = '0',
 *                                                 data = [{ to: recipientAddressIdOrString, amount: tokenAmount }].
 *  - POST  /transactions/rate         Calculate transaction rate information (fee, swap amounts, minimums).
 *                                         Body: { networkId, method, value?, fee?, gasPrice?, gasLimit?, data?, tokenIn?, tokenOut?, amountIn?, amountOut? }
 *  - GET   /transactions              List transactions with optional filters and pagination.
 *                                         Query: { walletId?, networkId?, status?, method?, limit?, offset? }
 *  - GET   /transactions/:id          Get a transaction by its UUID.
 *                                         Param: { id: string (UUID) }
 *  - PATCH /transactions/:id            Update a transaction status/block.
 *                                         Param: { id: string (UUID) }
 *                                         Body: { status?, block? }
 */
const createTransactionRoutes = (controller) => {
    const router = (0, express_1.Router)();
    router.post('/transactions', (0, validation_middleware_1.validateRequest)({ body: dto_1.createTransactionSchema }), controller.create);
    router.post('/transactions/rate', (0, validation_middleware_1.validateRequest)({ body: dto_1.transactionRateSchema }), controller.rate);
    router.get('/transactions', (0, validation_middleware_1.validateRequest)({ query: dto_1.getTransactionsQuerySchema }), controller.getAll);
    router.get('/transactions/:id', (0, validation_middleware_1.validateRequest)({ params: dto_1.transactionIdParamSchema }), controller.getById);
    router.patch('/transactions/:id', (0, validation_middleware_1.validateRequest)({
        params: dto_1.transactionIdParamSchema,
        body: dto_1.updateTransactionSchema,
    }), controller.update);
    return router;
};
exports.createTransactionRoutes = createTransactionRoutes;
//# sourceMappingURL=transaction.routes.js.map