fix(card): update feature flag listener on CardController#29350
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These changes improve the Card feature's responsiveness to remote feature flag changes and fix potential stale data issues. The SmokeCard tag covers:
Per the SmokeCard tag description, when selecting SmokeCard, also select SmokeTrade and SmokeConfirmations (Add Funds uses swaps which require transaction confirmations). However, the changes here are purely internal to the Card controller's feature flag handling - they don't touch swap/confirmation flows directly. Still, following the tag dependency guidance, SmokeTrade and SmokeConfirmations should be included as dependent tags. No other feature areas (accounts, network, browser, identity, etc.) are affected by these changes. Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
|



Description
This branch refreshes card home data and Baanx configuration when remote card feature flags change, and fixes a race where a slow unauthenticated
fetchCardHomeDatacould overwrite state after successful submitCredentials.Feature flags
app/selectors/featureFlagController/card/index.ts: exportsdefaultCardFeatureFlagandresolveCardFeatureFlag(empty remote payload → defaults).selectCardFeatureFlagnow usesresolveCardFeatureFlagso the same resolution rules apply in Redux selectors and Engine.BaanxProvider / init
BaanxProvider.ts: accepts optionalgetCardFeatureFlag(lazy) in addition to legacycardFeatureFlag. A private getter resolvescardFeatureFlagon each read so URLs/constants track the latest remote flags without recreating the provider.card-controller/index.ts: passesgetCardFeatureFlagfromRemoteFeatureFlagController:getState+resolveCardFeatureFlagintoBaanxProvider.CardController
RemoteFeatureFlagController:stateChangewith a selector that serializesremoteFeatureFlags.cardFeatureso only meaningful card-flag updates run the handler.#handleCardFeatureFlagChange: if an EVM address is selected,invalidateFetch(), clearscardHomeData/ setscardHomeDataStatustoidle, then refetches card home data.#fetchCardHomeDataWithLogging: centralizesfetchCardHomeData+Logger.errorfor account switch, feature-flag refresh,submitCredentials, andvalidateAndRefreshSession.#triggerCardholderCheck(accounts API URL path): usesresolveCardFeatureFlaginstead of ad-hoc casting.submitCredentials: setscardHomeDatatonulland statusidle, callsinvalidateFetch(), then fetches—so in-flight unauthenticated responses cannot win over authenticated data.Messenger / types
card-controller-messenger/index.ts: allows eventRemoteFeatureFlagController:stateChange.types.ts:CardControllerAllowedEventsincludesRemoteFeatureFlagControllerStateChangeEvent.Tests
CardController.test.ts: subscription to remote feature-flag state; handler clears state and refetches;drops in-flight unauthenticated card home data after successful auth.BaanxProvider.test.ts:getCardFeatureFlagread lazily duringgetOnChainAssets.Changelog
CHANGELOG entry: Card —
CardControllerlistens forRemoteFeatureFlagController:stateChangeand refetches card home data whencardFeaturechanges;BaanxProviderresolves card feature flags lazily; sharedresolveCardFeatureFlag;submitCredentialsinvalidates in-flight fetches and resets card home state to avoid stale unauthenticated data after login.Related issues
Fixes: #29348
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
Updates card state refresh triggers and fetch invalidation logic around auth and feature-flag changes; risk is moderate due to new event subscriptions and potential for extra network calls or missed updates if selectors are wrong.
Overview
Card home data now refreshes when remote
cardFeatureflags change.CardControllersubscribes toRemoteFeatureFlagController:stateChange, clearscardHomeData/status back toidle, invalidates any in-flight fetch, and refetches.Fixes a race where slow unauthenticated fetches could overwrite authenticated state. After successful
submitCredentials, the controller resets home data, bumps the fetch generation, and refetches via a shared#fetchCardHomeDataWithLogginghelper (also used by account-switch and session refresh paths).Feature-flag resolution and consumption were tightened. Adds
resolveCardFeatureFlag(and exportsdefaultCardFeatureFlag) to normalize empty remote payloads to defaults;BaanxProvidercan now read flags lazily via agetCardFeatureFlagcallback wired incardControllerInit, and the card-controller messenger/types allow the new remote-flag stateChange event.Tests add coverage for the new subscription behavior, the stale-fetch drop after auth, and lazy flag reads in
BaanxProvider.Reviewed by Cursor Bugbot for commit 0d9863b. Bugbot is set up for automated code reviews on this repo. Configure here.