Skip to content

fix(confirmations): cp-8.0.0 skip initial gas estimate for sponsored money account transactions#32129

Merged
matthewwalsh0 merged 2 commits into
mainfrom
fix/skip-initial-gas-estimate-sponsored-batches
Jun 23, 2026
Merged

fix(confirmations): cp-8.0.0 skip initial gas estimate for sponsored money account transactions#32129
matthewwalsh0 merged 2 commits into
mainfrom
fix/skip-initial-gas-estimate-sponsored-batches

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Jun 21, 2026

Copy link
Copy Markdown
Member

Description

Money Account deposit and withdrawal batches trigger synchronous gas estimation when addTransactionBatch is called. On networks where gas is sponsored (e.g. Monad Mainnet), a bug in gas estimation can cause a crash when the RPC unexpectedly returns null for the latest block — an error condition we are now handling defensively.

This PR passes skipInitialGasEstimate: true to deposit and withdrawal batches when isGasFeeSponsored is true, deferring gas estimation to the async background path where this error condition is handled safely. Non-sponsored flows are unaffected.

Changelog

CHANGELOG entry: Fixed a crash that could occur when initiating Money Account transactions on Monad

Related issues

Fixes:

Manual testing steps

Feature: Money Account deposit and withdrawal on a sponsored-gas network

  Scenario: user initiates a deposit on Monad Mainnet
    Given the user has a Money Account on Monad Mainnet
    And Monad Mainnet is selected

    When user taps Deposit and confirms the transaction
    Then the batch is submitted without crashing
    And gas estimation completes in the background

  Scenario: user initiates a withdrawal on Monad Mainnet
    Given the user has a Money Account with a mUSD balance on Monad Mainnet

    When user taps Withdraw and confirms the transaction
    Then the batch is submitted without crashing

  Scenario: user initiates a withdrawal on a non-sponsored network
    Given the user has a Money Account on a non-Monad network

    When user taps Withdraw and confirms the transaction
    Then skipInitialGasEstimate is false and gas is estimated synchronously as before

Screenshots/Recordings

Before

N/A

After

N/A

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

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 confirmation/transaction submission for Money Account flows; behavior change is gated to sponsored-gas (Monad) chains, with tests updated for withdrawals only.

Overview
Money Account deposit and withdrawal now pass skipInitialGasEstimate: true into addTransactionBatch when the vault chain is Monad Mainnet (same condition as isGasFeeSponsored via isMonadMainnetChainId), so synchronous gas estimation is skipped and runs on the async path instead.

Deposits also set isGasFeeSponsored on the batch (previously only withdrawals did). Withdrawal tests on Monad assert both sponsored flags; non-Monad withdrawal behavior is unchanged aside from not setting skipInitialGasEstimate.

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

@metamask-ci metamask-ci Bot added the team-confirmations Push issues to confirmations team label Jun 21, 2026
@metamask-ci

metamask-ci Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Related issues section is empty. Add Fixes: #123 / Closes: <URL> / Refs: <Jira key>, or write a short rationale after the colon.
  • Pre-merge author checklist has unchecked items (e.g. "I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards."). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@matthewwalsh0 matthewwalsh0 changed the title fix(money): skip initial gas estimate for sponsored Money Account batches fix(confirmations): skip initial gas estimate for sponsored money account batches Jun 21, 2026
@matthewwalsh0 matthewwalsh0 changed the title fix(confirmations): skip initial gas estimate for sponsored money account batches fix(confirmations): skip initial gas estimate for sponsored money account transactions Jun 21, 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 in app/components/UI/Money/hooks/useMoneyAccount.ts and its test file. The functional changes are:

  1. Deposit flow: Added skipInitialGasEstimate: isGasFeeSponsored to addTransactionBatch call. The isGasFeeSponsored variable was extracted (previously inline isMonadMainnetChainId(chainIdHex) for withdrawal, now consistent for both).

  2. Withdrawal flow: Added skipInitialGasEstimate: isGasFeeSponsored to addTransactionBatch call (previously only isGasFeeSponsored was passed, now skipInitialGasEstimate is also passed with the same value).

  3. Parameter reordering: Cosmetic alphabetical reordering of parameters in both calls.

SmokeMoney: Directly affected - these hooks power the Money account deposit and withdrawal flows (Card Add Funds and withdrawal).

SmokeConfirmations: The addTransactionBatch function is a transaction flow that goes through the confirmation UI. The new skipInitialGasEstimate parameter changes how gas estimation is handled during the confirmation flow, which could affect what users see in the confirmation screen. Per SmokeMoney tag description: "When selecting SmokeMoney for Card Add Funds or similar flows that execute swaps, also select SmokeSwap and SmokeConfirmations."

SmokeSwap: Not selected because the changes are specifically to Money account deposit/withdrawal (not swap flows). The SmokeMoney description mentions SmokeSwap for "Add Funds (Deposit/Swap paths)" but the change here is specifically about gas sponsorship for Monad Mainnet, not the swap path itself.

No performance tests are needed as this is a logic change to gas estimation parameters, not a rendering or load performance concern.

Performance Test Selection:
The changes add a skipInitialGasEstimate flag to transaction batch calls for sponsored gas scenarios. This is a logic/parameter change, not a rendering or load performance concern. No performance test scenarios are impacted.

View GitHub Actions results

@matthewwalsh0 matthewwalsh0 changed the title fix(confirmations): skip initial gas estimate for sponsored money account transactions fix(confirmations): cp-8.0.0 skip initial gas estimate for sponsored money account transactions Jun 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@matthewwalsh0
matthewwalsh0 marked this pull request as ready for review June 23, 2026 09:51
@matthewwalsh0
matthewwalsh0 requested a review from a team as a code owner June 23, 2026 09:51
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 23, 2026
@matthewwalsh0
matthewwalsh0 added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 902d193 Jun 23, 2026
125 checks passed
@matthewwalsh0
matthewwalsh0 deleted the fix/skip-initial-gas-estimate-sponsored-batches branch June 23, 2026 10:22
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 23, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-8.1.0 Issue or pull request that will be included in release 8.1.0 label Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.1.0 Issue or pull request that will be included in release 8.1.0 risk:low AI analysis: low risk size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants