From 44114e9304406d46268a4d4a2a54d91f666a739d Mon Sep 17 00:00:00 2001 From: ducphamle2 Date: Fri, 16 Aug 2024 16:45:51 -0700 Subject: [PATCH 1/2] backport: add http timeout & more data decode tx resp --- packages/tendermint-rpc/src/rpcclients/http.ts | 7 ++++++- .../tendermint-rpc/src/tendermint34/adaptor/responses.ts | 1 + .../tendermint-rpc/src/tendermint37/adaptor/responses.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/tendermint-rpc/src/rpcclients/http.ts b/packages/tendermint-rpc/src/rpcclients/http.ts index 1d389504bd..0bc9849afe 100644 --- a/packages/tendermint-rpc/src/rpcclients/http.ts +++ b/packages/tendermint-rpc/src/rpcclients/http.ts @@ -40,9 +40,14 @@ export async function http( headers: Record | undefined, request?: any, ): Promise { + const timeout = Number( + //@ts-ignore + process.env.HTTP_TIMEOUT || 30000, + ); if (typeof fetch === "function" && !isExperimental(fetch)) { const settings = { method: method, + signal: timeout, body: request ? JSON.stringify(request) : undefined, headers: { // eslint-disable-next-line @typescript-eslint/naming-convention @@ -55,7 +60,7 @@ export async function http( .then((res: any) => res.json()); } else { return axios - .request({ url: url, method: method, data: request, headers: headers }) + .request({ url: url, method: method, data: request, headers: headers, timeout }) .then((res) => res.data); } } diff --git a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts index bc8d2051b3..2bbd3d1d0a 100644 --- a/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts +++ b/packages/tendermint-rpc/src/tendermint34/adaptor/responses.ts @@ -723,6 +723,7 @@ interface RpcTxResponse { function decodeTxResponse(data: RpcTxResponse): responses.TxResponse { return { + ...data, tx: fromBase64(assertNotEmpty(data.tx)), result: decodeTxData(assertObject(data.tx_result)), height: apiToSmallInt(assertNotEmpty(data.height)), diff --git a/packages/tendermint-rpc/src/tendermint37/adaptor/responses.ts b/packages/tendermint-rpc/src/tendermint37/adaptor/responses.ts index 8db6e3cb38..c694550259 100644 --- a/packages/tendermint-rpc/src/tendermint37/adaptor/responses.ts +++ b/packages/tendermint-rpc/src/tendermint37/adaptor/responses.ts @@ -724,6 +724,7 @@ interface RpcTxResponse { function decodeTxResponse(data: RpcTxResponse): responses.TxResponse { return { + ...data, tx: fromBase64(assertNotEmpty(data.tx)), result: decodeTxData(assertObject(data.tx_result)), height: apiToSmallInt(assertNotEmpty(data.height)), From e3b8e691a4ff83034cfecb2ddfbe54ddb3a817e4 Mon Sep 17 00:00:00 2001 From: ducphamle2 Date: Fri, 16 Aug 2024 17:12:37 -0700 Subject: [PATCH 2/2] feat: also return more data from tx in searchTx --- packages/stargate/src/stargateclient.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/stargate/src/stargateclient.ts b/packages/stargate/src/stargateclient.ts index e463a2e326..9782930b6c 100644 --- a/packages/stargate/src/stargateclient.ts +++ b/packages/stargate/src/stargateclient.ts @@ -510,6 +510,7 @@ export class StargateClient { return results.txs.map((tx): IndexedTx => { const txMsgData = TxMsgData.decode(tx.result.data ?? new Uint8Array()); return { + ...tx, height: tx.height, txIndex: tx.index, hash: toHex(tx.hash).toUpperCase(),