-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: List cache with different keys returns same result #10939
base: develop
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
|
67f1c2e
to
69e99eb
Compare
@@ -79,13 +79,16 @@ const combineTokenMaps = (lists: ListsState['byUrl'], urls: string[]): any => { | |||
const current = lists[currentUrl]?.current | |||
if (!current) return allTokens | |||
try { | |||
const newTokens = Object.assign(listToTokenMap(current, 'address')) | |||
return combineMaps(allTokens, newTokens) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to create a new object on each iteration
@@ -79,13 +79,16 @@ const combineTokenMaps = (lists: ListsState['byUrl'], urls: string[]): any => { | |||
const current = lists[currentUrl]?.current | |||
if (!current) return allTokens | |||
try { | |||
const newTokens = Object.assign(listToTokenMap(current, 'address')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need shallow copy
69e99eb
to
4f2e591
Compare
PR-Codex overview
This PR focuses on enhancing the type safety and immutability of token-related data structures in the
@pancakeswap/tokens
package by exporting thecreateEmptyList
function and updating the return types ofEMPTY_LIST
andcreateEmptyList
.Detailed summary
createEmptyList
from a private to an exported function.createEmptyList
to return aReadonly<TokenAddressMap<ChainId>>
.EMPTY_LIST
to be of typeReadonly<TokenAddressMap<ChainId>>
.combineTokenMaps
to check forurls?.length
.newTokens
incombineTokenMaps
for improved clarity.listCache
to store aMap<string, TokenAddressMap>
instead ofTokenAddressMap
.listToTokenMap
to require akey
parameter and adjusted its logic to handle the newlistCache
structure.