Skip to content

Commit

Permalink
adjust ibcResponses timeouts and intervals
Browse files Browse the repository at this point in the history
  • Loading branch information
assafmo committed Jul 22, 2024
1 parent d36f49a commit 57c6fa7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"prepare": "pnpm run build",
"dev": "cross-env NODE_ENV=development babel-node src/index --extensions \".tsx,.ts,.js\"",
"watch": "cross-env NODE_ENV=development babel-watch src/index --extensions \".tsx,.ts,.js\"",
"lint": "eslint src --fix"
"lint": "eslint src --fix",
"ts:watch": "tsc -w"
},
"publishConfig": {
"access": "public"
Expand Down
16 changes: 8 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ export type IbcResponse = {
* Retrieves the IBC responses for a given transaction response, with options to customize the timeout and check interval for the IBC response transactions. If `txResponse.code = 0` and the transaction resulted in sending IBC packets, `getIbcResponse()` will return a list of IBC acknowledgement or timeout transactions which signal whether the original IBC packet was accepted, rejected or timed-out on the receiving chain.
*
* @param {object} txResponse - The transaction response object.
* @param {number} [resolveResponsesTimeoutMs=120000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 180000 (3 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=15000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 12000 (12 seconds).
* @param {number} [resolveResponsesTimeoutMs=180000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 180000 (3 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=12000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 12000 (12 seconds).
* @returns {Promise<object>} A list of IBC acknowledgement or timeout transactions which signal whether the original IBC packet was accepted, rejected or timed-out on the receiving chain.
*/
export function getTxIbcResponses(
stargateClient: StargateClient,
txResponse: DeliverTxResponse,
resolveResponsesTimeoutMs: number = 120000,
resolveResponsesCheckIntervalMs: number = 10000,
resolveResponsesTimeoutMs: number = 180000,
resolveResponsesCheckIntervalMs: number = 12000,
): Array<Promise<IbcResponse>> {
if (txResponse.code !== 0) {
return [];
Expand Down Expand Up @@ -362,8 +362,8 @@ export function getTxIbcResponses(
* @param {string} packetSequence - The sequence number of the original IBC packet.
* @param {string} packetSrcChannel - The source channel of the original IBC packet.
* @param {"ack" | "timeout"} [type="ack"] - The type of IBC response to search for.
* @param {number} [resolveResponsesTimeoutMs=120000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 120000 (2 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=15000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 15000 (15 seconds).
* @param {number} [resolveResponsesTimeoutMs=180000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 180000 (3 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=12000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 15000 (15 seconds).
* @param {{ isDone: boolean }} [isDoneObject={ isDone: false }] - An object to track if the search process has been completed.
* @returns {Promise<IbcResponse>} A promise that resolves with an IBC response object containing the type of response and the transaction details, or rejects with a timeout error if no response is found within the specified timeout.
*/
Expand All @@ -372,8 +372,8 @@ export async function findIbcResponse(
packetSequence: string,
packetSrcChannel: string,
type: "ack" | "timeout" = "ack",
resolveResponsesTimeoutMs: number = 120000,
resolveResponsesCheckIntervalMs: number = 15000,
resolveResponsesTimeoutMs: number = 180000,
resolveResponsesCheckIntervalMs: number = 12000,
isDoneObject: { isDone: boolean } = { isDone: false },
): Promise<IbcResponse> {
return new Promise(async (resolve, reject) => {
Expand Down
8 changes: 4 additions & 4 deletions types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export declare type IbcResponse = {
* Retrieves the IBC responses for a given transaction response, with options to customize the timeout and check interval for the IBC response transactions. If `txResponse.code = 0` and the transaction resulted in sending IBC packets, `getIbcResponse()` will return a list of IBC acknowledgement or timeout transactions which signal whether the original IBC packet was accepted, rejected or timed-out on the receiving chain.
*
* @param {object} txResponse - The transaction response object.
* @param {number} [resolveResponsesTimeoutMs=120000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 120000 (2 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=15000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 15000 (15 seconds).
* @param {number} [resolveResponsesTimeoutMs=180000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 180000 (3 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=12000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 12000 (12 seconds).
* @returns {Promise<object>} A list of IBC acknowledgement or timeout transactions which signal whether the original IBC packet was accepted, rejected or timed-out on the receiving chain.
*/
export declare function getTxIbcResponses(stargateClient: StargateClient, txResponse: DeliverTxResponse, resolveResponsesTimeoutMs?: number, resolveResponsesCheckIntervalMs?: number): Array<Promise<IbcResponse>>;
Expand All @@ -192,8 +192,8 @@ export declare function getTxIbcResponses(stargateClient: StargateClient, txResp
* @param {string} packetSequence - The sequence number of the original IBC packet.
* @param {string} packetSrcChannel - The source channel of the original IBC packet.
* @param {"ack" | "timeout"} [type="ack"] - The type of IBC response to search for.
* @param {number} [resolveResponsesTimeoutMs=120000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 120000 (2 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=15000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 15000 (15 seconds).
* @param {number} [resolveResponsesTimeoutMs=180000] - The timeout in milliseconds for waiting for IBC response txs to commit on-chain. Defaults to 180000 (3 minutes).
* @param {number} [resolveResponsesCheckIntervalMs=12000] - The interval in milliseconds between checks when waiting for IBC response txs to commit on-chain. Defaults to 15000 (15 seconds).
* @param {{ isDone: boolean }} [isDoneObject={ isDone: false }] - An object to track if the search process has been completed.
* @returns {Promise<IbcResponse>} A promise that resolves with an IBC response object containing the type of response and the transaction details, or rejects with a timeout error if no response is found within the specified timeout.
*/
Expand Down

0 comments on commit 57c6fa7

Please sign in to comment.