Skip to content

Commit 806d76e

Browse files
authored
feat(predict): Predict details outcome / status improvements (#21486)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** - Increases parity towards to the designs wrt to handling of the outcomes when a market is closed and subsequently resolved (signaled by the `resolutionStatus` field on the outcome) - As discussed, a little concerned about how convoluted the logic on `<PredictMarketDetails>` is getting. Feeling is we go with it for now and plan for a refactor post beta. - Note it currently doesn't address the handled of a closed / resolved multiple market (primarily because I don't currently have an easy way to create one without mocking which will be a bit fiddly). Will add in a follow-up. <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: [PRED-189](https://consensyssoftware.atlassian.net/browse/PRED-189) ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <img width="420" alt="image" src="https://github.com/user-attachments/assets/3d0e6a40-c67d-475d-887c-ffebbc7b02b5" /> ## **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. [PRED-189]: https://consensyssoftware.atlassian.net/browse/PRED-189?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds UMA resolution status from Polymarket and updates market details/outcome UI to show winners/losers with resolved/ended messaging, plus broad i18n refactors and tests. > > - **Predict Market Details (UI/Logic)**: > - Auto-switch timeframe to `MAX` when market is closed; compute `winningOutcomeToken`/`losingOutcomeToken` via `useMemo`. > - Closed markets: show winner/loser outcomes, render resolved vs ended messaging, and "waiting for final resolution" when unresolved. > - Only render action buttons for single-outcome markets; outcomes tab always for closed markets. > - Replace hardcoded strings with i18n keys (`predict.loading`, `predict.market_details.*`). > - **Outcome Card (`PredictMarketOutcome`)**: > - Title fallback: `groupItemTitle || title`. > - Closed-market badges/icons: show Winner only when `price === 1`; show lose icon otherwise; show % when open. > - **Data/Types**: > - Add `umaResolutionStatus` to `PolymarketApiMarket`; map to `resolutionStatus` on parsed outcomes; add optional `resolutionStatus` to `PredictOutcome` type. > - **Localization**: > - New strings under `predict.market_details` (volume, end date, resolver, powered by, yes/no, on, market_ended_on/market_resulted_to, waiting_for_final_resolution) and `predict.loading`. > - **Tests**: > - Update/expand unit tests for parsing, market details rendering, closed-market flows, i18n text, and button behaviors. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 17a7f9a. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 2006796 commit 806d76e

File tree

8 files changed

+488
-93
lines changed

8 files changed

+488
-93
lines changed

app/components/UI/Predict/components/PredictMarketOutcome/PredictMarketOutcome.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const PredictMarketOutcome: React.FC<PredictMarketOutcomeProps> = ({
7373
if (isClosed && outcomeToken) {
7474
return outcomeToken.title;
7575
}
76-
return outcome.groupItemTitle;
76+
return outcome.groupItemTitle || outcome.title || '';
7777
};
7878

7979
const getImageUrl = (): string => outcome.image;
@@ -150,7 +150,7 @@ const PredictMarketOutcome: React.FC<PredictMarketOutcomeProps> = ({
150150
>
151151
{getTitle()}
152152
</Text>
153-
{isClosed && outcomeToken && (
153+
{isClosed && outcomeToken && outcomeToken.price === 1 && (
154154
<Text
155155
variant={TextVariant.BodyXS}
156156
color={TextColor.Success}
@@ -167,9 +167,15 @@ const PredictMarketOutcome: React.FC<PredictMarketOutcomeProps> = ({
167167
<Text>
168168
{isClosed && outcomeToken ? (
169169
<Icon
170-
name={IconName.CheckBold}
170+
name={
171+
outcomeToken.price === 1
172+
? IconName.CheckBold
173+
: IconName.CircleX
174+
}
171175
size={IconSize.Md}
172-
color={TextColor.Success}
176+
color={
177+
outcomeToken.price === 1 ? TextColor.Success : TextColor.Muted
178+
}
173179
/>
174180
) : (
175181
<Text>{getYesPercentage()}</Text>

app/components/UI/Predict/providers/polymarket/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export interface PolymarketApiMarket {
141141
resolvedBy: string;
142142
orderPriceMinTickSize: number;
143143
events?: PolymarketApiEvent[];
144+
umaResolutionStatus: string;
144145
}
145146

146147
export interface PolymarketApiSeries {

app/components/UI/Predict/providers/polymarket/utils.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ describe('polymarket utils', () => {
882882
status: 'open',
883883
active: true,
884884
resolvedBy: '0x0000000000000000000000000000000000000000',
885+
umaResolutionStatus: 'unresolved',
885886
},
886887
],
887888
liquidity: 1000000,
@@ -914,6 +915,7 @@ describe('polymarket utils', () => {
914915
groupItemTitle: 'Weather',
915916
status: 'open',
916917
volume: 1000,
918+
resolutionStatus: 'unresolved',
917919
tokens: [
918920
{
919921
id: 'token-1',
@@ -1426,6 +1428,7 @@ describe('polymarket utils', () => {
14261428
status: 'open',
14271429
active: true,
14281430
resolvedBy: '0x0000000000000000000000000000000000000000',
1431+
umaResolutionStatus: 'unresolved',
14291432
},
14301433
],
14311434
liquidity: 1000000,
@@ -1539,6 +1542,7 @@ describe('polymarket utils', () => {
15391542
status: 'open',
15401543
active: true,
15411544
resolvedBy: '0x0000000000000000000000000000000000000000',
1545+
umaResolutionStatus: 'unresolved',
15421546
};
15431547

15441548
it('fetch single market successfully', async () => {

app/components/UI/Predict/providers/polymarket/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export const parsePolymarketEvents = (
409409
negRisk: market.negRisk,
410410
tickSize: market.orderPriceMinTickSize.toString(),
411411
resolvedBy: market.resolvedBy,
412+
resolutionStatus: market.umaResolutionStatus,
412413
};
413414
}),
414415
liquidity: event.liquidity,

app/components/UI/Predict/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export type PredictOutcome = {
114114
negRisk?: boolean;
115115
tickSize?: string;
116116
resolvedBy?: string;
117+
resolutionStatus?: string;
117118
};
118119

119120
export type PredictOutcomeToken = {

0 commit comments

Comments
 (0)