@accret/bridge-sdk
Version:
33 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRpcUrl = getRpcUrl;
const types_1 = require("../types");
function getRpcUrl({ chainId, evm_api_key, solana_api_key, }) {
if (!evm_api_key && !process.env.EVM_API_KEY) {
throw new Error("EVM API key is required");
}
if (!solana_api_key && !process.env.SOLANA_API_KEY) {
throw new Error("Solana API key is required");
}
evm_api_key = evm_api_key || process.env.EVM_API_KEY;
solana_api_key = solana_api_key || process.env.SOLANA_API_KEY;
switch (chainId) {
case types_1.AccretSupportedChain.SOLANA_CHAIN:
return `https://mainnet.helius-rpc.com/?api-key=${solana_api_key}`;
case types_1.AccretSupportedChain.ETHEREUM_CHAIN:
return `https://mainnet.infura.io/v3/${evm_api_key}`;
case types_1.AccretSupportedChain.POLYGON_CHAIN:
return `https://polygon-mainnet.infura.io/v3/${evm_api_key}`;
case types_1.AccretSupportedChain.BASE_CHAIN:
return `https://base-mainnet.infura.io/v3/${evm_api_key}`;
case types_1.AccretSupportedChain.ARBITRUM_CHAIN:
return `https://arbitrum-mainnet.infura.io/v3/${evm_api_key}`;
case types_1.AccretSupportedChain.BNB_CHAIN:
return `https://bsc-mainnet.infura.io/v3/${evm_api_key}`;
case types_1.AccretSupportedChain.AVALANCHE_CHAIN:
return `https://avalanche-mainnet.infura.io/v3/${evm_api_key}`;
default:
throw new Error(`Unsupported chainId: ${chainId}`);
}
}
//# sourceMappingURL=getRpcUrl.js.map