[pull] main from MetaMask:main#584
Merged
Merged
Conversation
…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 -->
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.
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 : )