Skip to content

refactor(confirmations): use approval callbacks instead of prep mutations - #35754

Draft
pedronfigueiredo wants to merge 3 commits into
mainfrom
pnf/canonical-transaction-approval-preparation-handoff-implementation
Draft

pedronfigueiredo wants to merge 3 commits into
mainfrom
pnf/canonical-transaction-approval-preparation-handoff-implementation

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Related pull requests

Description

Mobile now relies on TransactionController approval-time callbacks (isSponsored and shouldSign) instead of imperatively preparing approval metadata in the confirmation flow.

Mobile still owns capability discovery and client-specific behavior: signer-versus-payer handling, waitForResult, Smart Transaction fee-token batch construction, fee-token EIP-7702 routing, hardware send deferral, ApprovalController acceptance, fiat branching, network enablement, and product navigation. The controller now derives external signing internally, so the confirmation flow no longer needs to mutate isExternalSign before approval.

Characterization coverage was updated for hardware payer/software signer behavior, gas-fee-token handling, ignored fee tokens, and hardware send routing.

Validation

  • npx jest --no-watchman app/components/Views/confirmations/hooks/transactions/useTransactionConfirm.test.ts app/util/transactions/hooks/index.test.ts

@pedronfigueiredo pedronfigueiredo added area-transactions DO-NOT-MERGE Pull requests that should not be merged team-confirmations Push issues to confirmations team labels Sep 4, 2026
@pedronfigueiredo pedronfigueiredo self-assigned this Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

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.

@github-actions github-actions Bot added the size-M label Sep 4, 2026
@metamask-ci

metamask-ci Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

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

Warnings — informational, address before merging:

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

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🧪 Flaky unit test detection

Run history flaky detection

View recent run history

Historical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow.

Failures / runs sampled per window:

File 7d 15d 30d
app/components/Views/confirmations/hooks/transactions/useTransactionConfirm.test.ts 0/106 0/262 0/451

AI-detected flaky patterns

app/components/Views/confirmations/hooks/transactions/useTransactionConfirm.test.ts

  • J1 — Missing act() around async state updates (critical)

This check is informational only and does not block merging.

@pedronfigueiredo pedronfigueiredo changed the title refactor(confirmations): use canonical transaction approval preparation refactor(confirmations): use approval callbacks instead of prep mutations Sep 9, 2026
@metamask-ci metamask-ci Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations, SmokeSwap, SmokeAccounts
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR refactors the gasless/sponsored transaction logic in two key files:

  1. useTransactionConfirm.ts: Removes client-side gasless eligibility checks (shouldApplyGasFeeSponsorship, useIsGaslessSupported, handleGasless7702). Previously, the UI layer was overriding isGasFeeSponsored and isExternalSign flags. Now these are passed through as-is from the transaction metadata, with the controller hooks layer handling the decisions.

  2. index.ts (transaction hooks): Adds two new TransactionController hooks - isSponsored and shouldSignHook - that now handle sponsorship eligibility and signing mode at the controller level. These incorporate hardware wallet detection, smart transaction support, relay support checks, and EIP-7702 eligibility.

Impact areas:

  • SmokeConfirmations: Core transaction confirmation flow is directly affected. The signing path for gas-sponsored transactions, EIP-7702 gas fee token flows, and hardware wallet transactions all changed. The isGasFeeSponsored flag is no longer cleared client-side, and isExternalSign is no longer set client-side. This is a behavioral change in how transactions are submitted.
  • SmokeSwap: Gasless swaps rely on the sponsorship/signing logic that was refactored. The gasless swap path (where isGasFeeSponsored determines if a relay handles the transaction) is directly affected.
  • SmokeAccounts: Hardware wallet account flows are affected - the hardware wallet detection now happens in the controller hooks layer rather than the UI layer, changing how hardware wallet transactions are routed through the signing path.

The risk is high because this changes core transaction signing behavior that affects multiple user flows. The test file changes confirm the behavioral changes (e.g., isGasFeeSponsored is now passed through rather than cleared, isExternalSign is no longer set client-side).

Performance Test Selection:
The changes are focused on transaction signing logic and controller hooks - not on rendering performance, asset loading, or app launch flows. The refactoring moves decision logic from the UI layer to the controller hooks layer but doesn't introduce new rendering paths or data fetching that would impact measured performance metrics. No performance test tags are warranted.

View GitHub Actions results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-transactions DO-NOT-MERGE Pull requests that should not be merged INVALID-PR-TEMPLATE PR's body doesn't match template size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant