From 160fd14130f9112f3a1d88cbfb7d50fbb1c19883 Mon Sep 17 00:00:00 2001 From: Dhvani Patel Date: Sun, 22 Oct 2023 20:08:37 -0400 Subject: [PATCH] patch nonce issue with multiple mud worlds --- packages/common/src/createContract.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/common/src/createContract.ts b/packages/common/src/createContract.ts index 9eeff85445..7b9799fa9c 100644 --- a/packages/common/src/createContract.ts +++ b/packages/common/src/createContract.ts @@ -115,11 +115,11 @@ export function createContract< return await pRetry( async () => { - if (!nonceManager.hasNonce()) { - await nonceManager.resetNonce(); + if (!contract.nonceManager.hasNonce()) { + await contract.nonceManager.resetNonce(); } - const nonce = nonceManager.nextNonce(); + const nonce = contract.nonceManager.nextNonce(); debug("calling write function with nonce", nonce, preparedWrite); return await walletClient.writeContract({ nonce, @@ -130,9 +130,9 @@ export function createContract< retries: 3, onFailedAttempt: async (error) => { // On nonce errors, reset the nonce and retry - if (nonceManager.shouldResetNonce(error)) { + if (contract.nonceManager.shouldResetNonce(error)) { debug("got nonce error, retrying", error); - await nonceManager.resetNonce(); + await contract.nonceManager.resetNonce(); return; } // TODO: prepareWrite again if there are gas errors?