var _a;
import { CHAIN_IDs, MAINNET_CHAIN_IDs as _MAINNET_CHAIN_IDs, PUBLIC_NETWORKS } from "../constants";
var MAINNET_CHAIN_IDs = Object.values(_MAINNET_CHAIN_IDs);
// Chain-specific overrides for when the endpoint name does not match the canonical chain name.
var endpoints = (_a = {},
    _a[CHAIN_IDs.ARBITRUM] = "arbitrum",
    _a[CHAIN_IDs.BSC] = "bsc",
    _a);
export function getURL(chainId, apiKey, transport) {
    var _a, _b;
    var chain = (_a = endpoints[chainId]) !== null && _a !== void 0 ? _a : (_b = PUBLIC_NETWORKS[chainId]) === null || _b === void 0 ? void 0 : _b.name;
    if (!chain) {
        throw new Error("No known Infura provider for chainId ".concat(chainId));
    }
    if (chainId !== CHAIN_IDs.MAINNET && MAINNET_CHAIN_IDs.includes(chainId)) {
        chain = "".concat(chain, "-mainnet");
    }
    chain = chain.toLowerCase().replace(" ", "-");
    return transport === "https" ? "https://".concat(chain, ".infura.io/v3/").concat(apiKey) : "wss://".concat(chain, ".infura.io/ws/v3/").concat(apiKey);
}
//# sourceMappingURL=infura.js.map