Skip to content

feat: allow EIP7702 wallets to batch transactions#7844

Open
kernelwhisperer wants to merge 2 commits into
refactor/wallet-capabilitiesfrom
feat/7702-batch-support
Open

feat: allow EIP7702 wallets to batch transactions#7844
kernelwhisperer wants to merge 2 commits into
refactor/wallet-capabilitiesfrom
feat/7702-batch-support

Conversation

@kernelwhisperer

@kernelwhisperer kernelwhisperer commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements https://linear.app/cowswap/issue/FE-265/batch-support-for-eoas-and-eip7702-delegated-eoas

Adds EIP-7702 batching capability detection while keeping TWAP restricted to Safe wallets.

  • Recognizes EIP-5792 atomic.status values supported and ready
  • Preserves legacy atomicBatch.supported detection
  • Removes the mobile WalletConnect capability-check bypass
  • For TWAP, it keeps Safe App support implicit; Safe via WalletConnect must report batching capabilities

To Test

  1. Connect a MetaMask account without Smart account set up
  • Enable in Settings -> Transactions -> Smart Transactions (should be on by default)
  • TWAP remains disabled & the unsupported-wallet warning appears
  • Swapping can batch approve & swap
Image
Screencast.From.2026-07-10.10-58-16.webm
  1. Connect a MetaMask account with Smart account set up
  • Enable in Settings -> Transactions -> Smart Transactions (should be on by default)
  • Enable in Accounts -> Smart Accounts -> Enable for a network
  • TWAP remains disabled & the unsupported-wallet warning appears
  • Swapping can batch approve & swap
Screencast.From.2026-07-10.10-59-24.webm
  1. Connect a SafeWallet through the Safe App
  • TWAP is available
  • No unsupported-wallet warning appears
  • Batching works in SWAP
  1. Connect a SafeWallet through WalletConnect
  • TWAP is available
  • No unsupported-wallet warning appears
  • Batching works in SWAP
  1. Connect an inactive (not yet deployed) SafeWallet through WalletConnect
  • TWAP is available
  • No unsupported-wallet warning appears
  • Batching works in SWAP
  1. Connect an Ambire wallet
  • TWAP remains disabled
  • The unsupported-wallet warning appears
  • Batching works in SWAP
  1. Connect a Rabby EOA wallet
  • Batching does not work in SWAP

Background

Capability detection is independent from TWAP wallet eligibility: this change recognizes EIP-7702 batching, but TWAP remains restricted to Safe wallets.

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
cowfi Ready Ready Preview Jul 10, 2026 11:58am
explorer-dev Canceled Canceled Jul 10, 2026 11:58am
sdk-tools Ready Ready Preview Jul 10, 2026 11:58am
storybook Ready Ready Preview Jul 10, 2026 11:58am
swap-dev Ready Ready Preview Jul 10, 2026 11:58am
widget-configurator Ready Ready Preview Jul 10, 2026 11:58am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored Jul 10, 2026 11:58am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bccf0e2e-8ac0-4930-adf8-42652bd7c89b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/7702-batch-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploying explorer-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 43f9906
Status: ✅  Deploy successful!
Preview URL: https://189fffe1.explorer-dev-dxz.pages.dev
Branch Preview URL: https://feat-7702-batch-support.explorer-dev-dxz.pages.dev

View logs

* WalletConnect in mobile browsers initiates a request with confirmation to the wallet
* to get the capabilities. It breaks the flow with perpetual requests.
*/
export async function getShouldSkipCapabilitiesCheck(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This function was removed in #7742 and replaced with a 5s timeout. It was reintroduced during conflict resolution.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploying swap-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 43f9906
Status: ✅  Deploy successful!
Preview URL: https://db03e14e.swap-dev-5u6.pages.dev
Branch Preview URL: https://feat-7702-batch-support.swap-dev-5u6.pages.dev

View logs

@linear-code

linear-code Bot commented Jul 10, 2026

Copy link
Copy Markdown

FE-265


logWallet.debug('Fetching wallet capabilities', { account, chainId })

// TODO remove this completely: it doesn't resolve capabilities for no wallet: MM, Safe, Ambire.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From my testing wagmi is useless, it never resolves capabilities...

@kernelwhisperer kernelwhisperer marked this pull request as ready for review July 10, 2026 12:16
@kernelwhisperer kernelwhisperer requested review from a team July 10, 2026 12:18
@kernelwhisperer kernelwhisperer self-assigned this Jul 10, 2026
@kernelwhisperer kernelwhisperer changed the title feat: allow 7702 wallet to batch support feat: allow EIP7702 wallets to batch transactions Jul 10, 2026

@elena-zh elena-zh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @kernelwhisperer , thank you.

Base smart account is working perfectly fine now.

What is not working/not working as expected:

  1. Safe+WC: bundling stopped working
Image
  1. MM smart account: now it does not use gasless transactions for placing orders with permittable tokens
Image
  1. MM+Smart account: impossible to place a ETH-flow order without wrapping
Image

4 MM+regular account (not smart one): impossible to sign a permit

Image
  1. MM+ regular account on Avalanche, Plasma, Ink (chains that do not support smart accounts): impossible to place an order with a gasless permit inside
Image

Could you please review this issues and fix them?

@fairlighteth fairlighteth self-requested a review July 10, 2026 15:02

@fairlighteth fairlighteth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ AI Review (Codex GPT-5, worked 25m): atomic batching can partially execute or use wrong-chain capabilities

Finding: [BLOCKING] Require atomic execution for ready wallets

  • Location: libs/wallet/src/api/state/walletCapabilitiesAtom.ts:177 and libs/wallet/src/api/hooks/useSendBatchTransactions.ts:36
  • This one is important: the PR accepts atomic.status === 'ready', but the sender omits forceAtomic.
  • viem defaults forceAtomic to false, producing atomicRequired: false. EIP-5792 then permits sequential execution and does not require a ready wallet to upgrade.
  • Approve/presign and wrap/approve/presign flows can partially execute, leaving allowances or wrapped funds behind, or activating a posted order after token preparation failed.
  • Security classification: verified-vulnerability, P2 (Medium). A targeted viem reproduction captured atomicRequired as [false, true] without and with forceAtomic.

Suggested fix

  • Pass forceAtomic: true from useSendBatchTransactions.
  • Add a boundary test asserting the resulting wallet_sendCalls.atomicRequired, including upgrade rejection and unsupported atomicity.

Finding: [BLOCKING] Do not reuse another chain's batching capability

  • Location: libs/wallet/src/api/state/walletCapabilitiesAtom.ts:35
  • resolveCapabilitiesForChain returns the first response entry when the active chain is absent. EIP-5792 states that atomic support is chain-specific and an absent chain means unsupported.
  • With ready now accepted, a Mainnet entry can incorrectly enable batching on Avalanche, Plasma, or Ink.
  • Commit 171de9b93 previously restricted this fallback to confirmed Safe-via-WalletConnect connections specifically to prevent non-Safe cross-chain false positives.

Suggested fix

  • Require the exact numeric/hex active-chain key for non-Safe wallets. Preserve a Safe-WC fallback only if it remains necessary.
  • Replace the current mismatched-chain test with assertions that non-Safe batching stays disabled.

Finding: [NON-BLOCKING] Keep batching-incompatible Safes out of compatible analytics

  • Location: apps/cowswap-frontend/src/modules/twap/containers/TwapFormWidget/index.tsx:132
  • The warning handles both unsupported states, but analytics now checks only WALLET_NOT_SUPPORTED.
  • A Safe-WC connection with failed capability detection remains TX_BUNDLING_NOT_SUPPORTED, then falls through to compatible or safe-that-could-be-converted even though TWAP is disabled.

Suggested fix

  • Handle both unsupported states before the fallback-handler branches, or add a distinct batching-unavailable event.
  • Add effect-level coverage for a Safe with batching disabled.
Review scope and related context
  • DeepSec PR mode ran against the exact PR file list: run 20260710151419-a335c60ae97dff7f, exit 1, artifact /tmp/deepsec-comment-pr-7844-review-2055455.md.
  • DeepSec confirmed the wrong-chain fallback. Its other two findings were pre-existing behavior outside this PR's changes.
  • The existing changes-requested review already covers Safe-WC, permit, gasless, ETH-flow, and unsupported-chain symptoms; those are not repeated here.
  • Targeted verification passed: 29 wallet tests, 4 TWAP tests, and changed-file ESLint.
  • The failing Cypress cases reproduce identically on the base branch and develop, so they are not attributable to this PR.
🤖 Prompt for AI agents
Verify these findings against PR 7844's current head.

1. Require atomic execution when `ready` enables batching and test the final wallet_sendCalls payload.
2. Reject non-Safe capability responses that omit the active chain.
3. Keep TX_BUNDLING_NOT_SUPPORTED out of compatible TWAP analytics.

Keep changes focused and rerun the wallet capability and TWAP tests.

Generated using the pr-review skill from the CoW Protocol skills repo.
Generated using the security-review skill from the CoW Protocol skills repo.

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