chore: pass cached security data from token list to token details cp-7.76.0#29603
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| source: isFullView | ||
| ? TokenDetailsSource.MobileTokenListPage | ||
| : TokenDetailsSource.MobileTokenList, | ||
| ...(securityData !== undefined && { securityData }), |
There was a problem hiding this comment.
When a user taps a token, we read the already-fetched security data from the TanStack Query cache and pass it via nav params. useTokenSecurityData on the details side already supports prefetchedData and skips its on-demand fetch when provided. When the flag is OFF, nothing changes; the on-demand fetch fires as before. One file changed (TokenListItem.tsx).
Alternative approach for later: Once we remove the feature flag and the security badge fetch is always-on, we could replace useTokenSecurityData in TokenDetails with useTokenListSecurityBadgeQuery directly. TokenDetails would check the TanStack cache itself and fetch only if needed .. no nav params, no manual cache read in onItemPress. This works regardless of how the user navigates to Token Details. But it's a bigger-ish change: add an enabled option to the hook, add CAIP address normalization so list and details share the same cache key, swap the hook in TokenDetails, and potentially remove useTokenSecurityData + migrate its tests.
| securityData = | ||
| queryClient.getQueryData<TokenSecurityData | null>( | ||
| tokenListSecurityBadgeKeys.byAsset(caipAssetIdForSecurity), | ||
| ) ?? undefined; |
There was a problem hiding this comment.
The fetching we have means that it shouldn't do two calls even if we call it both here and inside TokenListSecurityBadge.
We can definitely do it like this, and it's perfectly ok, but there's a beauty in just using the hook we have and nothing else.
There was a problem hiding this comment.
@bergarces by just using the hook we have, you are referencing the alternative approach i mention here ?
remove the on demand call and make it use tanstack query if no prefetched security data passed?
224e470
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Performance Test Selection: |
|
juanmigdr
left a comment
There was a problem hiding this comment.
Very confused about the implementation... I dont think you need to pass the security data to token details. You can just reuse the hook in token details and pass down the token address. This way it will make the API call if necessary or fetch from cache otherwise. ANd that way we have reused logic in token details page and tokens list



Description
When the token list security badges feature flag is enabled, read the already-fetched security data from the TanStack Query
cache on item press and forward it via navigation params, eliminating the on-demand fetch in TokenDetails.
Changelog
CHANGELOG entry: remove on demand api call to get security data when passed from token list and FF is ON
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes the token list tap navigation payload to optionally include cached
TokenSecurityDatafrom TanStack Query, which could affect the Asset Details screen’s behavior when the security-badges feature flag is enabled. Risk is limited by feature-flag gating but still touches navigation params and cache key usage.Overview
When
selectTokenListSecurityBadgesEnabledis on and a CAIP asset id has been resolved, tapping a token inTokenListItemnow readsTokenSecurityDatafrom the TanStack Query cache (tokenListSecurityBadgeKeys.byAsset(caipId)) and forwards it to theAssetroute viasecurityDatanavigation params.Adds/updates unit tests to mock
useQueryClient+ CAIP resolution and assertsecurityDatais included only when the flag is enabled and cached data exists.Reviewed by Cursor Bugbot for commit 224e470. Bugbot is set up for automated code reviews on this repo. Configure here.