UNPKG

@archwayhq/arch3-core

Version:

Core library to interact with Archway Network

29 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.connectCometWithBatchClient = void 0; const tendermint_rpc_1 = require("@cosmjs/tendermint-rpc"); /** * Auto-detects Tendermint/CometBFT 0.34/0.37/0.38 version for connecting to an RPC Client with an HttpBatchClient. * * @param endpoint - String URL of the RPC endpoint to connect or an {@link HttpEndpoint} object. * @param options - Optional configuration to control how the {@link HttpBatchClient} will batch requests. * * @returns A connected {@link CometClient} */ async function connectCometWithBatchClient(endpoint, options) { let rpcClient = new tendermint_rpc_1.HttpBatchClient(endpoint, options); const tendermint37Client = await tendermint_rpc_1.Tendermint37Client.create(rpcClient); const version = (await tendermint37Client.status()).nodeInfo.version; if (version.startsWith('0.37.')) { return tendermint37Client; } tendermint37Client.disconnect(); rpcClient.disconnect(); rpcClient = new tendermint_rpc_1.HttpBatchClient(endpoint, options); if (version.startsWith('0.38.')) { return await tendermint_rpc_1.Comet38Client.create(rpcClient); } return await tendermint_rpc_1.Tendermint34Client.create(rpcClient); } exports.connectCometWithBatchClient = connectCometWithBatchClient; //# sourceMappingURL=utils.js.map