Skip to content

Commit 3f6ebd8

Browse files
committed
Make .create constructors non-async
This is a braking follow-up to #1380
1 parent e4b94b2 commit 3f6ebd8

File tree

8 files changed

+116
-119
lines changed

8 files changed

+116
-119
lines changed

packages/cosmwasm-stargate/src/cosmwasmclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class CosmWasmClient {
105105
* Creates an instance from a manually created Comet client.
106106
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
107107
*/
108-
public static async create(cometClient: CometClient): Promise<CosmWasmClient> {
108+
public static create(cometClient: CometClient): CosmWasmClient {
109109
return new CosmWasmClient(cometClient);
110110
}
111111

packages/stargate/src/stargateclient.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ export class StargateClient {
221221
* Creates an instance from a manually created Comet client.
222222
* Use this to use `Comet38Client` or `Tendermint37Client` instead of `Tendermint34Client`.
223223
*/
224-
public static async create(
225-
cometClient: CometClient,
226-
options: StargateClientOptions = {},
227-
): Promise<StargateClient> {
224+
public static create(cometClient: CometClient, options: StargateClientOptions = {}): StargateClient {
228225
return new StargateClient(cometClient, options);
229226
}
230227

packages/tendermint-rpc/src/comet38/comet38client.spec.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
2525
describe("create", () => {
2626
it("can auto-discover Tendermint version and communicate", async () => {
2727
pendingWithoutTendermint();
28-
const client = await Comet38Client.create(rpcFactory());
28+
const client = Comet38Client.create(rpcFactory());
2929
const info = await client.abciInfo();
3030
expect(info).toBeTruthy();
3131
client.disconnect();
3232
});
3333

3434
it("can connect to Tendermint with known version", async () => {
3535
pendingWithoutTendermint();
36-
const client = await Comet38Client.create(rpcFactory());
36+
const client = Comet38Client.create(rpcFactory());
3737
expect(await client.abciInfo()).toBeTruthy();
3838
client.disconnect();
3939
});
4040
});
4141

4242
it("can get genesis", async () => {
4343
pendingWithoutTendermint();
44-
const client = await Comet38Client.create(rpcFactory());
44+
const client = Comet38Client.create(rpcFactory());
4545
const genesis = await client.genesis();
4646
expect(genesis).toBeTruthy();
4747
client.disconnect();
@@ -50,7 +50,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
5050
describe("broadcastTxCommit", () => {
5151
it("can broadcast a transaction", async () => {
5252
pendingWithoutTendermint();
53-
const client = await Comet38Client.create(rpcFactory());
53+
const client = Comet38Client.create(rpcFactory());
5454
const tx = buildKvTx(randomString(), randomString());
5555

5656
const response = await client.broadcastTxCommit({ tx: tx });
@@ -70,7 +70,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
7070
describe("broadcastTxSync", () => {
7171
it("can broadcast a transaction", async () => {
7272
pendingWithoutTendermint();
73-
const client = await Comet38Client.create(rpcFactory());
73+
const client = Comet38Client.create(rpcFactory());
7474
const tx = buildKvTx(randomString(), randomString());
7575

7676
const response = await client.broadcastTxSync({ tx: tx });
@@ -86,7 +86,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
8686
describe("broadcastTxAsync", () => {
8787
it("can broadcast a transaction", async () => {
8888
pendingWithoutTendermint();
89-
const client = await Comet38Client.create(rpcFactory());
89+
const client = Comet38Client.create(rpcFactory());
9090
const tx = buildKvTx(randomString(), randomString());
9191

9292
const response = await client.broadcastTxAsync({ tx: tx });
@@ -98,7 +98,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
9898

9999
it("gets the same tx hash from backend as calculated locally", async () => {
100100
pendingWithoutTendermint();
101-
const client = await Comet38Client.create(rpcFactory());
101+
const client = Comet38Client.create(rpcFactory());
102102
const tx = buildKvTx(randomString(), randomString());
103103
const calculatedTxHash = hashTx(tx);
104104

@@ -111,7 +111,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
111111
describe("abciQuery", () => {
112112
it("can query the state", async () => {
113113
pendingWithoutTendermint();
114-
const client = await Comet38Client.create(rpcFactory());
114+
const client = Comet38Client.create(rpcFactory());
115115

116116
const key = randomString();
117117
const value = randomString();
@@ -137,7 +137,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
137137

138138
it("can get a commit", async () => {
139139
pendingWithoutTendermint();
140-
const client = await Comet38Client.create(rpcFactory());
140+
const client = Comet38Client.create(rpcFactory());
141141
const response = await client.commit(4);
142142

143143
expect(response).toBeTruthy();
@@ -152,7 +152,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
152152

153153
it("can get validators", async () => {
154154
pendingWithoutTendermint();
155-
const client = await Comet38Client.create(rpcFactory());
155+
const client = Comet38Client.create(rpcFactory());
156156
const response = await client.validators({});
157157

158158
expect(response).toBeTruthy();
@@ -170,7 +170,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
170170

171171
it("can get all validators", async () => {
172172
pendingWithoutTendermint();
173-
const client = await Comet38Client.create(rpcFactory());
173+
const client = Comet38Client.create(rpcFactory());
174174
const response = await client.validatorsAll();
175175

176176
expect(response).toBeTruthy();
@@ -188,7 +188,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
188188

189189
it("can call a bunch of methods", async () => {
190190
pendingWithoutTendermint();
191-
const client = await Comet38Client.create(rpcFactory());
191+
const client = Comet38Client.create(rpcFactory());
192192

193193
expect(await client.block()).toBeTruthy();
194194
expect(await client.genesis()).toBeTruthy();
@@ -200,7 +200,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
200200
describe("status", () => {
201201
it("works", async () => {
202202
pendingWithoutTendermint();
203-
const client = await Comet38Client.create(rpcFactory());
203+
const client = Comet38Client.create(rpcFactory());
204204

205205
const status = await client.status();
206206

@@ -241,7 +241,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
241241
describe("numUnconfirmedTxs", () => {
242242
it("works", async () => {
243243
pendingWithoutTendermint();
244-
const client = await Comet38Client.create(rpcFactory());
244+
const client = Comet38Client.create(rpcFactory());
245245

246246
const response = await client.numUnconfirmedTxs();
247247

@@ -255,7 +255,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
255255
describe("blockResults", () => {
256256
it("works", async () => {
257257
pendingWithoutTendermint();
258-
const client = await Comet38Client.create(rpcFactory());
258+
const client = Comet38Client.create(rpcFactory());
259259

260260
const height = 3;
261261
const results = await client.blockResults(height);
@@ -270,7 +270,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
270270
describe("blockSearch", () => {
271271
beforeAll(async () => {
272272
if (tendermintEnabled()) {
273-
const client = await Comet38Client.create(rpcFactory());
273+
const client = Comet38Client.create(rpcFactory());
274274

275275
// eslint-disable-next-line no-inner-declarations
276276
async function sendTx(): Promise<void> {
@@ -295,7 +295,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
295295

296296
it("can paginate over blockSearch results", async () => {
297297
pendingWithoutTendermint();
298-
const client = await Comet38Client.create(rpcFactory());
298+
const client = Comet38Client.create(rpcFactory());
299299

300300
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
301301

@@ -314,7 +314,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
314314

315315
it("can get all search results in one call", async () => {
316316
pendingWithoutTendermint();
317-
const client = await Comet38Client.create(rpcFactory());
317+
const client = Comet38Client.create(rpcFactory());
318318

319319
const query = buildQuery({ raw: "block.height >= 1 AND block.height <= 3" });
320320

@@ -333,7 +333,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
333333
describe("blockchain", () => {
334334
it("returns latest in descending order by default", async () => {
335335
pendingWithoutTendermint();
336-
const client = await Comet38Client.create(rpcFactory());
336+
const client = Comet38Client.create(rpcFactory());
337337

338338
// Run in parallel to increase chance there is no block between the calls
339339
const [status, blockchain] = await Promise.all([client.status(), client.blockchain()]);
@@ -350,7 +350,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
350350

351351
it("can limit by maxHeight", async () => {
352352
pendingWithoutTendermint();
353-
const client = await Comet38Client.create(rpcFactory());
353+
const client = Comet38Client.create(rpcFactory());
354354

355355
const height = (await client.status()).syncInfo.latestBlockHeight;
356356
const blockchain = await client.blockchain(undefined, height - 1);
@@ -364,7 +364,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
364364

365365
it("works with maxHeight in the future", async () => {
366366
pendingWithoutTendermint();
367-
const client = await Comet38Client.create(rpcFactory());
367+
const client = Comet38Client.create(rpcFactory());
368368

369369
const height = (await client.status()).syncInfo.latestBlockHeight;
370370
const blockchain = await client.blockchain(undefined, height + 20);
@@ -379,7 +379,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
379379

380380
it("can limit by minHeight and maxHeight", async () => {
381381
pendingWithoutTendermint();
382-
const client = await Comet38Client.create(rpcFactory());
382+
const client = Comet38Client.create(rpcFactory());
383383

384384
const height = (await client.status()).syncInfo.latestBlockHeight;
385385
const blockchain = await client.blockchain(height - 2, height - 1);
@@ -393,7 +393,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
393393

394394
it("contains all the info", async () => {
395395
pendingWithoutTendermint();
396-
const client = await Comet38Client.create(rpcFactory());
396+
const client = Comet38Client.create(rpcFactory());
397397

398398
const height = (await client.status()).syncInfo.latestBlockHeight;
399399
const blockchain = await client.blockchain(height - 1, height - 1);
@@ -422,7 +422,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
422422
describe("tx", () => {
423423
it("can query a tx properly", async () => {
424424
pendingWithoutTendermint();
425-
const client = await Comet38Client.create(rpcFactory());
425+
const client = Comet38Client.create(rpcFactory());
426426

427427
const find = randomString();
428428
const me = randomString();
@@ -462,7 +462,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
462462

463463
beforeAll(async () => {
464464
if (tendermintEnabled()) {
465-
const client = await Comet38Client.create(rpcFactory());
465+
const client = Comet38Client.create(rpcFactory());
466466

467467
// eslint-disable-next-line no-inner-declarations
468468
async function sendTx(): Promise<[Uint8Array, responses.BroadcastTxCommitResponse]> {
@@ -490,7 +490,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
490490
it("finds a single tx by hash", async () => {
491491
pendingWithoutTendermint();
492492
assert(tx1 && broadcast1);
493-
const client = await Comet38Client.create(rpcFactory());
493+
const client = Comet38Client.create(rpcFactory());
494494

495495
const result = await client.txSearch({ query: `tx.hash='${toHex(broadcast1.hash)}'` });
496496
expect(result.txs.length).toEqual(1);
@@ -512,7 +512,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
512512

513513
it("finds a single tx by tags", async () => {
514514
pendingWithoutTendermint();
515-
const client = await Comet38Client.create(rpcFactory());
515+
const client = Comet38Client.create(rpcFactory());
516516

517517
const txKey2 = randomString();
518518
const txValue2 = randomString();
@@ -562,7 +562,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
562562
// Code 0.35: https://github.com/tendermint/tendermint/blob/v0.35.6/internal/rpc/core/tx.go#L93
563563
// Code 0.37: https://github.com/cometbft/cometbft/blob/v0.37.0-rc3/rpc/core/tx.go#L87
564564
pendingWithoutTendermint();
565-
const client = await Comet38Client.create(rpcFactory());
565+
const client = Comet38Client.create(rpcFactory());
566566

567567
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
568568

@@ -579,7 +579,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
579579

580580
it("can set the order", async () => {
581581
pendingWithoutTendermint();
582-
const client = await Comet38Client.create(rpcFactory());
582+
const client = Comet38Client.create(rpcFactory());
583583

584584
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
585585

@@ -594,7 +594,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
594594

595595
it("can paginate over txSearch results", async () => {
596596
pendingWithoutTendermint();
597-
const client = await Comet38Client.create(rpcFactory());
597+
const client = Comet38Client.create(rpcFactory());
598598

599599
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
600600

@@ -613,7 +613,7 @@ function defaultTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValues)
613613

614614
it("can get all search results in one call", async () => {
615615
pendingWithoutTendermint();
616-
const client = await Comet38Client.create(rpcFactory());
616+
const client = Comet38Client.create(rpcFactory());
617617

618618
const query = buildQuery({ tags: [{ key: "app.key", value: txKey }] });
619619

@@ -637,7 +637,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
637637

638638
(async () => {
639639
const events: responses.NewBlockHeaderEvent[] = [];
640-
const client = await Comet38Client.create(rpcFactory());
640+
const client = Comet38Client.create(rpcFactory());
641641
const stream = client.subscribeNewBlockHeader();
642642
expect(stream).toBeTruthy();
643643
const subscription = stream.subscribe({
@@ -696,7 +696,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
696696
const transactionData2 = buildKvTx(randomString(), randomString());
697697

698698
const events: responses.NewBlockEvent[] = [];
699-
const client = await Comet38Client.create(rpcFactory());
699+
const client = Comet38Client.create(rpcFactory());
700700
const stream = client.subscribeNewBlock();
701701
const subscription = stream.subscribe({
702702
next: (event) => {
@@ -755,7 +755,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
755755
pendingWithoutTendermint();
756756

757757
const events: responses.TxEvent[] = [];
758-
const client = await Comet38Client.create(rpcFactory());
758+
const client = Comet38Client.create(rpcFactory());
759759
const stream = client.subscribeTx();
760760
const subscription = stream.subscribe({
761761
next: (event) => {
@@ -799,7 +799,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
799799
const transactionData2 = buildKvTx(randomString(), randomString());
800800

801801
const events: responses.TxEvent[] = [];
802-
const client = await Comet38Client.create(rpcFactory());
802+
const client = Comet38Client.create(rpcFactory());
803803
const query = buildQuery({ tags: [{ key: "app.creator", value: expected.appCreator }] });
804804
const stream = client.subscribeTx(query);
805805
expect(stream).toBeTruthy();
@@ -837,7 +837,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
837837
it("can unsubscribe and re-subscribe to the same stream", async () => {
838838
pendingWithoutTendermint();
839839

840-
const client = await Comet38Client.create(rpcFactory());
840+
const client = Comet38Client.create(rpcFactory());
841841
const stream = client.subscribeNewBlockHeader();
842842

843843
const event1 = await firstEvent(stream);
@@ -870,7 +870,7 @@ function websocketTestSuite(rpcFactory: () => RpcClient, expected: ExpectedValue
870870
it("can subscribe twice", async () => {
871871
pendingWithoutTendermint();
872872

873-
const client = await Comet38Client.create(rpcFactory());
873+
const client = Comet38Client.create(rpcFactory());
874874
const stream1 = client.subscribeNewBlockHeader();
875875
const stream2 = client.subscribeNewBlockHeader();
876876

packages/tendermint-rpc/src/comet38/comet38client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class Comet38Client {
5050
/**
5151
* Creates a new Tendermint client given an RPC client.
5252
*/
53-
public static async create(rpcClient: RpcClient): Promise<Comet38Client> {
53+
public static create(rpcClient: RpcClient): Comet38Client {
5454
return new Comet38Client(rpcClient);
5555
}
5656

0 commit comments

Comments
 (0)