Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
35d39840
Commit
35d39840
authored
Mar 10, 2020
by
ianlapham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add import to token search
parent
217a7008
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
77 deletions
+107
-77
index.js
src/components/Button/index.js
+3
-0
index.js
src/components/PoolFinder/index.js
+15
-10
index.js
src/components/SearchModal/index.js
+32
-3
Exchanges.tsx
src/contexts/Exchanges.tsx
+5
-5
Tokens.tsx
src/contexts/Tokens.tsx
+3
-3
index.js
src/pages/Supply/index.js
+49
-56
No files found.
src/components/Button/index.js
View file @
35d39840
...
@@ -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;
}
}
`
`
...
...
src/components/
TokenFind
/index.js
→
src/components/
PoolFinder
/index.js
View file @
35d39840
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
)
src/components/SearchModal/index.js
View file @
35d39840
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>
...
...
src/contexts/Exchanges.tsx
View file @
35d39840
...
@@ -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
...
...
src/contexts/Tokens.tsx
View file @
35d39840
...
@@ -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!
...
...
src/pages/Supply/index.js
View file @
35d39840
...
@@ -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
()
...
@@ -63,8 +61,6 @@ function Supply({ history }) {
...
@@ -63,8 +61,6 @@ function Supply({ history }) {
})
})
return
(
return
(
<>
{
!
showPositionFind
&&
(
<>
<>
<
ButtonPrimary
<
ButtonPrimary
onClick
=
{()
=>
{
onClick
=
{()
=>
{
...
@@ -116,9 +112,6 @@ function Supply({ history }) {
...
@@ -116,9 +112,6 @@ function Supply({ history }) {
<
/Card
>
<
/Card
>
<
/FixedBottom
>
<
/FixedBottom
>
<
/Positions
>
<
/Positions
>
<
/
>
)}
{
showPositionFind
&&
<
TokenFind
/>
}
<
SearchModal
isOpen
=
{
showPoolSearch
}
onDismiss
=
{()
=>
setShowPoolSearch
(
false
)}
/
>
<
SearchModal
isOpen
=
{
showPoolSearch
}
onDismiss
=
{()
=>
setShowPoolSearch
(
false
)}
/
>
<
/
>
<
/
>
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment