"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
require("reflect-metadata");
const data_source_1 = require("../infrastructure/persistence/data-source");
const redis_client_1 = require("../infrastructure/cache/redis-client");
const repositories_factory_1 = require("../main/factories/repositories.factory");
const services_factory_1 = require("../main/factories/services.factory");
const use_cases_factory_1 = require("../main/factories/use-cases.factory");
const seed_tokens_helper_1 = require("./seed-tokens.helper");
const networkId = process.argv[2];
if (!networkId) {
    // eslint-disable-next-line no-console
    console.error('Usage: npm run seed:network:tokens -- <network-id>');
    process.exit(1);
}
const run = async () => {
    await (0, data_source_1.initializeDatabase)();
    const repositories = (0, repositories_factory_1.createRepositories)();
    const services = (0, services_factory_1.createServices)(redis_client_1.redisClient);
    const useCases = (0, use_cases_factory_1.createUseCases)(repositories, services);
    const network = await repositories.networkRepository.findById(networkId);
    if (!network) {
        throw new Error(`Network not found: ${networkId}`);
    }
    services.logger.info('Seeding tokens for network', { network: network.name, id: network.id });
    const result = await (0, seed_tokens_helper_1.seedTokensForNetwork)(network, useCases, repositories.tokenRepository, services.coinMarketCapClient, services.logger);
    services.logger.info('Network token seeding complete', {
        network: network.name,
        ...result,
    });
    await redis_client_1.redisClient.quit();
    process.exit(0);
};
run().catch((error) => {
    // eslint-disable-next-line no-console
    console.error('Network token seeding failed', error);
    process.exit(1);
});
//# sourceMappingURL=seed-network-tokens.js.map