Move legacy client to ./legacy folder
This commit is contained in:
parent
15c480b8bf
commit
1bef41ee94
@ -1,39 +1,8 @@
|
||||
export { Adaptor } from "./adaptor";
|
||||
export { adaptor33, adaptor34 } from "./adaptors";
|
||||
export { Client } from "./client";
|
||||
export {
|
||||
DateTime,
|
||||
ReadonlyDateWithNanoseconds,
|
||||
fromRfc3339WithNanoseconds,
|
||||
fromSeconds,
|
||||
toRfc3339WithNanoseconds,
|
||||
toSeconds,
|
||||
} from "./dates";
|
||||
export {
|
||||
AbciInfoRequest,
|
||||
AbciQueryParams,
|
||||
AbciQueryRequest,
|
||||
BlockRequest,
|
||||
BlockchainRequest,
|
||||
BlockResultsRequest,
|
||||
BroadcastTxRequest,
|
||||
BroadcastTxParams,
|
||||
CommitRequest,
|
||||
GenesisRequest,
|
||||
HealthRequest,
|
||||
Method,
|
||||
Request,
|
||||
QueryTag,
|
||||
StatusRequest,
|
||||
SubscriptionEventType,
|
||||
TxParams,
|
||||
TxRequest,
|
||||
TxSearchParams,
|
||||
TxSearchRequest,
|
||||
ValidatorsRequest,
|
||||
ValidatorsParams,
|
||||
} from "./requests";
|
||||
export {
|
||||
adaptor33,
|
||||
adaptor34,
|
||||
Adaptor,
|
||||
Client,
|
||||
AbciInfoResponse,
|
||||
AbciQueryResponse,
|
||||
Attribute,
|
||||
@ -78,6 +47,36 @@ export {
|
||||
Version,
|
||||
Vote,
|
||||
VoteType,
|
||||
} from "./responses";
|
||||
AbciInfoRequest,
|
||||
AbciQueryParams,
|
||||
AbciQueryRequest,
|
||||
BlockRequest,
|
||||
BlockchainRequest,
|
||||
BlockResultsRequest,
|
||||
BroadcastTxRequest,
|
||||
BroadcastTxParams,
|
||||
CommitRequest,
|
||||
GenesisRequest,
|
||||
HealthRequest,
|
||||
Method,
|
||||
Request,
|
||||
QueryTag,
|
||||
StatusRequest,
|
||||
SubscriptionEventType,
|
||||
TxParams,
|
||||
TxRequest,
|
||||
TxSearchParams,
|
||||
TxSearchRequest,
|
||||
ValidatorsRequest,
|
||||
ValidatorsParams,
|
||||
} from "./legacy";
|
||||
export {
|
||||
DateTime,
|
||||
ReadonlyDateWithNanoseconds,
|
||||
fromRfc3339WithNanoseconds,
|
||||
fromSeconds,
|
||||
toRfc3339WithNanoseconds,
|
||||
toSeconds,
|
||||
} from "./dates";
|
||||
export { HttpClient, WebsocketClient } from "./rpcclients"; // TODO: Why do we export those outside of this package?
|
||||
export { BlockIdFlag, CommitSignature, ValidatorEd25519Pubkey, ValidatorPubkey } from "./types";
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { JsonRpcRequest, JsonRpcSuccessResponse } from "@cosmjs/json-rpc";
|
||||
|
||||
import { SubscriptionEvent } from "../rpcclients";
|
||||
import * as requests from "./requests";
|
||||
import * as responses from "./responses";
|
||||
import { SubscriptionEvent } from "./rpcclients";
|
||||
|
||||
export interface Adaptor {
|
||||
readonly params: Params;
|
||||
@ -2,8 +2,8 @@
|
||||
import { toBase64, toHex } from "@cosmjs/encoding";
|
||||
import { JsonRpcRequest } from "@cosmjs/json-rpc";
|
||||
|
||||
import { createJsonRpcRequest } from "../../../jsonrpc";
|
||||
import { assertNotEmpty, Integer, may } from "../../encodings";
|
||||
import { createJsonRpcRequest } from "../../jsonrpc";
|
||||
import * as requests from "../../requests";
|
||||
|
||||
interface HeightParam {
|
||||
@ -3,7 +3,9 @@ import { fromBase64, fromHex } from "@cosmjs/encoding";
|
||||
import { JsonRpcSuccessResponse } from "@cosmjs/json-rpc";
|
||||
import { assert } from "@cosmjs/utils";
|
||||
|
||||
import { fromRfc3339WithNanoseconds } from "../../dates";
|
||||
import { fromRfc3339WithNanoseconds } from "../../../dates";
|
||||
import { SubscriptionEvent } from "../../../rpcclients";
|
||||
import { BlockIdFlag, CommitSignature, ValidatorPubkey } from "../../../types";
|
||||
import {
|
||||
assertArray,
|
||||
assertBoolean,
|
||||
@ -19,8 +21,6 @@ import {
|
||||
} from "../../encodings";
|
||||
import { hashTx } from "../../hasher";
|
||||
import * as responses from "../../responses";
|
||||
import { SubscriptionEvent } from "../../rpcclients";
|
||||
import { BlockIdFlag, CommitSignature, ValidatorPubkey } from "../../types";
|
||||
|
||||
interface AbciInfoResult {
|
||||
readonly response: RpcAbciInfoResponse;
|
||||
@ -5,14 +5,14 @@ import { sleep } from "@cosmjs/utils";
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
import { Stream } from "xstream";
|
||||
|
||||
import { ExpectedValues, tendermintInstances } from "../config.spec";
|
||||
import { HttpClient, RpcClient, WebsocketClient } from "../rpcclients";
|
||||
import { chainIdMatcher } from "../testutil.spec";
|
||||
import { Adaptor } from "./adaptor";
|
||||
import { adaptorForVersion } from "./adaptors";
|
||||
import { Client } from "./client";
|
||||
import { ExpectedValues, tendermintInstances } from "./config.spec";
|
||||
import { buildQuery } from "./requests";
|
||||
import * as responses from "./responses";
|
||||
import { HttpClient, RpcClient, WebsocketClient } from "./rpcclients";
|
||||
import { chainIdMatcher } from "./testutil.spec";
|
||||
|
||||
function tendermintEnabled(): boolean {
|
||||
return !!process.env.TENDERMINT_ENABLED;
|
||||
@ -1,18 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Stream } from "xstream";
|
||||
|
||||
import { Adaptor, Decoder, Encoder, Params, Responses } from "./adaptor";
|
||||
import { adaptorForVersion } from "./adaptors";
|
||||
import { createJsonRpcRequest } from "./jsonrpc";
|
||||
import * as requests from "./requests";
|
||||
import * as responses from "./responses";
|
||||
import { createJsonRpcRequest } from "../jsonrpc";
|
||||
import {
|
||||
HttpClient,
|
||||
instanceOfRpcStreamingClient,
|
||||
RpcClient,
|
||||
SubscriptionEvent,
|
||||
WebsocketClient,
|
||||
} from "./rpcclients";
|
||||
} from "../rpcclients";
|
||||
import { Adaptor, Decoder, Encoder, Params, Responses } from "./adaptor";
|
||||
import { adaptorForVersion } from "./adaptors";
|
||||
import * as requests from "./requests";
|
||||
import * as responses from "./responses";
|
||||
|
||||
export class Client {
|
||||
/**
|
||||
@ -1,7 +1,7 @@
|
||||
import { toUtf8 } from "@cosmjs/encoding";
|
||||
import { Int53 } from "@cosmjs/math";
|
||||
|
||||
import { ReadonlyDateWithNanoseconds } from "./dates";
|
||||
import { ReadonlyDateWithNanoseconds } from "../dates";
|
||||
import { BlockId, Version } from "./responses";
|
||||
|
||||
/**
|
||||
@ -1,7 +1,7 @@
|
||||
import { fromBase64, fromHex } from "@cosmjs/encoding";
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
import { ReadonlyDateWithNanoseconds } from "./dates";
|
||||
import { ReadonlyDateWithNanoseconds } from "../dates";
|
||||
import { hashBlock, hashTx } from "./hasher";
|
||||
|
||||
describe("Hasher", () => {
|
||||
73
packages/tendermint-rpc/src/legacy/index.ts
Normal file
73
packages/tendermint-rpc/src/legacy/index.ts
Normal file
@ -0,0 +1,73 @@
|
||||
export { adaptor33, adaptor34 } from "./adaptors";
|
||||
export { Adaptor } from "./adaptor";
|
||||
export { Client } from "./client";
|
||||
export {
|
||||
AbciInfoRequest,
|
||||
AbciQueryParams,
|
||||
AbciQueryRequest,
|
||||
BlockRequest,
|
||||
BlockchainRequest,
|
||||
BlockResultsRequest,
|
||||
BroadcastTxRequest,
|
||||
BroadcastTxParams,
|
||||
CommitRequest,
|
||||
GenesisRequest,
|
||||
HealthRequest,
|
||||
Method,
|
||||
Request,
|
||||
QueryTag,
|
||||
StatusRequest,
|
||||
SubscriptionEventType,
|
||||
TxParams,
|
||||
TxRequest,
|
||||
TxSearchParams,
|
||||
TxSearchRequest,
|
||||
ValidatorsRequest,
|
||||
ValidatorsParams,
|
||||
} from "./requests";
|
||||
export {
|
||||
AbciInfoResponse,
|
||||
AbciQueryResponse,
|
||||
Attribute,
|
||||
Block,
|
||||
BlockchainResponse,
|
||||
BlockGossipParams,
|
||||
BlockId,
|
||||
BlockMeta,
|
||||
BlockParams,
|
||||
BlockResponse,
|
||||
BlockResultsResponse,
|
||||
BroadcastTxAsyncResponse,
|
||||
BroadcastTxCommitResponse,
|
||||
broadcastTxCommitSuccess,
|
||||
BroadcastTxSyncResponse,
|
||||
broadcastTxSyncSuccess,
|
||||
Commit,
|
||||
CommitResponse,
|
||||
ConsensusParams,
|
||||
Event,
|
||||
Evidence,
|
||||
EvidenceParams,
|
||||
GenesisResponse,
|
||||
Header,
|
||||
HealthResponse,
|
||||
NewBlockEvent,
|
||||
NewBlockHeaderEvent,
|
||||
NodeInfo,
|
||||
ProofOp,
|
||||
QueryProof,
|
||||
Response,
|
||||
StatusResponse,
|
||||
SyncInfo,
|
||||
TxData,
|
||||
TxEvent,
|
||||
TxProof,
|
||||
TxResponse,
|
||||
TxSearchResponse,
|
||||
TxSizeParams,
|
||||
Validator,
|
||||
ValidatorsResponse,
|
||||
Version,
|
||||
Vote,
|
||||
VoteType,
|
||||
} from "./responses";
|
||||
@ -1,7 +1,7 @@
|
||||
import { ReadonlyDate } from "readonly-date";
|
||||
|
||||
import { ReadonlyDateWithNanoseconds } from "./dates";
|
||||
import { CommitSignature, ValidatorPubkey } from "./types";
|
||||
import { ReadonlyDateWithNanoseconds } from "../dates";
|
||||
import { CommitSignature, ValidatorPubkey } from "../types";
|
||||
|
||||
export type Response =
|
||||
| AbciInfoResponse
|
||||
@ -1,6 +1,5 @@
|
||||
import { defaultInstance } from "../config.spec";
|
||||
import { createJsonRpcRequest } from "../jsonrpc";
|
||||
import { Method } from "../requests";
|
||||
import { HttpClient } from "./httpclient";
|
||||
|
||||
function pendingWithoutTendermint(): void {
|
||||
@ -16,10 +15,10 @@ describe("HttpClient", () => {
|
||||
pendingWithoutTendermint();
|
||||
const client = new HttpClient(tendermintUrl);
|
||||
|
||||
const healthResponse = await client.execute(createJsonRpcRequest(Method.Health));
|
||||
const healthResponse = await client.execute(createJsonRpcRequest("health"));
|
||||
expect(healthResponse.result).toEqual({});
|
||||
|
||||
const statusResponse = await client.execute(createJsonRpcRequest(Method.Status));
|
||||
const statusResponse = await client.execute(createJsonRpcRequest("status"));
|
||||
expect(statusResponse.result).toBeTruthy();
|
||||
expect(statusResponse.result.node_info).toBeTruthy();
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { defaultInstance } from "../config.spec";
|
||||
import { createJsonRpcRequest } from "../jsonrpc";
|
||||
import { Method } from "../requests";
|
||||
import { HttpClient } from "./httpclient";
|
||||
import { instanceOfRpcStreamingClient } from "./rpcclient";
|
||||
import { WebsocketClient } from "./websocketclient";
|
||||
@ -31,7 +30,7 @@ describe("RpcClient", () => {
|
||||
it("should also work with trailing slashes", async () => {
|
||||
pendingWithoutTendermint();
|
||||
|
||||
const statusRequest = createJsonRpcRequest(Method.Status);
|
||||
const statusRequest = createJsonRpcRequest("status");
|
||||
|
||||
const httpClient = new HttpClient(tendermintUrl + "/");
|
||||
expect(await httpClient.execute(statusRequest)).toBeDefined();
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { Uint53 } from "@cosmjs/math";
|
||||
import { toListPromise } from "@cosmjs/stream";
|
||||
import { Stream } from "xstream";
|
||||
|
||||
import { defaultInstance } from "../config.spec";
|
||||
import { Integer } from "../encodings";
|
||||
import { createJsonRpcRequest } from "../jsonrpc";
|
||||
import { Method } from "../requests";
|
||||
import { SubscriptionEvent } from "./rpcclient";
|
||||
import { WebsocketClient } from "./websocketclient";
|
||||
|
||||
@ -22,10 +21,10 @@ describe("WebsocketClient", () => {
|
||||
|
||||
const client = new WebsocketClient(tendermintUrl);
|
||||
|
||||
const healthResponse = await client.execute(createJsonRpcRequest(Method.Health));
|
||||
const healthResponse = await client.execute(createJsonRpcRequest("health"));
|
||||
expect(healthResponse.result).toEqual({});
|
||||
|
||||
const statusResponse = await client.execute(createJsonRpcRequest(Method.Status));
|
||||
const statusResponse = await client.execute(createJsonRpcRequest("status"));
|
||||
expect(statusResponse.result).toBeTruthy();
|
||||
expect(statusResponse.result.node_info).toBeTruthy();
|
||||
|
||||
@ -57,8 +56,9 @@ describe("WebsocketClient", () => {
|
||||
|
||||
if (events.length === 2) {
|
||||
// make sure they are consequtive heights
|
||||
const height = (i: number): number => Integer.parse(events[i].data.value.header.height);
|
||||
expect(height(1)).toEqual(height(0) + 1);
|
||||
const eventHeight = (index: number): number =>
|
||||
Uint53.fromString(events[index].data.value.header.height).toNumber();
|
||||
expect(eventHeight(1)).toEqual(eventHeight(0) + 1);
|
||||
|
||||
subscription.unsubscribe();
|
||||
|
||||
@ -132,7 +132,7 @@ describe("WebsocketClient", () => {
|
||||
});
|
||||
|
||||
client
|
||||
.execute(createJsonRpcRequest(Method.Status))
|
||||
.execute(createJsonRpcRequest("status"))
|
||||
.then((startusResponse) => expect(startusResponse).toBeTruthy())
|
||||
.catch(done.fail);
|
||||
});
|
||||
@ -165,12 +165,12 @@ describe("WebsocketClient", () => {
|
||||
|
||||
const client = new WebsocketClient(tendermintUrl);
|
||||
// dummy command to ensure client is connected
|
||||
await client.execute(createJsonRpcRequest(Method.Health));
|
||||
await client.execute(createJsonRpcRequest("health"));
|
||||
|
||||
client.disconnect();
|
||||
|
||||
await client
|
||||
.execute(createJsonRpcRequest(Method.Health))
|
||||
.execute(createJsonRpcRequest("health"))
|
||||
.then(() => fail("must not resolve"))
|
||||
.catch((error) => expect(error).toMatch(/socket has disconnected/i));
|
||||
});
|
||||
@ -182,7 +182,7 @@ describe("WebsocketClient", () => {
|
||||
(async () => {
|
||||
const client = new WebsocketClient(tendermintUrl);
|
||||
// dummy command to ensure client is connected
|
||||
await client.execute(createJsonRpcRequest(Method.Health));
|
||||
await client.execute(createJsonRpcRequest("health"));
|
||||
|
||||
client.disconnect();
|
||||
|
||||
@ -198,7 +198,7 @@ describe("WebsocketClient", () => {
|
||||
|
||||
const client = new WebsocketClient(tendermintUrl);
|
||||
|
||||
const req = createJsonRpcRequest(Method.Health);
|
||||
const req = createJsonRpcRequest("health");
|
||||
expect(() => client.listen(req)).toThrowError(/request method must be "subscribe"/i);
|
||||
|
||||
await client.connected();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user