From 28442aa9226907ceb926287906cc14135aafd18e Mon Sep 17 00:00:00 2001 From: Hareesh Nagaraj Date: Thu, 3 Feb 2022 13:54:43 -0500 Subject: [PATCH] fix: enable maxRetries option to SendOptions (#22893) * Web3.js - enable maxRetries option to SendOptions * Prettier --- web3.js/src/connection.ts | 7 +++++++ web3.js/src/util/send-and-confirm-transaction.ts | 1 + 2 files changed, 8 insertions(+) diff --git a/web3.js/src/connection.ts b/web3.js/src/connection.ts index e55f4f4c53..7b55f16055 100644 --- a/web3.js/src/connection.ts +++ b/web3.js/src/connection.ts @@ -99,6 +99,8 @@ export type SendOptions = { skipPreflight?: boolean; /** preflight commitment level */ preflightCommitment?: Commitment; + /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */ + maxRetries?: number; }; /** @@ -111,6 +113,8 @@ export type ConfirmOptions = { commitment?: Commitment; /** preflight commitment level */ preflightCommitment?: Commitment; + /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */ + maxRetries?: number; }; /** @@ -3931,6 +3935,9 @@ export class Connection { const preflightCommitment = (options && options.preflightCommitment) || this.commitment; + if (options && options.maxRetries) { + config.maxRetries = options.maxRetries; + } if (skipPreflight) { config.skipPreflight = skipPreflight; } diff --git a/web3.js/src/util/send-and-confirm-transaction.ts b/web3.js/src/util/send-and-confirm-transaction.ts index 9070c221a1..9be26b58c6 100644 --- a/web3.js/src/util/send-and-confirm-transaction.ts +++ b/web3.js/src/util/send-and-confirm-transaction.ts @@ -24,6 +24,7 @@ export async function sendAndConfirmTransaction( const sendOptions = options && { skipPreflight: options.skipPreflight, preflightCommitment: options.preflightCommitment || options.commitment, + maxRetries: options.maxRetries, }; const signature = await connection.sendTransaction(