Commit e36d829
chore(runway): cherry-pick fix(perps): geo-restrictions on ui (#25392)
- fix(perps): geo-restrictions on ui cp-7.63.0 (#25379)
## **Description**
This PR fixes the missing geo-restriction checks in several perpetuals
trading flows as reported in #25374.
**PerpsOrderBookView.tsx:**
- Added geo-restriction check to `handleLongPress` - shows geo-block
modal instead of navigating to long order
- Added geo-restriction check to `handleShortPress` - shows geo-block
modal instead of navigating to short order
- Added geo-restriction check to `handleClosePosition` - shows geo-block
modal instead of navigating to close position
- Added geo-restriction check to `handleModifyPress` - shows geo-block
modal instead of opening modify sheet
**PerpsMarketDetailsView.tsx:**
- Added geo-restriction check to `handleAutoClosePress` - shows
geo-block modal instead of navigating to TP/SL screen
- Added geo-restriction check to `handleMarginPress` - shows geo-block
modal instead of opening adjust margin sheet
- Added geo-restriction check to `handleAddMarginFromBanner` - shows
geo-block modal instead of navigating to add margin
- Added geo-restriction check to `handleSetStopLossFromBanner` - shows
geo-block modal instead of setting stop loss
**PerpsTabView.tsx:**
- Added geo-restriction check to `handleCloseAllPress` - shows geo-block
modal instead of navigating to close all positions modal
**PerpsHomeView.tsx:**
- Added geo-restriction check to `handleCloseAllPress` - shows geo-block
modal instead of opening close all positions sheet
**eventNames.ts:**
- Added new analytics source values for tracking geo-block notifications
from each flow
**Note:** Cancel all orders is intentionally NOT geo-blocked - users
should be able to cancel their existing orders similar to withdrawals.
## **Changelog**
CHANGELOG entry: Fixed geo-restriction enforcement for perpetuals
trading flows including order book actions, position management,
stop-loss prompts, and close all positions
## **Related issues**
Fixes: #25374
## **Manual testing steps**
```gherkin
Feature: Geo-restriction on perps trading flows
Scenario: User in geo-blocked region cannot trade via order book
Given user is in a geo-blocked region (e.g., US)
And user has navigated to the perps order book screen
When user taps on Long button
Then geo-restriction modal should appear
And user should not navigate to long order screen
When user taps on Short button
Then geo-restriction modal should appear
And user should not navigate to short order screen
When user taps on Close button (with existing position)
Then geo-restriction modal should appear
And user should not navigate to close position screen
When user taps on Modify button (with existing position)
Then geo-restriction modal should appear
And modify sheet should not open
Scenario: User in geo-blocked region cannot manage positions
Given user is in a geo-blocked region (e.g., US)
And user has an existing perpetuals position
When user taps on Auto-close button on position card
Then geo-restriction modal should appear
And user should not navigate to TP/SL screen
When user taps on Margin button on position card
Then geo-restriction modal should appear
And adjust margin sheet should not open
Scenario: User in geo-blocked region cannot use stop-loss prompt actions
Given user is in a geo-blocked region (e.g., US)
And user has an existing position with stop-loss prompt visible
When user taps on Add Margin from stop-loss prompt banner
Then geo-restriction modal should appear
And user should not navigate to add margin screen
When user taps on Set Stop Loss from stop-loss prompt banner
Then geo-restriction modal should appear
And stop loss should not be set
Scenario: User in geo-blocked region cannot close all positions
Given user is in a geo-blocked region (e.g., US)
And user has existing perpetuals positions
When user taps on Close All button in perps tab
Then geo-restriction modal should appear
And close all positions modal should not open
When user taps on Close All button in perps home
Then geo-restriction modal should appear
And close all positions sheet should not open
Scenario: User in geo-blocked region CAN cancel all orders
Given user is in a geo-blocked region (e.g., US)
And user has existing perpetuals orders
When user taps on Cancel All button
Then cancel all orders modal should open (NOT geo-blocked)
```
## **Screenshots/Recordings**
### **Before**
Users in geo-blocked regions could access trading flows without
restriction
### **After**
Geo-restriction modal appears for all trading flows when user is not
eligible
## **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**
> Adds eligibility gating to multiple trading and position-management UI
actions; mistakes could wrongly block eligible users or allow restricted
actions through. Changes are localized to UI handlers and analytics but
touch critical perps flows.
>
> **Overview**
> **Enforces geo-restrictions across key Perps UI actions.** Order book
Long/Short/Close/Modify, market details auto-close (TP/SL), adjust
margin, stop-loss prompt actions, and bulk close-all entry points now
check `selectPerpsEligibility` and show the geo-block tooltip instead of
navigating/opening sheets.
>
> **Adds analytics attribution for blocked actions.** New
`PerpsEventValues.SOURCE` constants are introduced to distinguish which
UI trigger surfaced the geo-block notification.
>
> **Updates tests to cover new gating behavior.** Mocks are extended and
new cases added to assert geo-block modal display and that
navigation/sheets are not triggered when ineligible.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1698d05. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
[d87e9ea](d87e9ea)
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>1 parent 87d2dae commit e36d829
8 files changed
Lines changed: 671 additions & 13 deletions
File tree
- app/components/UI/Perps
- Views
- PerpsHomeView
- PerpsMarketDetailsView
- PerpsOrderBookView
- PerpsTabView
- constants
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
340 | 346 | | |
341 | 347 | | |
342 | 348 | | |
343 | | - | |
| 349 | + | |
344 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
345 | 362 | | |
346 | | - | |
| 363 | + | |
347 | 364 | | |
348 | 365 | | |
349 | 366 | | |
| |||
576 | 593 | | |
577 | 594 | | |
578 | 595 | | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
579 | 610 | | |
580 | 611 | | |
581 | 612 | | |
| |||
0 commit comments