Skip to content

fix: Predict withdraw beforeSign handling#29968

Merged
pedronfigueiredo merged 1 commit into
mainfrom
pnf/predict-withdraw-across-mobile
May 15, 2026
Merged

fix: Predict withdraw beforeSign handling#29968
pedronfigueiredo merged 1 commit into
mainfrom
pnf/predict-withdraw-across-mobile

Conversation

@pedronfigueiredo

@pedronfigueiredo pedronfigueiredo commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Guards Predict withdraw beforeSign so it only signs the active withdraw transaction.
  • Skips signing when the withdraw calldata is already Safe execution calldata produced by the MetaMask Pay follow-up flow.
  • Reuses the active withdraw state consistently when updating transaction params.
  • Adds unit coverage for stale transaction IDs and already-signed Safe calldata.

Changelog

CHANGELOG entry: Fixed Predict withdraw signing when withdraw transaction calldata is already prepared.


Note

Medium Risk
Touches transaction pre-signing for Predict withdrawals, which can affect what data gets signed and where it is sent. Changes are well-scoped with added unit coverage, but mistakes could block withdrawals or sign incorrect transactions.

Overview
Predict withdraw beforeSign now only runs signWithdraw for the currently active withdraw transaction (by transactionId) and reuses that active state when setting to/updating tx params.

It also skips signing when the nested withdraw calldata is not an ERC-20 transfer selector (e.g., already-prepared Safe execution calldata from MetaMask Pay), and adds unit tests covering stale transaction IDs, pre-signed calldata pass-through, and updated call-data expectations.

Reviewed by Cursor Bugbot for commit 5681381. 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 11, 2026
@pedronfigueiredo pedronfigueiredo self-assigned this May 11, 2026
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo requested a review from a team as a code owner May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo changed the title Fix Predict withdraw beforeSign handling fix: Predict withdraw beforeSign handling May 12, 2026
@metamaskbotv2 metamaskbotv2 Bot added the INVALID-PR-TEMPLATE PR's body doesn't match template label May 12, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-mobile branch from 9c03228 to 64c10b4 Compare May 12, 2026 10:29
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-mobile branch from 64c10b4 to 5681381 Compare May 14, 2026 09:22
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are isolated to PredictController.ts's beforeSign method, which handles the withdraw/cash-out transaction signing flow for Polymarket predictions. Two new guards were added:

  1. A transaction ID check to prevent MetaMask Pay follow-up transactions from being incorrectly intercepted
  2. An ERC20 transfer function selector check (0xa9059cbb) to skip already-signed Safe calldata

This directly impacts the Predictions withdraw/cash-out flow, which is covered by SmokePredictions. Per the tag dependency rules:

  • SmokePredictions → also select SmokeWalletPlatform (Predictions is a section inside Trending tab) and SmokeConfirmations (opening/closing positions are on-chain transactions)

No other areas are affected - the changes are purely within the PredictController's beforeSign logic with no UI, navigation, or other controller changes.

Performance Test Selection:
The changes are a targeted bug fix in PredictController's beforeSign method adding two guard conditions. These are simple conditional checks that add negligible overhead and do not affect rendering, data loading, list performance, or any performance-sensitive paths. No performance tests are warranted.

View GitHub Actions results

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.79%. Comparing base (3751d9a) to head (5681381).
⚠️ Report is 170 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29968      +/-   ##
==========================================
+ Coverage   81.54%   81.79%   +0.25%     
==========================================
  Files        5343     5393      +50     
  Lines      142128   143855    +1727     
  Branches    32411    32852     +441     
==========================================
+ Hits       115899   117669    +1770     
+ Misses      18299    18162     -137     
- Partials     7930     8024      +94     

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

@sonarqubecloud

Copy link
Copy Markdown

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

LGTM

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 0b1fa04 May 15, 2026
180 of 181 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/predict-withdraw-across-mobile branch May 15, 2026 13:45
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 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 release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants