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
6df2f367
Unverified
Commit
6df2f367
authored
Feb 09, 2023
by
Jordan Frankfurt
Committed by
GitHub
Feb 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: use general sort rank instead of only volume rank for row numbers (#5955)
parent
80edf5a0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
25 deletions
+20
-25
TokenRow.tsx
src/components/Tokens/TokenTable/TokenRow.tsx
+4
-4
TokenTable.tsx
src/components/Tokens/TokenTable/TokenTable.tsx
+2
-2
TopTokens.ts
src/graphql/data/TopTokens.ts
+14
-19
No files found.
src/components/Tokens/TokenTable/TokenRow.tsx
View file @
6df2f367
...
@@ -424,12 +424,12 @@ interface LoadedRowProps {
...
@@ -424,12 +424,12 @@ interface LoadedRowProps {
tokenListLength
:
number
tokenListLength
:
number
token
:
NonNullable
<
TopToken
>
token
:
NonNullable
<
TopToken
>
sparklineMap
:
SparklineMap
sparklineMap
:
SparklineMap
volume
Rank
:
number
sort
Rank
:
number
}
}
/* Loaded State: row component with token information */
/* Loaded State: row component with token information */
export
const
LoadedRow
=
forwardRef
((
props
:
LoadedRowProps
,
ref
:
ForwardedRef
<
HTMLDivElement
>
)
=>
{
export
const
LoadedRow
=
forwardRef
((
props
:
LoadedRowProps
,
ref
:
ForwardedRef
<
HTMLDivElement
>
)
=>
{
const
{
tokenListIndex
,
tokenListLength
,
token
,
volume
Rank
}
=
props
const
{
tokenListIndex
,
tokenListLength
,
token
,
sort
Rank
}
=
props
const
filterString
=
useAtomValue
(
filterStringAtom
)
const
filterString
=
useAtomValue
(
filterStringAtom
)
const
lowercaseChainName
=
useParams
<
{
chainName
?:
string
}
>
().
chainName
?.
toUpperCase
()
??
'
ethereum
'
const
lowercaseChainName
=
useParams
<
{
chainName
?:
string
}
>
().
chainName
?.
toUpperCase
()
??
'
ethereum
'
...
@@ -446,7 +446,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -446,7 +446,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
token_address
:
token
.
address
,
token_address
:
token
.
address
,
token_symbol
:
token
.
symbol
,
token_symbol
:
token
.
symbol
,
token_list_index
:
tokenListIndex
,
token_list_index
:
tokenListIndex
,
token_list_rank
:
volume
Rank
,
token_list_rank
:
sort
Rank
,
token_list_length
:
tokenListLength
,
token_list_length
:
tokenListLength
,
time_frame
:
timePeriod
,
time_frame
:
timePeriod
,
search_token_address_input
:
filterString
,
search_token_address_input
:
filterString
,
...
@@ -463,7 +463,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
...
@@ -463,7 +463,7 @@ export const LoadedRow = forwardRef((props: LoadedRowProps, ref: ForwardedRef<HT
>
>
<
TokenRow
<
TokenRow
header=
{
false
}
header=
{
false
}
listNumber=
{
volume
Rank
}
listNumber=
{
sort
Rank
}
tokenInfo=
{
tokenInfo=
{
<
ClickableName
>
<
ClickableName
>
<
QueryTokenLogo
token=
{
token
}
/>
<
QueryTokenLogo
token=
{
token
}
/>
...
...
src/components/Tokens/TokenTable/TokenTable.tsx
View file @
6df2f367
...
@@ -77,7 +77,7 @@ function LoadingTokenTable({ rowCount = PAGE_SIZE }: { rowCount?: number }) {
...
@@ -77,7 +77,7 @@ function LoadingTokenTable({ rowCount = PAGE_SIZE }: { rowCount?: number }) {
export
default
function
TokenTable
()
{
export
default
function
TokenTable
()
{
const
chainName
=
validateUrlChainParam
(
useParams
<
{
chainName
?:
string
}
>
().
chainName
)
const
chainName
=
validateUrlChainParam
(
useParams
<
{
chainName
?:
string
}
>
().
chainName
)
const
{
tokens
,
token
Volume
Rank
,
loadingTokens
,
sparklines
}
=
useTopTokens
(
chainName
)
const
{
tokens
,
token
Sort
Rank
,
loadingTokens
,
sparklines
}
=
useTopTokens
(
chainName
)
/* loading and error state */
/* loading and error state */
if
(
loadingTokens
&&
!
tokens
)
{
if
(
loadingTokens
&&
!
tokens
)
{
...
@@ -109,7 +109,7 @@ export default function TokenTable() {
...
@@ -109,7 +109,7 @@ export default function TokenTable() {
tokenListLength=
{
tokens
.
length
}
tokenListLength=
{
tokens
.
length
}
token=
{
token
}
token=
{
token
}
sparklineMap=
{
sparklines
}
sparklineMap=
{
sparklines
}
volumeRank=
{
tokenVolume
Rank
[
token
.
address
]
}
sortRank=
{
tokenSort
Rank
[
token
.
address
]
}
/>
/>
)
)
)
}
)
}
...
...
src/graphql/data/TopTokens.ts
View file @
6df2f367
...
@@ -139,7 +139,7 @@ export type TopToken = NonNullable<NonNullable<TopTokens100Query>['topTokens']>[
...
@@ -139,7 +139,7 @@ export type TopToken = NonNullable<NonNullable<TopTokens100Query>['topTokens']>[
interface
UseTopTokensReturnValue
{
interface
UseTopTokensReturnValue
{
tokens
:
TopToken
[]
|
undefined
tokens
:
TopToken
[]
|
undefined
token
Volume
Rank
:
Record
<
string
,
number
>
token
Sort
Rank
:
Record
<
string
,
number
>
loadingTokens
:
boolean
loadingTokens
:
boolean
sparklines
:
SparklineMap
sparklines
:
SparklineMap
}
}
...
@@ -172,26 +172,21 @@ export function useTopTokens(chain: Chain): UseTopTokensReturnValue {
...
@@ -172,26 +172,21 @@ export function useTopTokens(chain: Chain): UseTopTokensReturnValue {
)
)
const
unwrappedTokens
=
useMemo
(()
=>
data
?.
topTokens
?.
map
((
token
)
=>
unwrapToken
(
chainId
,
token
)),
[
chainId
,
data
])
const
unwrappedTokens
=
useMemo
(()
=>
data
?.
topTokens
?.
map
((
token
)
=>
unwrapToken
(
chainId
,
token
)),
[
chainId
,
data
])
const
tokenVolumeRank
=
useMemo
(
const
sortedTokens
=
useSortedTokens
(
unwrappedTokens
)
const
tokenSortRank
=
useMemo
(
()
=>
()
=>
unwrappedTokens
sortedTokens
?.
reduce
((
acc
,
cur
,
i
)
=>
{
?.
sort
((
a
,
b
)
=>
{
if
(
!
a
.
market
?.
volume
||
!
b
.
market
?.
volume
)
return
0
return
a
.
market
.
volume
.
value
>
b
.
market
.
volume
.
value
?
-
1
:
1
})
.
reduce
((
acc
,
cur
,
i
)
=>
{
if
(
!
cur
.
address
)
return
acc
if
(
!
cur
.
address
)
return
acc
return
{
return
{
...
acc
,
...
acc
,
[
cur
.
address
]:
i
+
1
,
[
cur
.
address
]:
i
+
1
,
}
}
},
{})
??
{},
},
{})
??
{},
[
unwrapp
edTokens
]
[
sort
edTokens
]
)
)
const
filteredTokens
=
useFilteredTokens
(
unwrappedTokens
)
const
filteredTokens
=
useFilteredTokens
(
sortedTokens
)
const
sortedTokens
=
useSortedTokens
(
filteredTokens
)
return
useMemo
(
return
useMemo
(
()
=>
({
tokens
:
sortedTokens
,
tokenVolume
Rank
,
loadingTokens
,
sparklines
}),
()
=>
({
tokens
:
filteredTokens
,
tokenSort
Rank
,
loadingTokens
,
sparklines
}),
[
loadingTokens
,
tokenVolumeRank
,
sorted
Tokens
,
sparklines
]
[
filteredTokens
,
tokenSortRank
,
loading
Tokens
,
sparklines
]
)
)
}
}
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