mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 13:47:12 +00:00
Improve HttpBatchClient constructor and add missing exports
This commit is contained in:
parent
8a7787885f
commit
37ed295a2e
11
CHANGELOG.md
11
CHANGELOG.md
@ -6,6 +6,17 @@ and this project adheres to
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- @cosmjs/tendermint-rpc: The options in the `HttpBatchClient` constructor are
|
||||
now of type `Partial<HttpBatchClientOptions>`, allowing you to set only the
|
||||
fields you want to change ([#1309]).
|
||||
- @cosmjs/tendermint-rpc: Add missing exports `HttpBatchClient`,
|
||||
`HttpBatchClientOptions`, `RpcClient` ([#1311]).
|
||||
|
||||
[#1309]: https://github.com/cosmos/cosmjs/issues/1309
|
||||
[#1311]: https://github.com/cosmos/cosmjs/issues/1311
|
||||
|
||||
### Fixed
|
||||
|
||||
- @cosmjs/cosmwasm-stargate: Fix `ContractCodeHistory` decoding when msg
|
||||
|
@ -12,11 +12,17 @@ export {
|
||||
toRfc3339WithNanoseconds,
|
||||
toSeconds,
|
||||
} from "./dates";
|
||||
// The public Tendermint34Client.create constructor allows manually choosing an RpcClient.
|
||||
// This is currently the only way to switch to the HttpBatchClient (which may become default at some point).
|
||||
// Due to this API, we make RPC client implementations public.
|
||||
export {
|
||||
// This type is part of the Tendermint34Client.connect API
|
||||
HttpEndpoint,
|
||||
HttpBatchClient,
|
||||
HttpBatchClientOptions,
|
||||
HttpClient,
|
||||
HttpEndpoint, // This type is part of the Tendermint34Client.connect API
|
||||
RpcClient, // Interface type in Tendermint34Client.create
|
||||
WebsocketClient,
|
||||
} from "./rpcclients";
|
||||
export { HttpClient, WebsocketClient } from "./rpcclients"; // TODO: Why do we export those outside of this package?
|
||||
export {
|
||||
AbciInfoRequest,
|
||||
AbciInfoResponse,
|
||||
|
@ -14,7 +14,10 @@ export interface HttpBatchClientOptions {
|
||||
batchSizeLimit: number;
|
||||
}
|
||||
|
||||
export const defaultHttpBatchClientOptions: HttpBatchClientOptions = {
|
||||
// Those values are private and can change any time.
|
||||
// Does a user need to know them? I don't think so. You either set
|
||||
// a custom value or leave the option field unset.
|
||||
const defaultHttpBatchClientOptions: HttpBatchClientOptions = {
|
||||
dispatchInterval: 20,
|
||||
batchSizeLimit: 20,
|
||||
};
|
||||
@ -31,11 +34,11 @@ export class HttpBatchClient implements RpcClient {
|
||||
reject: (a: Error) => void;
|
||||
}> = [];
|
||||
|
||||
public constructor(
|
||||
endpoint: string | HttpEndpoint,
|
||||
options: HttpBatchClientOptions = defaultHttpBatchClientOptions,
|
||||
) {
|
||||
this.options = options;
|
||||
public constructor(endpoint: string | HttpEndpoint, options: Partial<HttpBatchClientOptions> = {}) {
|
||||
this.options = {
|
||||
batchSizeLimit: options.batchSizeLimit ?? defaultHttpBatchClientOptions.batchSizeLimit,
|
||||
dispatchInterval: options.dispatchInterval ?? defaultHttpBatchClientOptions.dispatchInterval,
|
||||
};
|
||||
if (typeof endpoint === "string") {
|
||||
// accept host.name:port and assume http protocol
|
||||
this.url = hasProtocol(endpoint) ? endpoint : "http://" + endpoint;
|
||||
|
@ -1,6 +1,6 @@
|
||||
// This folder contains Tendermint-specific RPC clients
|
||||
|
||||
export { defaultHttpBatchClientOptions, HttpBatchClient } from "./httpbatchclient";
|
||||
export { HttpBatchClient, HttpBatchClientOptions } from "./httpbatchclient";
|
||||
export { HttpClient, HttpEndpoint } from "./httpclient";
|
||||
export { instanceOfRpcStreamingClient, RpcClient, RpcStreamingClient, SubscriptionEvent } from "./rpcclient";
|
||||
export { WebsocketClient } from "./websocketclient";
|
||||
|
Loading…
x
Reference in New Issue
Block a user