Skip to content

fix(confirmations): handle batch predict deposits and quote‑based alerts#25326

Merged
pedronfigueiredo merged 10 commits intomainfrom
pnf/gasless-perps
Jan 30, 2026
Merged

fix(confirmations): handle batch predict deposits and quote‑based alerts#25326
pedronfigueiredo merged 10 commits intomainfrom
pnf/gasless-perps

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented Jan 28, 2026

  • Update pay token selection to use hasTransactionType for predict deposit detection (covers nested/batch txs), and tighten typing/guarding around transactionMeta when updating selectedGasFeeToken. Perps behavior remains unchanged.
  • Suppress the native insufficient balance alert when the pay token matches the required token and pay‑controller quotes are loading/available, letting pay‑token balance/fee alerts drive blocking instead.
  • Add unit coverage for the quote‑present case and expand mocks for quote/loading state in useInsufficientBalanceAlert tests.

Description

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

Before

After

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
Changes blocking alert behavior and updates how selectedGasFeeToken is set during pay-token selection for predictDeposit, which could impact confirmation gating and gas/token selection in edge cases.

Overview
Confirmation alerts now defer to transaction-pay UI when pay quotes/source amounts are in play. useInsufficientBalanceAlert stops emitting the native insufficient-balance blocking alert whenever useTransactionPayHasSourceAmount() indicates pay source amounts are being used, replacing the prior pay-token/required-token matching logic.

Pay-token selection for predictDeposit is more robust. useTransactionPayToken uses hasTransactionType to detect predictDeposit (covering nested/batch transactions) and only updates selectedGasFeeToken when transactionMeta is present, with tighter typing.

Tests for useInsufficientBalanceAlert were updated to mock useTransactionPayHasSourceAmount and cover the new suppression behavior.

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

@pedronfigueiredo pedronfigueiredo self-assigned this Jan 28, 2026
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner January 28, 2026 16:19
@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Jan 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.

@pedronfigueiredo pedronfigueiredo changed the title fix(confirmations): handle batch predict/perps deposits in pay token … fix(confirmations): handle batch predict/perps deposits in pay token selection Jan 28, 2026
OGPoyraz
OGPoyraz previously approved these changes Jan 28, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/gasless-perps branch 2 times, most recently from e385103 to 3d547d5 Compare January 28, 2026 16:30
@pedronfigueiredo pedronfigueiredo added skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Jan 28, 2026
OGPoyraz
OGPoyraz previously approved these changes Jan 28, 2026
OGPoyraz
OGPoyraz previously approved these changes Jan 28, 2026
matthewwalsh0
matthewwalsh0 previously approved these changes Jan 28, 2026
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 28, 2026
@pedronfigueiredo pedronfigueiredo removed this pull request from the merge queue due to a manual request Jan 28, 2026
@pedronfigueiredo pedronfigueiredo marked this pull request as draft January 28, 2026 18:55
Copy link
Copy Markdown

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

!transactionMetadata ||
isTransactionValueUpdating ||
(payToken && !isPayTokenTarget)
(payToken && !isPayTokenTarget && !isUsingPay)
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.

Sorry for the confusion.

The goal here is to skip this alert if we're using MetaMask Pay with a quote.

So we'd want to return if isUsingPay is true.

And we shouldn't need payToken && !isPayTokenTarget since isUsingPay will only be true if there is a pay token, and the controller decided a quote is needed so generated a source amount.

(!isGasFeeTokensEmpty && !selectedGasFeeToken));

const showAlert =
!shouldSkipInsufficientBalanceForPayToken &&
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.

These changes shouldn't be needed as we can early return above with no alerts if isUsingPay.

…selection

Use hasTransactionType so batch transactions containing predict/perps deposits
are recognized when a payment token is selected. This keeps predict gasless
selection working while leaving perps behavior unchanged.
Update selectedGasFeeToken for perps deposit transactions when the payment token matches the required token, so gasless relay can proceed without native ETH.
This reverts commit b8c2ac181a11300e992d8749edab921d9190cb43.
@pedronfigueiredo
Copy link
Copy Markdown
Contributor Author

Tested scenarios:

Perps

  • USDC on Arbitrum
    • Worked
  • BNB on Binance Chain
    • Worked
  • USDC on Ethereum (without native token balance)
    • Worked

Predict

  • USDC.e on Polygon
    • Worked
  • BNB on Binance Chain
    • trading route not available
  • USDC on ethereum
    • Worked

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
Changes are localized to the confirmations flow: insufficient balance alert logic now short-circuits when Transaction Pay source amounts are used, and the pay token hook alters behavior for predictDeposit transactions using hasTransactionType and updates to selectedGasFeeToken typing. This directly impacts the redesigned confirmations experience and any flows that use Transaction Pay (gas fee token payments) such as swaps/bridge, and Predictions deposit confirmations. No Engine/controllers were changed, and scope is UI hooks, so broader suites are unnecessary.

Performance Test Selection:
Hook-level logic changes do not affect rendering complexity, startup, or list-heavy components. No state management/controller performance implications. Performance tests are unnecessary.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit f43252c Jan 30, 2026
89 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/gasless-perps branch January 30, 2026 15:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
@metamaskbot metamaskbot added the release-7.65.0 Issue or pull request that will be included in release 7.65.0 label Jan 30, 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.65.0 Issue or pull request that will be included in release 7.65.0 size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants