refactor(predict): simplify to single-provider architecture#26031
refactor(predict): simplify to single-provider architecture#26031
Conversation
…rovider in controller Replace providers: Map<string, PredictProvider> with a single provider: PolymarketProvider instance. Remove initialization machinery (initializeProviders, performInitialization, isInitialized). Simplify all method signatures to remove providerId param. Flatten state shape for eligibility, balances, pendingDeposits (accountMeta left unchanged for backwards compatibility).
Remove providerId from GetMarketsParams, GetPositionsParams, PlaceOrderParams, PreviewOrderParams, GetPriceHistoryParams, GetPriceParams, GetBalanceParams. Convert PrepareDepositParams, PrepareWithdrawParams, GetAccountStateParams, ClaimParams to empty interfaces. Clean up Omit<..., 'providerId'> patterns in PredictProvider interface and PolymarketProvider.
Update selectPredictBalanceByAddress and
selectPredictPendingDepositByAddress to take { address }
instead of { providerId, address }. Access flat state
directly (balances[address] instead of
balances[providerId][address]).
Remove providerId from hook option interfaces and all downstream calls to controller methods and selectors. Hooks now use the single provider implicitly.
Remove providerId from component props, hook calls, and child component prop passing across all Predict UI files.
…er architecture Update PredictController.test.ts, PolymarketProvider.test.ts, utils.test.ts, and Engine predict-controller index.test.ts to use flat state shapes and remove providerId from all method call params. Remove multi-provider test cases.
Remove providerId from all hook test option objects, controller call assertions, and component test props. Update mock state shapes for flat eligibility, balances, and pendingDeposits.
|
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. |
9d0900b to
8a8e3fa
Compare
app/components/UI/Predict/components/PredictGameChart/PredictGameChart.wrapper.test.tsx
Show resolved
Hide resolved
app/components/UI/Predict/controllers/PredictController.test.ts
Outdated
Show resolved
Hide resolved
Remove obsolete tests for deleted functionality (provider initialization, performInitialization, provider-not-available error paths, multi-provider aggregation). Fix remaining tests to match new flat state shapes and single-provider mock setup. Rewrite getActivity test to use real controller with mocked PolymarketProvider constructor.
…le-provider Update mock state shapes (flat balances, pendingDeposits, eligibility), remove providerId from toHaveBeenCalledWith assertions and hook option expectations. Delete tests for removed custom-providerId behavior.
…RKET_PROVIDER_ID constant
…ith POLYMARKET_PROVIDER_ID Replace all 169 occurrences across 34 production and test files with the POLYMARKET_PROVIDER_ID constant from constants.ts.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag Selection Rationale:
The risk is medium because while this is a significant internal refactoring, it's primarily removing unused multi-provider flexibility rather than changing core functionality. All unit tests have been updated, and the changes are well-contained within the Predict feature. Performance Test Selection: |
|




Description
The PredictController was designed with multi-provider support (using a
Map<string, PredictProvider>), but we only ever use Polymarket and have no plans to support additional providers. This PR simplifies the entire Predict feature to single-provider architecture.Changes:
providers: Map<string, PredictProvider>with a singleprovider: PolymarketProviderinstance. Remove initialization machinery (initializeProviders,performInitialization,isInitialized).eligibility,balances, andpendingDepositsby removing the provider-key nesting.accountMetais left unchanged for backwards compatibility (persisted data).providerIdfrom all param types (GetMarketsParams,GetPositionsParams,PlaceOrderParams,PreviewOrderParams,GetPriceHistoryParams,GetPriceParams,GetBalanceParams, etc.)providerIdoption from all ~20 hooksselectPredictBalanceByAddressandselectPredictPendingDepositByAddressto use flat stateproviderIdprop passing throughout UI layerChangelog
CHANGELOG entry: null
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
N/A — no UI changes, purely internal refactoring.
Before
Multi-provider architecture with
Map<string, PredictProvider>andproviderIdparams throughout.After
Single
PolymarketProviderinstance, flat state shapes, noproviderIdparams needed.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Broad signature/state refactor across Predict hooks and components could cause subtle runtime breakage if any call sites or controller methods still expect
providerId. Risk is mitigated by updated unit tests but warrants focused regression on deposit/claim/cashout flows and price-history fetching.Overview
Refactors Predict toward a single-provider (Polymarket) model by removing
providerIdparameters/props from UI calls into Predict hooks (e.g.,usePredictActionGuard,usePredictClaim,useUnrealizedPnL,usePredictPriceHistory).Updates affected components (e.g., balance/add-funds sheets, market cards, picks, position details, game chart) to rely on navigation/market IDs only, and adjusts tests accordingly (replacing hardcoded
'polymarket'strings withPOLYMARKET_PROVIDER_IDand deleting coverage for custom provider IDs).Reworks
PredictController.getActivityunit test to construct a real messenger-backed controller and to mockPolymarketProviderdirectly, validating default selected-address behavior and explicit-address overrides without multi-provider merging/lookup scenarios.Written by Cursor Bugbot for commit b1f33c3. This will update automatically on new commits. Configure here.