"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.chainIsCCTPEnabled = chainIsCCTPEnabled;
exports.chainIsOFTEnabled = chainIsOFTEnabled;
exports.chainRequiresL1ToL2Finalization = chainRequiresL1ToL2Finalization;
exports.getOriginFromURL = getOriginFromURL;
var constants_1 = require("../constants");
exports.hreNetworks = {
    666: "Hardhat1",
    1342: "Hardhat2",
    31337: "HardhatNetwork",
};
function getNetworkName(networkId) {
    var _a, _b, _c;
    networkId = Number(networkId);
    return (_c = (_b = (_a = constants_1.PUBLIC_NETWORKS[networkId]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : exports.hreNetworks[networkId]) !== null && _c !== void 0 ? _c : "unknown (".concat(networkId, ")");
}
function getNativeTokenSymbol(chainId) {
    var _a, _b;
    return (_b = (_a = constants_1.PUBLIC_NETWORKS[Number(chainId)]) === null || _a === void 0 ? void 0 : _a.nativeToken) !== null && _b !== void 0 ? _b : "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) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) === constants_1.ChainFamily.OP_STACK;
}
function chainIsZkStack(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) === constants_1.ChainFamily.ZK_STACK;
}
function chainIsOrbit(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.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) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) !== constants_1.ChainFamily.SVM;
}
function chainIsSvm(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) === constants_1.ChainFamily.SVM;
}
function chainIsCCTPEnabled(chainId) {
    var _a;
    var cctpExceptions = [];
    return ((_a = constants_1.PRODUCTION_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.cctpDomain) !== constants_1.CCTP_NO_DOMAIN && !cctpExceptions.includes(chainId);
}
function chainIsOFTEnabled(chainId) {
    var _a;
    var oftEnabled = [constants_1.CHAIN_IDs.ARBITRUM, constants_1.CHAIN_IDs.POLYGON, constants_1.CHAIN_IDs.HYPEREVM, constants_1.CHAIN_IDs.PLASMA];
    return oftEnabled.includes(chainId) && ((_a = constants_1.PRODUCTION_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.oftEid) !== constants_1.OFT_NO_EID;
}
function chainRequiresL1ToL2Finalization(chainId) {
    return chainIsCCTPEnabled(chainId) || chainIsLinea(chainId);
}
function getOriginFromURL(url) {
    try {
        return new URL(url).origin;
    }
    catch (e) {
        return "UNKNOWN";
    }
}
//# sourceMappingURL=NetworkUtils.js.map