Repository navigation
fix(swap): hide MetaMask version warning on mobile browsers - #7464
limitofzero merged 1 commit into
Conversation
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
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
All contributors have signed the CLA ✍️ ✅ |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Metamask transaction warning hook is updated to suppress the warning on mobile devices. A new ChangesMobile Metamask Warning Suppression
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
I have read the CLA Document and I hereby sign the CLA |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
elena-zh
left a comment
There was a problem hiding this comment.
Hey @tenderdeve , thank you for addressing this issue
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_clientVersionreturns null (as it can in the mobile context),isAffectedfalls back to theisMetamaskflag 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
isMobileguard touseShouldDisplayMetamaskWarningso the MetaMask version check is skipped entirely on mobile devices.To Test
Background
The
useShouldDisplayMetamaskWarninghook callsweb3_clientVersionto detect the MetaMask extension version. On mobile, this RPC method can returnnull, which causesisAffectedto be set toundefined. The fallback logic (isAffected === undefined ? isMetamask : isAffected) then evaluates toisMetamask = 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