Add an optional adaptor argument to Client.connect

This commit is contained in:
Simon Warta 2020-11-18 14:41:07 +01:00
parent 3576bcd332
commit e4d1fd1425
3 changed files with 9 additions and 3 deletions

View File

@ -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)

View File

@ -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<Client> {
public static async connect(url: string, adaptor?: Adaptor): Promise<Client> {
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);
}
/**

View File

@ -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<Client>;
static connect(url: string, adaptor?: Adaptor): Promise<Client>;
/**
* Creates a new Tendermint client given an RPC client.
*