Skip to content

[pull] main from MetaMask:main#584

Merged
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main
Mar 7, 2026
Merged

[pull] main from MetaMask:main#584
pull[bot] merged 2 commits into
Reality2byte:mainfrom
MetaMask:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Mar 7, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

Matt561 and others added 2 commits March 6, 2026 23:43
…ve confirmations (#27155)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
The `useMusdConversionStaleApprovalCleanup` hook was rejecting pending
mUSD approvals whenever the app returned from background — including
when the user simply tapped an in-app "terms apply" link that opened the
browser. This caused the confirmation screen to enter a stuck loading
state.

This PR adds a screen-aware guard with deeplink detection so the hook
can distinguish between:

- Returning from an in-app link (browser round-trip) → preserves the
approval
- Incoming deeplink that navigates the user away → rejects the approval
- Not on a confirmation screen → rejects immediately (existing behavior)

Detection uses React Native's Linking url event listener, which fires
for incoming deeplinks but not for returns from `Linking.openURL()`.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: fixed mUSD conversion confirmation no longer gets stuck
when tapping external links that briefly background the app.

## **Related issues**

Fixes: [MUSD-456: Opening "terms apply" link on Max and Custom convert
rejects the transaction and navigates
back](https://consensyssoftware.atlassian.net/browse/MUSD-456)

## **Manual testing steps**

```gherkin
Feature: mUSD conversion stale approval cleanup

  Scenario: user taps external link on confirmation screen and returns
    Given user is on the mUSD conversion confirmation screen with a pending approval

    When user taps the "terms apply" link and returns from the browser
    Then the pending approval is preserved and the confirmation screen remains functional

  Scenario: user returns to app via deeplink while on confirmation screen
    Given user is on the mUSD conversion confirmation screen with a pending approval

    When the app is reopened via an incoming deeplink
    Then the stale pending approval is rejected and the user is not stuck in a disabled state

  Scenario: user returns from background when not on confirmation screen
    Given user has a pending mUSD conversion approval and is not on a confirmation screen

    When the app returns from background
    Then the stale pending approval is rejected immediately
```

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

https://github.com/user-attachments/assets/3898d1c2-54d4-420d-ae11-9ebc47a80ef6

### **After**

<!-- [screenshots/recordings] -->

https://github.com/user-attachments/assets/7197fac6-ef08-4089-b02b-7316fe922992

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

## **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 the conditions under which pending mUSD approvals are
auto-rejected and adds deeplink detection based on `Linking` events,
which could affect approval lifecycle/navigation if misclassified. Scope
is limited and covered by expanded unit tests.
> 
> **Overview**
> Prevents `useMusdConversionStaleApprovalCleanup` from auto-rejecting
pending mUSD approvals when the user is *actively in the confirmation
flow* (e.g. `REDESIGNED_CONFIRMATIONS` / `TOOLTIP_MODAL`) and the app
returns from background without an incoming deeplink.
> 
> Adds `Linking` `url` event tracking to distinguish true deeplink
resumes (reject approvals and optionally `goBack` from the orphaned
confirmation screen) from browser round-trips, refactors rejection into
a helper, and significantly expands tests to cover listener lifecycle,
screen-aware guarding, deeplink flag reset behavior, and post-rejection
navigation.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
032186e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
…nd cp-7.69.0 (#27162)

## **Description**

Reverts #26954.

Polymarket has resolved the underlying CLOB infrastructure issue that
was causing intermittent `not enough balance / allowance` 400 errors
during order placement. The temporary `refreshBalanceAllowance()`
workaround (calling `GET /balance-allowance/update` before each order)
is no longer needed and is removed here.

### Changes:
- **`utils.ts`**: Remove `refreshBalanceAllowance()` utility and related
HMAC auth logic
- **`PolymarketProvider.ts`**: Remove the preflight refresh call from
`placeOrder()`
- **`utils.test.ts`**: Remove associated unit tests
- **`PolymarketProvider.test.ts`**: Remove associated integration tests

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
Feature: Polymarket order placement without refresh workaround

  Scenario: user places a BUY order on a prediction market
    Given the user has USDC deposited in their Polymarket proxy wallet

    When user places a BUY order on any market
    Then the order completes successfully without a preflight refresh call

  Scenario: user places a SELL order on a prediction market
    Given the user holds outcome tokens for a market

    When user places a SELL order
    Then the order completes successfully without a preflight refresh call
```

## **Screenshots/Recordings**

N/A — no UI changes

### **Before**

<!-- N/A -->

### **After**

<!-- N/A -->

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

## **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 Polymarket order submission behavior by removing a preflight
balance/allowance refresh; if the upstream CLOB issue is not fully
resolved, this could reintroduce intermittent order failures under load.
> 
> **Overview**
> Removes the temporary Polymarket CLOB *balance/allowance refresh*
workaround by deleting `refreshBalanceAllowance` from `utils.ts` and
dropping the pre-submit call in `PolymarketProvider.placeOrder()`.
> 
> Cleans up the associated unit/integration coverage by removing mocks
and test cases that asserted the refresh call ordering and failure
handling.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
db50f7d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pull pull Bot locked and limited conversation to collaborators Mar 7, 2026
@pull pull Bot added the ⤵️ pull label Mar 7, 2026
@pull pull Bot merged commit 8099e72 into Reality2byte:main Mar 7, 2026
0 of 9 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants