diff --git a/CHANGELOG.md b/CHANGELOG.md index 768e8da0..bc1e3044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ - @cosmjs/tendermint-rpc: Make the constructor of `Client` private. Add `Client.create` for creating a Tendermint client given an RPC client and an optional adaptor. +- @cosmjs/tendermint-rpc: Add an optional adaptor argument to `Client.connect` + which allows skipping the auto-detection. ## 0.23.1 (2020-10-27) diff --git a/packages/tendermint-rpc/src/client.ts b/packages/tendermint-rpc/src/client.ts index 76862189..c34b0d55 100644 --- a/packages/tendermint-rpc/src/client.ts +++ b/packages/tendermint-rpc/src/client.ts @@ -18,11 +18,13 @@ export class Client { * Creates a new Tendermint client for the given endpoint. * * Uses HTTP when the URL schema is http or https. Uses WebSockets otherwise. + * + * If the adaptor is not set an auto-detection is performed. */ - public static async connect(url: string): Promise { + public static async connect(url: string, adaptor?: Adaptor): Promise { const useHttp = url.startsWith("http://") || url.startsWith("https://"); const rpcClient = useHttp ? new HttpClient(url) : new WebsocketClient(url); - return Client.create(rpcClient); + return Client.create(rpcClient, adaptor); } /** diff --git a/packages/tendermint-rpc/types/client.d.ts b/packages/tendermint-rpc/types/client.d.ts index ab3d3ec8..836c3058 100644 --- a/packages/tendermint-rpc/types/client.d.ts +++ b/packages/tendermint-rpc/types/client.d.ts @@ -8,8 +8,10 @@ export declare class Client { * Creates a new Tendermint client for the given endpoint. * * Uses HTTP when the URL schema is http or https. Uses WebSockets otherwise. + * + * If the adaptor is not set an auto-detection is performed. */ - static connect(url: string): Promise; + static connect(url: string, adaptor?: Adaptor): Promise; /** * Creates a new Tendermint client given an RPC client. *