"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSolanaDevnet = exports.getSolanaChainId = void 0;
const bignumber_1 = require("@ethersproject/bignumber");
const ethers_1 = require("ethers");
/**
 * Returns the chainId for a given solana cluster.
 */
const getSolanaChainId = (cluster) => {
    return bignumber_1.BigNumber.from(BigInt(ethers_1.ethers.utils.keccak256(ethers_1.ethers.utils.toUtf8Bytes(`solana-${cluster}`))) & BigInt("0xFFFFFFFFFFFF"));
};
exports.getSolanaChainId = getSolanaChainId;
/**
 * Returns true if the provider is on the devnet cluster.
 */
const isSolanaDevnet = (provider) => {
    const solanaRpcEndpoint = provider.connection.rpcEndpoint;
    if (solanaRpcEndpoint.includes("devnet"))
        return true;
    else if (solanaRpcEndpoint.includes("mainnet"))
        return false;
    else
        throw new Error(`Unsupported solanaCluster endpoint: ${solanaRpcEndpoint}`);
};
exports.isSolanaDevnet = isSolanaDevnet;
