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: fix not found issue and convert&revert issue #249

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ const DepositBase = ({
pricePerFullShare,
setInputAmount,
token,
supTokenList,
switchMethod,
tokenSymbol,
useIFARM,
Expand Down Expand Up @@ -339,9 +338,8 @@ const DepositBase = ({
toast.error('Please choose your Output Token.')
return
}
const supToken = supTokenList.find(el => el.symbol === pickedToken.symbol)
if (!hasPortalsError && !supToken) {
toast.error("Can't Deposit with Unsupported token!")
if (!hasPortalsError) {
toast.error('There was an error on Portals Service!')
return
}
if (new BigNumber(inputAmount).isGreaterThan(new BigNumber(balance))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const SelectTokenList = ({
}) => {
const { fontColor, fontColor2, hoverColor, activeColorModal } = useThemeContext()
const [showList, setShowList] = useState(false)
const [curSupportedVault, setCurSupportedVault] = useState(supportedVault)
const { chainId } = useWallet()
const { getPortalsToken } = usePortals()

Expand Down Expand Up @@ -76,7 +77,9 @@ const SelectTokenList = ({
if (supTokenNoBalanceList && balanceList && filterWord !== undefined && filterWord !== '') {
const ethereumAddressRegex = /^(0x)?[0-9a-fA-F]{40}$/
if (ethereumAddressRegex.test(filterWord)) {
let TokenDetail = {}
let TokenDetail = {},
defaultTokenInvolve = false,
balanceListInvolve = false
try {
TokenDetail = (await getPortalsToken(chainId, filterWord)) || {}
} catch (e) {
Expand All @@ -94,8 +97,10 @@ const SelectTokenList = ({
}
}
if (Object.keys(TokenDetail).length !== 0) {
setCurSupportedVault(true)
if (!(Object.keys(defaultToken).length === 0 && defaultToken.constructor === Object)) {
if (defaultToken.symbol.includes(TokenDetail.symbol.toLowerCase().trim())) {
defaultTokenInvolve = true
setDefaultCurToken(defaultToken)
} else {
setDefaultCurToken(null)
Expand All @@ -105,6 +110,9 @@ const SelectTokenList = ({
const newList = balanceList.filter(el =>
el.symbol.toLowerCase().includes(TokenDetail.symbol.toLowerCase().trim()),
)
if (newList.length > 0) {
balanceListInvolve = true
}
setBalanceTokenList(newList)
}
if (defaultCurToken === null) {
Expand All @@ -116,6 +124,16 @@ const SelectTokenList = ({
} else {
setSupTokenList([])
}
if (supTokenNoBalanceList.length !== 0 && !defaultTokenInvolve && !balanceListInvolve) {
const newList = supTokenNoBalanceList.filter(el =>
el.symbol.toLowerCase().includes(TokenDetail.symbol.toLowerCase().trim()),
)
if (newList.length > 0) {
setSupTokenList(newList)
} else {
setSupTokenList([TokenDetail])
}
}
} else {
setSupTokenList([])
if (!(Object.keys(defaultToken).length === 0 && defaultToken.constructor === Object)) {
Expand Down Expand Up @@ -152,7 +170,7 @@ const SelectTokenList = ({
}
}
fetch()
}, [filterWord, supTokenNoBalanceList, balanceList, chainId]) // eslint-disable-line react-hooks/exhaustive-deps
}, [filterWord, supTokenNoBalanceList, balanceList, chainId, setCurSupportedVault]) // eslint-disable-line react-hooks/exhaustive-deps

useEffect(() => {
const count =
Expand Down Expand Up @@ -205,16 +223,16 @@ const SelectTokenList = ({
{!hasPortalsError && balanceTokenList.length > 0 && (
<>
<Label fontColor={fontColor} padding="15px 24px 0px">
{supportedVault ? 'Supported tokens in your wallet' : 'Soon to be supported'}
{curSupportedVault ? 'Supported tokens in your wallet' : 'Soon to be supported'}
</Label>
{balanceTokenList.map((data, i) => (
<Container
key={i}
className={i === clickBalanceListId ? 'active' : ''}
onClick={() => {
if (supportedVault) handleBalanceListClick(i)
if (curSupportedVault) handleBalanceListClick(i)
}}
cursor={supportedVault ? 'pointer' : 'not-allowed'}
cursor={curSupportedVault ? 'pointer' : 'not-allowed'}
hoverColor={hoverColor}
activeColor={activeColorModal}
>
Expand All @@ -239,9 +257,9 @@ const SelectTokenList = ({
<Label
fontColor={fontColor}
padding="15px 24px 0px"
showLabel={supportedVault ? 'block' : 'none'}
showLabel={curSupportedVault ? 'block' : 'none'}
>
{supportedVault
{curSupportedVault
? `Other supported convert tokens, which you don't have on your wallet`
: `Other, currently unsupported tokens, which you don't have in your wallet`}
</Label>
Expand All @@ -250,9 +268,9 @@ const SelectTokenList = ({
key={i}
className={i === clicksupTokenNoBalanceListId ? 'active' : ''}
onClick={() => {
if (supportedVault) handleSupTokenNoBalanceListClick(i)
if (curSupportedVault) handleSupTokenNoBalanceListClick(i)
}}
cursor={supportedVault ? 'pointer' : 'not-allowed'}
cursor={curSupportedVault ? 'pointer' : 'not-allowed'}
hoverColor={hoverColor}
activeColor={activeColorModal}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const SelectTokenList = ({
}) => {
const { fontColor, fontColor2, hoverColor, activeColorModal } = useThemeContext()
const [showList, setShowList] = useState(false)
const [curSupportedVault, setCurSupportedVault] = useState(supportedVault)
const { chainId } = useWallet()
const { getPortalsToken } = usePortals()

Expand Down Expand Up @@ -64,7 +65,9 @@ const SelectTokenList = ({
if (supTokenNoBalanceList && balanceList && filterWord !== undefined && filterWord !== '') {
const ethereumAddressRegex = /^(0x)?[0-9a-fA-F]{40}$/
if (ethereumAddressRegex.test(filterWord)) {
let TokenDetail = {}
let TokenDetail = {},
defaultTokenInvolve = false,
balanceListInvolve = false
try {
TokenDetail = (await getPortalsToken(chainId, filterWord)) || {}
} catch (e) {
Expand All @@ -82,8 +85,10 @@ const SelectTokenList = ({
}
}
if (Object.keys(TokenDetail).length !== 0) {
setCurSupportedVault(true)
if (!(Object.keys(defaultToken).length === 0 && defaultToken.constructor === Object)) {
if (defaultToken.symbol.includes(TokenDetail.symbol.toLowerCase().trim())) {
defaultTokenInvolve = true
setDefaultCurToken(defaultToken)
} else {
setDefaultCurToken(null)
Expand All @@ -93,6 +98,9 @@ const SelectTokenList = ({
const newList = balanceList.filter(el =>
el.symbol.toLowerCase().includes(TokenDetail.symbol.toLowerCase().trim()),
)
if (newList.length > 0) {
balanceListInvolve = true
}
setBalanceTokenList(newList)
}
if (defaultCurToken === null) {
Expand All @@ -104,6 +112,16 @@ const SelectTokenList = ({
} else {
setSupTokenList([])
}
if (supTokenNoBalanceList.length !== 0 && !defaultTokenInvolve && !balanceListInvolve) {
const newList = supTokenNoBalanceList.filter(el =>
el.symbol.toLowerCase().includes(TokenDetail.symbol.toLowerCase().trim()),
)
if (newList.length > 0) {
setSupTokenList(newList)
} else {
setSupTokenList([TokenDetail])
}
}
} else {
setSupTokenList([])
if (!(Object.keys(defaultToken).length === 0 && defaultToken.constructor === Object)) {
Expand Down Expand Up @@ -196,7 +214,7 @@ const SelectTokenList = ({
{!hasPortalsError && balanceTokenList.length > 0 && (
<>
<Label fontColor={fontColor} padding="15px 24px 0px">
{supportedVault
{curSupportedVault
? 'Tokens in your wallet which you can revert fTokens into'
: 'Soon to be supported'}
</Label>
Expand All @@ -205,9 +223,9 @@ const SelectTokenList = ({
key={i}
className={i === clickBalanceListId ? 'active' : ''}
onClick={() => {
if (supportedVault) handleBalanceListClick(i)
if (curSupportedVault) handleBalanceListClick(i)
}}
cursor={supportedVault ? 'pointer' : 'not-allowed'}
cursor={curSupportedVault ? 'pointer' : 'not-allowed'}
hoverColor={hoverColor}
activeColor={activeColorModal}
>
Expand Down Expand Up @@ -238,7 +256,7 @@ const SelectTokenList = ({
<Label
fontColor={fontColor}
padding="15px 24px 0px"
showLabel={supportedVault ? 'block' : 'none'}
showLabel={curSupportedVault ? 'block' : 'none'}
>
Other supported tokens, which you can revert to{' '}
</Label>
Expand All @@ -247,9 +265,9 @@ const SelectTokenList = ({
key={i}
className={i === clicksupTokenNoBalanceListId ? 'active' : ''}
onClick={() => {
if (supportedVault) handleSupTokenNoBalanceListClick(i)
if (curSupportedVault) handleSupTokenNoBalanceListClick(i)
}}
cursor={supportedVault ? 'pointer' : 'not-allowed'}
cursor={curSupportedVault ? 'pointer' : 'not-allowed'}
hoverColor={hoverColor}
activeColor={activeColorModal}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const WithdrawBase = ({
lpTokenBalance,
stakedAmount,
token,
supTokenList,
switchMethod,
useIFARM,
setRevertFromInfoAmount,
Expand Down Expand Up @@ -317,9 +316,8 @@ const WithdrawBase = ({
toast.error('Please choose your Output Token.')
return
}
const supToken = supTokenList.find(el => el.symbol === pickedToken.symbol)
if (!hasPortalsError && !supToken) {
toast.error("Can't revert with Unsupported token!")
if (!hasPortalsError) {
toast.error('There was an error on Portals Service!')
return
}

Expand Down
Loading