Skip to content

Viem Migration - wc safe wallet reject approval long error#7478

Closed
brunota20 wants to merge 3 commits into
developfrom
bruno/cow-923-vault-wc-wallet-reject-approval-long-error
Closed

Viem Migration - wc safe wallet reject approval long error#7478
brunota20 wants to merge 3 commits into
developfrom
bruno/cow-923-vault-wc-wallet-reject-approval-long-error

Conversation

@brunota20
Copy link
Copy Markdown
Collaborator

Summary

Fixes
https://www.notion.so/cownation/Safe-WC-iOS-app-reject-approval-long-error-34c8da5f04ca8041998de02db4e10dde?v=2fc8da5f04ca81ada4ca000c320d51ef&source=copy_link

When rejecting an approval transaction in Safe iOS wallet via WalletConnect, the user sees a long, verbose error message containing raw request arguments
(addresses, data, gas, function signatures) instead of a clean rejection message.

This PR improves rejection detection and error display for viem-wrapped errors.

To Test

  1. Connect to CoW Swap using Safe iOS app via WalletConnect
  • Initiate an approve TX
  • Reject signing the TX in the wallet
  • Verify the error shown is "User rejected approval transaction" instead of a long RPC error with request arguments
  1. Verify other wallet rejection flows still work
  • Reject an approval with MetaMask — should show "User rejected approval transaction"
  • Reject a swap/signing with any wallet — should show clean rejection message

Background

Viem wraps provider errors in ContractFunctionExecutionError which includes all request arguments in error.message. The previous rejection detection had two
issues:

  1. Cause chain traversal was gated on instanceof Error — viem/WalletConnect can nest plain objects in the cause chain, which were not traversed
  2. Viem's details property was not checked — viem stores the original provider error message in error.details, which may contain the rejection signal

As a safety net, the error display now uses viem's error.shortMessage (which omits request arguments) instead of error.message for non-rejection errors.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

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

Project Deployment Actions Updated (UTC)
cowfi Building Building Preview May 14, 2026 11:03am
explorer-dev Ready Ready Preview May 14, 2026 11:03am
storybook Ready Ready Preview May 14, 2026 11:03am
swap-dev Building Building Preview May 14, 2026 11:03am
widget-configurator Ready Ready Preview May 14, 2026 11:03am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored May 14, 2026 11:03am
sdk-tools Ignored Ignored Preview May 14, 2026 11:03am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Important

Review skipped

Draft detected.

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: 93da54e7-f521-44bf-bf72-b3feba6e7309

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 bruno/cow-923-vault-wc-wallet-reject-approval-long-error

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.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 11, 2026

Deploying swap-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 16f47ab
Status:🚫  Build failed.

View logs

@elena-zh
Copy link
Copy Markdown
Contributor

Closing the PR for now as the reported issue is reproducible with deprecated wallets.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants