"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOriginFromURL = exports.chainRequiresL1ToL2Finalization = exports.chainIsCCTPEnabled = exports.chainIsSvm = exports.chainIsEvm = exports.chainIsL1 = exports.chainIsBSC = exports.chainIsLinea = exports.chainIsArbitrum = exports.chainIsOrbit = exports.chainIsZkStack = exports.chainIsOPStack = exports.chainIsMatic = exports.chainIsTestnet = exports.chainIsProd = exports.getNativeTokenSymbol = exports.getNetworkName = exports.hreNetworks = void 0;
var constants_1 = require("../constants");
exports.hreNetworks = {
    666: "Hardhat1",
    1337: "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, ")");
}
exports.getNetworkName = getNetworkName;
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";
}
exports.getNativeTokenSymbol = getNativeTokenSymbol;
function chainIsProd(chainId) {
    return Object.values(constants_1.MAINNET_CHAIN_IDs).includes(chainId);
}
exports.chainIsProd = chainIsProd;
function chainIsTestnet(chainId) {
    return Object.values(constants_1.TESTNET_CHAIN_IDs).includes(chainId);
}
exports.chainIsTestnet = chainIsTestnet;
function chainIsMatic(chainId) {
    return [constants_1.CHAIN_IDs.POLYGON, constants_1.CHAIN_IDs.POLYGON_AMOY].includes(chainId);
}
exports.chainIsMatic = chainIsMatic;
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;
}
exports.chainIsOPStack = chainIsOPStack;
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;
}
exports.chainIsZkStack = chainIsZkStack;
function chainIsOrbit(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) === constants_1.ChainFamily.ORBIT;
}
exports.chainIsOrbit = chainIsOrbit;
function chainIsArbitrum(chainId) {
    return [constants_1.CHAIN_IDs.ARBITRUM, constants_1.CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
}
exports.chainIsArbitrum = chainIsArbitrum;
function chainIsLinea(chainId) {
    return [constants_1.CHAIN_IDs.LINEA].includes(chainId);
}
exports.chainIsLinea = chainIsLinea;
function chainIsBSC(chainId) {
    return [constants_1.CHAIN_IDs.BSC].includes(chainId);
}
exports.chainIsBSC = chainIsBSC;
function chainIsL1(chainId) {
    return [constants_1.CHAIN_IDs.MAINNET, constants_1.CHAIN_IDs.SEPOLIA].includes(chainId);
}
exports.chainIsL1 = chainIsL1;
function chainIsEvm(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) !== constants_1.ChainFamily.SVM;
}
exports.chainIsEvm = chainIsEvm;
function chainIsSvm(chainId) {
    var _a;
    return ((_a = constants_1.PUBLIC_NETWORKS[chainId]) === null || _a === void 0 ? void 0 : _a.family) === constants_1.ChainFamily.SVM;
}
exports.chainIsSvm = chainIsSvm;
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);
}
exports.chainIsCCTPEnabled = chainIsCCTPEnabled;
function chainRequiresL1ToL2Finalization(chainId) {
    return chainIsCCTPEnabled(chainId) || chainIsLinea(chainId);
}
exports.chainRequiresL1ToL2Finalization = chainRequiresL1ToL2Finalization;
function getOriginFromURL(url) {
    try {
        return new URL(url).origin;
    }
    catch (e) {
        return "UNKNOWN";
    }
}
exports.getOriginFromURL = getOriginFromURL;
//# sourceMappingURL=NetworkUtils.js.map