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
f15e5725
Unverified
Commit
f15e5725
authored
Feb 22, 2023
by
Jordan Frankfurt
Committed by
GitHub
Feb 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: token list load issue WEB-2083 (#6019)
parent
83c8393f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
TokenLogoLookupTable.ts
src/constants/TokenLogoLookupTable.ts
+7
-3
Tokens.ts
src/hooks/Tokens.ts
+1
-1
listSort.ts
src/utils/listSort.ts
+12
-8
nativeTokens.ts
src/utils/nativeTokens.ts
+3
-0
No files found.
src/constants/TokenLogoLookupTable.ts
View file @
f15e5725
...
...
@@ -9,8 +9,12 @@ class TokenLogoLookupTable {
initialize
()
{
const
dict
:
{
[
key
:
string
]:
string
[]
|
undefined
}
=
{}
DEFAULT_LIST_OF_LISTS
.
forEach
((
list
)
=>
store
.
getState
().
lists
.
byUrl
[
list
].
current
?.
tokens
.
forEach
((
token
)
=>
{
DEFAULT_LIST_OF_LISTS
.
forEach
((
list
)
=>
{
const
listData
=
store
.
getState
().
lists
.
byUrl
[
list
]
if
(
!
listData
)
{
return
}
listData
.
current
?.
tokens
.
forEach
((
token
)
=>
{
if
(
token
.
logoURI
)
{
const
lowercaseAddress
=
token
.
address
.
toLowerCase
()
const
currentEntry
=
dict
[
lowercaseAddress
+
'
:
'
+
token
.
chainId
]
...
...
@@ -21,7 +25,7 @@ class TokenLogoLookupTable {
}
}
})
)
}
)
this
.
dict
=
dict
this
.
initialized
=
true
}
...
...
src/hooks/Tokens.ts
View file @
f15e5725
...
...
@@ -112,7 +112,7 @@ export function useSearchInactiveTokenLists(search: string | undefined, minResul
const
result
:
WrappedTokenInfo
[]
=
[]
const
addressSet
:
{
[
address
:
string
]:
true
}
=
{}
for
(
const
url
of
inactiveUrls
)
{
const
list
=
lists
[
url
].
current
const
list
=
lists
[
url
]
?
.
current
if
(
!
list
)
continue
for
(
const
tokenInfo
of
list
.
tokens
)
{
if
(
tokenInfo
.
chainId
===
chainId
&&
tokenFilter
(
tokenInfo
))
{
...
...
src/utils/listSort.ts
View file @
f15e5725
import
{
DEFAULT_LIST_OF_LISTS
}
from
'
./../constants/lists
'
const
DEFAULT_LIST_PRIORITIES
=
DEFAULT_LIST_OF_LISTS
.
reduce
<
{
[
listUrl
:
string
]:
number
}
>
((
memo
,
listUrl
,
index
)
=>
{
memo
[
listUrl
]
=
index
+
1
return
memo
},
{})
const
DEFAULT_LIST_PRIORITIES
=
DEFAULT_LIST_OF_LISTS
.
reduce
(
(
acc
,
listUrl
,
index
)
=>
({
...
acc
,
[
listUrl
]:
index
+
1
,
}),
{}
)
as
Record
<
string
,
number
>
// use ordering of default list of lists to assign priority
export
default
function
sortByListPriority
(
urlA
:
string
,
urlB
:
string
)
{
if
(
DEFAULT_LIST_PRIORITIES
[
urlA
]
&&
DEFAULT_LIST_PRIORITIES
[
urlB
])
{
return
DEFAULT_LIST_PRIORITIES
[
urlA
]
-
DEFAULT_LIST_PRIORITIES
[
urlB
]
}
return
0
const
A
=
DEFAULT_LIST_PRIORITIES
[
urlA
]
const
B
=
DEFAULT_LIST_PRIORITIES
[
urlB
]
if
(
!
A
)
return
0
if
(
!
B
)
return
0
return
A
-
B
}
src/utils/nativeTokens.ts
View file @
f15e5725
...
...
@@ -4,6 +4,9 @@ import { CHAIN_NAME_TO_CHAIN_ID } from 'graphql/data/util'
export
function
getNativeTokenDBAddress
(
chain
:
Chain
):
string
|
undefined
{
const
pageChainId
=
CHAIN_NAME_TO_CHAIN_ID
[
chain
]
if
(
pageChainId
===
undefined
)
{
return
undefined
}
switch
(
chain
)
{
case
Chain
.
Celo
:
case
Chain
.
Polygon
:
...
...
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