Skip to content

fix: handle unparseable tx responses from delegation wallets#2890

Merged
mgrabina merged 1 commit intomainfrom
fix/sendtx-wallet-compat
Mar 4, 2026
Merged

fix: handle unparseable tx responses from delegation wallets#2890
mgrabina merged 1 commit intomainfrom
fix/sendtx-wallet-compat

Conversation

@mgrabina
Copy link
Contributor

@mgrabina mgrabina commented Mar 4, 2026

Summary

  • Users with MetaMask Delegation Framework enabled are blocked from completing any on-chain transaction (approvals, swaps, repays, etc.)
  • ethers v5 fails to parse the transaction response because the nonce field is undefined in the RPC response routed through MetaMask's delegation transport
  • The transaction actually succeeds on-chain, but the UI shows an error and prevents the user from proceeding
  • Fix: catch the specific INVALID_ARGUMENT error with a transactionHash present and recover via waitForTransaction, returning a minimal TransactionResponse shim with .hash and .wait()

Root cause

MetaMask's Delegation Framework wraps user transactions through its DelegationManager contract (redeemDelegations). The wallet's RPC proxy returns responses where the nonce field is missing/undefined. ethers v5's Formatter.transactionResponse() calls BigNumber.from(undefined), which throws INVALID_ARGUMENT.

The same class of bug can affect Safe wallets (different cause, same error pattern).

Safety

  • Only triggers on error.code === 'INVALID_ARGUMENT' && error.transactionHash — the transactionHash field is only set by ethers v5 when the tx was actually sent
  • Checks receipt.status === 0 to properly surface reverted transactions
  • All 26 downstream sendTx callsites only use .hash and .wait() — no other TransactionResponse properties are accessed
  • Zero impact on normal EOA or existing SC wallet flows

Test plan

  • Verify normal EOA transactions (supply, borrow, repay, swap) still work on all networks
  • Test with a MetaMask Delegation Framework user on Base — approval and swap should complete without error
  • Test with a Safe wallet — transactions should complete without the nonce parsing error
  • Verify a reverted transaction still shows an error (not a false success)

🤖 Generated with Claude Code

MetaMask Delegation Framework (and similar SC wallets) can return
transaction responses where ethers v5 cannot parse fields like nonce,
causing an INVALID_ARGUMENT error even though the tx succeeded on-chain.

Recover by catching the specific error pattern (INVALID_ARGUMENT with
a transactionHash present) and falling back to waitForTransaction. The
shim checks receipt.status to properly surface reverted transactions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
interface Ready Ready Preview, Comment Mar 4, 2026 4:00pm

Request Review

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

📦 Next.js Bundle Analysis for aave-ui

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@mgrabina mgrabina merged commit 38081be into main Mar 4, 2026
14 of 21 checks passed
@mgrabina mgrabina deleted the fix/sendtx-wallet-compat branch March 4, 2026 23:08
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