chore(runway): cherry-pick fix: cp-7.80.0 prevent send flow from submitting to zero address after clearing pasted recipient#30844
Merged
Conversation
…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 -->
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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. |
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release or stable branch (release/* or stable) All E2E tests pre-selected. |
vpintorico
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a user pastes an address in the send flow, an auto-review
useEffectis triggered to streamline the UX. If the "New address"alert modal appears and the user cancels it, then presses the "Clear"
button, the
pastedRecipientstate was not being cleared. This caused arace condition:
handleClearInputwould settoto empty, which causedhasUnacknowledgedAlertsto becomefalse(no alerts for emptyaddresses), while
pastedRecipientandtoAddressValidatedstill heldthe old address. The auto-review
useEffectwould then see allconditions pass and fire
handleSubmitPresswith an emptytovalue,which got cast to
0x0000...0000.Fix:
pastedRecipientinhandleClearInputso the auto-revieweffect cannot re-trigger with stale state after clearing.
proceedWithSubmitto reject emptyrecipient 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
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
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
SRPs
to import wallets with many accounts and tokens
performance metrics
trace()for usage andaddTokenfor an example
For performance guidelines and tooling, see the Performance
Guide.
Pre-merge reviewer checklist
app, test code being changed).
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
pastedRecipientstayed set whiletowas emptied.RecipientInputnow resetspastedRecipientinhandleClearInput(along withupdateTo('')) so the pasteauto-review
useEffectcannot re-fire on stale paste state.RecipientproceedWithSubmitalso bails out when there is noresolvedAddressorto, blocking submission with an emptyrecipient (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.