Add an optional adaptor argument to Client.connect
This commit is contained in:
parent
3576bcd332
commit
e4d1fd1425
@ -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)
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
4
packages/tendermint-rpc/types/client.d.ts
vendored
4
packages/tendermint-rpc/types/client.d.ts
vendored
@ -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.
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user