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
1af34ae0
Unverified
Commit
1af34ae0
authored
Feb 10, 2022
by
Zach Pomerantz
Committed by
GitHub
Feb 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: EtherscanA component (#3284)
* feat: EtherscanA component * refactor: EtherscanLink from ExternalLink
parent
9cb19dd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
10 deletions
+38
-10
EtherscanLink.tsx
src/lib/components/EtherscanLink.tsx
+32
-0
ExternalLink.tsx
src/lib/components/ExternalLink.tsx
+1
-1
SwapButton.tsx
src/lib/components/Swap/SwapButton.tsx
+5
-9
No files found.
src/lib/components/EtherscanLink.tsx
0 → 100644
View file @
1af34ae0
import
{
SupportedChainId
}
from
'
constants/chains
'
import
useActiveWeb3React
from
'
lib/hooks/useActiveWeb3React
'
import
styled
,
{
Color
}
from
'
lib/theme
'
import
{
ReactNode
,
useMemo
}
from
'
react
'
import
{
ExplorerDataType
,
getExplorerLink
}
from
'
utils/getExplorerLink
'
import
ExternalLink
from
'
./ExternalLink
'
const
Link
=
styled
(
ExternalLink
)
<
{
color
:
Color
}
>
`
color:
${({
theme
,
color
})
=>
theme
[
color
]}
text-decoration: none;
`
interface
EtherscanLinkProps
{
type
:
ExplorerDataType
data
?:
string
color
?:
Color
children
:
ReactNode
}
export
default
function
EtherscanLink
({
data
,
type
,
color
=
'
currentColor
'
,
children
}:
EtherscanLinkProps
)
{
const
{
chainId
}
=
useActiveWeb3React
()
const
url
=
useMemo
(
()
=>
data
&&
getExplorerLink
(
chainId
||
SupportedChainId
.
MAINNET
,
data
,
type
),
[
chainId
,
data
,
type
]
)
return
(
<
Link
href=
{
url
}
color=
{
color
}
target=
"_blank"
>
{
children
}
</
Link
>
)
}
src/lib/components/ExternalLink.tsx
View file @
1af34ae0
...
...
@@ -8,7 +8,7 @@ export default function ExternalLink({
href
,
rel
=
'
noopener noreferrer
'
,
...
rest
}:
Omit
<
HTMLProps
<
HTMLAnchorElement
>
,
'
as
'
|
'
ref
'
|
'
onClick
'
>
&
{
href
:
string
})
{
}:
Omit
<
HTMLProps
<
HTMLAnchorElement
>
,
'
as
'
|
'
ref
'
|
'
onClick
'
>
&
{
href
?
:
string
})
{
return
(
<
a
target=
{
target
}
rel=
{
rel
}
href=
{
href
}
{
...
rest
}
>
{
rest
.
children
}
...
...
src/lib/components/Swap/SwapButton.tsx
View file @
1af34ae0
import
{
Trans
}
from
'
@lingui/macro
'
import
{
Token
,
TradeType
}
from
'
@uniswap/sdk-core
'
import
{
CHAIN_INFO
}
from
'
constants/chainInfo
'
import
{
useERC20PermitFromTrade
}
from
'
hooks/useERC20Permit
'
import
{
useUpdateAtom
}
from
'
jotai/utils
'
import
{
useAtomValue
}
from
'
jotai/utils
'
...
...
@@ -18,12 +17,14 @@ import useTransactionDeadline from 'lib/hooks/useTransactionDeadline'
import
{
Link
,
Spinner
}
from
'
lib/icons
'
import
{
displayTxHashAtom
,
Field
,
independentFieldAtom
}
from
'
lib/state/swap
'
import
{
TransactionType
}
from
'
lib/state/transactions
'
import
styled
,
{
useTheme
}
from
'
lib/theme
'
import
{
useTheme
}
from
'
lib/theme
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
invariant
from
'
tiny-invariant
'
import
{
ExplorerDataType
}
from
'
utils/getExplorerLink
'
import
ActionButton
from
'
../ActionButton
'
import
Dialog
from
'
../Dialog
'
import
EtherscanLink
from
'
../EtherscanLink
'
import
Row
from
'
../Row
'
import
{
SummaryDialog
}
from
'
./Summary
'
...
...
@@ -31,11 +32,6 @@ interface SwapButtonProps {
disabled
?:
boolean
}
const
EtherscanA
=
styled
.
a
`
color: currentColor;
text-decoration: none;
`
function
useIsPendingApproval
(
token
?:
Token
,
spender
?:
string
):
boolean
{
return
Boolean
(
usePendingApproval
(
token
,
spender
))
}
...
...
@@ -91,13 +87,13 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
disabled
:
true
,
update
:
{
message
:
(
<
Etherscan
A
href=
{
approvalHash
&&
`${CHAIN_INFO[chainId].explorer}tx/${approvalHash}`
}
target=
"_blank"
>
<
Etherscan
Link
type=
{
ExplorerDataType
.
TRANSACTION
}
data=
{
approvalHash
}
>
<
Row
gap=
{
0.25
}
>
<
Trans
>
Approval pending
<
Link
/>
</
Trans
>
</
Row
>
</
Etherscan
A
>
</
Etherscan
Link
>
),
action
:
<
Trans
>
Approve
</
Trans
>,
icon
:
Spinner
,
...
...
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