Fix: Prevented infinity swap tx sending on user rejection#204
Fix: Prevented infinity swap tx sending on user rejection#204Andrew718PLTS merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
PR Overview
This PR fixes an issue where a rejected swap transaction could result in an infinite loop by adding a reference flag (swapRejectedRef) to prevent resubmission after a user rejection.
- Introduces a swapRejectedRef to track user rejections and prevent duplicate swap transactions.
- Updates the success toast message wording for clarity.
- Adjusts the useEffect condition to include the swap rejection flag.
Reviewed Changes
| File | Description |
|---|---|
| src/features/swap/SwapConfirm.tsx | Added a swapRejectedRef check in the useEffect to block further txs |
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
nvtaveras
left a comment
There was a problem hiding this comment.
Tested it on the preview and works fine for me. I was wondering tho, do you know why this doesn't happen for the approval tx? If I reject the initial approval the popup doesn't come up again. Why is it different for the swap?
|
@nvtaveras It was triggering the swap TX repeatedly because of the |

Description
It prevents infinity swap tx sending on user rejection by adding the
swapRejectedRefsetting when it's been rejected by the user (checking via error message).Additionally, to read:
The
useStatedoesn't work in this case because the React state updates asynchronously, so useEffect does not immediately pick up the change in isSwapRejected during the first rejection (that's why I had a case when the first rejection is ignored).Other changes
None
Tested
Reject when there's an approval and a swap TXs.
Reject when there's no approval TX.
Related issues
Checklist before requesting a review