feat: allow immediate fetching of topAssets without changing the network #401
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
This PR removes
state.topAssetsLastFetched
, and allows the immediate fetching of top assets without relying on a'NetworkController:networkDidChange'
event. We rely on thestate.chainCache[chainId].topAssetsLastFetched
instead of the previousstate.topAssetsLastFetched
now to determine if we can fetch or just read from the cache.Currently in Mobile the way we wipe the
state.topAssetsLastFetched
is by the user exiting the Swaps app, and switching networks.The use case is for the Mobile Bridge, specifically the situation where a user is switching back and forth between destination chain filters but without actually changing their app network.
state.topAssetsLastFetched
was never used by Mobile, only in test mocks for the background state.References
Related to MetaMask/metamask-mobile#14258
Changelog
@metamask/swaps-controller
state.topAssetsLastFetched
removedstate.chainCache[chainId].topAssetsLastFetched
to determine cache threshold. This allows for immediate fetching of top assets from a different chain without actually changing the MM app's network. Previously if we fetched top assets for Chain A and then immediately we want to fetch for Chain B, this would be impossible without actually switching networks. This is needed to fetch top destination tokens for Bridge transactions.Checklist