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
897e7f45
Unverified
Commit
897e7f45
authored
Feb 11, 2022
by
Zach Pomerantz
Committed by
GitHub
Feb 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: approval action button (#3297)
parent
a7fb7dc9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
ActionButton.tsx
src/lib/components/ActionButton.tsx
+8
-1
index.tsx
src/lib/components/Swap/Summary/index.tsx
+2
-2
SwapButton.tsx
src/lib/components/Swap/SwapButton.tsx
+6
-5
No files found.
src/lib/components/ActionButton.tsx
View file @
897e7f45
...
@@ -54,10 +54,17 @@ export const Overlay = styled(Row)<{ action?: boolean }>`
...
@@ -54,10 +54,17 @@ export const Overlay = styled(Row)<{ action?: boolean }>`
${({
action
})
=>
action
&&
actionCss
}
${({
action
})
=>
action
&&
actionCss
}
`
`
export
interface
Action
{
message
:
ReactNode
icon
?:
Icon
onClick
:
()
=>
void
children
:
ReactNode
}
export
interface
ActionButtonProps
{
export
interface
ActionButtonProps
{
color
?:
Color
color
?:
Color
disabled
?:
boolean
disabled
?:
boolean
action
?:
{
message
:
ReactNode
;
icon
?:
Icon
;
onClick
:
()
=>
void
;
children
:
ReactNode
}
action
?:
Action
onClick
:
()
=>
void
onClick
:
()
=>
void
children
:
ReactNode
children
:
ReactNode
}
}
...
...
src/lib/components/Swap/Summary/index.tsx
View file @
897e7f45
...
@@ -16,7 +16,7 @@ import { formatCurrencyAmount, formatPrice } from 'utils/formatCurrencyAmount'
...
@@ -16,7 +16,7 @@ import { formatCurrencyAmount, formatPrice } from 'utils/formatCurrencyAmount'
import
{
computeRealizedPriceImpact
}
from
'
utils/prices
'
import
{
computeRealizedPriceImpact
}
from
'
utils/prices
'
import
{
tradeMeaningfullyDiffers
}
from
'
utils/tradeMeaningFullyDiffer
'
import
{
tradeMeaningfullyDiffers
}
from
'
utils/tradeMeaningFullyDiffer
'
import
ActionButton
from
'
../../ActionButton
'
import
ActionButton
,
{
Action
}
from
'
../../ActionButton
'
import
Column
from
'
../../Column
'
import
Column
from
'
../../Column
'
import
{
Header
}
from
'
../../Dialog
'
import
{
Header
}
from
'
../../Dialog
'
import
Row
from
'
../../Row
'
import
Row
from
'
../../Row
'
...
@@ -112,7 +112,7 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial
...
@@ -112,7 +112,7 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial
[
confirmedTrade
,
trade
]
[
confirmedTrade
,
trade
]
)
)
const
action
=
useMemo
(()
=>
{
const
action
=
useMemo
(()
:
Action
|
undefined
=>
{
if
(
doesTradeDiffer
)
{
if
(
doesTradeDiffer
)
{
return
{
return
{
message
:
<
Trans
>
Price updated
</
Trans
>,
message
:
<
Trans
>
Price updated
</
Trans
>,
...
...
src/lib/components/Swap/SwapButton.tsx
View file @
897e7f45
...
@@ -22,7 +22,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
...
@@ -22,7 +22,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
import
invariant
from
'
tiny-invariant
'
import
invariant
from
'
tiny-invariant
'
import
{
ExplorerDataType
}
from
'
utils/getExplorerLink
'
import
{
ExplorerDataType
}
from
'
utils/getExplorerLink
'
import
ActionButton
from
'
../ActionButton
'
import
ActionButton
,
{
ActionButtonProps
}
from
'
../ActionButton
'
import
Dialog
from
'
../Dialog
'
import
Dialog
from
'
../Dialog
'
import
EtherscanLink
from
'
../EtherscanLink
'
import
EtherscanLink
from
'
../EtherscanLink
'
import
Row
from
'
../Row
'
import
Row
from
'
../Row
'
...
@@ -76,7 +76,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
...
@@ -76,7 +76,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
})
})
},
[
addTransaction
,
getApproval
])
},
[
addTransaction
,
getApproval
])
const
actionProps
=
useMemo
(()
=>
{
const
actionProps
=
useMemo
(()
:
Partial
<
ActionButtonProps
>
|
undefined
=>
{
if
(
disabled
)
return
{
disabled
:
true
}
if
(
disabled
)
return
{
disabled
:
true
}
if
(
chainId
&&
inputCurrencyAmount
)
{
if
(
chainId
&&
inputCurrencyAmount
)
{
...
@@ -85,7 +85,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
...
@@ -85,7 +85,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
}
else
if
(
approval
===
ApprovalState
.
PENDING
)
{
}
else
if
(
approval
===
ApprovalState
.
PENDING
)
{
return
{
return
{
disabled
:
true
,
disabled
:
true
,
update
:
{
action
:
{
message
:
(
message
:
(
<
EtherscanLink
type=
{
ExplorerDataType
.
TRANSACTION
}
data=
{
approvalHash
}
>
<
EtherscanLink
type=
{
ExplorerDataType
.
TRANSACTION
}
data=
{
approvalHash
}
>
<
Row
gap=
{
0.25
}
>
<
Row
gap=
{
0.25
}
>
...
@@ -102,9 +102,10 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
...
@@ -102,9 +102,10 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
}
}
}
else
if
(
approval
===
ApprovalState
.
NOT_APPROVED
)
{
}
else
if
(
approval
===
ApprovalState
.
NOT_APPROVED
)
{
return
{
return
{
update
:
{
action
:
{
message
:
<
Trans
>
Approve
{
inputCurrencyAmount
.
currency
.
symbol
}
first
</
Trans
>,
message
:
<
Trans
>
Approve
{
inputCurrencyAmount
.
currency
.
symbol
}
first
</
Trans
>,
action
:
<
Trans
>
Approve
</
Trans
>,
onClick
:
addApprovalTransaction
,
children
:
<
Trans
>
Approve
</
Trans
>,
},
},
}
}
}
}
...
...
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