Skip to content

Cherry-picking commits from main to release/7.76.3-ota for PR #29933#30022

Merged
chloeYue merged 1 commit into
release/7.76.3-otafrom
runway-cherry-pick-7.76.3-1778575937
May 12, 2026
Merged

Cherry-picking commits from main to release/7.76.3-ota for PR #29933#30022
chloeYue merged 1 commit into
release/7.76.3-otafrom
runway-cherry-pick-7.76.3-1778575937

Conversation

@runway-github

@runway-github runway-github Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Predict order placement support for Polymarket Deposit Wallet
accounts on top of the Deposit Wallet deposit foundation.

This PR:

  • Adds the POLY_1271 Polymarket signature type.
  • Adds Deposit Wallet / ERC-1271 order signing via the TypedDataSign
    wrapper.
  • Routes order maker/signer fields from active Predict account state.
  • Uses Deposit Wallet maker/signer for Deposit Wallet users.
  • Preserves legacy Safe order signing for grandfathered Safe users.
  • Runs Deposit Wallet create/setup preflight before submitting Deposit
    Wallet orders.
  • Passes an optional signed legacy Safe migration sweep as
    allowancesTx for Deposit Wallet orders, so stranded pUSD/USDC.e can be
    swept before the backend relays the order.
  • Skips Safe trade allowance and Permit2 fee preflight for Deposit
    Wallet orders.
  • Continues signing CLOB L2 headers with the EOA owner address.

This PR is temporarily stacked on predict/dw-deposit-foundation while
PRs 1 and 2 are under review, and should be rebased/retargeted after
those merge.

Validation run locally:

yarn jest app/components/UI/Predict/providers/polymarket/protocol/orderCodec.test.ts app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts --runInBand
yarn lint:tsc

Changelog

CHANGELOG entry: Fixed Predict order placement for Polymarket Deposit
Wallet accounts

Related issues

Fixes:
PRED-860

Manual testing steps

Feature: Predict Deposit Wallet order flow

  Scenario: Deposit Wallet user places a Predict order
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet has enough pUSD balance and required setup from the deposit flow
    When the user places a Predict buy or sell order
    Then the order is signed with POLY_1271 semantics
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user places first order before wallet setup
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet still needs creation or allowance setup
    When the user places a Predict buy or sell order
    Then the app creates/sets up the Deposit Wallet before order submission
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user has funds stranded in legacy Safe
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the deterministic legacy Safe has sweepable pUSD or USDC.e
    When the user places a Predict buy or sell order
    Then the signed legacy Safe sweep is included as allowancesTx
      And the backend can submit the sweep before relaying the order

  Scenario: Legacy Safe user places a Predict order
    Given a Predict user is grandfathered to the legacy Safe wallet
    When the user places a Predict buy or sell order
    Then the order continues to use legacy Safe signing and preflight behavior

Screenshots/Recordings

Before

N/A - provider/order-signing change only.

After

N/A - provider/order-signing change only.

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 core Predict order submission/signing paths, adding a new
ERC-1271 signing format and deposit-wallet preflight flows; mistakes
could cause failed or incorrectly-signed orders. Legacy Safe behavior is
preserved but now shares more conditional branching.

Overview
Adds end-to-end order placement support for Polymarket Deposit
Wallet
accounts.

Order submission now derives maker/signer from the resolved account
state and, for deposit-wallet users, performs a create/allowance batch
preflight before signing/submitting. Deposit-wallet orders use the new
SignatureType.POLY_1271 and are signed via signProtocolOrder using
an ERC-7739 TypedDataSign wrapper, while Safe users keep legacy Safe
signing.

Fee collection and Safe trade preflight steps (Permit2 fee
authorization + allowances tx) are skipped for deposit-wallet orders;
instead an optional legacy Safe migration sweep can be attached as
allowancesTx. L2 CLOB headers are consistently signed using the EOA
owner address. Tests were expanded to cover both Safe and deposit-wallet
order flows and the new signing payload.

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

