tendermint-rpc: Enable all params in validators query
This commit is contained in:
parent
cbf9f25a88
commit
484fdc2fd0
@ -84,6 +84,19 @@ function encodeTxSearchParams(params: requests.TxSearchParams): RpcTxSearchParam
|
||||
};
|
||||
}
|
||||
|
||||
interface RpcValidatorsParams {
|
||||
readonly height?: string;
|
||||
readonly page?: string;
|
||||
readonly per_page?: string;
|
||||
}
|
||||
function encodeValidatorsParams(params: requests.ValidatorsParams): RpcValidatorsParams {
|
||||
return {
|
||||
height: may(Integer.encode, params.height),
|
||||
page: may(Integer.encode, params.page),
|
||||
per_page: may(Integer.encode, params.per_page),
|
||||
};
|
||||
}
|
||||
|
||||
export class Params {
|
||||
public static encodeAbciInfo(req: requests.AbciInfoRequest): JsonRpcRequest {
|
||||
return createJsonRpcRequest(req.method);
|
||||
@ -141,6 +154,6 @@ export class Params {
|
||||
}
|
||||
|
||||
public static encodeValidators(req: requests.ValidatorsRequest): JsonRpcRequest {
|
||||
return createJsonRpcRequest(req.method, encodeHeightParam(req.params));
|
||||
return createJsonRpcRequest(req.method, encodeValidatorsParams(req.params));
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, adaptor: Adaptor, expecte
|
||||
it("can get validators", async () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = await Client.create(rpcFactory(), adaptor);
|
||||
const response = await client.validators();
|
||||
const response = await client.validators({});
|
||||
|
||||
expect(response).toBeTruthy();
|
||||
expect(response.blockHeight).toBeGreaterThanOrEqual(1);
|
||||
|
||||
@ -248,10 +248,10 @@ export class Client {
|
||||
};
|
||||
}
|
||||
|
||||
public async validators(height?: number): Promise<responses.ValidatorsResponse> {
|
||||
public async validators(params: requests.ValidatorsParams): Promise<responses.ValidatorsResponse> {
|
||||
const query: requests.ValidatorsRequest = {
|
||||
method: requests.Method.Validators,
|
||||
params: { height: height },
|
||||
params: params,
|
||||
};
|
||||
return this.doCall(query, this.p.encodeValidators, this.r.decodeValidators);
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ export {
|
||||
TxSearchParams,
|
||||
TxSearchRequest,
|
||||
ValidatorsRequest,
|
||||
ValidatorsParams,
|
||||
} from "./requests";
|
||||
export {
|
||||
AbciInfoResponse,
|
||||
|
||||
@ -161,9 +161,13 @@ export interface TxSearchParams {
|
||||
|
||||
export interface ValidatorsRequest {
|
||||
readonly method: Method.Validators;
|
||||
readonly params: {
|
||||
readonly height?: number;
|
||||
};
|
||||
readonly params: ValidatorsParams;
|
||||
}
|
||||
|
||||
export interface ValidatorsParams {
|
||||
readonly height?: number;
|
||||
readonly page?: number;
|
||||
readonly per_page?: number;
|
||||
}
|
||||
|
||||
export interface BuildQueryComponents {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user