Skip to content

feat: add hook for updating MM pay transaction amount update for money account deposits#29561

Merged
jpuri merged 32 commits into
mainfrom
custom_amt_update_hook
May 5, 2026
Merged

feat: add hook for updating MM pay transaction amount update for money account deposits#29561
jpuri merged 32 commits into
mainfrom
custom_amt_update_hook

Conversation

@jpuri

@jpuri jpuri commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Description

Add code to update amount for money account deposit. The function for money account data updates is placeholder only.

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

NA

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • 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
Touches the confirmation custom-amount flow and transaction data mutation paths; while Money Account updaters are stubs, the new routing and async error-handling could affect how/when amounts are applied and errors surfaced.

Overview
Adds Money Account-aware amount updating for confirmations. Introduces useUpdateTransactionPayAmount, which routes amount changes: for moneyAccountDeposit/moneyAccountWithdraw it prepares per-nested-call updates and applies them via updateAtomicBatchData, otherwise it falls back to the existing useUpdateTokenAmount path.

Wires custom amount entry into the new updater and hardens Done handling. useTransactionCustomAmount now delegates updateTokenAmount to useUpdateTransactionPayAmount, and CustomAmountInfo’s Done handler is made async with try/catch/finally to always flush UI state and log failures.

Scaffolds Money Account re-encoding. Adds placeholder updateMoneyAccountDepositTokenAmount/updateMoneyAccountWithdrawTokenAmount (returning []) plus a shared UpdateTransactionPayAmountCall type and accompanying tests.

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

@jpuri jpuri added team-confirmations Push issues to confirmations team no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Apr 30, 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.

@jpuri jpuri marked this pull request as ready for review April 30, 2026 14:18
@jpuri jpuri requested review from a team as code owners April 30, 2026 14:18
@jpuri jpuri enabled auto-merge April 30, 2026 14:18
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 7.69231% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.84%. Comparing base (51b6bbd) to head (3a6798f).
⚠️ Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
...s/hooks/transactions/useUpdateCustomTokenAmount.ts 0.00% 9 Missing ⚠️
...nts/info/custom-amount-info/custom-amount-info.tsx 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #29561       +/-   ##
===========================================
- Coverage   82.15%   61.84%   -20.32%     
===========================================
  Files        5178     5185        +7     
  Lines      137450   137845      +395     
  Branches    31079    31194      +115     
===========================================
- Hits       112924    85248    -27676     
- Misses      16875    45938    +29063     
+ Partials     7651     6659      -992     

☔ 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.

if (isMoneyAccountDeposit) {
updateCustomTokenAmount(amountHuman);
} else {
updateTokenAmountCallback(amountHuman);

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.

Can we encapsulate this further and only call useUpdateTokenAmount inside useUpdateCustomTokenAmount if there is no type specific condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR is updated to address this.

import { updateMoneyAccountDepositTokenAmount } from '../../../../UI/Money/utils/moneyAccountTransactions';
import Logger from '../../../../../util/Logger';

export function useUpdateCustomTokenAmount() {

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.

Maybe useUpdateTransactionPayAmount and we could put it in the pay directory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggestion is implemented.

return;
}

const updates = updateMoneyAccountDepositTokenAmount(

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.

We'd need a money account type check here, so we can scale it with additional types in future, and fallback to the default useUpdateTokenAmount?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR is updated to address this.

}

const updates = updateMoneyAccountDepositTokenAmount(
transactionMeta,

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.

Nice, give them the full context to extract what they need 👍

};
}

export interface MoneyAccountDepositTokenAmountUpdate {

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.

Should this be defined within our new hook as something like UpdateAmountCall?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR is updated to make this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I moved it to app/components/Views/confirmations/types/transactions.ts to avoid circular dependency issue.

);

for (const { nestedTransactionIndex, transactionData } of updates) {
updateAtomicBatchData({

@matthewwalsh0 matthewwalsh0 May 1, 2026

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.

I've hit this before also, but ideally we'd have a bulkified version of this to update multiple calls at once for cleaner state updates, but not needed now.

Could also support calling updateEditableParams from here with the full data but only if needed in future.

Comment thread app/components/UI/Money/utils/moneyAccountTransactions.ts Outdated
@jpuri jpuri requested a review from matthewwalsh0 May 1, 2026 10:41
matthewwalsh0
matthewwalsh0 previously approved these changes May 1, 2026
amountHuman,
);

for (const { nestedTransactionIndex, transactionData } of updates) {

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.

Minor, we could move this out of the money account specific callback to minimise duplication if we have other types in future.

@jpuri jpuri dismissed stale reviews from MoMannn and matthewwalsh0 via c87ac08 May 4, 2026 13:34
MoMannn
MoMannn previously approved these changes May 5, 2026
matthewwalsh0
matthewwalsh0 previously approved these changes May 5, 2026
@jpuri jpuri dismissed stale reviews from matthewwalsh0 and MoMannn via d22c539 May 5, 2026 10:56

@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 d22c539. Configure here.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:

The changes in this PR are focused on the Money Account deposit/withdraw confirmation flow, specifically:

  1. moneyAccountTransactions.ts: Adds two stub functions (updateMoneyAccountDepositTokenAmount and updateMoneyAccountWithdrawTokenAmount) that return empty arrays for now — real encoding will be wired in later.

  2. useUpdateTransactionPayAmount.ts (new hook): Routes amount updates based on transaction type — delegates to the new Money Account stubs for moneyAccountDeposit/moneyAccountWithdraw types, and falls back to updateTokenAmount for all other types.

  3. useTransactionCustomAmount.ts: Switches from useUpdateTokenAmount directly to the new useUpdateTransactionPayAmount hook — this affects ALL flows using this hook (Perps, Predict, mUSD, generic token amounts).

  4. custom-amount-info.tsx: Refactors handleDone to be async with try/catch/finally error handling, and removes the isMoneyAccountDeposit guard (now always calls updateTokenAmount()). This component is used by: MoneyAccountDepositInfo, MoneyAccountWithdrawInfo, PerpsDepositInfo, PerpsWithdrawInfo, PredictDepositInfo, PredictWithdrawInfo, mUSDConversionInfo.

Tags selected:

  • SmokeMoney: Directly affected — Money Account deposit/withdraw confirmation flows are the primary target of these changes.
  • SmokeConfirmations: Required by SmokeMoney tag description; also the custom-amount-info component is part of the confirmation UI system.
  • SmokePerps: CustomAmountInfo is used by PerpsDepositInfo and PerpsWithdrawInfo; the handleDone refactoring could affect Perps confirmation flows.
  • SmokePredictions: CustomAmountInfo is used by PredictDepositInfo and PredictWithdrawInfo; same risk as Perps.
  • SmokeWalletPlatform: Required by SmokePerps and SmokePredictions tag descriptions (Perps and Predictions are sections inside Trending tab).
  • SmokeStake: Lending deposit/withdrawal flows use similar confirmation patterns and the useTransactionCustomAmount hook change could affect them.

The stub implementations return empty arrays so Money Account-specific behavior is unchanged functionally, but the routing logic and async error handling in handleDone affect all flows using CustomAmountInfo.

Performance Test Selection:
The changes are focused on confirmation flow logic (async error handling, routing of amount updates) and stub implementations. There are no UI rendering changes, list component changes, or data loading changes that would meaningfully impact performance metrics. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

@jpuri jpuri requested a review from matthewwalsh0 May 5, 2026 11:52
@jpuri jpuri added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit b80bef9 May 5, 2026
177 of 178 checks passed
@jpuri jpuri deleted the custom_amt_update_hook branch May 5, 2026 12:25
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-L team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants