"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getURL = getURL;
const constants_1 = require("../constants");
const MAINNET_CHAIN_IDs = Object.values(constants_1.MAINNET_CHAIN_IDs).map(Number);
const endpoints = {
    [constants_1.CHAIN_IDs.ARBITRUM]: "arbitrum",
    [constants_1.CHAIN_IDs.BSC]: "bsc",
};
function getURL(chainId, apiKey, transport) {
    let chain = endpoints[chainId] ?? constants_1.PUBLIC_NETWORKS[chainId]?.name;
    if (!chain) {
        throw new Error(`No known Infura provider for chainId ${chainId}`);
    }
    if (chainId !== constants_1.CHAIN_IDs.MAINNET && MAINNET_CHAIN_IDs.includes(chainId)) {
        chain = `${chain}-mainnet`;
    }
    chain = chain.toLowerCase().replace(" ", "-");
    return transport === "https" ? `https://${chain}.infura.io/v3/${apiKey}` : `wss://${chain}.infura.io/ws/v3/${apiKey}`;
}
//# sourceMappingURL=infura.js.map