-
Notifications
You must be signed in to change notification settings - Fork 393
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
Refactor prices caching #3526
Refactor prices caching #3526
Conversation
@@ -60,7 +48,6 @@ const assetsSlice = createSlice({ | |||
mappedAssets[newAsset.symbol] = [ | |||
{ | |||
...newAsset, |
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.
do we need to spread that newAsset
?
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.
Not really, but this has helped me spot a different bottleneck. Thanks!
Reducing the amount of updates we make to the assets slice should improve performance and reduce blocking UI due to store updates. The new prices slice indexes asset prices by asset ids, this way each update is diffed and processed faster.
The now available isTrustedToken checks if assets meet these replaced conditions, isTokenListAsset/isNetworkBaseAsset.
| (SmartContractFungibleAsset & { tokenLists: string[] }) | ||
| (SmartContractFungibleAsset & { verified: true }) { |
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.
tokenLists
and verified
should be at the metadata level.
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.
Good catch!
This should help reduce redundancy after trust checks
Removed symbols from network base asset ids generation, added chain id to ids for all asset types. This allows us to use these for indexing assets across networks in e.g. redux.
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.
I tested solutions and it seems that works well. Code looks also good, just minor comments.
@kkosiorowska looking at the outstanding comments, I'd say unless you have a clear signal that @hyphenized wants to act on any of it tomorrow morning, we land this as-is and use it to cut a small release that can go through the testing paces. |
These were overlooked during the process of segregating prices from the assets slice
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.
🚀 🚀 🚀
## What's Changed * v0.43.3 by @hyphenized in #3570 * Use JSON onboarding in e2e tests of transactions by @michalinacienciala in #3559 * Refactor prices caching by @hyphenized in #3526 * Fix assertions made on the latest transaction by @michalinacienciala in #3573 **Full Changelog**: v0.43.3...v0.44.0 Latest build: [extension-builds-3577](https://github.com/tahowallet/extension/suites/14645396551/artifacts/830824018) (as of Fri, 28 Jul 2023 14:43:48 GMT).
Relocates cached asset prices to a new redux slice. This reduces performance hits after price fetching by avoiding nested array diffs, which Immer struggles to manage. Consequently, it prevents unnecessary updates being serialized/deserialized.
To Test
This clears cached data for both account balances and assets, after switching from
main
to this branch:Latest build: extension-builds-3526 (as of Thu, 27 Jul 2023 06:33:36 GMT).