//@ts-nocheck
/**
* This file and any referenced files were automatically generated by @cosmology/telescope@1.8.3
* 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.
*/
import { QueryClient, createProtobufRpcClient, ProtobufRpcClient } from '@cosmjs/stargate'
import { connectComet, HttpEndpoint } from "@cosmjs/tendermint-rpc";
const _rpcClients: Record<string, ProtobufRpcClient> = {};
export const getRpcEndpointKey = (rpcEndpoint: string | HttpEndpoint) => {
if (typeof rpcEndpoint === 'string') {
return rpcEndpoint;
} else if (!!rpcEndpoint) {
//@ts-ignore
return rpcEndpoint.url;
}
}
export const getRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
const key = getRpcEndpointKey(rpcEndpoint);
if (!key) return;
if (_rpcClients.hasOwnProperty(key)) {
return _rpcClients[key];
}
const cometClient = await connectComet(rpcEndpoint);
//@ts-ignore
const client = new QueryClient(cometClient);
const rpc = createProtobufRpcClient(client);
_rpcClients[key] = rpc;
return rpc;
}
export const createRpcClient = async (rpcEndpoint: string | HttpEndpoint) => {
const cometClient = await connectComet(rpcEndpoint);
//@ts-ignore
const client = new QueryClient(cometClient);
const rpc = createProtobufRpcClient(client);
return rpc;
}