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
3aaa3fef
Unverified
Commit
3aaa3fef
authored
May 21, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: wrap/unwrap should not show computed trade details
parent
bc243e1c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
64 deletions
+69
-64
useWrapCallback.ts
src/hooks/useWrapCallback.ts
+4
-2
index.tsx
src/pages/Swap/index.tsx
+65
-62
No files found.
src/hooks/useWrapCallback.ts
View file @
3aaa3fef
...
@@ -33,11 +33,13 @@ export default function useWrapCallback(
...
@@ -33,11 +33,13 @@ export default function useWrapCallback(
return
useMemo
(()
=>
{
return
useMemo
(()
=>
{
if
(
!
wethContract
||
!
chainId
||
!
inputCurrency
||
!
outputCurrency
)
return
NOT_APPLICABLE
if
(
!
wethContract
||
!
chainId
||
!
inputCurrency
||
!
outputCurrency
)
return
NOT_APPLICABLE
const
weth
=
WETH9
[
chainId
]
if
(
!
weth
)
return
NOT_APPLICABLE
const
hasInputAmount
=
Boolean
(
inputAmount
?.
greaterThan
(
'
0
'
))
const
hasInputAmount
=
Boolean
(
inputAmount
?.
greaterThan
(
'
0
'
))
const
sufficientBalance
=
inputAmount
&&
balance
&&
!
balance
.
lessThan
(
inputAmount
)
const
sufficientBalance
=
inputAmount
&&
balance
&&
!
balance
.
lessThan
(
inputAmount
)
if
(
inputCurrency
.
isNative
&&
outputCurrency
.
equals
(
WETH9
[
chainId
]
))
{
if
(
inputCurrency
.
isNative
&&
weth
.
equals
(
outputCurrency
))
{
return
{
return
{
wrapType
:
WrapType
.
WRAP
,
wrapType
:
WrapType
.
WRAP
,
execute
:
execute
:
...
@@ -53,7 +55,7 @@ export default function useWrapCallback(
...
@@ -53,7 +55,7 @@ export default function useWrapCallback(
:
undefined
,
:
undefined
,
inputError
:
sufficientBalance
?
undefined
:
hasInputAmount
?
'
Insufficient ETH balance
'
:
'
Enter ETH amount
'
,
inputError
:
sufficientBalance
?
undefined
:
hasInputAmount
?
'
Insufficient ETH balance
'
:
'
Enter ETH amount
'
,
}
}
}
else
if
(
WETH9
[
chainId
]
.
equals
(
inputCurrency
)
&&
outputCurrency
.
isNative
)
{
}
else
if
(
weth
.
equals
(
inputCurrency
)
&&
outputCurrency
.
isNative
)
{
return
{
return
{
wrapType
:
WrapType
.
UNWRAP
,
wrapType
:
WrapType
.
UNWRAP
,
execute
:
execute
:
...
...
src/pages/Swap/index.tsx
View file @
3aaa3fef
...
@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) {
inputError
:
wrapInputError
,
inputError
:
wrapInputError
,
}
=
useWrapCallback
(
currencies
[
Field
.
INPUT
],
currencies
[
Field
.
OUTPUT
],
typedValue
)
}
=
useWrapCallback
(
currencies
[
Field
.
INPUT
],
currencies
[
Field
.
OUTPUT
],
typedValue
)
const
showWrap
:
boolean
=
wrapType
!==
WrapType
.
NOT_APPLICABLE
const
showWrap
:
boolean
=
wrapType
!==
WrapType
.
NOT_APPLICABLE
console
.
log
(
showWrap
)
const
{
address
:
recipientAddress
}
=
useENSAddress
(
recipient
)
const
{
address
:
recipientAddress
}
=
useENSAddress
(
recipient
)
const
parsedAmounts
=
useMemo
(
const
parsedAmounts
=
useMemo
(
...
@@ -428,6 +429,7 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -428,6 +429,7 @@ export default function Swap({ history }: RouteComponentProps) {
</>
</>
)
:
null
}
)
:
null
}
{
showWrap
?
null
:
(
<
Row
style=
{
{
justifyContent
:
!
trade
?
'
center
'
:
'
space-between
'
}
}
>
<
Row
style=
{
{
justifyContent
:
!
trade
?
'
center
'
:
'
space-between
'
}
}
>
<
RowFixed
>
<
RowFixed
>
{
[
V3TradeState
.
VALID
,
V3TradeState
.
SYNCING
,
V3TradeState
.
NO_ROUTE_FOUND
].
includes
(
v3TradeState
)
&&
{
[
V3TradeState
.
VALID
,
V3TradeState
.
SYNCING
,
V3TradeState
.
NO_ROUTE_FOUND
].
includes
(
v3TradeState
)
&&
...
@@ -492,6 +494,7 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -492,6 +494,7 @@ export default function Swap({ history }: RouteComponentProps) {
</
RowFixed
>
</
RowFixed
>
)
:
null
}
)
:
null
}
</
Row
>
</
Row
>
)
}
<
BottomGrouping
>
<
BottomGrouping
>
{
swapIsUnsupported
?
(
{
swapIsUnsupported
?
(
...
...
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