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
a6b9de3e
Commit
a6b9de3e
authored
Jan 08, 2020
by
Ian Lapham
Committed by
Noah Zinsmeister
Jan 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add warnign for broken ERC20 (#589)
parent
4abb607f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
20 deletions
+65
-20
index.js
src/components/ContextualInfoNew/index.js
+3
-2
index.jsx
src/components/ExchangePage/index.jsx
+30
-8
index.js
src/components/TransactionDetails/index.js
+6
-2
index.js
src/constants/index.js
+2
-1
AddLiquidity.js
src/pages/Pool/AddLiquidity.js
+1
-1
RemoveLiquidity.js
src/pages/Pool/RemoveLiquidity.js
+23
-6
No files found.
src/components/ContextualInfoNew/index.js
View file @
a6b9de3e
...
@@ -6,7 +6,7 @@ import { ReactComponent as Dropup } from '../../assets/images/dropup-blue.svg'
...
@@ -6,7 +6,7 @@ import { ReactComponent as Dropup } from '../../assets/images/dropup-blue.svg'
import
{
ReactComponent
as
Dropdown
}
from
'
../../assets/images/dropdown-blue.svg
'
import
{
ReactComponent
as
Dropdown
}
from
'
../../assets/images/dropdown-blue.svg
'
const
SummaryWrapper
=
styled
.
div
`
const
SummaryWrapper
=
styled
.
div
`
color:
${({
error
,
theme
})
=>
(
error
?
theme
.
salmonRed
:
theme
.
doveGray
)}
;
color:
${({
error
,
brokenTokenWarning
,
theme
})
=>
(
error
||
brokenTokenWarning
?
theme
.
salmonRed
:
theme
.
doveGray
)}
;
font-size: 0.75rem;
font-size: 0.75rem;
text-align: center;
text-align: center;
margin-top: 1rem;
margin-top: 1rem;
...
@@ -92,11 +92,12 @@ export default function ContextualInfo({
...
@@ -92,11 +92,12 @@ export default function ContextualInfo({
isError
=
false
,
isError
=
false
,
slippageWarning
,
slippageWarning
,
highSlippageWarning
,
highSlippageWarning
,
brokenTokenWarning
,
dropDownContent
dropDownContent
})
{
})
{
const
[
showDetails
,
setShowDetails
]
=
useState
(
false
)
const
[
showDetails
,
setShowDetails
]
=
useState
(
false
)
return
!
allowExpand
?
(
return
!
allowExpand
?
(
<
SummaryWrapper
>
{
contextualInfo
}
<
/SummaryWrapper
>
<
SummaryWrapper
brokenTokenWarning
=
{
brokenTokenWarning
}
>
{
contextualInfo
}
<
/SummaryWrapper
>
)
:
(
)
:
(
<>
<>
<
SummaryWrapperContainer
<
SummaryWrapperContainer
...
...
src/components/ExchangePage/index.jsx
View file @
a6b9de3e
...
@@ -5,14 +5,10 @@ import { ethers } from 'ethers'
...
@@ -5,14 +5,10 @@ import { ethers } from 'ethers'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
Button
}
from
'
../../theme
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
{
useWeb3React
}
from
'
../../hooks
'
import
CurrencyInputPanel
from
'
../CurrencyInputPanel
'
import
{
brokenTokens
}
from
'
../../constants
'
import
AddressInputPanel
from
'
../AddressInputPanel
'
import
OversizedPanel
from
'
../OversizedPanel
'
import
TransactionDetails
from
'
../TransactionDetails
'
import
ArrowDown
from
'
../../assets/svg/SVGArrowDown
'
import
{
amountFormatter
,
calculateGasMargin
}
from
'
../../utils
'
import
{
amountFormatter
,
calculateGasMargin
}
from
'
../../utils
'
import
{
useExchangeContract
}
from
'
../../hooks
'
import
{
useExchangeContract
}
from
'
../../hooks
'
import
{
useTokenDetails
}
from
'
../../contexts/Tokens
'
import
{
useTokenDetails
}
from
'
../../contexts/Tokens
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
...
@@ -21,6 +17,13 @@ import { useAddressAllowance } from '../../contexts/Allowances'
...
@@ -21,6 +17,13 @@ import { useAddressAllowance } from '../../contexts/Allowances'
import
{
useWalletModalToggle
}
from
'
../../contexts/Application
'
import
{
useWalletModalToggle
}
from
'
../../contexts/Application
'
import
{
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
Button
}
from
'
../../theme
'
import
CurrencyInputPanel
from
'
../CurrencyInputPanel
'
import
AddressInputPanel
from
'
../AddressInputPanel
'
import
OversizedPanel
from
'
../OversizedPanel
'
import
TransactionDetails
from
'
../TransactionDetails
'
import
ArrowDown
from
'
../../assets/svg/SVGArrowDown
'
const
INPUT
=
0
const
INPUT
=
0
const
OUTPUT
=
1
const
OUTPUT
=
1
...
@@ -270,6 +273,8 @@ export default function ExchangePage({ initialCurrency, sending = false, params
...
@@ -270,6 +273,8 @@ export default function ExchangePage({ initialCurrency, sending = false, params
return
''
return
''
}
}
const
[
brokenTokenWarning
,
setBrokenTokenWarning
]
=
useState
()
const
[
deadlineFromNow
,
setDeadlineFromNow
]
=
useState
(
DEFAULT_DEADLINE_FROM_NOW
)
const
[
deadlineFromNow
,
setDeadlineFromNow
]
=
useState
(
DEFAULT_DEADLINE_FROM_NOW
)
const
[
rawSlippage
,
setRawSlippage
]
=
useState
(()
=>
initialSlippage
())
const
[
rawSlippage
,
setRawSlippage
]
=
useState
(()
=>
initialSlippage
())
...
@@ -298,6 +303,18 @@ export default function ExchangePage({ initialCurrency, sending = false, params
...
@@ -298,6 +303,18 @@ export default function ExchangePage({ initialCurrency, sending = false, params
const
{
independentValue
,
dependentValue
,
independentField
,
inputCurrency
,
outputCurrency
}
=
swapState
const
{
independentValue
,
dependentValue
,
independentField
,
inputCurrency
,
outputCurrency
}
=
swapState
useEffect
(()
=>
{
setBrokenTokenWarning
(
false
)
for
(
let
i
=
0
;
i
<
brokenTokens
.
length
;
i
++
)
{
if
(
brokenTokens
[
i
].
toLowerCase
()
===
outputCurrency
.
toLowerCase
()
||
brokenTokens
[
i
].
toLowerCase
()
===
inputCurrency
.
toLowerCase
()
)
{
setBrokenTokenWarning
(
true
)
}
}
},
[
outputCurrency
,
inputCurrency
])
const
[
recipient
,
setRecipient
]
=
useState
({
const
[
recipient
,
setRecipient
]
=
useState
({
address
:
initialRecipient
(),
address
:
initialRecipient
(),
name
:
''
name
:
''
...
@@ -806,6 +823,7 @@ export default function ExchangePage({ initialCurrency, sending = false, params
...
@@ -806,6 +823,7 @@ export default function ExchangePage({ initialCurrency, sending = false, params
rawSlippage=
{
rawSlippage
}
rawSlippage=
{
rawSlippage
}
slippageWarning=
{
slippageWarning
}
slippageWarning=
{
slippageWarning
}
highSlippageWarning=
{
highSlippageWarning
}
highSlippageWarning=
{
highSlippageWarning
}
brokenTokenWarning=
{
brokenTokenWarning
}
setDeadline=
{
setDeadlineFromNow
}
setDeadline=
{
setDeadlineFromNow
}
deadline=
{
deadlineFromNow
}
deadline=
{
deadlineFromNow
}
inputError=
{
inputError
}
inputError=
{
inputError
}
...
@@ -831,12 +849,16 @@ export default function ExchangePage({ initialCurrency, sending = false, params
...
@@ -831,12 +849,16 @@ export default function ExchangePage({ initialCurrency, sending = false, params
/>
/>
<
Flex
>
<
Flex
>
<
Button
<
Button
disabled=
{
!
account
&&
!
error
?
false
:
!
isValid
||
customSlippageError
===
'
invalid
'
}
disabled=
{
brokenTokenWarning
?
true
:
!
account
&&
!
error
?
false
:
!
isValid
||
customSlippageError
===
'
invalid
'
}
onClick=
{
account
&&
!
error
?
onSwap
:
toggleWalletModal
}
onClick=
{
account
&&
!
error
?
onSwap
:
toggleWalletModal
}
warning=
{
highSlippageWarning
||
customSlippageError
===
'
warning
'
}
warning=
{
highSlippageWarning
||
customSlippageError
===
'
warning
'
}
loggedOut=
{
!
account
}
loggedOut=
{
!
account
}
>
>
{
!
account
{
brokenTokenWarning
?
'
Swap
'
:
!
account
?
'
Connect to a Wallet
'
?
'
Connect to a Wallet
'
:
sending
:
sending
?
highSlippageWarning
||
customSlippageError
===
'
warning
'
?
highSlippageWarning
||
customSlippageError
===
'
warning
'
...
...
src/components/TransactionDetails/index.js
View file @
a6b9de3e
...
@@ -326,8 +326,10 @@ export default function TransactionDetails(props) {
...
@@ -326,8 +326,10 @@ export default function TransactionDetails(props) {
function
renderSummary
()
{
function
renderSummary
()
{
let
contextualInfo
=
''
let
contextualInfo
=
''
let
isError
=
false
let
isError
=
false
if
(
props
.
brokenTokenWarning
)
{
if
(
props
.
inputError
||
props
.
independentError
)
{
contextualInfo
=
t
(
'
brokenToken
'
)
isError
=
true
}
else
if
(
props
.
inputError
||
props
.
independentError
)
{
contextualInfo
=
props
.
inputError
||
props
.
independentError
contextualInfo
=
props
.
inputError
||
props
.
independentError
isError
=
true
isError
=
true
}
else
if
(
!
props
.
inputCurrency
||
!
props
.
outputCurrency
)
{
}
else
if
(
!
props
.
inputCurrency
||
!
props
.
outputCurrency
)
{
...
@@ -356,6 +358,7 @@ export default function TransactionDetails(props) {
...
@@ -356,6 +358,7 @@ export default function TransactionDetails(props) {
contextualInfo
=
{
contextualInfo
?
contextualInfo
:
slippageWarningText
}
contextualInfo
=
{
contextualInfo
?
contextualInfo
:
slippageWarningText
}
allowExpand
=
{
allowExpand
=
{
!!
(
!!
(
!
props
.
brokenTokenWarning
&&
props
.
inputCurrency
&&
props
.
inputCurrency
&&
props
.
outputCurrency
&&
props
.
outputCurrency
&&
props
.
inputValueParsed
&&
props
.
inputValueParsed
&&
...
@@ -366,6 +369,7 @@ export default function TransactionDetails(props) {
...
@@ -366,6 +369,7 @@ export default function TransactionDetails(props) {
isError
=
{
isError
}
isError
=
{
isError
}
slippageWarning
=
{
props
.
slippageWarning
&&
!
contextualInfo
}
slippageWarning
=
{
props
.
slippageWarning
&&
!
contextualInfo
}
highSlippageWarning
=
{
props
.
highSlippageWarning
&&
!
contextualInfo
}
highSlippageWarning
=
{
props
.
highSlippageWarning
&&
!
contextualInfo
}
brokenTokenWarning
=
{
props
.
brokenTokenWarning
}
renderTransactionDetails
=
{
renderTransactionDetails
}
renderTransactionDetails
=
{
renderTransactionDetails
}
dropDownContent
=
{
dropDownContent
}
dropDownContent
=
{
dropDownContent
}
/
>
/
>
...
...
src/constants/index.js
View file @
a6b9de3e
...
@@ -88,7 +88,8 @@ export const SUPPORTED_WALLETS = {
...
@@ -88,7 +88,8 @@ export const SUPPORTED_WALLETS = {
export
const
brokenTokens
=
[
export
const
brokenTokens
=
[
'
0xB8c77482e45F1F44dE1745F52C74426C631bDD52
'
,
'
0xB8c77482e45F1F44dE1745F52C74426C631bDD52
'
,
'
0x95dAaaB98046846bF4B2853e23cba236fa394A31
'
,
'
0x95dAaaB98046846bF4B2853e23cba236fa394A31
'
,
'
0x55296f69f40Ea6d20E478533C15A6B08B654E758
'
'
0x55296f69f40Ea6d20E478533C15A6B08B654E758
'
,
'
0xc3761EB917CD790B30dAD99f6Cc5b4Ff93C4F9eA
'
]
]
export
const
NetworkContextName
=
'
NETWORK
'
export
const
NetworkContextName
=
'
NETWORK
'
src/pages/Pool/AddLiquidity.js
View file @
a6b9de3e
...
@@ -420,7 +420,7 @@ export default function AddLiquidity({ params }) {
...
@@ -420,7 +420,7 @@ export default function AddLiquidity({ params }) {
function
formatBalance
(
value
)
{
function
formatBalance
(
value
)
{
return
`Balance:
${
value
}
`
return
`Balance:
${
value
}
`
}
// check for broken tokens
}
useEffect
(()
=>
{
useEffect
(()
=>
{
setBrokenTokenWarning
(
false
)
setBrokenTokenWarning
(
false
)
...
...
src/pages/Pool/RemoveLiquidity.js
View file @
a6b9de3e
...
@@ -6,15 +6,18 @@ import { ethers } from 'ethers'
...
@@ -6,15 +6,18 @@ import { ethers } from 'ethers'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
useWeb3React
,
useExchangeContract
}
from
'
../../hooks
'
import
{
useWeb3React
,
useExchangeContract
}
from
'
../../hooks
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
import
{
useTokenDetails
}
from
'
../../contexts/Tokens
'
import
{
useAddressBalance
,
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
calculateGasMargin
,
amountFormatter
}
from
'
../../utils
'
import
{
brokenTokens
}
from
'
../../constants
'
import
{
Button
}
from
'
../../theme
'
import
{
Button
}
from
'
../../theme
'
import
CurrencyInputPanel
from
'
../../components/CurrencyInputPanel
'
import
CurrencyInputPanel
from
'
../../components/CurrencyInputPanel
'
import
ContextualInfo
from
'
../../components/ContextualInfo
'
import
ContextualInfo
from
'
../../components/ContextualInfo
'
import
OversizedPanel
from
'
../../components/OversizedPanel
'
import
OversizedPanel
from
'
../../components/OversizedPanel
'
import
ArrowDown
from
'
../../assets/svg/SVGArrowDown
'
import
ArrowDown
from
'
../../assets/svg/SVGArrowDown
'
import
{
useTransactionAdder
}
from
'
../../contexts/Transactions
'
import
{
useTokenDetails
}
from
'
../../contexts/Tokens
'
import
{
useAddressBalance
,
useETHPriceInUSD
}
from
'
../../contexts/Balances
'
import
{
calculateGasMargin
,
amountFormatter
}
from
'
../../utils
'
// denominated in bips
// denominated in bips
const
ALLOWED_SLIPPAGE
=
ethers
.
utils
.
bigNumberify
(
200
)
const
ALLOWED_SLIPPAGE
=
ethers
.
utils
.
bigNumberify
(
200
)
...
@@ -145,6 +148,8 @@ export default function RemoveLiquidity({ params }) {
...
@@ -145,6 +148,8 @@ export default function RemoveLiquidity({ params }) {
const
addTransaction
=
useTransactionAdder
()
const
addTransaction
=
useTransactionAdder
()
const
[
brokenTokenWarning
,
setBrokenTokenWarning
]
=
useState
()
// clear url of query
// clear url of query
useEffect
(()
=>
{
useEffect
(()
=>
{
const
history
=
createBrowserHistory
()
const
history
=
createBrowserHistory
()
...
@@ -155,6 +160,16 @@ export default function RemoveLiquidity({ params }) {
...
@@ -155,6 +160,16 @@ export default function RemoveLiquidity({ params }) {
const
[
value
,
setValue
]
=
useState
(
params
.
poolTokenAmount
?
params
.
poolTokenAmount
:
''
)
const
[
value
,
setValue
]
=
useState
(
params
.
poolTokenAmount
?
params
.
poolTokenAmount
:
''
)
const
[
inputError
,
setInputError
]
=
useState
()
const
[
inputError
,
setInputError
]
=
useState
()
const
[
valueParsed
,
setValueParsed
]
=
useState
()
const
[
valueParsed
,
setValueParsed
]
=
useState
()
useEffect
(()
=>
{
setBrokenTokenWarning
(
false
)
for
(
let
i
=
0
;
i
<
brokenTokens
.
length
;
i
++
)
{
if
(
brokenTokens
[
i
].
toLowerCase
()
===
outputCurrency
.
toLowerCase
())
{
setBrokenTokenWarning
(
true
)
}
}
},
[
outputCurrency
])
// parse value
// parse value
useEffect
(()
=>
{
useEffect
(()
=>
{
try
{
try
{
...
@@ -301,8 +316,10 @@ export default function RemoveLiquidity({ params }) {
...
@@ -301,8 +316,10 @@ export default function RemoveLiquidity({ params }) {
function
renderSummary
()
{
function
renderSummary
()
{
let
contextualInfo
=
''
let
contextualInfo
=
''
let
isError
=
false
let
isError
=
false
if
(
brokenTokenWarning
)
{
if
(
inputError
)
{
contextualInfo
=
t
(
'
brokenToken
'
)
isError
=
true
}
else
if
(
inputError
)
{
contextualInfo
=
inputError
contextualInfo
=
inputError
isError
=
true
isError
=
true
}
else
if
(
!
outputCurrency
||
outputCurrency
===
'
ETH
'
)
{
}
else
if
(
!
outputCurrency
||
outputCurrency
===
'
ETH
'
)
{
...
...
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