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
99a3cfaf
Unverified
Commit
99a3cfaf
authored
Sep 27, 2022
by
Jordan Frankfurt
Committed by
GitHub
Sep 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: support NATIVE page for all supported chains (#4722)
support NATIVE page for all supported chains
parent
6c908eb7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
23 deletions
+33
-23
tokens.ts
src/constants/tokens.ts
+14
-0
index.tsx
src/pages/TokenDetails/index.tsx
+19
-23
No files found.
src/constants/tokens.ts
View file @
99a3cfaf
...
@@ -388,6 +388,20 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token | undefined } =
...
@@ -388,6 +388,20 @@ export const WRAPPED_NATIVE_CURRENCY: { [chainId: number]: Token | undefined } =
'
WMATIC
'
,
'
WMATIC
'
,
'
Wrapped MATIC
'
'
Wrapped MATIC
'
),
),
[
SupportedChainId
.
CELO
]:
new
Token
(
SupportedChainId
.
CELO
,
'
0x471ece3750da237f93b8e339c536989b8978a438
'
,
18
,
'
CELO
'
,
'
Celo native asset
'
),
[
SupportedChainId
.
CELO_ALFAJORES
]:
new
Token
(
SupportedChainId
.
CELO_ALFAJORES
,
'
0xf194afdf50b03e69bd7d057c1aa9e10c9954e4c9
'
,
18
,
'
CELO
'
,
'
Celo native asset
'
),
}
}
export
function
isCelo
(
chainId
:
number
):
chainId
is
SupportedChainId
.
CELO
|
SupportedChainId
.
CELO_ALFAJORES
{
export
function
isCelo
(
chainId
:
number
):
chainId
is
SupportedChainId
.
CELO
|
SupportedChainId
.
CELO_ALFAJORES
{
...
...
src/pages/TokenDetails/index.tsx
View file @
99a3cfaf
...
@@ -112,29 +112,31 @@ export default function TokenDetails() {
...
@@ -112,29 +112,31 @@ export default function TokenDetails() {
const
token
=
useTokenQuery
(
tokenAddress
??
''
,
currentChainName
,
timePeriod
).
tokens
?.[
0
]
const
token
=
useTokenQuery
(
tokenAddress
??
''
,
currentChainName
,
timePeriod
).
tokens
?.[
0
]
const
navigate
=
useNavigate
()
const
navigate
=
useNavigate
()
const
switchChains
=
(
newChain
:
Chain
)
=>
{
const
switchChains
=
useCallback
(
if
(
tokenAddressParam
===
'
NATIVE
'
)
{
(
newChain
:
Chain
)
=>
{
navigate
(
`/tokens/
${
newChain
.
toLowerCase
()}
/NATIVE`
)
const
chainSegment
=
newChain
.
toLowerCase
()
}
else
{
if
(
tokenAddressParam
===
'
NATIVE
'
)
{
token
?.
project
?.
tokens
?.
forEach
((
token
)
=>
{
navigate
(
`/tokens/
${
chainSegment
}
/NATIVE`
)
if
(
token
.
chain
===
newChain
&&
token
.
address
)
{
}
else
{
navigate
(
`/tokens/
${
newChain
.
toLowerCase
()}
/
${
token
.
address
}
`
)
token
?.
project
?.
tokens
?.
forEach
((
token
)
=>
{
}
if
(
token
.
chain
===
newChain
&&
token
.
address
)
{
})
navigate
(
`/tokens/
${
chainSegment
}
/
${
token
.
address
}
`
)
}
}
}
})
}
},
[
navigate
,
token
?.
project
?.
tokens
,
tokenAddressParam
]
)
useOnGlobalChainSwitch
(
switchChains
)
useOnGlobalChainSwitch
(
switchChains
)
const
[
continueSwap
,
setContinueSwap
]
=
useState
<
{
resolve
:
(
value
:
boolean
|
PromiseLike
<
boolean
>
)
=>
void
}
>
()
const
[
continueSwap
,
setContinueSwap
]
=
useState
<
{
resolve
:
(
value
:
boolean
|
PromiseLike
<
boolean
>
)
=>
void
}
>
()
// TODO: Make useToken() work on non-mainenet chains or replace this logic
const
shouldShowSpeedbump
=
!
useIsUserAddedTokenOnChain
(
tokenAddress
,
chainId
)
&&
tokenWarning
!==
null
const
shouldShowSpeedbump
=
!
useIsUserAddedTokenOnChain
(
tokenAddress
,
chainId
)
&&
tokenWarning
!==
null
// Show token safety modal if Swap-reviewing a warning token, at all times if the current token is blocked
// Show token safety modal if Swap-reviewing a warning token, at all times if the current token is blocked
const
onReviewSwap
=
useCallback
(()
=>
{
const
onReviewSwap
=
useCallback
(
return
new
Promise
<
boolean
>
((
resolve
)
=>
{
()
=>
new
Promise
<
boolean
>
((
resolve
)
=>
(
shouldShowSpeedbump
?
setContinueSwap
({
resolve
})
:
resolve
(
true
))),
shouldShowSpeedbump
?
setContinueSwap
({
resolve
})
:
resolve
(
true
)
[
shouldShowSpeedbump
]
})
)
},
[
shouldShowSpeedbump
])
const
onResolveSwap
=
useCallback
(
const
onResolveSwap
=
useCallback
(
(
value
:
boolean
)
=>
{
(
value
:
boolean
)
=>
{
...
@@ -191,12 +193,6 @@ export default function TokenDetails() {
...
@@ -191,12 +193,6 @@ export default function TokenDetails() {
?
new
Token
(
CHAIN_NAME_TO_CHAIN_ID
[
currentChainName
],
token
.
address
,
18
,
token
.
symbol
,
token
.
name
)
?
new
Token
(
CHAIN_NAME_TO_CHAIN_ID
[
currentChainName
],
token
.
address
,
18
,
token
.
symbol
,
token
.
name
)
:
undefined
)
:
undefined
)
// TODO: Fix this logic to not automatically redirect on refresh, yet still catch invalid addresses
//const location = useLocation()
//if (token === undefined) {
// return <Navigate to={{ ...location, pathname: '/tokens' }} replace />
//}
return
(
return
(
<
TokenDetailsLayout
>
<
TokenDetailsLayout
>
{
token
&&
(
{
token
&&
(
...
...
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