[36fb960](https://github.com/MetaMask/metamask-mobile/commit/36fb960de439c638ea61858c2dbd7ed93c042635)

## **Description**

Adds Predict order placement support for Polymarket Deposit Wallet
accounts on top of the Deposit Wallet deposit foundation.

This PR:
- Adds the `POLY_1271` Polymarket signature type.
- Adds Deposit Wallet / ERC-1271 order signing via the `TypedDataSign`
wrapper.
- Routes order maker/signer fields from active Predict account state.
- Uses Deposit Wallet maker/signer for Deposit Wallet users.
- Preserves legacy Safe order signing for grandfathered Safe users.
- Runs Deposit Wallet create/setup preflight before submitting Deposit
Wallet orders.
- Passes an optional signed legacy Safe migration sweep as
`allowancesTx` for Deposit Wallet orders, so stranded pUSD/USDC.e can be
swept before the backend relays the order.
- Skips Safe trade allowance and Permit2 fee preflight for Deposit
Wallet orders.
- Continues signing CLOB L2 headers with the EOA owner address.

This PR is temporarily stacked on `predict/dw-deposit-foundation` while
PRs 1 and 2 are under review, and should be rebased/retargeted after
those merge.

Validation run locally:

```bash
yarn jest app/components/UI/Predict/providers/polymarket/protocol/orderCodec.test.ts app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts --runInBand
yarn lint:tsc
```

## **Changelog**

CHANGELOG entry: Fixed Predict order placement for Polymarket Deposit
Wallet accounts

## **Related issues**

Fixes:
[PRED-860](https://consensyssoftware.atlassian.net/browse/PRED-860)

## **Manual testing steps**

```gherkin
Feature: Predict Deposit Wallet order flow

  Scenario: Deposit Wallet user places a Predict order
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet has enough pUSD balance and required setup from the deposit flow
    When the user places a Predict buy or sell order
    Then the order is signed with POLY_1271 semantics
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user places first order before wallet setup
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet still needs creation or allowance setup
    When the user places a Predict buy or sell order
    Then the app creates/sets up the Deposit Wallet before order submission
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user has funds stranded in legacy Safe
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the deterministic legacy Safe has sweepable pUSD or USDC.e
    When the user places a Predict buy or sell order
    Then the signed legacy Safe sweep is included as allowancesTx
      And the backend can submit the sweep before relaying the order

  Scenario: Legacy Safe user places a Predict order
    Given a Predict user is grandfathered to the legacy Safe wallet
    When the user places a Predict buy or sell order
    Then the order continues to use legacy Safe signing and preflight behavior
```

## **Screenshots/Recordings**

### **Before**

N/A - provider/order-signing change only.

### **After**

N/A - provider/order-signing change only.

## **Pre-merge author checklist**

- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.


[PRED-860]:
https://consensyssoftware.atlassian.net/browse/PRED-860?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes core Predict order submission/signing paths, adding a new
ERC-1271 signing format and deposit-wallet preflight flows; mistakes
could cause failed or incorrectly-signed orders. Legacy Safe behavior is
preserved but now shares more conditional branching.
> 
> **Overview**
> Adds end-to-end order placement support for Polymarket **Deposit
Wallet** accounts.
> 
> Order submission now derives maker/signer from the resolved account
state and, for deposit-wallet users, performs a create/allowance batch
preflight before signing/submitting. Deposit-wallet orders use the new
`SignatureType.POLY_1271` and are signed via `signProtocolOrder` using
an ERC-7739 `TypedDataSign` wrapper, while Safe users keep legacy Safe
signing.
> 
> Fee collection and Safe trade preflight steps (Permit2 fee
authorization + allowances tx) are skipped for deposit-wallet orders;
instead an optional legacy Safe migration sweep can be attached as
`allowancesTx`. L2 CLOB headers are consistently signed using the EOA
owner address. Tests were expanded to cover both Safe and deposit-wallet
order flows and the new signing payload.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b2bf1ee. 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 May 12, 2026 08:52
@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-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label May 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

All E2E tests pre-selected.

View GitHub Actions results

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

@sonarqubecloud

Copy link
Copy Markdown

@chloeYue chloeYue merged commit ca0e791 into release/7.76.3-ota May 12, 2026
118 checks passed
@chloeYue chloeYue deleted the runway-cherry-pick-7.76.3-1778575937 branch May 12, 2026 10:03
@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants