Skip to content

Commit

Permalink
feat: hide disclaimer token for erc20 standard
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Oct 3, 2023
1 parent 7213438 commit e62093d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/pages/AddLiquidity/TokenPair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,11 @@ const TokenPair = ({
</Warning>
)}

<DisclaimerERC20 href="https://docs.kyberswap.com/liquidity-solutions/kyberswap-elastic/user-guides/add-liquidity-to-an-existing-elastic-pool#non-standard-tokens" />
<DisclaimerERC20
href="https://docs.kyberswap.com/liquidity-solutions/kyberswap-elastic/user-guides/add-liquidity-to-an-existing-elastic-pool#non-standard-tokens"
token0={currencyIdB}
token1={currencyIdA}
/>

<div style={{ marginBottom: '1.5rem' }} />

Expand Down
27 changes: 26 additions & 1 deletion src/pages/AddLiquidityV2/components/DisclaimerERC20.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
import { Trans } from '@lingui/macro'
import { AlertTriangle } from 'react-feather'
import { Flex, Text } from 'rebass'
import { useGetTokenListQuery } from 'services/ksSetting'

import { WarningCard } from 'components/Card'
import { useActiveWeb3React } from 'hooks'
import useTheme from 'hooks/useTheme'
import { ExternalLink } from 'theme'

export default function DisclaimerERC20({ href }: { href?: string }) {
export default function DisclaimerERC20({ href, token0, token1 }: { href?: string; token0: string; token1: string }) {
const theme = useTheme()
const { chainId } = useActiveWeb3React()
const { data: data0 } = useGetTokenListQuery(
{
chainId,
query: token0,
},
{
skip: !token0 || !token1,
},
)
const { data: data1 } = useGetTokenListQuery(
{
chainId,
query: token1,
},
{
skip: !token0 || !token1,
},
)

const hide = data0?.data?.tokens?.[0].isStandardERC20 && data1?.data?.tokens?.[0].isStandardERC20
if (hide) return null

return (
<WarningCard padding="10px 16px">
<Flex alignItems="center" sx={{ gap: '12px' }} lineHeight={1.5}>
Expand Down
8 changes: 5 additions & 3 deletions src/pages/AddLiquidityV2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1629,9 +1629,11 @@ export default function AddLiquidity() {
<Flex>{warnings}</Flex>
</Row>
)}
<Flex maxWidth={chartRef?.current?.clientWidth} alignSelf="flex-end">
<DisclaimerERC20 />
</Flex>
{tokenA && tokenB && (
<Flex maxWidth={chartRef?.current?.clientWidth} alignSelf="flex-end">
<DisclaimerERC20 token0={tokenA.address} token1={tokenB.address} />
</Flex>
)}

<Row justify="flex-end">
<Buttons />
Expand Down
6 changes: 5 additions & 1 deletion src/pages/CreatePool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,11 @@ export default function CreatePool() {
</Warning>
)}

<DisclaimerERC20 href="https://docs.kyberswap.com/liquidity-solutions/kyberswap-classic/user-guides/classic-pool-creation#non-standard-tokens" />
<DisclaimerERC20
href="https://docs.kyberswap.com/liquidity-solutions/kyberswap-classic/user-guides/classic-pool-creation#non-standard-tokens"
token0={currencyIdA || ''}
token1={currencyIdB || ''}
/>

{!account ? (
<ButtonLight onClick={toggleWalletModal}>
Expand Down
2 changes: 1 addition & 1 deletion src/services/ksSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const ksSettingApi = createApi({

getTokenList: builder.query<
TokenListResponse,
{ chainId: number; page?: number; pageSize?: number; isWhitelisted?: boolean; isStable?: boolean }
{ chainId: number; page?: number; pageSize?: number; isWhitelisted?: boolean; isStable?: boolean; query?: string }
>({
query: ({ chainId, ...params }) => ({
url: `/tokens`,
Expand Down
1 change: 1 addition & 0 deletions src/state/lists/wrappedTokenInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface TokenInfo {
readonly isWhitelisted?: boolean // from backend
readonly multichainInfo?: MultiChainTokenInfo // from multichain api
readonly domainSeparator?: string
readonly isStandardERC20?: boolean
}

export class WrappedTokenInfo extends Token {
Expand Down

0 comments on commit e62093d

Please sign in to comment.