UNPKG

interchainjs

Version:

InterchainJS is a JavaScript library for interacting with Cosmos SDK based blockchains.

31 lines (30 loc) 992 B
/** * This file and any referenced files were automatically generated by @cosmology/telescope@1.12.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. */ import { createQueryRpc, } from '@interchainjs/utils'; const _rpcClients = {}; export const getRpcEndpointKey = (rpcEndpoint) => { if (typeof rpcEndpoint === 'string') { return rpcEndpoint; } else if (!!rpcEndpoint) { //@ts-ignore return rpcEndpoint.url; } }; export const getRpcClient = async (rpcEndpoint) => { const key = getRpcEndpointKey(rpcEndpoint); if (!key) return; if (_rpcClients.hasOwnProperty(key)) { return _rpcClients[key]; } const rpc = await createRpcClient(rpcEndpoint); _rpcClients[key] = rpc; return rpc; }; export const createRpcClient = async (rpcEndpoint) => { return createQueryRpc(rpcEndpoint); };