Commit 35d39840 authored by ianlapham's avatar ianlapham

add import to token search

parent 217a7008
...@@ -40,6 +40,9 @@ export const ButtonPrimary = styled(Base)` ...@@ -40,6 +40,9 @@ export const ButtonPrimary = styled(Base)`
background-color: ${({ theme }) => theme.outlineGrey}; background-color: ${({ theme }) => theme.outlineGrey};
color: ${({ theme }) => theme.darkGrey} color: ${({ theme }) => theme.darkGrey}
cursor: auto; cursor: auto;
outline: none;
border: none;
box-shadow: none;
} }
` `
......
import React, { useState } from 'react' import React, { useState } from 'react'
import styled from 'styled-components'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { JSBI } from '@uniswap/sdk' import { JSBI } from '@uniswap/sdk'
...@@ -8,18 +7,18 @@ import { useToken } from '../../contexts/Tokens' ...@@ -8,18 +7,18 @@ import { useToken } from '../../contexts/Tokens'
import { useExchange } from '../../contexts/Exchanges' import { useExchange } from '../../contexts/Exchanges'
import { useAddressBalance } from '../../contexts/Balances' import { useAddressBalance } from '../../contexts/Balances'
import { LightCard } from '../../components/Card' import { LightCard } from '../Card'
import PositionCard from '../../components/PositionCard' import PositionCard from '../PositionCard'
import SearchModal from '../../components/SearchModal' import SearchModal from '../SearchModal'
import Row from '../../components/Row' import Row from '../Row'
import { Link } from '../../theme' import { Link } from '../../theme'
import { Text } from 'rebass' import { Text } from 'rebass'
import { AutoColumn, ColumnCenter } from '../../components/Column' import { AutoColumn, ColumnCenter } from '../Column'
import { Plus } from 'react-feather' import { Plus } from 'react-feather'
import { ButtonPrimary, ButtonDropwdown, ButtonDropwdownLight } from '../../components/Button' import { ButtonPrimary, ButtonDropwdown, ButtonDropwdownLight } from '../Button'
import TokenLogo from '../TokenLogo' import TokenLogo from '../TokenLogo'
function TokenFind({ history }) { function PoolFinder({ history }) {
const Fields = { const Fields = {
TOKEN0: 0, TOKEN0: 0,
TOKEN1: 1 TOKEN1: 1
...@@ -124,7 +123,13 @@ function TokenFind({ history }) { ...@@ -124,7 +123,13 @@ function TokenFind({ history }) {
<LightCard padding="45px"> <LightCard padding="45px">
<AutoColumn gap="8px" justify="center"> <AutoColumn gap="8px" justify="center">
<Text color="">No exchange found.</Text> <Text color="">No exchange found.</Text>
<Link>Create exchange instead.</Link> <Link
onClick={() => {
history.push('/add/' + token0Address + '-' + token1Address)
}}
>
Create exchange instead.
</Link>
</AutoColumn> </AutoColumn>
</LightCard> </LightCard>
) : ( ) : (
...@@ -160,4 +165,4 @@ function TokenFind({ history }) { ...@@ -160,4 +165,4 @@ function TokenFind({ history }) {
) )
} }
export default withRouter(TokenFind) export default withRouter(PoolFinder)
import React, { useState, useRef, useMemo, useEffect } from 'react' import React, { useState, useRef, useMemo, useEffect } from 'react'
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Link as StyledLink } from '../../theme/components'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import styled from 'styled-components' import styled from 'styled-components'
...@@ -126,6 +127,8 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens ...@@ -126,6 +127,8 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens
// all balances for both account and exchanges // all balances for both account and exchanges
let allBalances = useAllBalances() let allBalances = useAllBalances()
const [sortDirection, setSortDirection] = useState(true)
const tokenList = useMemo(() => { const tokenList = useMemo(() => {
return Object.keys(allTokens) return Object.keys(allTokens)
.sort((a, b) => { .sort((a, b) => {
...@@ -138,6 +141,22 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens ...@@ -138,6 +141,22 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens
return aSymbol === bSymbol ? 0 : aSymbol === 'ETH'.toLowerCase() ? -1 : 1 return aSymbol === bSymbol ? 0 : aSymbol === 'ETH'.toLowerCase() ? -1 : 1
} }
// sort by balance
const balanceA = allBalances?.[account]?.[a]
const balanceB = allBalances?.[account]?.[b]
if (balanceA && !balanceB) {
return sortDirection
}
if (!balanceA && balanceB) {
return sortDirection * -1
}
if (balanceA && balanceB) {
return sortDirection * parseFloat(balanceA.toExact()) > parseFloat(balanceB.toExact()) ? -1 : 1
}
// sort alphabetically // sort alphabetically
return aSymbol < bSymbol ? -1 : aSymbol > bSymbol ? 1 : 0 return aSymbol < bSymbol ? -1 : aSymbol > bSymbol ? 1 : 0
} else { } else {
...@@ -159,7 +178,7 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens ...@@ -159,7 +178,7 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens
balance: balance balance: balance
} }
}) })
}, [allTokens, hiddenToken, allBalances, account]) }, [allTokens, allBalances, account, sortDirection, hiddenToken])
const filteredTokenList = useMemo(() => { const filteredTokenList = useMemo(() => {
return tokenList.filter(tokenEntry => { return tokenList.filter(tokenEntry => {
...@@ -215,7 +234,6 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens ...@@ -215,7 +234,6 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens
BALANCES: 'BALANCES' BALANCES: 'BALANCES'
} }
const [activeFilter, setActiveFilter] = useState(FILTERS.BALANCES) const [activeFilter, setActiveFilter] = useState(FILTERS.BALANCES)
const [sortDirection, setSortDirection] = useState(true)
// sort tokens // sort tokens
const escapeStringRegexp = string => string const escapeStringRegexp = string => string
...@@ -392,7 +410,18 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens ...@@ -392,7 +410,18 @@ function SearchModal({ history, isOpen, onDismiss, onTokenSelect, urlAddedTokens
onChange={onInput} onChange={onInput}
/> />
<RowBetween> <RowBetween>
<div /> <div>
<Text>
Don't see a pool?{' '}
<StyledLink
onClick={() => {
history.push('/find')
}}
>
Import it.
</StyledLink>
</Text>
</div>
<div /> <div />
<Filter title="Your Balances" filter={FILTERS.BALANCES} /> <Filter title="Your Balances" filter={FILTERS.BALANCES} />
</RowBetween> </RowBetween>
......
...@@ -9,10 +9,10 @@ import { ChainId, WETH, Token, TokenAmount, Exchange, JSBI } from '@uniswap/sdk' ...@@ -9,10 +9,10 @@ import { ChainId, WETH, Token, TokenAmount, Exchange, JSBI } from '@uniswap/sdk'
const UPDATE = 'UPDATE' const UPDATE = 'UPDATE'
const ALL_EXCHANGES: [Token, Token][] = [ const ALL_EXCHANGES: [Token, Token][] = [
// [ [
// INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY][WETH[ChainId.RINKEBY].address], INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY][WETH[ChainId.RINKEBY].address],
// INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735'] INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735']
// ], ]
// [ // [
// INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735'], // INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735'],
// INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0x8ab15C890E5C03B5F240f2D146e3DF54bEf3Df44'] // INITIAL_TOKENS_CONTEXT[ChainId.RINKEBY]['0x8ab15C890E5C03B5F240f2D146e3DF54bEf3Df44']
...@@ -172,7 +172,7 @@ export function useTotalSupply(exchange: Exchange) { ...@@ -172,7 +172,7 @@ export function useTotalSupply(exchange: Exchange) {
} }
}) })
.catch(e => { .catch(e => {
console.log('error') console.log(e)
}) })
/** /**
* @todo * @todo
......
...@@ -6,9 +6,9 @@ import { isAddress, getTokenName, getTokenSymbol, getTokenDecimals, safeAccess } ...@@ -6,9 +6,9 @@ import { isAddress, getTokenName, getTokenSymbol, getTokenDecimals, safeAccess }
const UPDATE = 'UPDATE' const UPDATE = 'UPDATE'
export const ALL_TOKENS = [ export const ALL_TOKENS = [
WETH[ChainId.RINKEBY] WETH[ChainId.RINKEBY],
// new Token(ChainId.RINKEBY, '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735', 18, 'DAI', 'Dai Stablecoin'), new Token(ChainId.RINKEBY, '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735', 18, 'DAI', 'Dai Stablecoin'),
// new Token(ChainId.RINKEBY, '0x8ab15C890E5C03B5F240f2D146e3DF54bEf3Df44', 18, 'IANV2', 'IAn V2 Coin') new Token(ChainId.RINKEBY, '0x8ab15C890E5C03B5F240f2D146e3DF54bEf3Df44', 18, 'IANV2', 'IAn V2 Coin')
] ]
// only meant to be used in exchanges.ts! // only meant to be used in exchanges.ts!
......
...@@ -9,7 +9,6 @@ import { useAllExchanges } from '../../contexts/Exchanges' ...@@ -9,7 +9,6 @@ import { useAllExchanges } from '../../contexts/Exchanges'
import { useAllBalances, useAccountLPBalances } from '../../contexts/Balances' import { useAllBalances, useAccountLPBalances } from '../../contexts/Balances'
import Question from '../../components/Question' import Question from '../../components/Question'
import TokenFind from '../../components/TokenFind'
import SearchModal from '../../components/SearchModal' import SearchModal from '../../components/SearchModal'
import PositionCard from '../../components/PositionCard' import PositionCard from '../../components/PositionCard'
import Row, { RowBetween } from '../../components/Row' import Row, { RowBetween } from '../../components/Row'
...@@ -32,7 +31,6 @@ const FixedBottom = styled.div` ...@@ -32,7 +31,6 @@ const FixedBottom = styled.div`
function Supply({ history }) { function Supply({ history }) {
const { account } = useWeb3React() const { account } = useWeb3React()
const [showPositionFind, setShowPositionFind] = useState(false)
const [showPoolSearch, setShowPoolSearch] = useState(false) const [showPoolSearch, setShowPoolSearch] = useState(false)
const allTokens = useAllTokens() const allTokens = useAllTokens()
...@@ -64,61 +62,56 @@ function Supply({ history }) { ...@@ -64,61 +62,56 @@ function Supply({ history }) {
return ( return (
<> <>
{!showPositionFind && ( <ButtonPrimary
<> onClick={() => {
<ButtonPrimary setShowPoolSearch(true)
onClick={() => { }}
setShowPoolSearch(true) >
}} <Text fontSize={20}>Join a pool</Text>
> </ButtonPrimary>
<Text fontSize={20}>Join a pool</Text> <Positions>
</ButtonPrimary> <AutoColumn gap="20px">
<Positions> <RowBetween>
<AutoColumn gap="20px"> <Text fontWeight={500}>Your Pooled Liquidity</Text>
<RowBetween> <Question text="filler text" />
<Text fontWeight={500}>Your Pooled Liquidity</Text> </RowBetween>
<Question text="filler text" /> {filteredExchangeList}
</RowBetween> {filteredExchangeList?.length === 0 && (
{filteredExchangeList} <LightCard bg="rgba(255, 255, 255, 0.6)" padding={'45px'}>
{filteredExchangeList?.length === 0 && ( <Text color="#C3C5CB">Add liquidity to see your positions</Text>
<LightCard bg="rgba(255, 255, 255, 0.6)" padding={'45px'}> </LightCard>
<Text color="#C3C5CB">Add liquidity to see your positions</Text> )}
</LightCard> <AutoColumn justify="center">
)} <Text color="#AEAEAE">
<AutoColumn justify="center"> Already have liquidity?{' '}
<Text color="#AEAEAE"> <Link
Already have liquidity?{' '} onClick={() => {
<Link history.push('/find')
onClick={() => { }}
history.push('/find') >
}} Find it now.
> </Link>
Find it now. </Text>
</Link> </AutoColumn>
</Text> </AutoColumn>
</AutoColumn> <FixedBottom>
<Card bg="rgba(255, 255, 255, 0.6)" padding={'24px'}>
<AutoColumn gap="30px">
<Text fontSize="20px" fontWeight={500}>
Earn fees with pooled market making.
</Text>
<Text fontSize="12px">
<Link>Provide liquidity </Link>to earn .03% spread fees for providing market depth.
</Text>
<Link>
<Row>
Learn More <ArrowRight size="16" />
</Row>
</Link>
</AutoColumn> </AutoColumn>
<FixedBottom> </Card>
<Card bg="rgba(255, 255, 255, 0.6)" padding={'24px'}> </FixedBottom>
<AutoColumn gap="30px"> </Positions>
<Text fontSize="20px" fontWeight={500}>
Earn fees with pooled market making.
</Text>
<Text fontSize="12px">
<Link>Provide liquidity </Link>to earn .03% spread fees for providing market depth.
</Text>
<Link>
<Row>
Learn More <ArrowRight size="16" />
</Row>
</Link>
</AutoColumn>
</Card>
</FixedBottom>
</Positions>
</>
)}
{showPositionFind && <TokenFind />}
<SearchModal isOpen={showPoolSearch} onDismiss={() => setShowPoolSearch(false)} /> <SearchModal isOpen={showPoolSearch} onDismiss={() => setShowPoolSearch(false)} />
</> </>
) )
......
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