fix(zero-approval): stop logging expected USDT approve revert as an error - #7775
Conversation
…rror shouldZeroApprove detects USDT-style tokens (which require resetting the allowance to zero before setting a new one) by simulating the approve and catching the revert. That revert is expected, but it was logged via console.error with the full viem BaseError, flooding the console with a scary red stack on every sell-amount change. Log the expected first-pass revert as a quiet console.debug breadcrumb and the genuinely-unexpected zero-amount revert as a console.warn, using only the error's shortMessage instead of the whole multi-line viem error.
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
Cloudflare Pages preview mirror Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7775 Source fork branch:
|
Summary
Fixes #7547
shouldZeroApprovefigures out whether a token needs its allowance reset to zero first (USDT and friends) by simulating theapproveand catching the revert. That revert is expected — it's the whole detection mechanism — but it was logged withconsole.error(e)whereeis the full viemBaseError, so the console filled with a scary red stack (viem docs links, version, etc.) on every sell-amount change.Now the expected first-pass revert is a quiet
console.debugbreadcrumb, and the genuinely-unexpected case (the zero-amount approve also reverting) is aconsole.warn. Both log only the error'sshortMessageinstead of the whole multi-line viem error.To Test
shouldZeroApprove #1 errorstack with the viem error dump.debugbreadcrumb; the zero-approval flow still works (USDT still prompts the reset-to-zero step).Background
The expected-revert path fires reactively on every keystroke via the zero-approval warning hook, so the noisy log was especially spammy.