Skip to content

Commit

Permalink
fix token selected handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tienkane committed Nov 6, 2024
1 parent 92d3cd2 commit 3a2e562
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/pages/LiquidityWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ButtonPrimary } from 'components/Button'
import Input from 'components/Input'
import { NetworkSelector } from 'components/NetworkSelector'
import CurrencySearchModal from 'components/SearchModal/CurrencySearchModal'
import { ETHER_ADDRESS } from 'constants/index'
import { useActiveWeb3React } from 'hooks'
import { useChangeNetwork } from 'hooks/web3/useChangeNetwork'
import { useWalletModalToggle } from 'state/application/hooks'
Expand Down Expand Up @@ -50,21 +51,17 @@ export default function LiquidityWidget() {
const handleDismiss = () => setOpenTokenSelectModal(false)

const handleSelectToken = (token: any) => {
const selectedToken = token.wrapped ? { ...token, ...token.wrapped } : token
const selectedToken =
token.wrapped && !token.isNative ? { ...token, ...token.wrapped } : { ...token, address: ETHER_ADDRESS }
const tokens = initDepositTokens.split(',')
const indexOfToken = tokens.findIndex(t => t.toLowerCase() === selectedToken.address?.toLowerCase())
if (indexOfToken > -1) {
tokens.splice(indexOfToken, 1)
setInitDepositTokens(tokens.join(','))
const amounts = initAmounts.split(',')
amounts.splice(indexOfToken, 1)
setInitAmounts(amounts.join(','))
} else {
setInitDepositTokens(
initDepositTokens ? `${initDepositTokens},${selectedToken.address}` : `${selectedToken.address}`,
)
setInitAmounts(initAmounts ? `${initAmounts},` : '')
}

if (indexOfToken > -1) return
setInitDepositTokens(
initDepositTokens ? `${initDepositTokens},${selectedToken.address}` : `${selectedToken.address}`,
)
setInitAmounts(initAmounts ? `${initAmounts},` : '')

handleDismiss()
}

Expand Down

0 comments on commit 3a2e562

Please sign in to comment.