Add StargateClient
This commit is contained in:
parent
a8d8a0dfc2
commit
d393adf31a
@ -1,5 +0,0 @@
|
||||
describe("dummy", () => {
|
||||
it("has at least one test", () => {
|
||||
expect(2).toEqual(2);
|
||||
});
|
||||
});
|
||||
@ -0,0 +1 @@
|
||||
export { StargateClient } from "./stargateclient";
|
||||
13
packages/stargate/src/stargateclient.spec.ts
Normal file
13
packages/stargate/src/stargateclient.spec.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { StargateClient } from "./stargateclient";
|
||||
import { pendingWithoutSimapp, simapp } from "./testutils.spec";
|
||||
|
||||
describe("StargateClient", () => {
|
||||
describe("connect", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutSimapp();
|
||||
const client = await StargateClient.connect(simapp.tendermintUrl);
|
||||
expect(client).toBeTruthy();
|
||||
client.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
18
packages/stargate/src/stargateclient.ts
Normal file
18
packages/stargate/src/stargateclient.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Client as TendermintClient } from "@cosmjs/tendermint-rpc";
|
||||
|
||||
export class StargateClient {
|
||||
private readonly tmClient: TendermintClient;
|
||||
|
||||
public static async connect(endpoint: string): Promise<StargateClient> {
|
||||
const tmClient = await TendermintClient.connect(endpoint);
|
||||
return new StargateClient(tmClient);
|
||||
}
|
||||
|
||||
private constructor(tmClient: TendermintClient) {
|
||||
this.tmClient = tmClient;
|
||||
}
|
||||
|
||||
public disconnect(): void {
|
||||
this.tmClient.disconnect();
|
||||
}
|
||||
}
|
||||
10
packages/stargate/src/testutils.spec.ts
Normal file
10
packages/stargate/src/testutils.spec.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export function pendingWithoutSimapp(): void {
|
||||
if (!process.env.SIMAPP_ENABLED) {
|
||||
return pending("Set SIMAPP_ENABLED to enable Simapp based tests");
|
||||
}
|
||||
}
|
||||
|
||||
export const simapp = {
|
||||
tendermintUrl: "localhost:26657",
|
||||
chainId: "simd-testing",
|
||||
};
|
||||
1
packages/stargate/types/index.d.ts
vendored
1
packages/stargate/types/index.d.ts
vendored
@ -0,0 +1 @@
|
||||
export { StargateClient } from "./stargateclient";
|
||||
6
packages/stargate/types/stargateclient.d.ts
vendored
Normal file
6
packages/stargate/types/stargateclient.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
export declare class StargateClient {
|
||||
private readonly tmClient;
|
||||
static connect(endpoint: string): Promise<StargateClient>;
|
||||
private constructor();
|
||||
disconnect(): void;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user