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
eb394ee8
Unverified
Commit
eb394ee8
authored
May 03, 2019
by
Noah Zinsmeister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix exchange address logic
parent
44d77ce9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
index.js
src/components/AddressInputPanel/index.js
+16
-14
CreateExchange.js
src/pages/Pool/CreateExchange.js
+13
-16
No files found.
src/components/AddressInputPanel/index.js
View file @
eb394ee8
...
@@ -3,10 +3,10 @@ import classnames from 'classnames'
...
@@ -3,10 +3,10 @@ import classnames from 'classnames'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useTranslation
}
from
'
react-i18next
'
import
{
useWeb3Context
}
from
'
web3-react
'
import
{
useWeb3Context
}
from
'
web3-react
'
import
{
isAddress
}
from
'
../../utils
'
// import QrCode from '../QrCode' // commented out pending further review
// import QrCode from '../QrCode' // commented out pending further review
import
'
./address-input-panel.scss
'
import
'
./address-input-panel.scss
'
import
{
isAddress
}
from
'
../../utils
'
export
default
function
AddressInputPanel
({
title
,
onChange
=
()
=>
{},
onError
=
()
=>
{}
})
{
export
default
function
AddressInputPanel
({
title
,
onChange
=
()
=>
{},
onError
=
()
=>
{}
})
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
...
@@ -41,20 +41,22 @@ export default function AddressInputPanel({ title, onChange = () => {}, onError
...
@@ -41,20 +41,22 @@ export default function AddressInputPanel({ title, onChange = () => {}, onError
}
}
})
})
}
else
{
}
else
{
try
{
if
(
input
!==
''
)
{
library
.
resolveName
(
input
).
then
(
address
=>
{
try
{
if
(
!
stale
)
{
library
.
resolveName
(
input
).
then
(
address
=>
{
// if the input name resolves to an address
if
(
!
stale
)
{
if
(
address
)
{
// if the input name resolves to an address
setData
({
address
:
address
,
name
:
input
})
if
(
address
)
{
setError
(
null
)
setData
({
address
:
address
,
name
:
input
})
}
else
{
setError
(
null
)
setError
(
true
)
}
else
{
setError
(
true
)
}
}
}
}
}
)
}
)
}
catch
{
}
catch
{
setError
(
true
)
setError
(
true
)
}
}
}
}
}
...
...
src/pages/Pool/CreateExchange.js
View file @
eb394ee8
...
@@ -11,15 +11,19 @@ import OversizedPanel from '../../components/OversizedPanel'
...
@@ -11,15 +11,19 @@ import OversizedPanel from '../../components/OversizedPanel'
import
{
useTokenDetails
}
from
'
../../contexts/Static
'
import
{
useTokenDetails
}
from
'
../../contexts/Static
'
import
{
useTransactionContext
}
from
'
../../contexts/Transaction
'
import
{
useTransactionContext
}
from
'
../../contexts/Transaction
'
import
{
useFactoryContract
}
from
'
../../hooks
'
import
{
useFactoryContract
}
from
'
../../hooks
'
import
{
isAddress
}
from
'
../../utils
'
function
CreateExchange
({
history
,
location
})
{
function
CreateExchange
({
history
,
location
})
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
account
}
=
useWeb3Context
()
const
{
account
}
=
useWeb3Context
()
const
factory
=
useFactoryContract
()
const
factory
=
useFactoryContract
()
const
[
tokenAddress
,
setTokenAddress
]
=
useState
((
location
.
state
&&
location
.
state
.
tokenAddress
)
||
''
)
const
[
tokenAddress
,
setTokenAddress
]
=
useState
({
const
{
name
,
symbol
,
decimals
,
exchangeAddress
}
=
useTokenDetails
(
tokenAddress
)
address
:
(
location
.
state
&&
location
.
state
.
tokenAddress
)
||
''
,
name
:
''
})
const
[
tokenAddressError
,
setTokenAddressError
]
=
useState
()
const
{
name
,
symbol
,
decimals
,
exchangeAddress
}
=
useTokenDetails
(
tokenAddress
.
address
)
const
{
addTransaction
}
=
useTransactionContext
()
const
{
addTransaction
}
=
useTransactionContext
()
// clear location state, if it exists
// clear location state, if it exists
...
@@ -32,9 +36,9 @@ function CreateExchange({ history, location }) {
...
@@ -32,9 +36,9 @@ function CreateExchange({ history, location }) {
// validate everything
// validate everything
const
[
errorMessage
,
setErrorMessage
]
=
useState
(
!
account
&&
t
(
'
noWallet
'
))
const
[
errorMessage
,
setErrorMessage
]
=
useState
(
!
account
&&
t
(
'
noWallet
'
))
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
tokenAddress
&&
!
isAddress
(
tokenAddress
)
)
{
if
(
tokenAddress
Error
)
{
setErrorMessage
(
t
(
'
invalidTokenAddress
'
))
setErrorMessage
(
t
(
'
invalidTokenAddress
'
))
}
else
if
(
!
tokenAddress
||
symbol
===
undefined
||
decimals
===
undefined
||
exchangeAddress
===
undefined
)
{
}
else
if
(
symbol
===
undefined
||
decimals
===
undefined
||
exchangeAddress
===
undefined
)
{
setErrorMessage
()
setErrorMessage
()
}
else
if
(
symbol
===
null
)
{
}
else
if
(
symbol
===
null
)
{
setErrorMessage
(
t
(
'
invalidSymbol
'
))
setErrorMessage
(
t
(
'
invalidSymbol
'
))
...
@@ -51,12 +55,12 @@ function CreateExchange({ history, location }) {
...
@@ -51,12 +55,12 @@ function CreateExchange({ history, location }) {
return
()
=>
{
return
()
=>
{
setErrorMessage
()
setErrorMessage
()
}
}
},
[
tokenAddress
,
symbol
,
decimals
,
exchangeAddress
,
account
,
t
])
},
[
tokenAddress
.
address
,
symbol
,
decimals
,
exchangeAddress
,
account
,
t
,
tokenAddressError
])
async
function
createExchange
()
{
async
function
createExchange
()
{
const
estimatedGasLimit
=
await
factory
.
estimate
.
createExchange
(
tokenAddress
)
const
estimatedGasLimit
=
await
factory
.
estimate
.
createExchange
(
tokenAddress
.
address
)
factory
.
createExchange
(
tokenAddress
,
{
gasLimit
:
estimatedGasLimit
}).
then
(
response
=>
{
factory
.
createExchange
(
tokenAddress
.
address
,
{
gasLimit
:
estimatedGasLimit
}).
then
(
response
=>
{
addTransaction
(
response
.
hash
,
response
)
addTransaction
(
response
.
hash
,
response
)
ReactGA
.
event
({
ReactGA
.
event
({
category
:
'
Pool
'
,
category
:
'
Pool
'
,
...
@@ -69,14 +73,7 @@ function CreateExchange({ history, location }) {
...
@@ -69,14 +73,7 @@ function CreateExchange({ history, location }) {
return
(
return
(
<>
<>
<
AddressInputPanel
<
AddressInputPanel
title
=
{
t
(
'
tokenAddress
'
)}
onChange
=
{
setTokenAddress
}
onError
=
{
setTokenAddressError
}
/
>
title
=
{
t
(
'
tokenAddress
'
)}
value
=
{
tokenAddress
}
onChange
=
{
input
=>
{
setTokenAddress
(
input
)
}}
errorMessage
=
{
errorMessage
===
t
(
'
noWallet
'
)
?
''
:
errorMessage
}
/
>
<
OversizedPanel
hideBottom
>
<
OversizedPanel
hideBottom
>
<
div
className
=
"
pool__summary-panel
"
>
<
div
className
=
"
pool__summary-panel
"
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
<
div
className
=
"
pool__exchange-rate-wrapper
"
>
...
...
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