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
0770bab0
Unverified
Commit
0770bab0
authored
May 05, 2021
by
Noah Zinsmeister
Committed by
GitHub
May 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try manual approve if erc712 doesn't work (#1397)
* initial impl * fix async logic
parent
e5404dbf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
7 deletions
+53
-7
StakingModal.tsx
src/components/earn/StakingModal.tsx
+12
-1
useERC20Permit.ts
src/hooks/useERC20Permit.ts
+1
-1
MigrateV2Pair.tsx
src/pages/MigrateV2/MigrateV2Pair.tsx
+15
-1
index.tsx
src/pages/RemoveLiquidity/index.tsx
+12
-1
index.tsx
src/pages/Swap/index.tsx
+13
-3
No files found.
src/components/earn/StakingModal.tsx
View file @
0770bab0
...
@@ -128,7 +128,18 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui
...
@@ -128,7 +128,18 @@ export default function StakingModal({ isOpen, onDismiss, stakingInfo, userLiqui
if
(
!
pairContract
||
!
library
||
!
deadline
)
throw
new
Error
(
'
missing dependencies
'
)
if
(
!
pairContract
||
!
library
||
!
deadline
)
throw
new
Error
(
'
missing dependencies
'
)
if
(
!
parsedAmount
)
throw
new
Error
(
'
missing liquidity amount
'
)
if
(
!
parsedAmount
)
throw
new
Error
(
'
missing liquidity amount
'
)
return
gatherPermitSignature
?
gatherPermitSignature
()
:
approveCallback
()
if
(
gatherPermitSignature
)
{
try
{
await
gatherPermitSignature
()
}
catch
(
error
)
{
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if
(
error
?.
code
!==
4001
)
{
await
approveCallback
()
}
}
}
else
{
await
approveCallback
()
}
}
}
return
(
return
(
...
...
src/hooks/useERC20Permit.ts
View file @
0770bab0
...
@@ -219,7 +219,7 @@ export function useERC20Permit(
...
@@ -219,7 +219,7 @@ export function useERC20Permit(
message
,
message
,
})
})
library
return
library
.
send
(
'
eth_signTypedData_v4
'
,
[
account
,
data
])
.
send
(
'
eth_signTypedData_v4
'
,
[
account
,
data
])
.
then
(
splitSignature
)
.
then
(
splitSignature
)
.
then
((
signature
)
=>
{
.
then
((
signature
)
=>
{
...
...
src/pages/MigrateV2/MigrateV2Pair.tsx
View file @
0770bab0
...
@@ -239,7 +239,21 @@ function V2PairMigration({
...
@@ -239,7 +239,21 @@ function V2PairMigration({
const
{
signatureData
,
gatherPermitSignature
}
=
useV2LiquidityTokenPermit
(
pairBalance
,
migratorAddress
)
const
{
signatureData
,
gatherPermitSignature
}
=
useV2LiquidityTokenPermit
(
pairBalance
,
migratorAddress
)
const
approve
=
useCallback
(
async
()
=>
{
const
approve
=
useCallback
(
async
()
=>
{
isNotUniswap
?
approveManually
()
:
gatherPermitSignature
?
gatherPermitSignature
()
:
approveManually
()
if
(
isNotUniswap
)
{
// sushi has to be manually approved
await
approveManually
()
}
else
if
(
gatherPermitSignature
)
{
try
{
await
gatherPermitSignature
()
}
catch
(
error
)
{
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if
(
error
?.
code
!==
4001
)
{
await
approveManually
()
}
}
}
else
{
await
approveManually
()
}
},
[
isNotUniswap
,
gatherPermitSignature
,
approveManually
])
},
[
isNotUniswap
,
gatherPermitSignature
,
approveManually
])
const
addTransaction
=
useTransactionAdder
()
const
addTransaction
=
useTransactionAdder
()
...
...
src/pages/RemoveLiquidity/index.tsx
View file @
0770bab0
...
@@ -109,7 +109,18 @@ export default function RemoveLiquidity({
...
@@ -109,7 +109,18 @@ export default function RemoveLiquidity({
const
liquidityAmount
=
parsedAmounts
[
Field
.
LIQUIDITY
]
const
liquidityAmount
=
parsedAmounts
[
Field
.
LIQUIDITY
]
if
(
!
liquidityAmount
)
throw
new
Error
(
'
missing liquidity amount
'
)
if
(
!
liquidityAmount
)
throw
new
Error
(
'
missing liquidity amount
'
)
return
gatherPermitSignature
?
gatherPermitSignature
()
:
approveCallback
()
if
(
gatherPermitSignature
)
{
try
{
await
gatherPermitSignature
()
}
catch
(
error
)
{
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if
(
error
?.
code
!==
4001
)
{
await
approveCallback
()
}
}
}
else
{
await
approveCallback
()
}
}
}
// wrapped onUserInput to clear signatures
// wrapped onUserInput to clear signatures
...
...
src/pages/Swap/index.tsx
View file @
0770bab0
...
@@ -205,9 +205,19 @@ export default function Swap({ history }: RouteComponentProps) {
...
@@ -205,9 +205,19 @@ export default function Swap({ history }: RouteComponentProps) {
allowedSlippage
allowedSlippage
)
)
const
handleApprove
=
useCallback
(()
=>
{
const
handleApprove
=
useCallback
(
async
()
=>
{
if
(
signatureState
===
UseERC20PermitState
.
NOT_SIGNED
&&
gatherPermitSignature
)
gatherPermitSignature
()
if
(
signatureState
===
UseERC20PermitState
.
NOT_SIGNED
&&
gatherPermitSignature
)
{
else
approveCallback
()
try
{
await
gatherPermitSignature
()
}
catch
(
error
)
{
// try to approve if gatherPermitSignature failed for any reason other than the user rejecting it
if
(
error
?.
code
!==
4001
)
{
await
approveCallback
()
}
}
}
else
{
await
approveCallback
()
}
},
[
approveCallback
,
gatherPermitSignature
,
signatureState
])
},
[
approveCallback
,
gatherPermitSignature
,
signatureState
])
// check if user has gone through approval process, used to show two step buttons, reset on token change
// check if user has gone through approval process, used to show two step buttons, reset on token change
...
...
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