Skip to content

chore(runway): cherry-pick fix: cp-7.80.0 prevent send flow from submitting to zero address after clearing pasted recipient#30844

Merged
tommasini merged 2 commits into
release/7.80.0from
runway-cherry-pick-7.80.0-1780309394
Jun 1, 2026
Merged

chore(runway): cherry-pick fix: cp-7.80.0 prevent send flow from submitting to zero address after clearing pasted recipient#30844
tommasini merged 2 commits into
release/7.80.0from
runway-cherry-pick-7.80.0-1780309394

Conversation

@runway-github

@runway-github runway-github Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Description

When a user pastes an address in the send flow, an auto-review
useEffect is triggered to streamline the UX. If the "New address"
alert modal appears and the user cancels it, then presses the "Clear"
button, the pastedRecipient state was not being cleared. This caused a
race condition: handleClearInput would set to to empty, which caused
hasUnacknowledgedAlerts to become false (no alerts for empty
addresses), while pastedRecipient and toAddressValidated still held
the old address. The auto-review useEffect would then see all
conditions pass and fire handleSubmitPress with an empty to value,
which got cast to 0x0000...0000.

Fix:

  1. Clear pastedRecipient in handleClearInput so the auto-review
    effect cannot re-trigger with stale state after clearing.
  2. Add a defense-in-depth guard in proceedWithSubmit to reject empty
    recipient addresses.

Changelog

CHANGELOG entry: Fixed a bug where clearing a pasted recipient address
in the send flow could trigger a transaction to the zero address

Related issues

Fixes:

Manual testing steps

Feature: Send flow clear button

  Scenario: user clears pasted address after cancelling new address alert
    Given the user is on the send recipient screen

    When user pastes a valid address using the Paste button
    And user presses the Review button
    And the "New address" alert modal appears
    And user presses Cancel on the alert modal
    And user presses the Clear button
    Then the input field is cleared
    And no transaction is submitted
    And the user remains on the recipient screen

  Scenario: user clears pasted address without triggering review first
    Given the user is on the send recipient screen

    When user pastes a valid address using the Paste button
    And user presses the Clear button before auto-review triggers
    Then the input field is cleared
    And no transaction is submitted

Screenshots/Recordings

Before

Pressing Clear after cancelling the "New address" alert triggers a
transaction submission to 0x0000...0000.

After

Pressing Clear correctly resets the input without triggering any
transaction submission.

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
  • See trace() for usage and
    addToken
    for an example

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
Changes send submission guards and recipient state on a user-facing
money path; scope is small and covered by tests, but incorrect gating
could block valid sends or miss edge cases.

Overview
Fixes a send-flow bug where Clear after canceling the "New
address" alert could still auto-advance review because
pastedRecipient stayed set while to was emptied.

RecipientInput now resets pastedRecipient in
handleClearInput (along with updateTo('')) so the paste
auto-review useEffect cannot re-fire on stale paste state.
Recipient proceedWithSubmit also bails out when there is no
resolvedAddress or to, blocking submission with an empty
recipient (e.g. zero address). Tests cover clear + empty-recipient
paths.

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

[13349a0](https://github.com/MetaMask/metamask-mobile/commit/13349a0c8c223a6d4c28b3f0f222d978f5a7dd9a)

…itting to zero address after clearing pasted recipient (#30771)

## **Description**

When a user pastes an address in the send flow, an auto-review
`useEffect` is triggered to streamline the UX. If the "New address"
alert modal appears and the user cancels it, then presses the "Clear"
button, the `pastedRecipient` state was not being cleared. This caused a
race condition: `handleClearInput` would set `to` to empty, which caused
`hasUnacknowledgedAlerts` to become `false` (no alerts for empty
addresses), while `pastedRecipient` and `toAddressValidated` still held
the old address. The auto-review `useEffect` would then see all
conditions pass and fire `handleSubmitPress` with an empty `to` value,
which got cast to `0x0000...0000`.

**Fix:**
1. Clear `pastedRecipient` in `handleClearInput` so the auto-review
effect cannot re-trigger with stale state after clearing.
2. Add a defense-in-depth guard in `proceedWithSubmit` to reject empty
recipient addresses.

## **Changelog**

CHANGELOG entry: Fixed a bug where clearing a pasted recipient address
in the send flow could trigger a transaction to the zero address

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: Send flow clear button

  Scenario: user clears pasted address after cancelling new address alert
    Given the user is on the send recipient screen

    When user pastes a valid address using the Paste button
    And user presses the Review button
    And the "New address" alert modal appears
    And user presses Cancel on the alert modal
    And user presses the Clear button
    Then the input field is cleared
    And no transaction is submitted
    And the user remains on the recipient screen

  Scenario: user clears pasted address without triggering review first
    Given the user is on the send recipient screen

    When user pastes a valid address using the Paste button
    And user presses the Clear button before auto-review triggers
    Then the input field is cleared
    And no transaction is submitted
```

## **Screenshots/Recordings**

### **Before**

Pressing Clear after cancelling the "New address" alert triggers a
transaction submission to `0x0000...0000`.

### **After**

Pressing Clear correctly resets the input without triggering any
transaction submission.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

#### 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](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example

For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes send submission guards and recipient state on a user-facing
money path; scope is small and covered by tests, but incorrect gating
could block valid sends or miss edge cases.
> 
> **Overview**
> Fixes a send-flow bug where **Clear** after canceling the "New
address" alert could still auto-advance review because
**`pastedRecipient`** stayed set while **`to`** was emptied.
> 
> **`RecipientInput`** now resets **`pastedRecipient`** in
**`handleClearInput`** (along with **`updateTo('')`**) so the paste
auto-review **`useEffect`** cannot re-fire on stale paste state.
**`Recipient`** **`proceedWithSubmit`** also bails out when there is no
**`resolvedAddress`** or **`to`**, blocking submission with an empty
recipient (e.g. zero address). Tests cover clear + empty-recipient
paths.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
636fbc9. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested a review from a team as a code owner June 1, 2026 10:23
@metamaskbotv2 metamaskbotv2 Bot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Jun 1, 2026
@github-actions github-actions Bot added the size-S label Jun 1, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/7.80.0@b077de5). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...firmations/components/send/recipient/recipient.tsx 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             release/7.80.0   #30844   +/-   ##
=================================================
  Coverage                  ?   82.69%           
=================================================
  Files                     ?     5540           
  Lines                     ?   141879           
  Branches                  ?    32713           
=================================================
  Hits                      ?   117329           
  Misses                    ?    16723           
  Partials                  ?     7827           

☔ 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

github-actions Bot commented Jun 1, 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 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - PR targets a release or stable branch (release/* or stable)

All E2E tests pre-selected.

View GitHub Actions results

@tommasini tommasini merged commit f7dccc9 into release/7.80.0 Jun 1, 2026
199 of 203 checks passed
@tommasini tommasini deleted the runway-cherry-pick-7.80.0-1780309394 branch June 1, 2026 16:12
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-S team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants