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
6c94a0f5
Unverified
Commit
6c94a0f5
authored
Apr 07, 2022
by
Zach Pomerantz
Committed by
GitHub
Apr 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: swap validator (#3682)
parent
600aeaaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
useValidate.tsx
src/lib/components/Swap/useValidate.tsx
+8
-5
No files found.
src/lib/components/Swap/useValidate.tsx
View file @
6c94a0f5
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
IntegrationError
}
from
'
lib/errors
'
import
{
IntegrationError
}
from
'
lib/errors
'
import
{
FeeOptions
}
from
'
lib/hooks/swap/useSyncConvenienceFee
'
import
{
FeeOptions
}
from
'
lib/hooks/swap/useSyncConvenienceFee
'
import
{
DefaultAddress
,
TokenDefaults
}
from
'
lib/hooks/swap/useSyncTokenDefaults
'
import
{
DefaultAddress
,
TokenDefaults
}
from
'
lib/hooks/swap/useSyncTokenDefaults
'
...
@@ -48,19 +47,23 @@ export default function useValidate(props: ValidatorProps) {
...
@@ -48,19 +47,23 @@ export default function useValidate(props: ValidatorProps) {
}
}
},
[
convenienceFee
,
convenienceFeeRecipient
])
},
[
convenienceFee
,
convenienceFeeRecipient
])
const
{
defaultInput
TokenAddress
,
defaultInputAmount
,
defaultOutputTokenAddress
,
defaultOutputAmount
}
=
props
const
{
defaultInput
Amount
,
defaultOutputAmount
}
=
props
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
defaultOutputAmount
&&
defaultInputAmount
)
{
if
(
defaultOutputAmount
&&
defaultInputAmount
)
{
throw
new
IntegrationError
(
'
defaultInputAmount and defaultOutputAmount may not both be defined.
'
)
throw
new
IntegrationError
(
'
defaultInputAmount and defaultOutputAmount may not both be defined.
'
)
}
}
if
(
defaultInputAmount
&&
BigNumber
.
from
(
defaultInputAmount
).
lt
(
0
))
{
if
(
defaultInputAmount
&&
(
isNaN
(
+
defaultInputAmount
)
||
defaultInputAmount
<
0
))
{
throw
new
IntegrationError
(
`defaultInputAmount must be a positive number (you set it to
${
defaultInputAmount
}
)`
)
throw
new
IntegrationError
(
`defaultInputAmount must be a positive number (you set it to
${
defaultInputAmount
}
)`
)
}
}
if
(
defaultOutputAmount
&&
BigNumber
.
from
(
defaultOutputAmount
).
lt
(
0
))
{
if
(
defaultOutputAmount
&&
(
isNaN
(
+
defaultOutputAmount
)
||
defaultOutputAmount
<
0
))
{
throw
new
IntegrationError
(
throw
new
IntegrationError
(
`defaultOutputAmount must be a positive number (you set it to
${
defaultOutputAmount
}
).`
`defaultOutputAmount must be a positive number (you set it to
${
defaultOutputAmount
}
).`
)
)
}
}
},
[
defaultInputAmount
,
defaultOutputAmount
])
const
{
defaultInputTokenAddress
,
defaultOutputTokenAddress
}
=
props
useEffect
(()
=>
{
if
(
if
(
defaultInputTokenAddress
&&
defaultInputTokenAddress
&&
!
isAddressOrAddressMap
(
defaultInputTokenAddress
)
&&
!
isAddressOrAddressMap
(
defaultInputTokenAddress
)
&&
...
@@ -79,5 +82,5 @@ export default function useValidate(props: ValidatorProps) {
...
@@ -79,5 +82,5 @@ export default function useValidate(props: ValidatorProps) {
`defaultOutputTokenAddress must be a valid address or "NATIVE" (you set it to
${
defaultOutputTokenAddress
}
).`
`defaultOutputTokenAddress must be a valid address or "NATIVE" (you set it to
${
defaultOutputTokenAddress
}
).`
)
)
}
}
},
[
defaultInputTokenAddress
,
default
InputAmount
,
defaultOutputTokenAddress
,
defaultOutputAmount
])
},
[
defaultInputTokenAddress
,
default
OutputTokenAddress
])
}
}
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