Skip to content

fix: Perps withdraw back-swipe toast cp-7.78.0#30504

Merged
pedronfigueiredo merged 1 commit into
mainfrom
pnf/back-perps-withdraw
May 21, 2026
Merged

fix: Perps withdraw back-swipe toast cp-7.78.0#30504
pedronfigueiredo merged 1 commit into
mainfrom
pnf/back-perps-withdraw

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the Perps withdraw confirmation flow so user-initiated confirmation rejection, including iOS back-swipe, does not show the retryable "withdrawal wasn't started" error toast.

Root Cause

PR #30299 added an addTransactionBatch catch path that navigates back and shows the withdrawal-start failure toast for every rejected batch initialization. Back-swiping the confirmation rejects the approval with a user-rejected error, so that normal cancellation path was being treated as a real initialization failure.

Changes

  • Detect user-rejected errors before showing the withdrawal-start failure toast.
  • Keep the existing retry toast behavior for real addTransactionBatch failures.
  • Add regression coverage for user rejection so it does not call goBack, build the retry toast, or show the toast.

Fixes #30485.


Note

Low Risk
Low risk: scoped to Perps withdraw error handling and adds a regression test; behavior only changes for user-rejected/cancel paths.

Overview
Prevents Perps withdraw confirmation cancellations (user-rejected errors) from being treated as addTransactionBatch failures: on rejection, the hook now rethrows without calling navigation.goBack() or showing the retryable “withdrawalStartFailed” toast.

Adds a regression test covering a providerErrors.userRejectedRequest() rejection to ensure no back navigation or toast is triggered, while keeping the existing retry-toast behavior for real batch initialization failures.

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

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

@metamaskbotv2 metamaskbotv2 Bot added the team-confirmations Push issues to confirmations team label May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are isolated to the Perps withdrawal confirmation hook (usePerpsWithdrawConfirmation.ts) and its test file. The modification adds user rejection error detection: when a user rejects a withdrawal transaction confirmation, the hook now re-throws the error instead of showing a "withdrawal start failed" toast and navigating back. This is a targeted UX fix for the Perps withdrawal flow.

Impact:

  1. SmokePerps: Directly affected - the Perps withdrawal confirmation flow behavior changed. User rejection now propagates the error rather than showing a failure toast.
  2. SmokeWalletPlatform: Required by SmokePerps tag description - Perps is a section inside Trending tab.
  3. SmokeConfirmations: Required by SmokePerps tag description - withdrawal flows involve on-chain transaction confirmations.

No other areas are affected. The containsUserRejectedError utility is already used elsewhere (spam.ts) and is not being modified. The change is low-risk but warrants running Perps-related tests to validate the user rejection flow works correctly.

Performance Test Selection:
The changes are purely error handling logic in the Perps withdrawal hook - adding user rejection detection. There are no UI rendering changes, no data loading changes, no state management changes, and no component structure changes that would impact performance metrics.

View GitHub Actions results

@pedronfigueiredo pedronfigueiredo changed the title [codex] Fix Perps withdraw back-swipe toast fix: Perps withdraw back-swipe toast May 21, 2026
@pedronfigueiredo pedronfigueiredo added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label May 21, 2026
@metamaskbotv2 metamaskbotv2 Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label May 21, 2026
@sonarqubecloud

Copy link
Copy Markdown

@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review May 21, 2026 10:48
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner May 21, 2026 10:48
@pedronfigueiredo pedronfigueiredo changed the title fix: Perps withdraw back-swipe toast fix: Perps withdraw back-swipe toast cp-7.78.0 May 21, 2026
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue May 21, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.13%. Comparing base (66f0cb2) to head (c23f2c3).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...nts/UI/Perps/hooks/usePerpsWithdrawConfirmation.ts 76.92% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30504      +/-   ##
==========================================
- Coverage   82.13%   82.13%   -0.01%     
==========================================
  Files        5488     5488              
  Lines      147743   147756      +13     
  Branches    33969    33975       +6     
==========================================
+ Hits       121353   121363      +10     
+ Misses      18084    18083       -1     
- Partials     8306     8310       +4     

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

Merged via the queue into main with commit b76275a May 21, 2026
284 of 304 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/back-perps-withdraw branch May 21, 2026 11:14
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Navigating back from Perps withdraw results in error toast

3 participants