Remove QueryString
This commit is contained in:
parent
858bd2e083
commit
100b743d06
@ -33,6 +33,7 @@
|
||||
- @cosmjs/tendermint-rpc: Remove export `v0_33` in favour of `adaptor33` and
|
||||
`adaptor34`. Export the `Adaptor` type.
|
||||
- @cosmjs/tendermint-rpc: Export `DateTime` class.
|
||||
- @cosmjs/tendermint-rpc: Remove type `QueryString`. Use `string` instead.
|
||||
|
||||
## 0.23.1 (2020-10-27)
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ import {
|
||||
broadcastTxCommitSuccess,
|
||||
Client as TendermintClient,
|
||||
DateTime,
|
||||
QueryString,
|
||||
} from "@cosmjs/tendermint-rpc";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
|
||||
@ -343,10 +342,7 @@ export class CosmWasmClient {
|
||||
}
|
||||
|
||||
private async txsQuery(query: string): Promise<readonly IndexedTx[]> {
|
||||
const params = {
|
||||
query: query as QueryString,
|
||||
};
|
||||
const results = await this.tmClient.txSearchAll(params);
|
||||
const results = await this.tmClient.txSearchAll({ query: query });
|
||||
return results.txs.map((tx) => {
|
||||
return {
|
||||
height: tx.height,
|
||||
|
||||
@ -12,12 +12,7 @@ import {
|
||||
} from "@cosmjs/launchpad";
|
||||
import { Uint53, Uint64 } from "@cosmjs/math";
|
||||
import { decodePubkey } from "@cosmjs/proto-signing";
|
||||
import {
|
||||
adaptor34,
|
||||
broadcastTxCommitSuccess,
|
||||
Client as TendermintClient,
|
||||
QueryString,
|
||||
} from "@cosmjs/tendermint-rpc";
|
||||
import { adaptor34, broadcastTxCommitSuccess, Client as TendermintClient } from "@cosmjs/tendermint-rpc";
|
||||
import { assert, assertDefined } from "@cosmjs/utils";
|
||||
import Long from "long";
|
||||
|
||||
@ -281,10 +276,7 @@ export class StargateClient {
|
||||
}
|
||||
|
||||
private async txsQuery(query: string): Promise<readonly IndexedTx[]> {
|
||||
const params = {
|
||||
query: query as QueryString,
|
||||
};
|
||||
const results = await this.tmClient.txSearchAll(params);
|
||||
const results = await this.tmClient.txSearchAll({ query: query });
|
||||
return results.txs.map((tx) => {
|
||||
return {
|
||||
height: tx.height,
|
||||
|
||||
@ -75,7 +75,7 @@ function encodeTxParams(params: requests.TxParams): RpcTxParams {
|
||||
}
|
||||
|
||||
interface RpcTxSearchParams {
|
||||
readonly query: requests.QueryString;
|
||||
readonly query: string;
|
||||
readonly prove?: boolean;
|
||||
readonly page?: IntegerString;
|
||||
readonly per_page?: IntegerString;
|
||||
|
||||
@ -186,7 +186,7 @@ export class Client {
|
||||
return this.subscribe(request, this.r.decodeNewBlockHeaderEvent);
|
||||
}
|
||||
|
||||
public subscribeTx(query?: requests.QueryString): Stream<responses.TxEvent> {
|
||||
public subscribeTx(query?: string): Stream<responses.TxEvent> {
|
||||
const request: requests.SubscribeRequest = {
|
||||
method: requests.Method.Subscribe,
|
||||
query: {
|
||||
|
||||
@ -16,7 +16,6 @@ export {
|
||||
HealthRequest,
|
||||
Method,
|
||||
Request,
|
||||
QueryString,
|
||||
QueryTag,
|
||||
StatusRequest,
|
||||
SubscriptionEventType,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { buildQuery, QueryString } from "./requests";
|
||||
import { buildQuery } from "./requests";
|
||||
|
||||
describe("Requests", () => {
|
||||
describe("buildQuery", () => {
|
||||
@ -23,7 +23,7 @@ describe("Requests", () => {
|
||||
});
|
||||
|
||||
it("works for raw input", () => {
|
||||
const query = buildQuery({ raw: "aabbCCDD" as QueryString });
|
||||
const query = buildQuery({ raw: "aabbCCDD" });
|
||||
expect(query).toEqual("aabbCCDD");
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ describe("Requests", () => {
|
||||
{ key: "k", value: "9" },
|
||||
{ key: "L", value: "7" },
|
||||
],
|
||||
raw: "aabbCCDD" as QueryString,
|
||||
raw: "aabbCCDD",
|
||||
});
|
||||
expect(query).toEqual("k='9' AND L='7' AND aabbCCDD");
|
||||
});
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { As } from "type-tagger";
|
||||
|
||||
/**
|
||||
* RPC methods as documented in https://docs.tendermint.com/master/rpc/
|
||||
@ -129,12 +128,10 @@ export interface SubscribeRequest {
|
||||
readonly method: Method.Subscribe;
|
||||
readonly query: {
|
||||
readonly type: SubscriptionEventType;
|
||||
readonly raw?: QueryString;
|
||||
readonly raw?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type QueryString = string & As<"query">;
|
||||
|
||||
export interface QueryTag {
|
||||
readonly key: string;
|
||||
readonly value: string;
|
||||
@ -154,8 +151,9 @@ export interface TxSearchRequest {
|
||||
readonly method: Method.TxSearch;
|
||||
readonly params: TxSearchParams;
|
||||
}
|
||||
|
||||
export interface TxSearchParams {
|
||||
readonly query: QueryString;
|
||||
readonly query: string;
|
||||
readonly prove?: boolean;
|
||||
readonly page?: number;
|
||||
readonly per_page?: number;
|
||||
@ -170,13 +168,13 @@ export interface ValidatorsRequest {
|
||||
|
||||
export interface BuildQueryComponents {
|
||||
readonly tags?: readonly QueryTag[];
|
||||
readonly raw?: QueryString;
|
||||
readonly raw?: string;
|
||||
}
|
||||
|
||||
export function buildQuery(components: BuildQueryComponents): QueryString {
|
||||
export function buildQuery(components: BuildQueryComponents): string {
|
||||
const tags = components.tags ? components.tags : [];
|
||||
const tagComponents = tags.map((tag) => `${tag.key}='${tag.value}'`);
|
||||
const rawComponents = components.raw ? [components.raw] : [];
|
||||
|
||||
return [...tagComponents, ...rawComponents].join(" AND ") as QueryString;
|
||||
return [...tagComponents, ...rawComponents].join(" AND ");
|
||||
}
|
||||
|
||||
2
packages/tendermint-rpc/types/client.d.ts
vendored
2
packages/tendermint-rpc/types/client.d.ts
vendored
@ -62,7 +62,7 @@ export declare class Client {
|
||||
status(): Promise<responses.StatusResponse>;
|
||||
subscribeNewBlock(): Stream<responses.NewBlockEvent>;
|
||||
subscribeNewBlockHeader(): Stream<responses.NewBlockHeaderEvent>;
|
||||
subscribeTx(query?: requests.QueryString): Stream<responses.TxEvent>;
|
||||
subscribeTx(query?: string): Stream<responses.TxEvent>;
|
||||
/**
|
||||
* Get a single transaction by hash
|
||||
*
|
||||
|
||||
1
packages/tendermint-rpc/types/index.d.ts
vendored
1
packages/tendermint-rpc/types/index.d.ts
vendored
@ -16,7 +16,6 @@ export {
|
||||
HealthRequest,
|
||||
Method,
|
||||
Request,
|
||||
QueryString,
|
||||
QueryTag,
|
||||
StatusRequest,
|
||||
SubscriptionEventType,
|
||||
|
||||
10
packages/tendermint-rpc/types/requests.d.ts
vendored
10
packages/tendermint-rpc/types/requests.d.ts
vendored
@ -1,4 +1,3 @@
|
||||
import { As } from "type-tagger";
|
||||
/**
|
||||
* RPC methods as documented in https://docs.tendermint.com/master/rpc/
|
||||
*
|
||||
@ -113,10 +112,9 @@ export interface SubscribeRequest {
|
||||
readonly method: Method.Subscribe;
|
||||
readonly query: {
|
||||
readonly type: SubscriptionEventType;
|
||||
readonly raw?: QueryString;
|
||||
readonly raw?: string;
|
||||
};
|
||||
}
|
||||
export declare type QueryString = string & As<"query">;
|
||||
export interface QueryTag {
|
||||
readonly key: string;
|
||||
readonly value: string;
|
||||
@ -134,7 +132,7 @@ export interface TxSearchRequest {
|
||||
readonly params: TxSearchParams;
|
||||
}
|
||||
export interface TxSearchParams {
|
||||
readonly query: QueryString;
|
||||
readonly query: string;
|
||||
readonly prove?: boolean;
|
||||
readonly page?: number;
|
||||
readonly per_page?: number;
|
||||
@ -147,6 +145,6 @@ export interface ValidatorsRequest {
|
||||
}
|
||||
export interface BuildQueryComponents {
|
||||
readonly tags?: readonly QueryTag[];
|
||||
readonly raw?: QueryString;
|
||||
readonly raw?: string;
|
||||
}
|
||||
export declare function buildQuery(components: BuildQueryComponents): QueryString;
|
||||
export declare function buildQuery(components: BuildQueryComponents): string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user