fix: align approval hooks and permit spender checks#7620
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. 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 |
Deploying explorer-dev with
|
| Latest commit: |
3567a3c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7c5677ad.explorer-dev-dxz.pages.dev |
| Branch Preview URL: | https://deepsec-medium-04-approval-p.explorer-dev-dxz.pages.dev |
Deploying swap-dev with
|
| Latest commit: |
3567a3c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9f018ca0.swap-dev-5u6.pages.dev |
| Branch Preview URL: | https://deepsec-medium-04-approval-p.swap-dev-5u6.pages.dev |
- key permit support caches by spender - bypass default pre-generated permit data for custom spenders - restore eth-flow approval typing so app checks pass
fairlighteth
left a comment
There was a problem hiding this comment.
✅ AI Review (Codex GPT-5, worked 4m): no new non-duplicate findings
Review completed. I found no new non-duplicate comments worth posting.
Review scope and related context
Related context checked:
usePermitInfo,permittableTokensAtom, andgetTokenPermitInfo: current code now keys permit support lookup/cache by spender and avoids reusing default pre-generated permit data for custom spenders.- Approval-gate call sites in classic approval, permit pre-generation, ETH-flow, and Safe bundle paths: current diff looks internally consistent with the updated PR description.
- Existing PR comments: only bot/deploy comments are present, so there were no active human review threads to de-duplicate against.



Summary
Addresses the MEDIUM approval/permit integrity findings in
cowswap-frontend.This PR makes the approval entry points behave consistently across classic, permit, ETH-flow, and Safe bundle paths:
onBeforeApprovalgate.To Test
pnpm exec jest --config apps/cowswap-frontend/jest.config.mjs --runInBand --runTestsByPath apps/cowswap-frontend/src/modules/erc20Approve/hooks/useApproveCurrency.test.ts apps/cowswap-frontend/src/modules/erc20Approve/hooks/useGeneratePermitInAdvanceToTrade.test.ts apps/cowswap-frontend/src/modules/permit/hooks/usePermitInfo.test.tspasses.pnpm exec nx run permit-utils:test --runInBand --runTestsByPath libs/permit-utils/src/lib/generatePermitHook.test.ts libs/permit-utils/src/lib/getTokenPermitInfo.test.tspasses.pnpm exec tsc --noEmit -p apps/cowswap-frontend/tsconfig.app.jsonpasses.pnpm exec tsc --noEmit -p libs/permit-utils/tsconfig.lib.jsonpasses.onBeforeApproval, confirm the hook fires before the approval proceeds.onBeforeApproval, confirm the approval flow stops in each path.Background
The report found several variants of the same problem: different approval paths had drifted apart, so widget hooks and spender assumptions were not applied uniformly.
This PR pulls those paths back toward one approval boundary and makes both permit generation and permitability checks spender-aware.