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
fd4430fe
Unverified
Commit
fd4430fe
authored
Jan 03, 2023
by
eddie
Committed by
GitHub
Jan 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: include descriptions and links for native tokens (#5756)
parent
167cc695
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
17 deletions
+55
-17
token.test.ts
cypress/e2e/token.test.ts
+14
-0
About.tsx
src/components/Tokens/TokenDetails/About.tsx
+12
-3
Skeleton.tsx
src/components/Tokens/TokenDetails/Skeleton.tsx
+1
-1
index.tsx
src/components/Tokens/TokenDetails/index.tsx
+9
-12
index.tsx
src/pages/TokenDetails/index.tsx
+2
-1
nativeTokens.ts
src/utils/nativeTokens.ts
+17
-0
No files found.
cypress/e2e/token.test.ts
View file @
fd4430fe
...
...
@@ -17,4 +17,18 @@ describe('Testing tokens on uniswap page', () => {
cy
.
get
(
getTestSelector
(
'
token-details-return-button
'
)).
click
()
cy
.
get
(
getTestSelectorStartsWith
(
'
token-table
'
)).
its
(
'
length
'
).
should
(
'
be.gte
'
,
25
)
})
it
(
'
should go to native token on ethereum and render description
'
,
()
=>
{
cy
.
visit
(
'
/tokens/ethereum/NATIVE
'
)
cy
.
get
(
getTestSelector
(
'
token-details-about-section
'
)).
should
(
'
exist
'
)
cy
.
contains
(
'
Ethereum is a smart contract platform that enables developers
'
).
should
(
'
exist
'
)
cy
.
contains
(
'
Etherscan
'
).
should
(
'
exist
'
)
})
it
(
'
should go to native token on polygon and render description and links
'
,
()
=>
{
cy
.
visit
(
'
/tokens/polygon/NATIVE
'
)
cy
.
get
(
getTestSelector
(
'
token-details-about-section
'
)).
should
(
'
exist
'
)
cy
.
contains
(
'
Wrapped Matic on Polygon
'
).
should
(
'
exist
'
)
cy
.
contains
(
'
Block Explorer
'
).
should
(
'
exist
'
)
})
})
src/components/Tokens/TokenDetails/About.tsx
View file @
fd4430fe
import
{
Trans
}
from
'
@lingui/macro
'
import
{
SupportedChainId
}
from
'
@uniswap/sdk-core
'
import
{
getChainInfo
}
from
'
constants/chainInfo
'
import
{
darken
}
from
'
polished
'
import
{
useState
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
...
...
@@ -65,19 +67,22 @@ const ResourcesContainer = styled.div`
type
AboutSectionProps
=
{
address
:
string
chainId
:
SupportedChainId
description
?:
string
|
null
|
undefined
homepageUrl
?:
string
|
null
|
undefined
twitterName
?:
string
|
null
|
undefined
}
export
function
AboutSection
({
address
,
description
,
homepageUrl
,
twitterName
}:
AboutSectionProps
)
{
export
function
AboutSection
({
address
,
chainId
,
description
,
homepageUrl
,
twitterName
}:
AboutSectionProps
)
{
const
[
isDescriptionTruncated
,
setIsDescriptionTruncated
]
=
useState
(
true
)
const
shouldTruncate
=
!!
description
&&
description
.
length
>
TRUNCATE_CHARACTER_COUNT
const
tokenDescription
=
shouldTruncate
&&
isDescriptionTruncated
?
truncateDescription
(
description
)
:
description
const
baseExplorerUrl
=
getChainInfo
(
chainId
).
explorer
return
(
<
AboutContainer
>
<
AboutContainer
data
-
testid=
"token-details-about-section"
>
<
AboutHeader
>
<
Trans
>
About
</
Trans
>
</
AboutHeader
>
...
...
@@ -99,7 +104,11 @@ export function AboutSection({ address, description, homepageUrl, twitterName }:
<
Trans
>
Links
</
Trans
>
</
ThemedText
.
SubHeaderSmall
>
<
ResourcesContainer
>
<
Resource
name=
"Etherscan"
link=
{
`https://etherscan.io/address/${address}`
}
/>
<
Resource
data
-
testid=
"token-details-about-section-explorer-link"
name=
{
chainId
===
SupportedChainId
.
MAINNET
?
'
Etherscan
'
:
'
Block Explorer
'
}
link=
{
`${baseExplorerUrl}${address === 'NATIVE' ? '' : 'address/' + address}`
}
/>
<
Resource
name=
"More analytics"
link=
{
`https://info.uniswap.org/#/tokens/${address}`
}
/>
{
homepageUrl
&&
<
Resource
name=
"Website"
link=
{
homepageUrl
}
/>
}
{
twitterName
&&
<
Resource
name=
"Twitter"
link=
{
`https://twitter.com/${twitterName}`
}
/>
}
...
...
src/components/Tokens/TokenDetails/Skeleton.tsx
View file @
fd4430fe
...
...
@@ -25,7 +25,7 @@ export const TokenDetailsLayout = styled.div`
@media screen and (min-width:
${({
theme
})
=>
theme
.
breakpoint
.
sm
}
px) {
gap: 16px;
padding: 0 16px;
padding: 0 16px
52px
;
}
@media screen and (min-width:
${({
theme
})
=>
theme
.
breakpoint
.
md
}
px) {
gap: 40px;
...
...
src/components/Tokens/TokenDetails/index.tsx
View file @
fd4430fe
...
...
@@ -206,18 +206,15 @@ export default function TokenDetails({
priceHigh52W=
{
tokenQueryData
?.
market
?.
priceHigh52W
?.
value
}
priceLow52W=
{
tokenQueryData
?.
market
?.
priceLow52W
?.
value
}
/>
{
!
token
.
isNative
&&
(
<>
<
Hr
/>
<
AboutSection
address=
{
address
}
description=
{
tokenQueryData
?.
project
?.
description
}
homepageUrl=
{
tokenQueryData
?.
project
?.
homepageUrl
}
twitterName=
{
tokenQueryData
?.
project
?.
twitterName
}
/>
<
AddressSection
address=
{
address
}
/>
</>
)
}
<
Hr
/>
<
AboutSection
address=
{
address
}
chainId=
{
pageChainId
}
description=
{
tokenQueryData
?.
project
?.
description
}
homepageUrl=
{
tokenQueryData
?.
project
?.
homepageUrl
}
twitterName=
{
tokenQueryData
?.
project
?.
twitterName
}
/>
{
!
token
.
isNative
&&
<
AddressSection
address=
{
address
}
/>
}
</
LeftPanel
>
)
:
(
<
TokenDetailsSkeleton
/>
...
...
src/pages/TokenDetails/index.tsx
View file @
fd4430fe
...
...
@@ -7,6 +7,7 @@ import { useAtom } from 'jotai'
import
{
atomWithStorage
}
from
'
jotai/utils
'
import
{
useMemo
}
from
'
react
'
import
{
useParams
}
from
'
react-router-dom
'
import
{
getNativeTokenDBAddress
}
from
'
utils/nativeTokens
'
export
const
pageTimePeriodAtom
=
atomWithStorage
<
TimePeriod
>
(
'
tokenDetailsTimePeriod
'
,
TimePeriod
.
DAY
)
...
...
@@ -26,7 +27,7 @@ export default function TokenDetailsPage() {
const
{
data
:
tokenQuery
,
loading
:
tokenQueryLoading
}
=
useTokenQuery
({
variables
:
{
contract
,
contract
:
isNative
?
{
address
:
getNativeTokenDBAddress
(
chain
),
chain
}
:
contract
,
},
})
...
...
src/utils/nativeTokens.ts
0 → 100644
View file @
fd4430fe
import
{
nativeOnChain
}
from
'
constants/tokens
'
import
{
Chain
}
from
'
graphql/data/__generated__/types-and-hooks
'
import
{
CHAIN_NAME_TO_CHAIN_ID
}
from
'
graphql/data/util
'
export
function
getNativeTokenDBAddress
(
chain
:
Chain
):
string
{
const
pageChainId
=
CHAIN_NAME_TO_CHAIN_ID
[
chain
]
switch
(
chain
)
{
case
Chain
.
Celo
:
case
Chain
.
Polygon
:
return
nativeOnChain
(
pageChainId
).
wrapped
.
address
case
Chain
.
Ethereum
:
case
Chain
.
Arbitrum
:
case
Chain
.
EthereumGoerli
:
case
Chain
.
Optimism
:
return
'
ETH
'
}
}
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