"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const hardhat_1 = __importDefault(require("hardhat"));
const deploymentConfig_1 = require("../helpers/deploymentConfig");
const func = async function ({ getNamedAccounts, deployments, network }) {
    const { deploy } = deployments;
    const { deployer } = await getNamedAccounts();
    const accessControlManagerAddress = deploymentConfig_1.ADDRESSES[network.name].acm;
    const proxyOwnerAddress = deploymentConfig_1.ADDRESSES[network.name].timelock;
    const { timelock, pythOracleAddress } = deploymentConfig_1.ADDRESSES[network.name];
    if (pythOracleAddress) {
        await deploy("PythOracle", {
            contract: "PythOracle",
            from: deployer,
            log: true,
            deterministicDeployment: false,
            args: [],
            proxy: {
                owner: proxyOwnerAddress,
                proxyContract: "OptimizedTransparentProxy",
                execute: {
                    methodName: "initialize",
                    args: [pythOracleAddress, accessControlManagerAddress],
                },
            },
        });
        const pythOracle = await hardhat_1.default.ethers.getContract("PythOracle");
        const pythOracleOwner = await pythOracle.owner();
        if (pythOracleOwner === deployer) {
            await pythOracle.transferOwnership(timelock);
            console.log(`Ownership of PythOracle transfered from deployer to Timelock (${timelock})`);
        }
    }
};
func.tags = ["deploy-pyth-oracle"];
func.skip = async (env) => !env.network.live;
exports.default = func;
//# sourceMappingURL=2-deploy-pyth-oracle.js.map