Skip to content

fix: update required assets correctly for money account deposits#29806

Merged
jpuri merged 6 commits into
mainfrom
money_acc_fixes
May 8, 2026
Merged

fix: update required assets correctly for money account deposits#29806
jpuri merged 6 commits into
mainfrom
money_acc_fixes

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented May 6, 2026

Description

Fix money account deposits by setting correst required asset in transaction.

Changelog

CHANGELOG entry:

Related issues

Ref: https://consensyssoftware.atlassian.net/browse/CONF-1324

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 transaction amount update flow for moneyAccountDeposit, including writing requiredAssets via updateTransaction, which could affect what token/amount is used for deposits if decimals or asset ordering are wrong.

Overview
Fixes Money Account deposit pay-amount updates by syncing transactionMeta.requiredAssets[0].amount to the user-entered amount (converted to atomic units using required-token decimals, rounded up, and hex-encoded) before applying nested transaction updates.

Also updates getTokenAddress to prefer requiredAssets[0].address when no ERC-20 transfer call is detected, and adds/expands unit tests covering the new required-asset sync and address selection behavior.

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

@jpuri jpuri requested a review from a team as a code owner May 6, 2026 15:33
@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 May 6, 2026
@jpuri jpuri enabled auto-merge May 6, 2026 15:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

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.

@github-actions github-actions Bot added pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. size-M labels May 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@jpuri jpuri 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 6, 2026
return { updateTransactionPayAmount };
}

function syncMoneyAccountDepositRequiredAssets(
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, this is a more general updateRequiredAssetsAmount for any type to use if needed?

...transactionMeta,
requiredAssets: [{ ...existing[0], amount }, ...existing.slice(1)],
},
'Money Account deposit: sync requiredAssets amount',
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, Update requiredAssets amount as can be generic?

},
'Money Account deposit: sync requiredAssets amount',
);
} catch (error) {
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, not sure how this would throw as it's a synchronous state update.

} catch (error) {
Logger.error(
error as Error,
'Failed to sync Money Account deposit requiredAssets amount',
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, also can be generic.

);
});

describe('syncMoneyAccountDepositRequiredAssets', () => {
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, this isn't an exported function, so should be something like updates requires assets amount?

return nestedCall.to;
}

const requiredAssetAddress = transactionMeta?.requiredAssets?.[0]?.address;
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, if we have requiredAssets set, that should probably take priority over a found token transfer call above?

@jpuri jpuri added this pull request to the merge queue May 7, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 7, 2026
@MoMannn MoMannn added this pull request to the merge queue May 8, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 8, 2026
@jpuri jpuri enabled auto-merge May 8, 2026 09:26
Copy link
Copy Markdown
Contributor

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

Comment thread app/components/Views/confirmations/utils/transaction-pay.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on two areas:

  1. useUpdateTransactionPayAmount.ts: Adds syncMoneyAccountDepositRequiredAssets logic that syncs the requiredAssets[0].amount field when a user updates the deposit amount in a Money Account deposit transaction. This is specifically for the MetaMask Card/Money Account deposit flow (TransactionType.moneyAccountDeposit).

  2. transaction-pay.ts (getTokenAddress): Adds a new fallback path that returns requiredAssets[0].address when no nested transfer is found. This utility is imported by Perps utils (transactionTransforms.ts), Earn utils, and multiple confirmation components (pay-with-modal, bridge-fee-row, total-row, pay-token-amount, etc.).

Tag selection rationale:

  • SmokeMoney: Directly affects Money Account deposit flows (card/fiat on-ramp). The syncMoneyAccountDepositRequiredAssets function is specifically for moneyAccountDeposit transaction type.
  • SmokeConfirmations: transaction-pay.ts is used extensively in confirmation components. The getTokenAddress change affects token address resolution in confirmation flows (pay-with-modal, bridge-fee-row, total-row, pay-token-amount).
  • SmokeSwap: SmokeMoney description requires SmokeSwap when Add Funds/deposit flows are involved (card deposit can involve swap paths).
  • SmokePerps: transaction-pay.ts is directly imported by app/components/UI/Perps/utils/transactionTransforms.ts, so the getTokenAddress change could affect Perps transaction flows.
  • SmokeWalletPlatform: Required per SmokeMoney tag description when wallet home/actions entry to buy/sell is involved. Also required per SmokePerps description.

Performance Test Selection:
The changes are focused on transaction amount synchronization logic and token address resolution utilities. These are not UI rendering, list rendering, or app startup changes. The new syncMoneyAccountDepositRequiredAssets function is a lightweight synchronization utility that runs on user input, not a performance-critical rendering path. No performance tests are warranted.

View GitHub Actions results

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29806   +/-   ##
=======================================
  Coverage   81.50%   81.51%           
=======================================
  Files        5328     5328           
  Lines      141146   141158   +12     
  Branches    32157    32160    +3     
=======================================
+ Hits       115046   115061   +15     
+ Misses      18239    18236    -3     
  Partials     7861     7861           

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

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

@jpuri jpuri added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit a4f45f0 May 8, 2026
113 of 116 checks passed
@jpuri jpuri deleted the money_acc_fixes branch May 8, 2026 13:37
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 8, 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.78.0 Issue or pull request that will be included in release 7.78.0 size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants