-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
UnsupportedModal.tsx
64 lines (60 loc) · 2.25 KB
/
UnsupportedModal.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { useTranslation } from '@pancakeswap/localization'
import { Currency, Token } from '@pancakeswap/sdk'
import { AutoColumn, InjectedModalProps, Link, Modal, Text } from '@pancakeswap/uikit'
import { AutoRow } from 'components/Layout/Row'
import { CurrencyLogo } from 'components/Logo'
import { useActiveChainId } from 'hooks/useActiveChainId'
import { getBlockExploreLink } from 'utils'
import { wrappedCurrency } from 'utils/wrappedCurrency'
import { useUnsupportedTokens } from '../hooks/Tokens'
interface Props extends InjectedModalProps {
currencies: (Currency | undefined)[]
}
export const UnsupportedModal: React.FC<React.PropsWithChildren<Props>> = ({ currencies, onDismiss }) => {
const { chainId } = useActiveChainId()
const { t } = useTranslation()
const tokens =
chainId && currencies
? currencies.map((currency) => {
return wrappedCurrency(currency, chainId)
})
: []
const unsupportedTokens: { [address: string]: Token } = useUnsupportedTokens()
return (
<Modal title={t('Unsupported Assets')} onDismiss={onDismiss}>
<AutoColumn gap="lg">
{tokens.map((token) => {
return (
token &&
unsupportedTokens &&
Object.keys(unsupportedTokens).includes(token.address) && (
<AutoColumn key={token.address?.concat('not-supported')} gap="12px">
<AutoRow gap="5px" align="center">
<CurrencyLogo currency={token} size="24px" />
<Text>{token.symbol}</Text>
</AutoRow>
{chainId && (
<Link
external
small
color="primaryDark"
href={getBlockExploreLink(token.address, 'address', chainId)}
>
{token.address}
</Link>
)}
</AutoColumn>
)
)
})}
<AutoColumn gap="lg">
<Text>
{t(
'Some assets are not available through this interface because they may not work well with our smart contract or we are unable to allow trading for legal reasons.',
)}
</Text>
</AutoColumn>
</AutoColumn>
</Modal>
)
}