Skip to content

refactor(rewards): lift portfolio and leaderboard position hook calls to parent views#28049

Merged
VGR-GIT merged 5 commits into
mainfrom
rwds-smarter-leaderboard-section-rendering
Mar 30, 2026
Merged

refactor(rewards): lift portfolio and leaderboard position hook calls to parent views#28049
VGR-GIT merged 5 commits into
mainfrom
rwds-smarter-leaderboard-section-rendering

Conversation

@VGR-GIT

@VGR-GIT VGR-GIT commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR refactors how OndoCampaignDetailsView decides which sections to render, replacing ad-hoc inline conditions with a single useMemo that computes five boolean flags. It also replaces CampaignEntriesClosedBanner with RewardsInfoBanner for a unified visual treatment.

Other changes

  • OndoLeaderboard: new showTitle prop (default true) — parent can suppress the section title when rendering inline. computedAt timestamp moves to sit alongside the tier-tabs row instead of a standalone header row.
  • OndoLeaderboardPosition: new showTitle (default false) and computedAt props — full leaderboard view opts in to a header with a "last updated" timestamp.
  • OndoPortfolio: skeleton now shows when loading with an empty positions array (not just when portfolio is null).
  • CampaignTile: Enter Now badge is gated behind isOptinAllowed(campaign) so it disappears once the deposit cutoff has passed.
  • useGetOndoLeaderboard is now called unconditionally with campaignId instead of a computed conditional ID, since all render paths need leaderboard data.

Changelog

CHANGELOG entry: null

Screenshots/Recordings

Phase 1 - Opt in guidance

image image

Phase 1 - Opted in & Position Guidance & Leaderboard

image Screenshot from 2026-03-30 14-46-51

Phase 1 - Opted in & at least one position

image Screenshot from 2026-03-30 14-35-38

Phase 2 - Not Opted in & cut off date reached

image Screenshot from 2026-03-30 14-41-17

Phase 2 - Opted in & cut off date reached & No positions

image Screenshot from 2026-03-30 14-41-17

Phase 2 - Opted in & cut off date reached & positions

Screenshot from 2026-03-30 14-35-38

Completed - Not opted in or opted in and no positions

image Screenshot from 2026-03-30 13-39-10

Completed - opted in and at least one position

image Screenshot from 2026-03-30 13-50-02

Note

Medium Risk
Refactors the Ondo rewards screens’ section-gating and data-fetch paths (leaderboard/portfolio/position), which can affect what users see and when network calls happen, but does not touch auth or core transaction flows.

Overview
Improves Ondo rewards screens by lifting useGetOndoPortfolioPosition and useGetOndoLeaderboardPosition calls into the parent views and passing data/loading/error state down into OndoPortfolio and OndoLeaderboardPosition, removing their internal hook/selector coupling.

OndoCampaignDetailsView now computes a single set of boolean flags to control How it works, portfolio, leaderboard, and position sections, replaces the old entries-closed banner with a unified RewardsInfoBanner, and fetches leaderboard data unconditionally for the campaign. OndoLeaderboardView similarly wires in the position hook and renders leaderboard/position components without duplicated titles.

UI behavior tweaks: CampaignTile hides the “Enter now” label when opt-in is closed, OndoLeaderboard adds showTitle and adjusts where the “updated at” timestamp renders (including single-tier), and OndoPortfolio shows a skeleton when loading with an empty positions array. Copy updates add new competition-closed strings and rename the portfolio title in en.json.

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

… to parent views

OndoPortfolio and OndoLeaderboardPosition previously called their data
hooks internally, causing duplicate fetches when the parent view already
needed the same data for visibility gating. Both components now receive
hook result values as props, with the single fetch point living in
OndoCampaignDetailsView (portfolio + leaderboard position) and
OndoLeaderboardView (leaderboard position). Tests updated to pass props
directly, removing the need to mock internal hooks.

Co-authored-by: VGR-GIT <vangulckrik@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
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 the team-rewards Rewards team label Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.63%. Comparing base (d50db18) to head (2bbbf3b).
⚠️ Report is 71 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28049      +/-   ##
==========================================
+ Coverage   82.61%   82.63%   +0.01%     
==========================================
  Files        4849     4854       +5     
  Lines      124916   125065     +149     
  Branches    27873    27923      +50     
==========================================
+ Hits       103199   103342     +143     
+ Misses      14609    14605       -4     
- Partials     7108     7118      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@VGR-GIT VGR-GIT marked this pull request as ready for review March 30, 2026 12:48
@VGR-GIT VGR-GIT requested a review from a team as a code owner March 30, 2026 12:48
Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx Outdated
…details view

- Replace CampaignEntriesClosedBanner with RewardsInfoBanner for competition-closed state
- Always fetch leaderboard data (not conditionally) to support all render paths
- Compute section visibility (showHowItWorksSection, showCompetitionEndedBanner,
  showLeaderboardSection, showLeaderboardPositionSection, showPortfolioSection) in
  a single useMemo for clearer logic
- Add showTitle prop to OndoLeaderboard (default true) and OndoLeaderboardPosition
  (default false); move computedAt timestamp to sit alongside the tier tabs row
- Show competition-ended banner for complete campaigns and for active campaigns past
  the deposit cutoff date
- OndoPortfolio: show skeleton when loading with an empty positions array
- CampaignTile: gate Enter Now CTA behind isOptinAllowed check
- Update all associated tests to match new component contracts

Co-authored-by: VGR-GIT <vangulckrik@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added size-XL risk-low Low testing needed · Low bug introduction risk and removed size-L labels Mar 30, 2026
Comment thread app/components/UI/Rewards/hooks/useRewardCampaigns.ts Outdated
Comment thread app/components/UI/Rewards/components/Campaigns/CampaignJoinCTA.tsx
Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx Outdated
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 30, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 30, 2026
Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx
Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx
Comment thread app/components/UI/Rewards/components/Campaigns/OndoLeaderboard.tsx
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 30, 2026
Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx
… loading

The test expected the banner to appear while participant status was loading,
but the component intentionally gates the banner behind !isParticipantStatusLoading.
Updated the test description and assertion to match the correct behaviour.

Co-authored-by: VGR-GIT <vangulckrik@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 15 changed files are confined to the app/components/UI/Rewards/ directory (Ondo campaign UI components, views, hooks) and locales/en.json. The changes are:

  1. UI refactoring: OndoLeaderboardPosition and OndoPortfolio converted from self-fetching components to presentational components (prop-drilling pattern). No functional behavior change.
  2. Bug fix in CampaignTile.tsx: adds isOptinAllowed() guard to prevent showing Join CTA after opt-in window closes.
  3. OndoLeaderboard.tsx: adds showTitle prop and restructures header layout.
  4. OndoLeaderboardView.tsx: moves data fetching to parent view.
  5. useRewardCampaigns.ts: whitespace-only change (blank line removal).
  6. locales/en.json: additive new string keys for competition_closed_title/description and rename of positions_heading → title within the rewards namespace only.

No E2E tests exist for the Rewards/Ondo feature (confirmed by searching e2e/ and tests/ directories). The changes do not touch: Engine, controllers, navigation infrastructure, shared components (TabBar, modals, confirmations), or any other feature area. The Rewards feature is self-contained and not referenced by Trending or other tested components. Running any E2E test suite would not provide meaningful coverage for these changes, and no existing tests would be broken by them.

Performance Test Selection:
The changes are confined to the Rewards/Ondo campaign UI components. These are refactoring changes (prop-drilling, UI layout adjustments) within a specialized feature area. No performance-sensitive paths are affected: no account list rendering, no app startup, no login flow, no swap flow, no asset loading, and no predict/perps market loading. Performance tests are not warranted.

View GitHub Actions results

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Rewards/Views/OndoCampaignDetailsView.tsx
@sonarqubecloud

Copy link
Copy Markdown

@VGR-GIT VGR-GIT enabled auto-merge March 30, 2026 14:29
@VGR-GIT VGR-GIT added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 340209c Mar 30, 2026
60 of 63 checks passed
@VGR-GIT VGR-GIT deleted the rwds-smarter-leaderboard-section-rendering branch March 30, 2026 14:50
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 30, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 30, 2026
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.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-XL team-rewards Rewards team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants