refactor(predict): consolidate feature flag resolution and provider interface#26703
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. |
Introduce a consolidated PredictFeatureFlags interface that groups all predict feature flags (feeCollection, liveSportsLeagues, marketHighlightsFlag) into a single type. Add DEFAULT_PREDICT_FEATURE_FLAGS constant. Clean PredictProvider interface by removing per-method flag parameters (liveSportsLeagues, feeCollection) — these will be read internally by the provider via a getFeatureFlags callback. Remove liveSportsLeagues from GetMarketsParams since it is an internal concern, not a caller-facing parameter.
6da4fb1 to
085e3be
Compare
…vider PolymarketProvider now receives a getFeatureFlags callback via its constructor instead of receiving flags as per-method parameters. The provider reads liveSportsLeagues, feeCollection, and other flags internally, eliminating the need for callers to resolve and pass them.
…roller Replace scattered RemoteFeatureFlagController:getState calls across getMarkets(), getMarket(), and previewOrder() with a single resolveFeatureFlags() method that returns a PredictFeatureFlags object. This eliminates ~35 lines of duplicated flag resolution code from 3 separate methods and centralizes it in one reusable private method.
085e3be to
a16ca65
Compare
…ghtsFlag resolveFeatureFlags() already validates the version gate and falls back to DEFAULT_MARKET_HIGHLIGHTS_FLAG when invalid. The second call to validatedVersionGatedFeatureFlag() in getMarkets() was redundant. Replace with a check on highlights.length, which is the actual semantic guard — the resolver guarantees the flag is always valid.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Extract highlights with ?? [] fallback before accessing .length to prevent TypeError if remote flag data is malformed (passes version validation but lacks highlights property). Reuse the guarded variable in both the shouldFetchHighlights check and the market ID lookup.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
This is an internal refactoring that doesn't change user-facing functionality but affects the core prediction market controller. The changes are well-tested with updated unit tests. Tag Selection Rationale:
Performance Test Selection: |
Description
Consolidates scattered feature flag resolution in PredictController into a single
resolveFeatureFlags()method and injects flags into PolymarketProvider via a constructor callback.Problem: Feature flags (liveSportsLeagues, feeCollection, marketHighlights) were resolved independently in 3 separate PredictController methods (
getMarkets,getMarket,previewOrder), each callingRemoteFeatureFlagController:getStateand unwrapping flags ad-hoc. These flags were then passed as method parameters to PolymarketProvider.Solution:
PredictFeatureFlagstype consolidating all predict feature flagsresolveFeatureFlags()private method on PredictController — single resolution pointgetFeatureFlagscallback in constructor and reads flags internallyPredictProviderinterface — removed per-method flag parameters (liveSportsLeagues,feeCollection)liveSportsLeaguesfromGetMarketsParams(internal concern, not caller-facing)This is a pure refactor — zero behavior changes. Foundation for upcoming Permit2 fee authorization support.
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/PRED-715
Manual testing steps
Screenshots/Recordings
N/A — pure refactor, no UI changes.
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches Predict market fetching and order preview paths by changing how feature flags are resolved and threaded into the Polymarket provider. Risk is mainly around mismatched defaults or missing flag injection impacting live sports overlays, highlights ordering, or fee collection in previews.
Overview
Refactors Predict feature-flag plumbing by introducing
PredictFeatureFlagsand a singlePredictController.resolveFeatureFlags()that reads remote flags (live sports leagues, market highlights, fee collection) and supplies them toPolymarketProvidervia agetFeatureFlagsconstructor callback.PolymarketProvidernow consumes flags internally (no longer acceptsliveSportsLeagues/feeCollectionas method params), and thePredictProvider/GetMarketsParamstypes are simplified accordingly. Tests are updated to match the new provider constructor + method signatures and to assert fee collection defaults are applied duringpreviewOrderand highlight fetching.Written by Cursor Bugbot for commit fdb4a95. This will update automatically on new commits. Configure here.