"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 = deploymentConfig_1.ADDRESSES[network.name].timeloc;
    const { sidRegistryAddress, feedRegistryAddress } = deploymentConfig_1.ADDRESSES[network.name];
    if (sidRegistryAddress) {
        await deploy("BinanceOracle", {
            contract: "BinanceOracle",
            from: deployer,
            log: true,
            deterministicDeployment: false,
            args: [],
            proxy: {
                owner: proxyOwnerAddress,
                proxyContract: "OptimizedTransparentProxy",
                execute: {
                    methodName: "initialize",
                    args: [sidRegistryAddress, accessControlManagerAddress],
                },
            },
        });
        const binanceOracle = await hardhat_1.default.ethers.getContract("BinanceOracle");
        const binanceOracleOwner = await binanceOracle.owner();
        if (sidRegistryAddress === "0x0000000000000000000000000000000000000000") {
            await binanceOracle.setFeedRegistryAddress(feedRegistryAddress);
        }
        if (binanceOracleOwner === deployer) {
            await binanceOracle.transferOwnership(timelock);
            console.log(`Ownership of BinanceOracle transfered from deployer to Timelock (${timelock})`);
        }
    }
};
func.tags = ["deploy-binance-oracle"];
func.skip = async (env) => !env.network.live;
exports.default = func;
//# sourceMappingURL=2-deploy-binance-oracle.js.map