"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateNetworkUseCase = void 0;
const uuid_1 = require("uuid");
const network_1 = require("../../../domain/entities/network");
class CreateNetworkUseCase {
    networkRepository;
    imageStorage;
    constructor(networkRepository, imageStorage) {
        this.networkRepository = networkRepository;
        this.imageStorage = imageStorage;
    }
    async execute(input) {
        const id = (0, uuid_1.v4)();
        const thumbnail = input.thumbnail
            ? await this.imageStorage.downloadAndStore('network', id, input.thumbnail, {
                name: input.name,
                symbol: input.code,
            })
            : null;
        const network = network_1.Network.create(id, input.name, input.code, input.addressType, thumbnail, input.explorer, input.chainId ?? null, input.status, input.mcap ?? null);
        return this.networkRepository.save(network);
    }
}
exports.CreateNetworkUseCase = CreateNetworkUseCase;
//# sourceMappingURL=create-network.use-case.js.map