Skip to content

fix(money): wire Add mUSD entry + correct deposit toasts (MUSD-849, MUSD-845)#30741

Merged
Kureev merged 8 commits into
mainfrom
kureev/MUSD-849
May 28, 2026
Merged

fix(money): wire Add mUSD entry + correct deposit toasts (MUSD-849, MUSD-845)#30741
Kureev merged 8 commits into
mainfrom
kureev/MUSD-849

Conversation

@Kureev

@Kureev Kureev commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

Covers two related tickets:

  • MUSD-849 — "Add your $X.XX mUSD" in the Money "Add money" bottom sheet previously closed the modal with no further action. It now opens the same moneyAccountDeposit confirmation screen as Convert crypto, with mUSD pre-selected as the "Pay with" token on the chain holding the user's largest mUSD balance (Mainnet fallback).
  • MUSD-845 — Deposit toast copy now matches the Figma per intent:
    • Convert crypto → "Converting crypto" → "Conversion complete" / "Conversion failed" + "Unable to convert. Try again."
    • Add mUSD → "Adding funds" → "Funds added" / "Failed to add funds" + "Unable to add funds. Try again."

Intent is registered on the deposit batch synchronously in initiateDeposit() (the batchId is pre-generated client-side via the same uuid → bytesToHex recipe the transaction-controller uses internally), so the toast subscriber can resolve it even when a controller status event fires synchronously on an immediate-failure path. Entries are cleared on every terminal status (success / failed / dropped / cancelled / rejected) and on initiation throw.

Changelog

CHANGELOG entry: Fixed the "Add mUSD" option in the Money account "Add money" sheet so it opens the deposit flow with mUSD pre-selected, and corrected the in-progress / success / failed toast copy for both the Convert and Add flows.

Related issues

Fixes: MUSD-849, MUSD-845

Manual testing steps

Feature: Add mUSD to Money account from bottom sheet

  Scenario: User with mUSD balance taps "Add your $X mUSD"
    Given the user has mUSD on Mainnet and/or Linea
    And the user is on the Money account home screen

    When the user taps the Add button
    Then the "Add money" bottom sheet appears
    And it shows "Add your $X.XX mUSD" option

    When the user taps "Add your $X.XX mUSD"
    Then the deposit confirmation screen opens with header "Add funds"
    And the "Pay with" row is pre-selected to mUSD on the chain with the largest balance

Feature: Deposit toast copy reflects entry-point intent

  Scenario: Convert crypto lifecycle
    Given the user submitted a deposit via Convert crypto
    When the transaction is approved
    Then the in-progress toast title shows "Converting crypto"
    When the transaction is confirmed
    Then the success toast title shows "Conversion complete"
    When the transaction fails
    Then the failed toast shows "Conversion failed" / "Unable to convert. Try again."

  Scenario: Add mUSD lifecycle
    Given the user submitted a deposit via Add mUSD
    When the transaction is approved
    Then the in-progress toast title shows "Adding funds"
    When the transaction is confirmed
    Then the success toast title shows "Funds added"
    When the transaction fails
    Then the failed toast shows "Failed to add funds" / "Unable to add funds. Try again."

Screenshots/Recordings

Before

Tapping "Add your $X.XX mUSD" dismissed the bottom sheet with no further action. Deposit toasts used the generic "Transaction in progress / complete / failed" copy.

After

Tapping "Add your $X.XX mUSD" opens the deposit confirmation with mUSD pre-selected as "Pay with". Toast copy reflects the user's entry-point intent for the full lifecycle.

Simulator.Screen.Recording.-.iPhone.17.-.2026-05-28.at.15.34.18.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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
Changes money deposit initiation, confirmation pre-selection, and transaction toast behavior; risk is moderated by tests and scoped to deposit UX, but incorrect chain/token or intent handling could mislead users during fund movement.

Overview
The Add your $X mUSD row in the Money Add money sheet now starts the same money-account deposit flow as Convert crypto, instead of only closing the sheet. It passes intent: 'addMusd' and a preferredPaymentToken for mUSD on the chain with the largest per-chain balance (default chain when balances are missing).

initiateDeposit accepts optional intent and preferred payment token, pre-generates a batchId, registers intent in memory before submitting the batch, forwards the token into confirmation navigation, and clears intent on batch failure or terminal transaction status. The deposit confirmation screen passes that token into CustomAmountInfo as the pre-selected Pay with asset.

Deposit toasts (in progress, success, failed) now use separate copy for convert vs add mUSD, resolved from batch intent in useMoneyTransactionStatus, with new locale strings.

Reviewed by Cursor Bugbot for commit 3317cbe. Bugbot is set up for automated code reviews on this repo. Configure here.

Selecting "Add your $X.XX mUSD" in the Money "Add money" sheet
previously dismissed the modal with no further action. It now opens the
moneyAccountDeposit confirmation with mUSD pre-selected as the "Pay
with" token on the chain holding the user's largest mUSD balance.

While the in-progress toast was being touched, splits its copy by
entry-point intent:
- Convert crypto → "Converting crypto"
- Add mUSD → "Adding funds"

Intent is tagged on the deposit batch at initiateDeposit() and read by
the toast subscriber; it is cleared on every terminal status so the
intent map cannot leak.
@Kureev Kureev added team-earn pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels May 28, 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.

Extends the deposit toast intent split (added in the previous commit
for the in-progress state) to success and failed states so the copy
matches the Figma designs for the Convert and Add mUSD flows:

- Convert success: "Conversion complete" / "$X added to Money account."
- Convert failed:  "Conversion failed" / "Unable to convert. Try again."
- Add mUSD success: "Funds added" / "$X added to Money account."
- Add mUSD failed:  "Failed to add funds" / "Unable to add funds. Try again."

