"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const logger_1 = require("../../../ts/logger");
const constants_1 = require("../../helpers/constants");
const ContractStorage_1 = require("../../helpers/ContractStorage");
const Deployment_1 = require("../../helpers/Deployment");
const types_1 = require("../../helpers/types");
const deployment = Deployment_1.Deployment.getInstance();
const storage = ContractStorage_1.ContractStorage.getInstance();
/**
 * Deploy step registration and task itself
 */
deployment.deployTask(constants_1.EDeploySteps.TallyFactory, "Deploy tally factory").then((task) => task.setAction(async ({ incremental }, hre) => {
    deployment.setHre(hre);
    const deployer = await deployment.getDeployer();
    const tallyFactoryContractAddress = storage.getAddress(types_1.EContracts.TallyFactory, hre.network.name);
    if (incremental && tallyFactoryContractAddress) {
        // eslint-disable-next-line no-console
        (0, logger_1.logGreen)({ text: (0, logger_1.info)(`Skipping deployment of the ${types_1.EContracts.TallyFactory} contract`) });
        return;
    }
    const poseidonT3ContractAddress = storage.mustGetAddress(types_1.EContracts.PoseidonT3, hre.network.name);
    const poseidonT4ContractAddress = storage.mustGetAddress(types_1.EContracts.PoseidonT4, hre.network.name);
    const poseidonT5ContractAddress = storage.mustGetAddress(types_1.EContracts.PoseidonT5, hre.network.name);
    const poseidonT6ContractAddress = storage.mustGetAddress(types_1.EContracts.PoseidonT6, hre.network.name);
    const libraries = {
        "contracts/crypto/PoseidonT3.sol:PoseidonT3": poseidonT3ContractAddress,
        "contracts/crypto/PoseidonT4.sol:PoseidonT4": poseidonT4ContractAddress,
        "contracts/crypto/PoseidonT5.sol:PoseidonT5": poseidonT5ContractAddress,
        "contracts/crypto/PoseidonT6.sol:PoseidonT6": poseidonT6ContractAddress,
    };
    const linkedTallyFactoryContract = await hre.ethers.getContractFactory(types_1.EContracts.TallyFactory, {
        signer: deployer,
        libraries,
    });
    const tallyFactoryContract = await deployment.deployContractWithLinkedLibraries({
        contractFactory: linkedTallyFactoryContract,
    });
    await storage.register({
        id: types_1.EContracts.TallyFactory,
        contract: tallyFactoryContract,
        libraries,
        args: [],
        network: hre.network.name,
    });
}));
//# sourceMappingURL=06-tallyFactory.js.map