"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable no-console */
const config_1 = require("hardhat/config");
const logger_1 = require("../../ts/logger");
const Deployment_1 = require("../helpers/Deployment");
/**
 * Main deployment task which runs deploy steps in the same order that `Deployment#deployTask` is called.
 * Note: you probably need to use indices for deployment step files to support the correct order.
 * Make sure you have deploy-config.json (see deploy-config-example.json).
 */
(0, config_1.task)("deploy-full", "Deploy environment")
    .addFlag("incremental", "Incremental deployment")
    .addFlag("strict", "Fail on warnings")
    .addFlag("verify", "Verify contracts at Etherscan")
    .addOptionalParam("skip", "Skip steps with less or equal index", 0, config_1.types.int)
    .setAction(async ({ incremental, strict, verify, skip = 0 }, hre) => {
    const deployment = Deployment_1.Deployment.getInstance({ hre });
    deployment.setHre(hre);
    const deployer = await deployment.getDeployer();
    const startBalance = await deployer.provider.getBalance(deployer);
    let success = false;
    try {
        const steps = await deployment.start("full", { incremental, verify });
        await deployment.runSteps(steps, skip);
        await deployment.checkResults(strict);
        success = true;
    }
    catch (err) {
        (0, logger_1.logRed)({
            text: `\n=========================================================\nERROR: ${err.message}\n`,
        });
    }
    await deployment.finish(startBalance, success);
    if (verify) {
        (0, logger_1.logMagenta)({ text: (0, logger_1.info)("Verify all contracts") });
        await hre.run("verify-full");
    }
});
//# sourceMappingURL=deployFull.js.map