Avoid throwing error when transaction ID does not exist
Before we got "Error: Tx: RPC error -32603 - Internal error: tx (0000000000000000000000000000000000000000000000000000000000000000) not found"
This commit is contained in:
parent
297910039a
commit
fd725998c6
@ -202,6 +202,14 @@ describe("CosmWasmClient", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("can search by ID (non existent)", async () => {
|
||||
pendingWithoutCosmos();
|
||||
const client = CosmWasmClient.makeReadOnly(httpUrl);
|
||||
const nonExistentId = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
const result = await client.searchTx({ id: nonExistentId });
|
||||
expect(result.length).toEqual(0);
|
||||
});
|
||||
|
||||
it("can search by height", async () => {
|
||||
pendingWithoutCosmos();
|
||||
assert(posted, "value must be set in beforeAll()");
|
||||
|
||||
@ -164,7 +164,7 @@ export class CosmWasmClient {
|
||||
}
|
||||
|
||||
if (isSearchByIdQuery(query)) {
|
||||
return [await this.restClient.txsById(query.id)];
|
||||
return (await this.restClient.txs(`tx.hash=${query.id}`)).txs;
|
||||
} else if (isSearchByHeightQuery(query)) {
|
||||
return (await this.restClient.txs(`tx.height=${query.height}`)).txs;
|
||||
} else if (isSearchBySentFromOrToQuery(query)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user