Intent is read from the batch tag before the entry is cleared in the
terminal state handlers, then forwarded into the success/failed toast
builders.
@github-actions github-actions Bot added size-L and removed size-M labels May 28, 2026
@sonarqubecloud

Copy link
Copy Markdown

Kureev added 3 commits May 28, 2026 15:07
…-849)

When the user left a deposit confirmation screen without confirming
(leaving a stale unapproved tx) and then opened the bottom sheet again,
pressing Convert or Add mUSD did nothing.

Two races stacked together:
1. initiateDeposit called navigateToConfirmation *after* an
   `await buildMoneyAccountDepositBatch(...)`, so by the time it ran
   the sheet animation had already completed and navigation.goBack had
   been dispatched.
2. The bottom-sheet handlers called initiateDeposit inside the sheet's
   post-close callback, which fires after goBack. By that point the
   sheet was unmounting, so useConfirmNavigation's "reject pending,
   queue navigation" branch lost its state to the unmount and the
   queued navigation never fired.

Fix:
- Move navigateToConfirmation before the await in initiateDeposit so
  the queue branch is entered synchronously.
- Invert the order in handleConvertCrypto and handleMoveMusd: call
  initiateDeposit first, then close the sheet, so the sheet stays
  mounted long enough for the queued navigation to fire after the
  stale tx rejection propagates.
Storing intent in the Map after addTransactionBatch resolved left a
race window: the transaction's status events fire synchronously inside
addTransactionBatch, so an immediate-failure path produced the
"Conversion failed" toast even when the user pressed Add mUSD.

Pre-generate the batchId via uuid + bytesToHex (mirroring how the
controller generates one when not provided) and register intent in the
Map synchronously before any await. Pass that same batchId to
addTransactionBatch so the controller doesn't generate a different one.

If addTransactionBatch throws without ever creating the tx, the dangling
intent entry is removed in the catch branch.
@Kureev Kureev self-assigned this May 28, 2026
@Kureev Kureev changed the title fix(money): wire Add mUSD bottom-sheet entry to deposit flow (MUSD-849) fix(money): wire Add mUSD entry + correct deposit toasts (MUSD-849, MUSD-845) May 28, 2026
@Kureev Kureev removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 28, 2026
@Kureev Kureev marked this pull request as ready for review May 28, 2026 13:41
@Kureev Kureev requested review from a team as code owners May 28, 2026 13:41
Comment thread app/components/UI/Money/hooks/useMoneyAccount.ts

@OGPoyraz OGPoyraz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Confirmation changes LGTM

@Kureev Kureev enabled auto-merge May 28, 2026 13:57
@Kureev Kureev added skip-e2e skip E2E test jobs and removed skip-e2e skip E2E test jobs labels May 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on the MetaMask Card/Money feature area:

  1. MoneyAddMoneySheet.tsx: Implements the previously stubbed "Move mUSD → Money Account" flow. Now selects the chain with the highest mUSD balance and calls initiateDeposit with intent: 'addMusd' and a preferredPaymentToken.

  2. useMoneyAccount.ts: Extends initiateDeposit to accept InitiateDepositOptions (including preferredPaymentToken and intent), adds a batchId-to-intent map for tracking deposit intent across the transaction lifecycle, and passes batchId to addTransactionBatch.

  3. useMoneyToasts.tsx: Differentiates toast messages based on deposit intent (convert vs addMusd) for in-progress, success, and failed states.

  4. useMoneyTransactionStatus.ts: Reads deposit intent from the batch ID map to show intent-specific toasts, and clears intent on completion/failure/rejection.

  5. confirm-component.tsx: Adds preferredPaymentToken to ConfirmationParams interface — this touches the shared confirmation component used across many flows.

  6. money-account-deposit-info.tsx: Reads preferredPaymentToken from nav params and passes it to CustomAmountInfo.

  7. en.json: Adds new locale strings for intent-specific toast messages.

Tag selection rationale:

  • SmokeMoney: Primary area affected — Card Add Funds flow, MoneyAddMoneySheet, deposit flows, toast notifications. The card-home-add-funds.spec.ts test directly exercises this flow.
  • SmokeConfirmations: The confirmation component (confirm-component.tsx) is modified to add preferredPaymentToken to ConfirmationParams. The money-account-deposit-info.tsx reads this param and passes it to CustomAmountInfo. Per SmokeMoney tag description: "When selecting SmokeMoney for Card Add Funds or similar flows that execute swaps, also select SmokeSwap and SmokeConfirmations." The deposit flow goes through the confirmation screen.

SmokeSwap is NOT selected because the changes don't touch swap-specific code paths — the preferredPaymentToken is passed to CustomAmountInfo within the money account deposit confirmation, not the swap confirmation flow. The changes are scoped to the Money/Card deposit flow.

Performance Test Selection:
The changes are focused on business logic for the Money/Card deposit flow — adding intent tracking, preferred payment token selection, and intent-specific toast messages. There are no changes to rendering performance, list components, data loading patterns, or app initialization that would warrant performance testing.

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.

Reviewed by Cursor Bugbot for commit 3317cbe. Configure here.

}[];
};

export type DepositIntent = 'convert' | 'addMusd';

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.

Duplicate intent type defined in two files

Low Severity

DepositIntent in useMoneyToasts.tsx and MoneyAccountDepositIntent in useMoneyAccount.ts are identical 'convert' | 'addMusd' union types defined independently. If a new variant is added to one but not the other, intent values could silently mismatch across the toast and account layers. One definition that the other imports would eliminate this drift risk.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3317cbe. Configure here.

@Kureev Kureev added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit 907b278 May 28, 2026
243 of 318 checks passed
@Kureev Kureev deleted the kureev/MUSD-849 branch May 28, 2026 17:12
@github-actions github-actions Bot locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants