Skip to content

Commit

Permalink
patch nonce issue with multiple mud worlds
Browse files Browse the repository at this point in the history
  • Loading branch information
dhvanipa committed Oct 23, 2023
1 parent cb22d2b commit 160fd14
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/common/src/createContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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?
Expand Down

0 comments on commit 160fd14

Please sign in to comment.