Skip to content

Conversation

@arcoraven
Copy link
Contributor

@arcoraven arcoraven commented Dec 6, 2024

PR-Codex overview

This PR focuses on simplifying error handling related to nonce usage and insufficient funds in the transaction process. It refines error checks and modifies the logic for handling insufficient funds, ensuring clearer responses and better nonce management.

Detailed summary

  • Updated isNonceAlreadyUsedError to use direct string checks instead of an array.
  • Simplified isInsufficientFundsError to check for a single phrase.
  • Refactored _sendTransaction to improve handling of insufficient funds and nonce recycling.
  • Added deleteNoncesForBackendWallets call to reset nonce state when funds are insufficient.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}


export const isNonceAlreadyUsedError = (error: unknown) => {
const message = _parseMessage(error);
const errorPhrases = ["nonce too low", "already known"];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup, no logical change

Comment on lines +360 to +362
if (value === 0n) {
await deleteNoncesForBackendWallets([{ chainId, walletAddress: from }]);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change. If a transaction received an "insufficient funds" error from RPC and no value was provided, this wallet must be low on gas. Reset the nonce so the onchain nonce doesn't remain out of sync.

} satisfies ErroredTransaction;
}

if (isNonceAlreadyUsedError(error) || isReplacementGasFeeTooLow(error)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just moving this below the "out of funds" block above. No logic changes.

@arcoraven arcoraven closed this Dec 11, 2024
@arcoraven arcoraven deleted the ph/deleteNoncesIfOutOfFunds branch December 11, 2024 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants