"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.skipSourceNetworks = exports.skipRemoteNetworks = exports.onlyHardhat = exports.getContractAddressOrNullAddress = exports.getTokenConfig = exports.DEFAULT_BLOCKS_PER_YEAR = void 0;
exports.DEFAULT_BLOCKS_PER_YEAR = 21024000;
function getTokenConfig(tokenSymbol, tokens) {
    const tokenCofig = tokens.find(({ symbol }) => symbol.toLocaleLowerCase().trim() === tokenSymbol.toLocaleLowerCase().trim());
    if (tokenCofig) {
        return tokenCofig;
    }
    else {
        throw Error(`Token ${tokenSymbol} is not found in the config`);
    }
}
exports.getTokenConfig = getTokenConfig;
const getContractAddressOrNullAddress = async (deployments, name) => {
    try {
        return (await deployments.get(name)).address;
    }
    catch (e) {
        console.error(`${name} not found returning null address`);
        return "0x0000000000000000000000000000000000000000";
    }
};
exports.getContractAddressOrNullAddress = getContractAddressOrNullAddress;
const onlyHardhat = () => async (hre) => {
    return hre.network.name !== "hardhat";
};
exports.onlyHardhat = onlyHardhat;
const skipRemoteNetworks = () => async (hre) => {
    return hre.network.name !== "bscmainnet" && hre.network.name !== "bsctestnet" && hre.network.name !== "hardhat";
};
exports.skipRemoteNetworks = skipRemoteNetworks;
const skipSourceNetworks = ({ hardhat } = { hardhat: false }) => async (hre) => {
    return hre.network.name === "bsctestnet" || hre.network.name === "bscmainnet" || hardhat;
};
exports.skipSourceNetworks = skipSourceNetworks;
