forked from pancakeswap/pancake-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnsupportedCurrencyFooter.tsx
85 lines (78 loc) · 2.91 KB
/
UnsupportedCurrencyFooter.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { Currency, Token } from '@pancakeswap/sdk'
import { Button, Text, Modal, useModal, InjectedModalProps, Link } from '@pancakeswap/uikit'
import { useTranslation } from 'contexts/Localization'
import styled from 'styled-components'
import { AutoRow } from 'components/Layout/Row'
import { AutoColumn } from 'components/Layout/Column'
import { CurrencyLogo } from 'components/Logo'
import useActiveWeb3React from 'hooks/useActiveWeb3React'
import { getBscScanLink } from 'utils'
import { wrappedCurrency } from 'utils/wrappedCurrency'
import { useUnsupportedTokens } from '../hooks/Tokens'
interface Props extends InjectedModalProps {
currencies: (Currency | undefined)[]
}
const DetailsFooter = styled.div`
padding: 8px 0;
width: 100%;
max-width: 400px;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
color: ${({ theme }) => theme.colors.text};
background-color: ${({ theme }) => theme.colors.invertedContrast};
text-align: center;
`
const UnsupportedModal: React.FC<Props> = ({ currencies, onDismiss }) => {
const { chainId } = useActiveWeb3React()
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')} maxWidth="420px" 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="10px">
<AutoRow gap="5px" align="center">
<CurrencyLogo currency={token} size="24px" />
<Text>{token.symbol}</Text>
</AutoRow>
{chainId && (
<Link external small color="primaryDark" href={getBscScanLink(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>
)
}
export default function UnsupportedCurrencyFooter({ currencies }: { currencies: (Currency | undefined)[] }) {
const { t } = useTranslation()
const [onPresentModal] = useModal(<UnsupportedModal currencies={currencies} />)
return (
<DetailsFooter>
<Button variant="text" onClick={onPresentModal}>
{t('Read more about unsupported assets')}
</Button>
</DetailsFooter>
)
}