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
803eb46e
Unverified
Commit
803eb46e
authored
Jul 17, 2023
by
Charles Bachmeier
Committed by
GitHub
Jul 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Clear input and output when wrapping and unwrapping (#6913)
* add wrap handler * onWrap passed back tx hash * async await
parent
a3f0c54f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
13 deletions
+45
-13
useWrapCallback.tsx
src/hooks/useWrapCallback.tsx
+17
-12
index.tsx
src/pages/Swap/index.tsx
+28
-1
No files found.
src/hooks/useWrapCallback.tsx
View file @
803eb46e
...
...
@@ -141,6 +141,7 @@ Please file a bug detailing how this happened - https://github.com/Uniswap/inter
execute
:
sufficientBalance
&&
inputAmount
?
async
()
=>
{
try
{
const
txReceipt
=
await
wethContract
.
withdraw
(
`0x
${
inputAmount
.
quotient
.
toString
(
16
)}
`
)
addTransaction
(
txReceipt
,
{
type
:
TransactionType
.
WRAP
,
...
...
@@ -153,6 +154,10 @@ Please file a bug detailing how this happened - https://github.com/Uniswap/inter
type
:
WrapType
.
UNWRAP
,
})
return
txReceipt
.
hash
}
catch
(
error
)
{
console
.
error
(
'
Could not withdraw
'
,
error
)
throw
error
}
}
:
undefined
,
inputError
:
sufficientBalance
...
...
src/pages/Swap/index.tsx
View file @
803eb46e
...
...
@@ -435,6 +435,33 @@ export function Swap({
})
},
[
swapCallback
,
stablecoinPriceImpact
])
const
handleOnWrap
=
useCallback
(
async
()
=>
{
if
(
!
onWrap
)
return
try
{
const
txHash
=
await
onWrap
()
setSwapState
((
currentState
)
=>
({
...
currentState
,
swapError
:
undefined
,
txHash
,
}))
onUserInput
(
Field
.
INPUT
,
''
)
}
catch
(
error
)
{
if
(
!
didUserReject
(
error
))
{
sendAnalyticsEvent
(
SwapEventName
.
SWAP_ERROR
,
{
wrapType
,
input
:
currencies
[
Field
.
INPUT
],
output
:
currencies
[
Field
.
OUTPUT
],
})
}
console
.
error
(
'
Could not wrap/unwrap
'
,
error
)
setSwapState
((
currentState
)
=>
({
...
currentState
,
swapError
:
error
,
txHash
:
undefined
,
}))
}
},
[
currencies
,
onUserInput
,
onWrap
,
wrapType
])
// errors
const
[
swapQuoteReceivedDate
,
setSwapQuoteReceivedDate
]
=
useState
<
Date
|
undefined
>
()
...
...
@@ -684,7 +711,7 @@ export function Swap({
)
:
showWrap
?
(
<
ButtonPrimary
disabled=
{
Boolean
(
wrapInputError
)
}
onClick=
{
()
=>
onWrap
?.().
catch
((
e
)
=>
console
.
error
(
'
Could not wrap/unwrap
'
,
e
))
}
onClick=
{
handleOnWrap
}
fontWeight=
{
600
}
data
-
testid=
"wrap-button"
>
...
...
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