Skip to content

feat: allow sending to token contract as user acknowledges warning.#27416

Merged
jpuri merged 12 commits into
mainfrom
send_token_contract
Mar 16, 2026
Merged

feat: allow sending to token contract as user acknowledges warning.#27416
jpuri merged 12 commits into
mainfrom
send_token_contract

Conversation

@jpuri

@jpuri jpuri commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Description

Allow user to send to contract address, but add warning for that on both send and confirmation page.

Changelog

CHANGELOG entry:

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/6962

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

Screen.Recording.2026-03-12.at.4.59.07.PM.mov

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 recipient validation and submission gating so some address errors become acknowledgeable, which can affect when transactions are allowed to proceed. Also adds a new confirmation alert source and metrics mapping; incorrect classification could lead to missed warnings or unintended sends.

Overview
Users can now proceed when the recipient is detected as a token/smart-contract address by acknowledging a new SendAlertModal, instead of being hard-blocked at the recipient step.

This introduces an acknowledgeable validation state (toAddressErrorAllowAcknowledge) from useToAddressValidation/validateHexAddress, adds a new confirmation-page warning via useTokenContractAlert (AlertKeys.TokenContractAddress), and wires the new alert key into confirmation alert metrics/name resolution. Tests and i18n strings were updated/added to cover the modal flow and the new alert behavior.

Written by Cursor Bugbot for commit fa22e95. This will update automatically on new commits. 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 Mar 12, 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 March 12, 2026 12:37
@jpuri jpuri requested a review from a team as a code owner March 12, 2026 12:37
@jpuri jpuri enabled auto-merge March 12, 2026 12:39
@github-actions github-actions Bot added size-L and removed size-M labels Mar 12, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.96%. Comparing base (6b4798f) to head (637279d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...onfirmations/hooks/alerts/useTokenContractAlert.ts 55.00% 9 Missing ⚠️
...firmations/components/send/recipient/recipient.tsx 84.21% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27416      +/-   ##
==========================================
- Coverage   81.97%   81.96%   -0.01%     
==========================================
  Files        4699     4701       +2     
  Lines      122881   122920      +39     
  Branches    27126    27133       +7     
==========================================
+ Hits       100737   100757      +20     
- Misses      15167    15186      +19     
  Partials     6977     6977              

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

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 91%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are concentrated in the transaction confirmation send flow, specifically:

  • Recipient component and related tests
  • Send alert modal (UI, types, tests)
  • Confirmation alert hooks (useConfirmationAlerts, useTokenContractAlert)
  • Address validation logic and utilities (useToAddressValidation, send-address-validations)
  • Confirmation alert metrics hook
  • Confirmation alert constants

These files directly impact the transaction confirmation UI and validation logic for send flows (native token, ERC-20, contract interactions). This falls squarely under the SmokeConfirmations scope, which validates transaction sending, signature flows, smart contract interactions, and confirmation UI behavior.

There are no changes to controllers, Engine initialization, network management, trade flows, identity, snaps, or multi-chain session APIs. Therefore, other tags (e.g., SmokeTrade, SmokeNetworkExpansion, SmokeIdentity, SmokeWalletPlatform) are not required.

Given that confirmation logic is a critical user path and shared across many transaction types, this represents medium risk and should be validated via SmokeConfirmations E2E coverage.

Performance Test Selection:
The changes are limited to validation logic, alert hooks, modal components, and related tests. There are no changes to rendering-heavy lists, startup flows, account/network selectors, swaps quote fetching, or other performance-sensitive areas. Therefore, no dedicated performance test suites are required.

View GitHub Actions results

@github-actions github-actions Bot added size-XL and removed size-L labels Mar 12, 2026

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

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@pedronfigueiredo pedronfigueiredo self-requested a review March 12, 2026 17:26
@jpuri jpuri added this pull request to the merge queue Mar 16, 2026
Merged via the queue into main with commit ec5d4d4 Mar 16, 2026
96 of 97 checks passed
@jpuri jpuri deleted the send_token_contract branch March 16, 2026 09:58
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 16, 2026
@metamaskbot metamaskbot added the release-7.71.0 Issue or pull request that will be included in release 7.71.0 label Mar 16, 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.71.0 Issue or pull request that will be included in release 7.71.0 size-XL team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants