"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetTokensByNetworkUseCase = void 0;
const not_found_error_1 = require("../../../domain/errors/not-found-error");
const CACHE_TTL_SECONDS = 5 * 60; // 5 minutes
class GetTokensByNetworkUseCase {
    tokenRepository;
    networkRepository;
    cacheService;
    constructor(tokenRepository, networkRepository, cacheService) {
        this.tokenRepository = tokenRepository;
        this.networkRepository = networkRepository;
        this.cacheService = cacheService;
    }
    async execute(networkId) {
        const network = await this.networkRepository.findById(networkId);
        if (!network) {
            throw new not_found_error_1.NotFoundError('Network', networkId);
        }
        const cacheKey = `tokens:network:${networkId}`;
        return this.cacheService.wrap(cacheKey, () => this.tokenRepository.findByNetworkId(networkId), CACHE_TTL_SECONDS);
    }
}
exports.GetTokensByNetworkUseCase = GetTokensByNetworkUseCase;
//# sourceMappingURL=get-tokens-by-network.use-case.js.map