Rename to RestClient.txById and move above search

This commit is contained in:
Simon Warta 2020-03-18 00:27:48 +01:00
parent 9b609d3c96
commit eb03360b93
4 changed files with 14 additions and 14 deletions

View File

@ -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,

View File

@ -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,

View File

@ -343,6 +343,14 @@ export class RestClient {
// The /txs endpoints
public async txById(id: string): Promise<TxsResponse> {
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<SearchTxsResponse> {
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<TxsResponse> {
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<Uint8Array> {
const responseData = await this.post("/txs/encode", tx);

View File

@ -196,8 +196,8 @@ export declare class RestClient {
blocksLatest(): Promise<BlockResponse>;
blocks(height: number): Promise<BlockResponse>;
nodeInfo(): Promise<NodeInfoResponse>;
txById(id: string): Promise<TxsResponse>;
txsQuery(query: string): Promise<SearchTxsResponse>;
txsById(id: string): Promise<TxsResponse>;
/** returns the amino-encoding of the transaction performed by the server */
encodeTx(tx: CosmosSdkTx): Promise<Uint8Array>;
/**