"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hreNetworks = void 0;
exports.getNetworkName = getNetworkName;
exports.getNativeTokenSymbol = getNativeTokenSymbol;
exports.chainIsProd = chainIsProd;
exports.chainIsTestnet = chainIsTestnet;
exports.chainIsMatic = chainIsMatic;
exports.chainIsOPStack = chainIsOPStack;
exports.chainIsZkStack = chainIsZkStack;
exports.chainIsOrbit = chainIsOrbit;
exports.chainIsArbitrum = chainIsArbitrum;
exports.chainIsLinea = chainIsLinea;
exports.chainIsL1 = chainIsL1;
exports.chainIsEvm = chainIsEvm;
exports.chainIsSvm = chainIsSvm;
exports.chainIsTvm = chainIsTvm;
exports.chainHasNativeToken = chainHasNativeToken;
exports.chainIsCCTPEnabled = chainIsCCTPEnabled;
exports.chainIsOFTEnabled = chainIsOFTEnabled;
exports.chainRequiresL1ToL2Finalization = chainRequiresL1ToL2Finalization;
exports.getOriginFromURL = getOriginFromURL;
const constants_1 = require("../constants");
exports.hreNetworks = {
    666: "Hardhat1",
    1342: "Hardhat2",
    31337: "HardhatNetwork",
};
function getNetworkName(networkId) {
    networkId = Number(networkId);
    return constants_1.PUBLIC_NETWORKS[networkId]?.name ?? exports.hreNetworks[networkId] ?? `unknown (${networkId})`;
}
function getNativeTokenSymbol(chainId) {
    return constants_1.PUBLIC_NETWORKS[Number(chainId)]?.nativeToken ?? "ETH";
}
function chainIsProd(chainId) {
    return Object.values(constants_1.MAINNET_CHAIN_IDs).includes(chainId);
}
function chainIsTestnet(chainId) {
    return Object.values(constants_1.TESTNET_CHAIN_IDs).includes(chainId);
}
function chainIsMatic(chainId) {
    return [constants_1.CHAIN_IDs.POLYGON, constants_1.CHAIN_IDs.POLYGON_AMOY].includes(chainId);
}
function chainIsOPStack(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family === constants_1.ChainFamily.OP_STACK;
}
function chainIsZkStack(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family === constants_1.ChainFamily.ZK_STACK;
}
function chainIsOrbit(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family === constants_1.ChainFamily.ORBIT;
}
function chainIsArbitrum(chainId) {
    return [constants_1.CHAIN_IDs.ARBITRUM, constants_1.CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
}
function chainIsLinea(chainId) {
    return [constants_1.CHAIN_IDs.LINEA].includes(chainId);
}
function chainIsL1(chainId) {
    return [constants_1.CHAIN_IDs.MAINNET, constants_1.CHAIN_IDs.SEPOLIA].includes(chainId);
}
function chainIsEvm(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family !== constants_1.ChainFamily.SVM;
}
function chainIsSvm(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family === constants_1.ChainFamily.SVM;
}
function chainIsTvm(chainId) {
    return constants_1.PUBLIC_NETWORKS[chainId]?.family === constants_1.ChainFamily.TVM;
}
function chainHasNativeToken(chainId) {
    return ![constants_1.CHAIN_IDs.TEMPO].includes(chainId);
}
function chainIsCCTPEnabled(chainId) {
    const cctpExceptions = [];
    return constants_1.PRODUCTION_NETWORKS[chainId]?.cctpDomain !== constants_1.CCTP_NO_DOMAIN && !cctpExceptions.includes(chainId);
}
function chainIsOFTEnabled(chainId) {
    const oftEnabled = [
        constants_1.CHAIN_IDs.ARBITRUM,
        constants_1.CHAIN_IDs.HYPEREVM,
        constants_1.CHAIN_IDs.INK,
        constants_1.CHAIN_IDs.MEGAETH,
        constants_1.CHAIN_IDs.MONAD,
        constants_1.CHAIN_IDs.PLASMA,
        constants_1.CHAIN_IDs.POLYGON,
        constants_1.CHAIN_IDs.TRON,
        constants_1.CHAIN_IDs.UNICHAIN,
    ];
    return oftEnabled.includes(chainId) && constants_1.PRODUCTION_NETWORKS[chainId]?.oftEid !== constants_1.OFT_NO_EID;
}
function chainRequiresL1ToL2Finalization(chainId) {
    return chainIsCCTPEnabled(chainId) || chainIsLinea(chainId);
}
function getOriginFromURL(url) {
    try {
        return new URL(url).origin;
    }
    catch {
        return "UNKNOWN";
    }
}
//# sourceMappingURL=NetworkUtils.js.map