Skip to content

feat: add Claim button for empty cash section#27909

Merged
PatrykLucka merged 8 commits into
mainfrom
add-claim-bonus-for-empty-cash-section
Mar 30, 2026
Merged

feat: add Claim button for empty cash section#27909
PatrykLucka merged 8 commits into
mainfrom
add-claim-bonus-for-empty-cash-section

Conversation

@PatrykLucka

@PatrykLucka PatrykLucka commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Description

Reason: Users with no mUSD balance but a claimable Merkl bonus only saw the claim flow after drilling into the aggregated mUSD row / asset overview. The home Cash empty state did not surface a claim action, and claim failures could occur with little feedback.

Solution:

  • CashGetMusdEmptyState (homepage Cash section and Cash full view empty state): wires useMerklBonusClaim with shared LINEA_MUSD_ASSET_FOR_MERKL, shows a full-width secondary Claim CTA when there is a claimable reward and no pending claim.
  • Button copy uses earn.claim_bonus_with_fiat so the label includes the amount formatted with formatWithThreshold + getLocaleLanguageCode(), converting Merkl’s USD amount with the same USD → selected fiat basis as the mUSD price row (oneUsdInUserFiat from mainnet currency rates).
  • Errors from useMerklClaimTransaction are surfaced via useMerklBonusClaim as error and a plain toast on the empty state when a claim attempt fails.
  • useMerklClaimTransaction: if the first Merkl fetch returns no reward data, clears the in-memory Merkl cache and retries once to avoid stale empty cache vs. display.
  • MusdAggregatedRow: reuses LINEA_MUSD_ASSET_FOR_MERKL from constants; row press always navigates to Mainnet mUSD asset details (no longer branches to Cash full view when the user has mUSD).
  • Tests for CashGetMusdEmptyState, useMerklBonusClaim, useMerklClaimTransaction, and Homepage mocks updated as needed.
  • Locales: claim_bonus_with_fiat (and aligned keys where added) for the new string.

Changelog

CHANGELOG entry: Added a Claim bonus action on the home Cash section when users have no mUSD but have a claimable Merkl bonus, with the amount shown in the selected fiat currency.

Related issues

Fixes:

Manual testing steps

Feature: Cash section claim bonus when wallet has no mUSD

  Scenario: User with no mUSD and claimable Merkl bonus sees claim CTA on home
    Given mUSD conversion Cash is enabled and the user is geo-eligible
    And the user has no mUSD balance on supported chains
    And Merkl reports a claimable mUSD bonus above the minimum threshold
    When the user views the Wallet home screen
    Then the Cash section shows the empty "Get mUSD" state
    And a secondary button is shown whose label starts with "Claim" and includes a formatted fiat amount

  Scenario: User taps Claim bonus from Cash empty state
    Given the Claim bonus button is visible on the Cash empty state
    When the user taps the Claim bonus button
    Then the wallet proceeds with the Merkl claim flow (e.g. transaction confirmation) when reward data is available
    Or a toast appears with an error message when the claim cannot be completed

  Scenario: Cash full view empty state
    Given the user opens the Cash token list full view with no mUSD balance
    And a claimable bonus exists
    Then the same Claim bonus control is available with consistent labeling

Screenshots/Recordings

Before

After

Screenshot 2026-03-24 at 15 06 10

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
Adds a new claim path in the Cash empty-state UI and changes Merkl claim fetching to clear cache and retry, which could affect user flows and network/API behavior but is limited to the mUSD/Merkl feature area.

Overview
Adds a secondary “Claim bonus” CTA to the Cash (mUSD) empty state (homepage + full view) when a Merkl bonus is claimable, including fiat-formatted amount labeling and analytics tracking; claim failures now surface as a toast.

Extends useMerklBonusClaim to expose an error from useMerklClaimTransaction, and updates useMerklClaimTransaction to clear the Merkl in-memory cache and retry once when the initial rewards fetch returns no data.

Refactors Cash mUSD components to share a LINEA_MUSD_ASSET_FOR_MERKL constant and adjusts MusdAggregatedRow navigation to always open mainnet mUSD asset details; updates tests, mocks, locale string (earn.claim_bonus_with_fiat), and API-mocking defaults for Merkl rewards.

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

@PatrykLucka PatrykLucka self-assigned this Mar 25, 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 25, 2026
@PatrykLucka PatrykLucka changed the title feat: add error handling and claim bonus functionality for Merkl rewards feat: add Claim button for empty cash section Mar 25, 2026
@PatrykLucka PatrykLucka force-pushed the add-claim-bonus-for-empty-cash-section branch from c00bffe to 0efc195 Compare March 25, 2026 13:01
@PatrykLucka PatrykLucka force-pushed the add-claim-bonus-for-empty-cash-section branch from 0efc195 to 64884f4 Compare March 26, 2026 06:55
@PatrykLucka PatrykLucka marked this pull request as ready for review March 26, 2026 10:26
@PatrykLucka PatrykLucka requested review from a team as code owners March 26, 2026 10:26
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 26, 2026
shane-t
shane-t previously approved these changes Mar 26, 2026
@PatrykLucka PatrykLucka enabled auto-merge March 26, 2026 12:24
@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 27, 2026
@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 27, 2026
@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 27, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 27, 2026

@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/Views/Homepage/Homepage.test.tsx Outdated
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026
…etaMask/metamask-mobile into add-claim-bonus-for-empty-cash-section
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:

The changes in this PR are focused on:

  1. Merkl bonus claim improvements (useMerklBonusClaim, useMerklClaimTransaction): Adding error state propagation and a cache-clearing retry mechanism for stale reward data. These hooks are used in the Earn/mUSD staking flow.

  2. Homepage Cash section UI (CashGetMusdEmptyState, MusdAggregatedRow): Adding a "Claim bonus" button with fiat amount display to the empty state when a user has a claimable Merkl bonus but no mUSD balance. This is a new UI feature on the Homepage Cash section.

  3. API mock update (rewards.ts): Adding a Merkl API mock to the global default mocks. This is a critical change as it affects ALL E2E tests that use the default mock setup — it prevents real Merkl API calls from failing tests that render the Homepage Cash section.

  4. Localization: Adding claim_bonus_with_fiat string.

Tag selection rationale:

  • SmokeTrade: The stake action smoke test (stake-action-smoke.spec.ts) uses SmokeTrade and directly tests the Earn/staking flow. The Merkl claim transaction changes could affect staking confirmation flows. Per tag description, staking flows are covered under SmokeTrade.
  • SmokeConfirmations: Per SmokeTrade tag description, "When selecting SmokeTrade for swap/bridge, also select SmokeConfirmations." The Merkl claim executes an on-chain transaction (claim rewards), which goes through the confirmation flow.
  • SmokeWalletPlatform: The Homepage Cash section (CashGetMusdEmptyState, MusdAggregatedRow) is part of the wallet homepage. The new Merkl API mock in default mocks could affect any test that renders the homepage. SmokeWalletPlatform covers wallet platform features including homepage sections.

The changes are primarily additive (new UI feature, error handling improvement, new mock) with low risk of breaking existing functionality. The mock addition is the most impactful change as it affects all tests using default mocks, but it's a safe addition (returns empty array for Merkl rewards).

Performance Test Selection:
The changes are focused on Earn/mUSD Merkl bonus claim UI and hook logic. While there are UI changes to the Homepage Cash section, they are additive (new button, error handling) and don't involve list rendering, heavy data loading, or performance-critical paths. The hook changes add a retry mechanism but this is in the claim flow (user-initiated), not in the rendering/loading path. No performance test tags are warranted.

View GitHub Actions results

@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

@sonarqubecloud

Copy link
Copy Markdown

@PatrykLucka PatrykLucka added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit 5d0e19e Mar 30, 2026
193 of 199 checks passed
@PatrykLucka PatrykLucka deleted the add-claim-bonus-for-empty-cash-section branch March 30, 2026 09:41
@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

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-mobile-ux Mobile UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants