From 2b54f509dca2cf6ddb7a01e4b6a6ee174a117a2e Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 5 Mar 2024 12:00:51 +0000 Subject: [PATCH] fix(common): move prepare just before send tx (#2364) --- packages/common/src/sendTransaction.ts | 6 ++---- packages/common/src/writeContract.ts | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/common/src/sendTransaction.ts b/packages/common/src/sendTransaction.ts index b450f5c8d2..e9748ddc0a 100644 --- a/packages/common/src/sendTransaction.ts +++ b/packages/common/src/sendTransaction.ts @@ -52,17 +52,15 @@ export async function sendTransaction< account, } as CallParameters); - // TODO: estimate gas - return request; } - const preparedRequest = await prepare(); - return await nonceManager.mempoolQueue.add( () => pRetry( async () => { + const preparedRequest = await prepare(); + if (!nonceManager.hasNonce()) { await nonceManager.resetNonce(); } diff --git a/packages/common/src/writeContract.ts b/packages/common/src/writeContract.ts index 5ce34e5c24..99bce2b5e0 100644 --- a/packages/common/src/writeContract.ts +++ b/packages/common/src/writeContract.ts @@ -63,12 +63,12 @@ export async function writeContract< return result.request as unknown as WriteContractParameters; } - const preparedWrite = await prepareWrite(); - return nonceManager.mempoolQueue.add( () => pRetry( async () => { + const preparedWrite = await prepareWrite(); + if (!nonceManager.hasNonce()) { await nonceManager.resetNonce(); }