Skip to content

Conversation

@VGR-GIT
Copy link
Contributor

@VGR-GIT VGR-GIT commented Nov 18, 2025

Description

Switches the reward point calculation for predict from a hard coded approach to using the rewards API. It also uses the same approach recently introduced in the swaps flow, to allow add their account if it's not correctly tied to their rewards subscription.

Changelog

CHANGELOG entry: Estimate reward points in predict flow

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/RWDS-801

Screenshots/Recordings

After

Screenshot-88
Screenshot-2025-11-18-10:30:28
Screenshot-2025-11-18-10:31:15
Screenshot-2025-11-18-10:32:21

Pre-merge author checklist

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.

Note

Switch Predict to API-based points estimation with opt-in handling, update UI to show points/add-account, and extend rewards types/tests.

  • Predict flow:
    • Update PredictBuyPreview to use usePredictRewards(totalFee) and drive rewards UI; compute shouldShowRewardsRow and pass accountOptedIn, estimatedPoints, loading/error to PredictFeeSummary.
    • PredictFeeSummary props renamed shouldShowRewardsshouldShowRewardsRow; add accountOptedIn, error tooltip; render AddRewardsAccount when not opted in; wire RewardPointsAnimation states.
  • Hook: usePredictRewards:
    • New signature accepts totalFeeAmountUsd; selects multichain account by POLYGON_MAINNET_CAIP_CHAIN_ID and formats CAIP-10 without bridge-controller.
    • Checks feature flag and subscription, opt-in status/support; estimates points via RewardsController:estimatePoints using POLYGON_USDC_CAIP_ASSET_ID and parseUnits with 6 decimals.
    • Subscribes to RewardsController:accountLinked; returns {enabled,isLoading,accountOptedIn,shouldShowRewardsRow,estimatedPoints,hasError}.
  • Rewards UI:
    • RewardPointsAnimation: make infoOnPress optional; hide info icon unless provided; support hideValue from hook.
  • Types/Constants:
    • Extend rewards types with EstimatePredictContextDto, add PREDICT to PointsEventEarnType.
    • Add POLYGON_USDC_CAIP_ASSET_ID constant.
  • Tests:
    • Comprehensive updates for new props/flows, loading/error states, subscription/opt-in paths, and animation behavior.

Written by Cursor Bugbot for commit dadabd0. This will update automatically on new commits. Configure here.

@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added team-rewards Rewards team INVALID-PR-TEMPLATE PR's body doesn't match template labels Nov 18, 2025
@VGR-GIT VGR-GIT force-pushed the rwds-801-allow-add-account-predict-flow branch from f0efe05 to 9db7aa2 Compare November 18, 2025 10:18
@VGR-GIT VGR-GIT marked this pull request as ready for review November 18, 2025 10:19
@VGR-GIT VGR-GIT requested a review from a team as a code owner November 18, 2025 10:19
@VGR-GIT VGR-GIT force-pushed the rwds-801-allow-add-account-predict-flow branch from 9db7aa2 to dadabd0 Compare November 18, 2025 10:44
setEstimatedPoints(null);
setEnabled(false);
setAccountOptedIn(null);
setShouldShowRewardsRow(false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Zero Fees Break Rewards Logic

The early return condition treats totalFeeAmountUsd of 0 as missing data, causing rewards logic to skip when fees are zero. The check !totalFeeAmountUsd evaluates to true for 0, preventing opted-in users from seeing rewards when total fees are exactly zero. This should check for undefined or null instead of falsy values.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeCore, SmokeConfirmationsRedesigned, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeCard, SmokeNotifications, SmokeRewards, SmokePerps, SmokeRamps, SmokeMultiChainPermissions, SmokeAnalytics, SmokeMultiChainAPI, SmokePredictions
  • Risk Level: high
  • AI Confidence: %
click to see 🤖 AI reasoning details

Fallback: AI analysis did not complete successfully. Running all tests.

View GitHub Actions results

@sonarqubecloud
Copy link

@VGR-GIT VGR-GIT added this pull request to the merge queue Nov 18, 2025
@VGR-GIT VGR-GIT removed this pull request from the merge queue due to a manual request Nov 18, 2025
@VGR-GIT VGR-GIT added this pull request to the merge queue Nov 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2025
@VGR-GIT VGR-GIT added this pull request to the merge queue Nov 19, 2025
Merged via the queue into main with commit af6ba34 Nov 19, 2025
88 of 89 checks passed
@VGR-GIT VGR-GIT deleted the rwds-801-allow-add-account-predict-flow branch November 19, 2025 11:08
@github-actions github-actions bot locked and limited conversation to collaborators Nov 19, 2025
@metamaskbot metamaskbot added the release-7.61.0 Issue or pull request that will be included in release 7.61.0 label Nov 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.61.0 Issue or pull request that will be included in release 7.61.0 size-XL team-rewards Rewards team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants