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
40a7cea6
Unverified
Commit
40a7cea6
authored
May 08, 2020
by
Ian Lapham
Committed by
GitHub
May 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes, UI tweaks (#738)
* linking bug fixes, search UI tweaks * search style tweaks * organize imports
parent
e023a020
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
39 deletions
+75
-39
index.tsx
src/components/NavigationTabs/index.tsx
+1
-1
index.tsx
src/components/PoolFinder/index.tsx
+1
-1
index.tsx
src/components/SearchModal/index.tsx
+38
-32
AddLiquidity.tsx
src/pages/Pool/AddLiquidity.tsx
+35
-5
No files found.
src/components/NavigationTabs/index.tsx
View file @
40a7cea6
...
@@ -106,7 +106,7 @@ function NavigationTabs({ location: { pathname }, history }: RouteComponentProps
...
@@ -106,7 +106,7 @@ function NavigationTabs({ location: { pathname }, history }: RouteComponentProps
{
adding
||
removing
?
(
{
adding
||
removing
?
(
<
Tabs
>
<
Tabs
>
<
RowBetween
style=
{
{
padding
:
'
1rem 1rem 0 1rem
'
}
}
>
<
RowBetween
style=
{
{
padding
:
'
1rem 1rem 0 1rem
'
}
}
>
<
Hover
onClick=
{
()
=>
history
.
goBack
(
)
}
>
<
Hover
onClick=
{
()
=>
history
.
push
(
'
/pool
'
)
}
>
<
ArrowLink
/>
<
ArrowLink
/>
</
Hover
>
</
Hover
>
<
ActiveText
>
{
adding
?
'
Add
'
:
'
Remove
'
}
Liquidity
</
ActiveText
>
<
ActiveText
>
{
adding
?
'
Add
'
:
'
Remove
'
}
Liquidity
</
ActiveText
>
...
...
src/components/PoolFinder/index.tsx
View file @
40a7cea6
...
@@ -181,7 +181,7 @@ function PoolFinder({ history }: RouteComponentProps) {
...
@@ -181,7 +181,7 @@ function PoolFinder({ history }: RouteComponentProps) {
</
AutoColumn
>
</
AutoColumn
>
</
LightCard
>
</
LightCard
>
)
:
(
)
:
(
<
LightCard
bg=
"rgba(255, 255, 255, 0.6)"
padding=
{
'
45px
'
}
>
<
LightCard
padding=
{
'
45px
'
}
>
<
Text
color=
"#C3C5CB"
textAlign=
"center"
>
<
Text
color=
"#C3C5CB"
textAlign=
"center"
>
Select a token pair to find your liquidity.
Select a token pair to find your liquidity.
</
Text
>
</
Text
>
...
...
src/components/SearchModal/index.tsx
View file @
40a7cea6
...
@@ -8,6 +8,7 @@ import { RouteComponentProps, withRouter } from 'react-router-dom'
...
@@ -8,6 +8,7 @@ import { RouteComponentProps, withRouter } from 'react-router-dom'
import
{
COMMON_BASES
}
from
'
../../constants
'
import
{
COMMON_BASES
}
from
'
../../constants
'
import
{
Link
as
StyledLink
}
from
'
../../theme/components
'
import
{
Link
as
StyledLink
}
from
'
../../theme/components
'
import
Card
from
'
../../components/Card
'
import
Modal
from
'
../Modal
'
import
Modal
from
'
../Modal
'
import
Circle
from
'
../../assets/images/circle.svg
'
import
Circle
from
'
../../assets/images/circle.svg
'
import
TokenLogo
from
'
../TokenLogo
'
import
TokenLogo
from
'
../TokenLogo
'
...
@@ -18,7 +19,6 @@ import { Hover } from '../../theme'
...
@@ -18,7 +19,6 @@ import { Hover } from '../../theme'
import
{
ArrowLeft
,
X
}
from
'
react-feather
'
import
{
ArrowLeft
,
X
}
from
'
react-feather
'
import
{
CloseIcon
}
from
'
../../theme/components
'
import
{
CloseIcon
}
from
'
../../theme/components
'
import
{
ColumnCenter
}
from
'
../Column
'
import
{
ColumnCenter
}
from
'
../Column
'
import
Card
from
'
../../components/Card
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
ButtonPrimary
}
from
'
../../components/Button
'
import
{
Spinner
,
TYPE
}
from
'
../../theme
'
import
{
Spinner
,
TYPE
}
from
'
../../theme
'
import
{
RowBetween
,
RowFixed
,
AutoRow
}
from
'
../Row
'
import
{
RowBetween
,
RowFixed
,
AutoRow
}
from
'
../Row
'
...
@@ -39,11 +39,12 @@ const TokenModalInfo = styled.div`
...
@@ -39,11 +39,12 @@ const TokenModalInfo = styled.div`
margin: 0.25rem 0.5rem;
margin: 0.25rem 0.5rem;
justify-content: center;
justify-content: center;
user-select: none;
user-select: none;
min-height: 200px;
`
`
const
Token
List
=
styled
.
div
`
const
Item
List
=
styled
.
div
`
flex-grow: 1;
flex-grow: 1;
height:
100%
;
height:
240px
;
overflow-y: scroll;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
-webkit-overflow-scrolling: touch;
`
`
...
@@ -332,21 +333,24 @@ function SearchModal({
...
@@ -332,21 +333,24 @@ function SearchModal({
}
}
const
token0
=
allTokens
[
pair
.
token0
]
const
token0
=
allTokens
[
pair
.
token0
]
const
token1
=
allTokens
[
pair
.
token1
]
const
token1
=
allTokens
[
pair
.
token1
]
const
regexMatches
=
Object
.
keys
(
token0
).
map
(
field
=>
{
if
(
!
token0
||
!
token1
)
{
if
(
return
false
// no token fetched yet
(
field
===
'
address
'
&&
isAddress
)
||
}
else
{
(
field
===
'
name
'
&&
!
isAddress
)
||
const
regexMatches
=
Object
.
keys
(
token0
).
map
(
field
=>
{
(
field
===
'
symbol
'
&&
!
isAddress
)
if
(
)
{
(
field
===
'
address
'
&&
isAddress
)
||
return
(
(
field
===
'
name
'
&&
!
isAddress
)
||
token0
[
field
].
match
(
new
RegExp
(
escapeStringRegexp
(
searchQuery
),
'
i
'
))
||
(
field
===
'
symbol
'
&&
!
isAddress
)
token1
[
field
].
match
(
new
RegExp
(
escapeStringRegexp
(
searchQuery
),
'
i
'
))
)
{
)
return
(
}
token0
[
field
].
match
(
new
RegExp
(
escapeStringRegexp
(
searchQuery
),
'
i
'
))
||
return
false
token1
[
field
].
match
(
new
RegExp
(
escapeStringRegexp
(
searchQuery
),
'
i
'
))
})
)
}
return
regexMatches
.
some
(
m
=>
m
)
return
false
})
return
regexMatches
.
some
(
m
=>
m
)
}
})
})
},
[
allPairs
,
allTokens
,
searchQuery
,
sortedPairList
])
},
[
allPairs
,
allTokens
,
searchQuery
,
sortedPairList
])
...
@@ -430,19 +434,21 @@ function SearchModal({
...
@@ -430,19 +434,21 @@ function SearchModal({
}
else
{
}
else
{
return
<
TokenModalInfo
>
{
t
(
'
noToken
'
)
}
</
TokenModalInfo
>
return
<
TokenModalInfo
>
{
t
(
'
noToken
'
)
}
</
TokenModalInfo
>
}
}
}
}
else
{
// TODO is this the right place to link to create exchange?
/**
// else if (isAddress(searchQuery) && tokenAddress === ethers.constants.AddressZero) {
* @TODO
// return (
// TODO is this the right place to link to create exchange?
// <>
// else if (isAddress(searchQuery) && tokenAddress === ethers.constants.AddressZero) {
// <TokenModalInfo>{t('noToken')}</TokenModalInfo>
// return (
// <TokenModalInfo>
// <>
// <Link to={`/create-exchange/${searchQuery}`}>{t('createExchange')}</Link>
// <TokenModalInfo>{t('noToken')}</TokenModalInfo>
// </TokenModalInfo>
// <TokenModalInfo>
// </>
// <Link to={`/create-exchange/${searchQuery}`}>{t('createExchange')}</Link>
// )
// </TokenModalInfo>
// }
// </>
else
{
// )
// }
*/
return
filteredTokenList
return
filteredTokenList
.
sort
((
a
,
b
)
=>
{
.
sort
((
a
,
b
)
=>
{
if
(
b
?.
address
===
WETH
[
chainId
]?.
address
)
{
if
(
b
?.
address
===
WETH
[
chainId
]?.
address
)
{
...
@@ -635,7 +641,7 @@ function SearchModal({
...
@@ -635,7 +641,7 @@ function SearchModal({
</
PaddedColumn
>
</
PaddedColumn
>
)
}
)
}
{
!
showTokenImport
&&
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
}
{
!
showTokenImport
&&
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
}
{
!
showTokenImport
&&
<
TokenList
>
{
filterType
===
'
tokens
'
?
renderTokenList
()
:
renderPairsList
()
}
</
Token
List
>
}
{
!
showTokenImport
&&
<
ItemList
>
{
filterType
===
'
tokens
'
?
renderTokenList
()
:
renderPairsList
()
}
</
Item
List
>
}
{
!
showTokenImport
&&
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
}
{
!
showTokenImport
&&
<
div
style=
{
{
width
:
'
100%
'
,
height
:
'
1px
'
,
backgroundColor
:
theme
.
bg2
}
}
/>
}
{
!
showTokenImport
&&
(
{
!
showTokenImport
&&
(
<
Card
>
<
Card
>
...
...
src/pages/Pool/AddLiquidity.tsx
View file @
40a7cea6
...
@@ -30,6 +30,8 @@ import { useTransactionAdder, usePendingApproval } from '../../contexts/Transact
...
@@ -30,6 +30,8 @@ import { useTransactionAdder, usePendingApproval } from '../../contexts/Transact
import
{
ROUTER_ADDRESS
}
from
'
../../constants
'
import
{
ROUTER_ADDRESS
}
from
'
../../constants
'
import
{
getRouterContract
,
calculateGasMargin
,
isWETH
}
from
'
../../utils
'
import
{
getRouterContract
,
calculateGasMargin
,
isWETH
}
from
'
../../utils
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
useLocalStorageTokens
}
from
'
../../contexts/LocalStorage
'
import
{
useAllTokens
}
from
'
../../contexts/Tokens
'
// denominated in bips
// denominated in bips
const
ALLOWED_SLIPPAGE
=
50
const
ALLOWED_SLIPPAGE
=
50
...
@@ -182,6 +184,30 @@ function AddLiquidity({ token0, token1 }: AddLiquidityProps) {
...
@@ -182,6 +184,30 @@ function AddLiquidity({ token0, token1 }: AddLiquidityProps) {
[
Field
.
OUTPUT
]:
useToken
(
fieldData
[
Field
.
OUTPUT
].
address
)
[
Field
.
OUTPUT
]:
useToken
(
fieldData
[
Field
.
OUTPUT
].
address
)
}
}
// ensure input + output tokens are added to localstorage
const
[,
{
fetchTokenByAddress
,
addToken
}]
=
useLocalStorageTokens
()
const
allTokens
=
useAllTokens
()
const
inputTokenAddress
=
fieldData
[
Field
.
INPUT
].
address
useEffect
(()
=>
{
if
(
inputTokenAddress
&&
!
Object
.
keys
(
allTokens
).
some
(
tokenAddress
=>
tokenAddress
===
inputTokenAddress
))
{
fetchTokenByAddress
(
inputTokenAddress
).
then
(
token
=>
{
if
(
token
!==
null
)
{
addToken
(
token
)
}
})
}
},
[
inputTokenAddress
,
allTokens
,
fetchTokenByAddress
,
addToken
])
const
outputTokenAddress
=
fieldData
[
Field
.
OUTPUT
].
address
useEffect
(()
=>
{
if
(
outputTokenAddress
&&
!
Object
.
keys
(
allTokens
).
some
(
tokenAddress
=>
tokenAddress
===
outputTokenAddress
))
{
fetchTokenByAddress
(
outputTokenAddress
).
then
(
token
=>
{
if
(
token
!==
null
)
{
addToken
(
token
)
}
})
}
},
[
outputTokenAddress
,
allTokens
,
fetchTokenByAddress
,
addToken
])
// token contracts for approvals and direct sends
// token contracts for approvals and direct sends
const
tokenContractInput
:
Contract
=
useTokenContract
(
tokens
[
Field
.
INPUT
]?.
address
)
const
tokenContractInput
:
Contract
=
useTokenContract
(
tokens
[
Field
.
INPUT
]?.
address
)
const
tokenContractOutput
:
Contract
=
useTokenContract
(
tokens
[
Field
.
OUTPUT
]?.
address
)
const
tokenContractOutput
:
Contract
=
useTokenContract
(
tokens
[
Field
.
OUTPUT
]?.
address
)
...
@@ -225,11 +251,15 @@ function AddLiquidity({ token0, token1 }: AddLiquidityProps) {
...
@@ -225,11 +251,15 @@ function AddLiquidity({ token0, token1 }: AddLiquidityProps) {
newNonRelationalAmounts
[
Field
.
INPUT
]
=
null
newNonRelationalAmounts
[
Field
.
INPUT
]
=
null
}
}
}
else
{
}
else
{
const
typedValueParsed
=
parseUnits
(
typedValue
,
tokens
[
independentField
].
decimals
).
toString
()
try
{
if
(
independentField
===
Field
.
OUTPUT
)
{
const
typedValueParsed
=
parseUnits
(
typedValue
,
tokens
[
independentField
].
decimals
).
toString
()
newNonRelationalAmounts
[
Field
.
OUTPUT
]
=
new
TokenAmount
(
tokens
[
independentField
],
typedValueParsed
)
if
(
independentField
===
Field
.
OUTPUT
)
{
}
else
{
newNonRelationalAmounts
[
Field
.
OUTPUT
]
=
new
TokenAmount
(
tokens
[
independentField
],
typedValueParsed
)
newNonRelationalAmounts
[
Field
.
INPUT
]
=
new
TokenAmount
(
tokens
[
independentField
],
typedValueParsed
)
}
else
{
newNonRelationalAmounts
[
Field
.
INPUT
]
=
new
TokenAmount
(
tokens
[
independentField
],
typedValueParsed
)
}
}
catch
(
error
)
{
console
.
log
(
error
)
}
}
}
}
setNonrelationalAmounts
(
newNonRelationalAmounts
)
setNonrelationalAmounts
(
newNonRelationalAmounts
)
...
...
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