Skip to content

fix(swap): hide MetaMask version warning on mobile browsers - #7464

Merged
limitofzero merged 1 commit into
cowprotocol:developfrom
tenderdeve:fix/7462-hide-metamask-warning-mobile
May 7, 2026
Merged

limitofzero merged 1 commit into
cowprotocol:developfrom
tenderdeve:fix/7462-hide-metamask-warning-mobile

Conversation

@tenderdeve

@tenderdeve tenderdeve commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

The warning was incorrectly shown when using the MetaMask mobile app browser. The underlying bug only affects the desktop browser extension, not mobile. When web3_clientVersion returns null (as it can in the mobile context), isAffected falls back to the isMetamask flag which is true, causing the banner to show.
Skip the check entirely on mobile devices so the banner is only displayed for desktop browser extension users.

Fixes #7462

Summary

Fixes #7462

Added isMobile guard to useShouldDisplayMetamaskWarning so the MetaMask version check is skipped entirely on mobile devices.

To Test

  1. Open CoW Swap on a mobile device or in MetaMask's in-app browser
  • Warning banner should not appear when connected via MetaMask mobile
  • Warning banner should not appear when using MetaMask's built-in browser
  1. Open CoW Swap on desktop with MetaMask browser extension (version < 12.10.4)
  • Warning banner should still appear for affected desktop extension versions
  1. Open CoW Swap on desktop with MetaMask extension (version ≥ 12.10.4)
  • Warning banner should not appear

Background

The useShouldDisplayMetamaskWarning hook calls web3_clientVersion to detect the MetaMask extension version. On mobile, this RPC method can return null, which causes isAffected to be set to undefined. The fallback logic (isAffected === undefined ? isMetamask : isAffected) then evaluates to isMetamask = true, incorrectly showing the banner.

The fix adds isMobile (from @cowprotocol/common-utils, evaluated via UAParser at module load) as an early-exit condition — matching the xisting comment that "MM via SDK on mobile returns a Geth-style version string, not a MetaMask extension version."

Summary by CodeRabbit

  • Bug Fixes
    • Suppressed MetaMask transaction warnings on mobile devices to provide a smoother mobile trading experience.

The warning was incorrectly shown when using the MetaMask mobile
app browser. The underlying bug only affects the browser extension,
not mobile. When web3_clientVersion returns null (as it can in the
mobile context), isAffected falls back to the isMetamask flag which
is true, causing the banner to show.

Skip the check entirely on mobile devices so the banner is only
displayed for desktop browser extension users.

Fixes cowprotocol#7462
@vercel

vercel Bot commented May 7, 2026

Copy link
Copy Markdown

@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7c576450-e78c-4714-85c1-89834a8a8a6a

📥 Commits

Reviewing files that changed from the base of the PR and between 5e55c4b and 3064673.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/MetamaskTransactionWarning/index.tsx

Walkthrough

The Metamask transaction warning hook is updated to suppress the warning on mobile devices. A new isMobile import is added, and the effect guard logic checks for mobile status in addition to wallet client presence to short-circuit warning computation.

Changes

Mobile Metamask Warning Suppression

Layer / File(s) Summary
Mobile Detection Import
apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/MetamaskTransactionWarning/index.tsx
Import isMobile from @cowprotocol/common-utils to detect mobile environment.
Warning Guard Logic
apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/MetamaskTransactionWarning/index.tsx
The useShouldDisplayMetamaskWarning hook now checks isMobile in its early-exit condition, treating mobile as "not affected" and preventing version-check computation on mobile devices.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Mobile users hop with glee,
No warnings blocking their spree,
Metamask on the phone runs clean,
The smallest change, but oh, so keen! 📱✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: hiding the MetaMask version warning on mobile browsers.
Description check ✅ Passed The description follows the template with Summary, To Test, and Background sections; it provides clear context, reproduction steps, and testing instructions for both mobile and desktop scenarios.
Linked Issues check ✅ Passed The code changes address the linked issue #7462 by adding an isMobile guard to suppress the MetaMask warning on mobile devices, matching the expected behavior that the warning should only appear for desktop browser extensions.
Out of Scope Changes check ✅ Passed All changes are focused on suppressing the MetaMask warning on mobile devices; no unrelated modifications are present in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@tenderdeve

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 7, 2026
@vercel

vercel Bot commented May 7, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
swap-dev Ready Ready Preview May 7, 2026 9:05am

Request Review

@vercel
vercel Bot temporarily deployed to Preview – swap-dev May 7, 2026 09:05 Inactive

@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 @tenderdeve , thank you for addressing this issue

@elena-zh
elena-zh requested a review from a team May 7, 2026 11:23
@limitofzero
limitofzero merged commit c861fbd into cowprotocol:develop May 7, 2026
12 of 20 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026

This branch was previously deployed

1 inactive deployment
Preview – swap-dev — 30646735 Deployed May 7, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Metamask: hide warning banner for mobile versions

3 participants