Commit 1e4728a
authored
feat(predict): replace hardcoded live sports config with remote feature flag (MetaMask#24494)
## **Description**
Replaces the hardcoded `LIVE_SPORTS_LEAGUES` configuration with a remote
feature flag (`predictLiveSports`), allowing live sports functionality
to be enabled/disabled and leagues to be configured remotely without app
updates.
**Motivation**: The live sports feature needs to be controllable via
remote config to enable gradual rollout and quick disabling if issues
arise.
**Solution**:
- Added `PredictLiveSportsFlag` type: `{ enabled: boolean; leagues:
string[] }`
- Added `DEFAULT_LIVE_SPORTS_FLAG` constant (disabled by default, empty
leagues)
- Renamed `LIVE_SPORTS_LEAGUES` to `SUPPORTED_SPORTS_LEAGUES` (defines
what the app supports)
- Added `filterSupportedLeagues()` helper to validate remote config
against supported leagues
- Updated `PredictController.getMarkets()` and `getMarket()` to read the
flag from `RemoteFeatureFlagController`
- Updated provider interfaces to accept `liveSportsLeagues` parameter
- Removed the now-unused `selectPredictLiveNflEnabled` selector and
`isLiveSportsEnabled()` function
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/PRED-464
## **Manual testing steps**
```gherkin
Feature: Live Sports Remote Feature Flag
Scenario: Live sports disabled by default
Given the predictLiveSports flag is not set in remote config
When user views prediction markets
Then live sports markets are not fetched
Scenario: Live sports enabled via remote config
Given the predictLiveSports flag is { enabled: true, leagues: ["nfl"] }
When user views prediction markets
Then NFL live sports markets are included in results
Scenario: Unsupported league filtered out
Given the predictLiveSports flag is { enabled: true, leagues: ["nfl", "mlb"] }
When user views prediction markets
Then only NFL markets are fetched (mlb not in SUPPORTED_SPORTS_LEAGUES)
```
## **Screenshots/Recordings**
### **Before**
N/A - Internal refactor, no UI changes
### **After**
N/A - Internal refactor, no UI changes
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Enables remotely configurable live sports by validating and passing
leagues to market fetches.
>
> - Add `PredictLiveSportsFlag` and `DEFAULT_LIVE_SPORTS_FLAG`;
introduce `SUPPORTED_SPORTS_LEAGUES` and `filterSupportedLeagues` to
validate remote config
> - `PredictController.getMarkets()`/`getMarket()` read
`RemoteFeatureFlagController.predictLiveSports`, compute
`liveSportsLeagues`, and pass to providers
> - Update provider types/interfaces to accept `liveSportsLeagues`;
`PolymarketProvider` uses provided leagues (removes
`isLiveSportsEnabled` and `LIVE_SPORTS_LEAGUES`), loads `TeamsCache`
conditionally, and overlays game data only when leagues provided
> - Remove `selectPredictLiveNflEnabled` selector and related tests;
refresh tests across controller/provider to cover enabled/disabled and
undefined leagues paths
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
68f8e7d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent a4f46fa commit 1e4728a
10 files changed
Lines changed: 135 additions & 241 deletions
File tree
- app/components/UI/Predict
- constants
- controllers
- providers
- polymarket
- selectors/featureFlags
- types
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| |||
538 | 542 | | |
539 | 543 | | |
540 | 544 | | |
| 545 | + | |
541 | 546 | | |
542 | 547 | | |
543 | 548 | | |
| |||
562 | 567 | | |
563 | 568 | | |
564 | 569 | | |
| 570 | + | |
565 | 571 | | |
566 | 572 | | |
567 | 573 | | |
| |||
633 | 639 | | |
634 | 640 | | |
635 | 641 | | |
| 642 | + | |
636 | 643 | | |
637 | 644 | | |
638 | 645 | | |
| |||
Lines changed: 28 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
463 | 467 | | |
464 | 468 | | |
465 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
466 | 481 | | |
467 | 482 | | |
468 | | - | |
| 483 | + | |
469 | 484 | | |
470 | 485 | | |
471 | 486 | | |
| |||
560 | 575 | | |
561 | 576 | | |
562 | 577 | | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
563 | 587 | | |
564 | 588 | | |
| 589 | + | |
565 | 590 | | |
566 | 591 | | |
567 | 592 | | |
| |||
Lines changed: 60 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
145 | 144 | | |
146 | | - | |
147 | | - | |
| 145 | + | |
148 | 146 | | |
149 | 147 | | |
150 | 148 | | |
| |||
277 | 275 | | |
278 | 276 | | |
279 | 277 | | |
280 | | - | |
| 278 | + | |
281 | 279 | | |
282 | 280 | | |
283 | 281 | | |
| |||
291 | 289 | | |
292 | 290 | | |
293 | 291 | | |
294 | | - | |
| 292 | + | |
295 | 293 | | |
296 | 294 | | |
297 | 295 | | |
| |||
2425 | 2423 | | |
2426 | 2424 | | |
2427 | 2425 | | |
2428 | | - | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
2429 | 2430 | | |
2430 | 2431 | | |
2431 | 2432 | | |
| |||
6442 | 6443 | | |
6443 | 6444 | | |
6444 | 6445 | | |
6445 | | - | |
| 6446 | + | |
6446 | 6447 | | |
6447 | 6448 | | |
6448 | 6449 | | |
6449 | 6450 | | |
6450 | 6451 | | |
6451 | 6452 | | |
6452 | 6453 | | |
6453 | | - | |
| 6454 | + | |
6454 | 6455 | | |
6455 | 6456 | | |
6456 | 6457 | | |
6457 | 6458 | | |
6458 | 6459 | | |
6459 | 6460 | | |
6460 | | - | |
| 6461 | + | |
6461 | 6462 | | |
6462 | 6463 | | |
6463 | 6464 | | |
| |||
6470 | 6471 | | |
6471 | 6472 | | |
6472 | 6473 | | |
6473 | | - | |
| 6474 | + | |
| 6475 | + | |
| 6476 | + | |
6474 | 6477 | | |
6475 | 6478 | | |
6476 | 6479 | | |
| |||
6481 | 6484 | | |
6482 | 6485 | | |
6483 | 6486 | | |
6484 | | - | |
| 6487 | + | |
| 6488 | + | |
| 6489 | + | |
6485 | 6490 | | |
6486 | 6491 | | |
6487 | 6492 | | |
6488 | 6493 | | |
6489 | 6494 | | |
6490 | 6495 | | |
6491 | 6496 | | |
6492 | | - | |
| 6497 | + | |
6493 | 6498 | | |
6494 | 6499 | | |
6495 | 6500 | | |
| |||
6500 | 6505 | | |
6501 | 6506 | | |
6502 | 6507 | | |
6503 | | - | |
| 6508 | + | |
| 6509 | + | |
| 6510 | + | |
| 6511 | + | |
6504 | 6512 | | |
6505 | 6513 | | |
6506 | 6514 | | |
6507 | 6515 | | |
6508 | 6516 | | |
6509 | 6517 | | |
6510 | | - | |
| 6518 | + | |
6511 | 6519 | | |
6512 | 6520 | | |
6513 | 6521 | | |
| |||
6522 | 6530 | | |
6523 | 6531 | | |
6524 | 6532 | | |
| 6533 | + | |
6525 | 6534 | | |
6526 | 6535 | | |
6527 | 6536 | | |
| |||
6533 | 6542 | | |
6534 | 6543 | | |
6535 | 6544 | | |
6536 | | - | |
| 6545 | + | |
| 6546 | + | |
| 6547 | + | |
| 6548 | + | |
6537 | 6549 | | |
6538 | 6550 | | |
6539 | 6551 | | |
| |||
6660 | 6672 | | |
6661 | 6673 | | |
6662 | 6674 | | |
6663 | | - | |
| 6675 | + | |
6664 | 6676 | | |
6665 | 6677 | | |
6666 | | - | |
6667 | | - | |
6668 | | - | |
6669 | | - | |
6670 | | - | |
6671 | 6678 | | |
6672 | 6679 | | |
6673 | 6680 | | |
6674 | | - | |
| 6681 | + | |
6675 | 6682 | | |
6676 | 6683 | | |
6677 | 6684 | | |
6678 | | - | |
| 6685 | + | |
6679 | 6686 | | |
6680 | 6687 | | |
6681 | 6688 | | |
6682 | 6689 | | |
6683 | 6690 | | |
6684 | 6691 | | |
6685 | | - | |
| 6692 | + | |
6686 | 6693 | | |
6687 | 6694 | | |
6688 | 6695 | | |
6689 | 6696 | | |
6690 | | - | |
| 6697 | + | |
6691 | 6698 | | |
6692 | 6699 | | |
6693 | 6700 | | |
6694 | 6701 | | |
6695 | 6702 | | |
6696 | | - | |
| 6703 | + | |
6697 | 6704 | | |
6698 | 6705 | | |
6699 | 6706 | | |
6700 | | - | |
| 6707 | + | |
| 6708 | + | |
| 6709 | + | |
| 6710 | + | |
6701 | 6711 | | |
6702 | 6712 | | |
6703 | 6713 | | |
6704 | 6714 | | |
6705 | 6715 | | |
| 6716 | + | |
| 6717 | + | |
| 6718 | + | |
| 6719 | + | |
| 6720 | + | |
| 6721 | + | |
| 6722 | + | |
| 6723 | + | |
| 6724 | + | |
| 6725 | + | |
| 6726 | + | |
6706 | 6727 | | |
6707 | 6728 | | |
6708 | 6729 | | |
6709 | | - | |
| 6730 | + | |
6710 | 6731 | | |
6711 | 6732 | | |
6712 | 6733 | | |
6713 | 6734 | | |
6714 | 6735 | | |
6715 | 6736 | | |
6716 | | - | |
| 6737 | + | |
| 6738 | + | |
| 6739 | + | |
| 6740 | + | |
6717 | 6741 | | |
6718 | 6742 | | |
6719 | 6743 | | |
6720 | 6744 | | |
6721 | 6745 | | |
6722 | 6746 | | |
6723 | | - | |
| 6747 | + | |
6724 | 6748 | | |
6725 | 6749 | | |
6726 | 6750 | | |
| |||
6729 | 6753 | | |
6730 | 6754 | | |
6731 | 6755 | | |
| 6756 | + | |
6732 | 6757 | | |
6733 | 6758 | | |
6734 | 6759 | | |
6735 | 6760 | | |
6736 | 6761 | | |
6737 | 6762 | | |
6738 | | - | |
| 6763 | + | |
6739 | 6764 | | |
6740 | 6765 | | |
6741 | 6766 | | |
6742 | 6767 | | |
6743 | 6768 | | |
6744 | 6769 | | |
6745 | | - | |
| 6770 | + | |
| 6771 | + | |
| 6772 | + | |
| 6773 | + | |
6746 | 6774 | | |
6747 | 6775 | | |
6748 | 6776 | | |
| |||
0 commit comments