Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use fresh swapState when updaring swapStateVar #73

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

agualis
Copy link
Collaborator

@agualis agualis commented Oct 16, 2024

We had this bug:

  1. Go to swaps page and select swap/gnosis/USDC/COW
  2. Manually update the url to swap/gnosis/xDAI/COW and hit ENTER
  3. Bug: the tokenIn remains USDC when it should be xDAI

The reason is that the functions that udpate swapStateVar were using swapState without making sure that it had the most recent updated value, causing different issues when performing consecutive updates like in:

    setInitialChain(chain)
    setInitialTokenIn(tokenIn)
    setInitialTokenOut(tokenOut)
    setInitialAmounts(amountIn, amountOut)

The solution is enforcing that swapState has the lastest updated value with const swapState = swapStateVar() before updating it again.

@agualis agualis self-assigned this Oct 16, 2024
Copy link

vercel bot commented Oct 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mono-frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 9:36am
mono-test-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 16, 2024 9:36am

Copy link
Contributor

@garethfuller garethfuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for fixing, it looks like it's fixed the network switch bug too.

@agualis agualis merged commit 5fe6d0d into main Oct 16, 2024
7 checks passed
@agualis agualis deleted the fix/swapReactiveInit branch October 16, 2024 10:05
@agualis agualis linked an issue Oct 16, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix swap deep links
2 participants