"use strict";
/**
* This file and any referenced files were automatically generated by @cosmology/telescope@1.11.19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRpcClient = exports.getRpcClient = exports.getRpcEndpointKey = void 0;
const utils_1 = require("@interchainjs/cosmos/utils");
const _rpcClients = {};
const getRpcEndpointKey = (rpcEndpoint) => {
    if (typeof rpcEndpoint === 'string') {
        return rpcEndpoint;
    }
    else if (!!rpcEndpoint) {
        //@ts-ignore
        return rpcEndpoint.url;
    }
};
exports.getRpcEndpointKey = getRpcEndpointKey;
const getRpcClient = async (rpcEndpoint) => {
    const key = (0, exports.getRpcEndpointKey)(rpcEndpoint);
    if (!key)
        return;
    if (_rpcClients.hasOwnProperty(key)) {
        return _rpcClients[key];
    }
    const rpc = await (0, exports.createRpcClient)(rpcEndpoint);
    _rpcClients[key] = rpc;
    return rpc;
};
exports.getRpcClient = getRpcClient;
const createRpcClient = async (rpcEndpoint) => {
    return (0, utils_1.createQueryRpc)(rpcEndpoint);
};
exports.createRpcClient = createRpcClient;
