From eb03360b933c1182c325ea861b1de5514b4fcc4c Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Wed, 18 Mar 2020 00:27:48 +0100 Subject: [PATCH] Rename to RestClient.txById and move above search --- packages/sdk/src/cosmwasmclient.searchtx.spec.ts | 4 ++-- packages/sdk/src/restclient.spec.ts | 6 +++--- packages/sdk/src/restclient.ts | 16 ++++++++-------- packages/sdk/types/restclient.d.ts | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts index be9cd8b3..64d0edaa 100644 --- a/packages/sdk/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/sdk/src/cosmwasmclient.searchtx.spec.ts @@ -51,7 +51,7 @@ describe("CosmWasmClient.searchTx", () => { }; const result = await client.sendTokens(recipient, [transferAmount]); await sleep(50); // wait until tx is indexed - const txDetails = await new RestClient(wasmd.endpoint).txsById(result.transactionHash); + const txDetails = await new RestClient(wasmd.endpoint).txById(result.transactionHash); postedSend = { sender: faucet.address, recipient: recipient, @@ -71,7 +71,7 @@ describe("CosmWasmClient.searchTx", () => { }; const result = await client.execute(hashInstance, msg); await sleep(50); // wait until tx is indexed - const txDetails = await new RestClient(wasmd.endpoint).txsById(result.transactionHash); + const txDetails = await new RestClient(wasmd.endpoint).txById(result.transactionHash); postedExecute = { sender: faucet.address, contract: hashInstance, diff --git a/packages/sdk/src/restclient.spec.ts b/packages/sdk/src/restclient.spec.ts index 0c216d1e..2e1ff474 100644 --- a/packages/sdk/src/restclient.spec.ts +++ b/packages/sdk/src/restclient.spec.ts @@ -325,7 +325,7 @@ describe("RestClient", () => { // The /txs endpoints - describe("txsById", () => { + describe("txById", () => { let posted: | { readonly sender: string; @@ -363,7 +363,7 @@ describe("RestClient", () => { pendingWithoutWasmd(); assert(posted); const client = new RestClient(wasmd.endpoint); - const result = await client.txsById(posted.hash); + const result = await client.txById(posted.hash); expect(result.height).toBeGreaterThanOrEqual(1); expect(result.txhash).toEqual(posted.hash); const logs = parseLogs(result.logs); @@ -422,7 +422,7 @@ describe("RestClient", () => { const result = await client.sendTokens(recipient, transferAmount); await sleep(50); // wait until tx is indexed - const txDetails = await new RestClient(wasmd.endpoint).txsById(result.transactionHash); + const txDetails = await new RestClient(wasmd.endpoint).txById(result.transactionHash); posted = { sender: faucet.address, recipient: recipient, diff --git a/packages/sdk/src/restclient.ts b/packages/sdk/src/restclient.ts index e66b0906..9b12c95f 100644 --- a/packages/sdk/src/restclient.ts +++ b/packages/sdk/src/restclient.ts @@ -343,6 +343,14 @@ export class RestClient { // The /txs endpoints + public async txById(id: string): Promise { + const responseData = await this.get(`/txs/${id}`); + if (!(responseData as any).tx) { + throw new Error("Unexpected response data format"); + } + return responseData as TxsResponse; + } + public async txsQuery(query: string): Promise { const responseData = await this.get(`/txs?${query}`); if (!(responseData as any).txs) { @@ -351,14 +359,6 @@ export class RestClient { return responseData as SearchTxsResponse; } - public async txsById(id: string): Promise { - const responseData = await this.get(`/txs/${id}`); - if (!(responseData as any).tx) { - throw new Error("Unexpected response data format"); - } - return responseData as TxsResponse; - } - /** returns the amino-encoding of the transaction performed by the server */ public async encodeTx(tx: CosmosSdkTx): Promise { const responseData = await this.post("/txs/encode", tx); diff --git a/packages/sdk/types/restclient.d.ts b/packages/sdk/types/restclient.d.ts index 90a28789..97dda92a 100644 --- a/packages/sdk/types/restclient.d.ts +++ b/packages/sdk/types/restclient.d.ts @@ -196,8 +196,8 @@ export declare class RestClient { blocksLatest(): Promise; blocks(height: number): Promise; nodeInfo(): Promise; + txById(id: string): Promise; txsQuery(query: string): Promise; - txsById(id: string): Promise; /** returns the amino-encoding of the transaction performed by the server */ encodeTx(tx: CosmosSdkTx): Promise; /**