"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const arbitrumone_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/arbitrumone.json"));
const arbitrumsepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/arbitrumsepolia.json"));
const basemainnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/basemainnet.json"));
const basesepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/basesepolia.json"));
const ethereum_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/ethereum.json"));
const opbnbmainnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/opbnbmainnet.json"));
const opbnbtestnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/opbnbtestnet.json"));
const opmainnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/opmainnet.json"));
const opsepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/opsepolia.json"));
const sepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/sepolia.json"));
const unichainmainnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/unichainmainnet.json"));
const unichainsepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/unichainsepolia.json"));
const zksyncmainnet_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/zksyncmainnet.json"));
const zksyncsepolia_json_1 = __importDefault(require("@venusprotocol/governance-contracts/deployments/zksyncsepolia.json"));
const hardhat_1 = require("hardhat");
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function (hre) {
    const { deployments, getNamedAccounts } = hre;
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const getTimelock = async () => {
        switch (hre.network.name) {
            case "bsctestnet":
            case "bscmainnet": {
                const timelock = await deployments.get("NormalTimelock");
                return timelock.address;
            }
        }
        return "";
    };
    const acmAdminAccount = {
        sepolia: sepolia_json_1.default.contracts.NormalTimelock.address,
        ethereum: ethereum_json_1.default.contracts.NormalTimelock.address,
        opbnbtestnet: opbnbtestnet_json_1.default.contracts.NormalTimelock.address,
        opbnbmainnet: opbnbmainnet_json_1.default.contracts.NormalTimelock.address,
        arbitrumsepolia: arbitrumsepolia_json_1.default.contracts.NormalTimelock.address,
        arbitrumone: arbitrumone_json_1.default.contracts.NormalTimelock.address,
        zksyncsepolia: zksyncsepolia_json_1.default.contracts.NormalTimelock.address,
        zksyncmainnet: zksyncmainnet_json_1.default.contracts.NormalTimelock.address,
        opsepolia: opsepolia_json_1.default.contracts.NormalTimelock.address,
        opmainnet: opmainnet_json_1.default.contracts.NormalTimelock.address,
        basesepolia: basesepolia_json_1.default.contracts.NormalTimelock.address,
        basemainnet: basemainnet_json_1.default.contracts.NormalTimelock.address,
        unichainsepolia: unichainsepolia_json_1.default.contracts.NormalTimelock.address,
        unichainmainnet: unichainmainnet_json_1.default.contracts.NormalTimelock.address,
        berachainbartio: "0x8699D418D8bae5CFdc566E4fce897B08bd9B03B0",
        bscmainnet: await getTimelock(),
        bsctestnet: await getTimelock(),
        hardhat: deployer,
    };
    const deployerSigner = await hre.ethers.getSigner(deployer);
    const treasuryInstance = await deploy("VTreasuryV8", {
        contract: "VTreasuryV8",
        from: deployer,
        args: [],
        log: true,
        autoMine: true,
        skipIfAlreadyDeployed: true,
    });
    const adminAccount = acmAdminAccount[hre.network.name];
    const VTreasuryV8 = await hardhat_1.ethers.getContractAt("VTreasuryV8", treasuryInstance.address);
    if ((await VTreasuryV8.owner()).toLowerCase() != adminAccount.toLowerCase()) {
        console.log("Transferring owner to venus admin account");
        const tx = await VTreasuryV8.connect(deployerSigner).transferOwnership(adminAccount);
        tx.wait();
        console.log("Ownership Transferred to: ", await VTreasuryV8.pendingOwner());
    }
};
func.tags = ["VTreasuryV8"];
func.skip = (0, deploymentConfig_1.skipSourceNetworks)();
exports.default = func;
