Commit 5a2f81c4 authored by eddie's avatar eddie Committed by GitHub

fix: show error message when token is not found (#6057)

* fix: show error message when token is not found

* fix: make onContinue optional
parent c34742c2
...@@ -4,7 +4,7 @@ import { ButtonPrimary } from 'components/Button' ...@@ -4,7 +4,7 @@ import { ButtonPrimary } from 'components/Button'
import { AutoColumn } from 'components/Column' import { AutoColumn } from 'components/Column'
import CurrencyLogo from 'components/Logo/CurrencyLogo' import CurrencyLogo from 'components/Logo/CurrencyLogo'
import TokenSafetyLabel from 'components/TokenSafety/TokenSafetyLabel' import TokenSafetyLabel from 'components/TokenSafety/TokenSafetyLabel'
import { checkWarning, getWarningCopy, TOKEN_SAFETY_ARTICLE, Warning } from 'constants/tokenSafety' import { checkWarning, getWarningCopy, TOKEN_SAFETY_ARTICLE, Warning, WARNING_LEVEL } from 'constants/tokenSafety'
import { useToken } from 'hooks/Tokens' import { useToken } from 'hooks/Tokens'
import { ExternalLink as LinkIconFeather } from 'react-feather' import { ExternalLink as LinkIconFeather } from 'react-feather'
import { Text } from 'rebass' import { Text } from 'rebass'
...@@ -77,7 +77,7 @@ const Buttons = ({ ...@@ -77,7 +77,7 @@ const Buttons = ({
showCancel, showCancel,
}: { }: {
warning: Warning warning: Warning
onContinue: () => void onContinue?: () => void
onCancel: () => void onCancel: () => void
onBlocked?: () => void onBlocked?: () => void
showCancel?: boolean showCancel?: boolean
...@@ -251,9 +251,13 @@ export default function TokenSafety({ ...@@ -251,9 +251,13 @@ export default function TokenSafety({
<Trans>Learn more</Trans> <Trans>Learn more</Trans>
</StyledExternalLink> </StyledExternalLink>
) )
const tokenNotFoundWarning = {
level: WARNING_LEVEL.UNKNOWN,
message: <Trans>Token not found</Trans>,
canProceed: false,
}
return ( return displayWarning ? (
displayWarning && (
<Wrapper> <Wrapper>
<Container> <Container>
<AutoColumn> <AutoColumn>
...@@ -277,6 +281,19 @@ export default function TokenSafety({ ...@@ -277,6 +281,19 @@ export default function TokenSafety({
/> />
</Container> </Container>
</Wrapper> </Wrapper>
) ) : (
<Wrapper>
<Container>
<ShortColumn>
<SafetyLabel warning={tokenNotFoundWarning} />
</ShortColumn>
<ShortColumn>
<InfoText>
{heading} {description} {learnMoreUrl}
</InfoText>
</ShortColumn>
<Buttons warning={tokenNotFoundWarning} onCancel={onCancel} showCancel={true} />
</Container>
</Wrapper>
) )
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment