Skip to content

fix: enhance useMerklBonusClaim with session lock and reward refetching cp-7.72.0#28147

Merged
nickewansmith merged 2 commits intomainfrom
MUSD-563-claim-button-is-still-visible-after-successfully-claiming
Mar 31, 2026
Merged

fix: enhance useMerklBonusClaim with session lock and reward refetching cp-7.72.0#28147
nickewansmith merged 2 commits intomainfrom
MUSD-563-claim-button-is-still-visible-after-successfully-claiming

Conversation

@PatrykLucka
Copy link
Copy Markdown
Contributor

@PatrykLucka PatrykLucka commented Mar 31, 2026

Description

Fixes a regression where the Claim bonus CTA for mUSD could remain visible after a successful claim and allow reopening claim flow with effectively no claimable value.

The solution introduces a post-claim lock in useMerklBonusClaim, then unlocks that CTA after reward data is refreshed (manual pull-to-refresh, section refresh/remount, or periodic auto-refresh). It also fixes stale reward state handling so old claimable values are cleared when reward fetch returns no matching reward.

Changelog

CHANGELOG entry: Fixed an issue where the mUSD Claim bonus button could remain visible after claiming and trigger another claim flow.

Related issues

Fixes: #28135

Manual testing steps

Feature: mUSD claim bonus CTA state lifecycle

  Scenario: CTA hides after successful claim and reappears after refresh when claimable again
    Given user has claimable mUSD bonus
    And user is on Homepage with Cash section visible
    When user taps "Claim bonus" and confirms the transaction
    Then loader is shown briefly
    And "Claim bonus" is hidden after successful submission

    When user pulls to refresh Homepage
    Then Cash section refreshes
    And claim bonus eligibility is re-evaluated

    When sufficient time passes for auto-refresh interval
    Then claim bonus eligibility is re-evaluated automatically

  Scenario: stale claimable state is cleared
    Given previous claimable reward was shown
    When rewards fetch returns no matching reward
    Then "Claim bonus" is not shown

Screenshots/Recordings

Before

After

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

Medium Risk
Touches claim CTA gating and introduces a periodic fetch interval; incorrect locking/versioning could hide the CTA or increase background network activity unexpectedly.

Overview
Fixes the mUSD Merkl “Claim bonus” CTA lifecycle by adding a post-claim session lock in useMerklBonusClaim that hides the CTA after a successful claim submission and only re-enables it after rewards data has refreshed (via a new rewardsFetchVersion).

Enhances useMerklRewards with auto-refresh (60s), a rewardsFetchVersion counter, and clearing of stale claimableReward when a refetch returns no matching reward; the Homepage now wires CashSection into the global refresh flow and exposes a section refresh() that forces a remount of the cash row to reset claim state. Tests were updated/added to cover the lock/unlock behavior, stale clearing, interval cleanup, version increments, and cash row remount on refresh.

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

@PatrykLucka PatrykLucka self-assigned this Mar 31, 2026
@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-mobile-ux Mobile UX team label Mar 31, 2026
@PatrykLucka PatrykLucka marked this pull request as ready for review March 31, 2026 10:58
@PatrykLucka PatrykLucka requested a review from a team as a code owner March 31, 2026 10:58
Copy link
Copy Markdown

@cursor cursor bot left a comment

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 2 potential issues.

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.

@github-actions github-actions bot added the risk-low Low testing needed · Low bug introduction risk label Mar 31, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on the Earn/Cash/mUSD Merkl rewards claim flow:

  1. useMerklRewards.ts: Added rewardsFetchVersion counter (incremented after each fetch), auto-refresh interval (60s), and a bug fix to reset claimableReward to null when no matching reward exists.

  2. useMerklBonusClaim.ts: Added a "claim session lock" that hides the claim CTA after a successful claim submission until the next rewards refetch resolves (using rewardsFetchVersion). This prevents double-claiming UX issues.

  3. CashSection.tsx: Converted to forwardRef with useImperativeHandle exposing a refresh() method that forces remount of child components (resetting the claim session lock). Added refreshVersion key to MusdAggregatedRow and CashGetMusdEmptyState.

  4. Homepage.tsx: Added cashSectionRef and included cashSectionRef.current?.refresh() in the global pull-to-refresh flow.

Risk Assessment: LOW - These are isolated changes to the Earn/Cash mUSD feature. The Homepage change is purely additive (adding CashSection to the refresh cycle). No shared navigation, modal, or confirmation infrastructure is modified.

Tag Selection Rationale:

  • SmokeTrade: The Earn/staking flows are accessed via the Trade wallet actions menu. Changes to the claim flow and Homepage refresh could affect staking entry points. Also selected because SmokeTrade covers native ETH staking flows.
  • SmokeWalletPlatform: The Homepage is the core wallet platform view. The CashSection refresh integration affects the wallet home pull-to-refresh behavior.
  • SmokeConfirmations: Per SmokeTrade tag description, when selecting SmokeTrade for swap/bridge/staking flows, also select SmokeConfirmations.

No E2E tests directly cover Merkl rewards or mUSD claim flows, so the selected tags provide the best available coverage for the affected areas (Homepage, wallet platform, staking/earn flows).

Performance Test Selection:
No performance-sensitive changes detected. The auto-refresh interval (60s) is a background timer with minimal impact. No list rendering, heavy computation, or critical user flow performance paths are modified. The changes are isolated to the Earn/Cash claim flow logic and Homepage ref wiring.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@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

Copy link
Copy Markdown
Contributor

@nickewansmith nickewansmith left a comment

Choose a reason for hiding this comment

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

lgtm

@nickewansmith nickewansmith added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit bf586c0 Mar 31, 2026
111 checks passed
@nickewansmith nickewansmith deleted the MUSD-563-claim-button-is-still-visible-after-successfully-claiming branch March 31, 2026 15:25
@github-actions github-actions bot locked and limited conversation to collaborators Mar 31, 2026
@weitingsun weitingsun added release-7.73.0 Issue or pull request that will be included in release 7.73.0 and removed release-100.10.0 labels Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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-M team-mobile-ux Mobile UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Claim button is still visible after successfully claiming.

4 participants