cowprotocol / cowswap

🐮 CowSwap: First CoW Protocol UI
https://swap.cow.fi/
GNU General Public License v3.0
122 stars 92 forks source link

Possible to select the same token in the From to Fields #2708

Open elena-zh opened 1 year ago

elena-zh commented 1 year ago
  1. Open https://swap.cow.fi/#/1/swap/WETH/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2?sellAmount=1 (make sure that you are not connected to other networks in CoW Swap).
  2. Check the form

AR: the same token is displayed in the from/to fields (a token name and its address in the URL) image.png ER: impossible to pick the same token

baibhavKumar1 commented 1 year ago

Hey, looks like issue is already resolved. On trying to set same token in to and from input box , it's taking the token in one box and asking to select token in other one and if there are already two different tokens present , it's interchanging the value, not letting to keep same value in both box.

elena-zh commented 1 year ago

Hey, looks like issue is already resolved. On trying to set same token in to and from input box , it's taking the token in one box and asking to select token in other one and if there are already two different tokens present , it's interchanging the value, not letting to keep same value in both box.

Hey @Wholesomebruh , thank you for checking this. Unfortunately, the issue is still reproducible. Please, follow the exact steps in the issue description in order to reproduce it.

anxolin commented 1 week ago

Indeed there's an issue.

I think it only happens cause the check if its the same token or not is done based on the parameters of the URL https://github.com/cowprotocol/cowswap/blob/fix-issues-same-token/apps/cowswap-frontend/src/modules/trade/hooks/setupTradeState/useSetupTradeState.ts#L133

Ideally, we would convert that into an address for the check. The derived state shows WETH and 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 is the same thing. So I would suggest using that