Commit 5b84ef7
chore(runway): cherry-pick fix(perps): geo-restrict modify and close cp-7.63.0 (#25328)
- fix(perps): geo-restrict modify and close cp-7.63.0 (#25314)
## **Description**
Implements geo-restriction for 'close position' and 'modify' actions in
Perps trading to ensure compliance with regional regulations.
**Problem:** Currently, there is no geo-restriction check for the 'close
position' and 'modify' actions. Users in geo-restricted regions can
access these features, which should be blocked for compliance.
**Solution:** Added geo-restriction checks to both `handleClosePosition`
and `handleModifyPress` handlers in `PerpsMarketDetailsView`. When a
geo-restricted user taps either button:
1. The geo-block bottom sheet is displayed
2. The action is blocked (no navigation occurs)
3. Analytics event is tracked with the specific action source for
monitoring
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: #25315
Jira: https://consensyssoftware.atlassian.net/browse/TAT-2449
## **Manual testing steps**
```gherkin
Feature: Geo-restriction for close position and modify actions
Scenario: Geo-restricted user tries to close position
Given user is in a geo-restricted region
And user has an open position in Perps
When user taps the "Close" button on the market details screen
Then the geo-restriction bottom sheet is displayed
And the close position flow is not initiated
Scenario: Geo-restricted user tries to modify position
Given user is in a geo-restricted region
And user has an open position in Perps
When user taps the "Modify" button on the market details screen
Then the geo-restriction bottom sheet is displayed
And the modify action sheet is not opened
Scenario: Eligible user can close position
Given user is NOT in a geo-restricted region
And user has an open position in Perps
When user taps the "Close" button on the market details screen
Then user is navigated to the close position flow
Scenario: Eligible user can modify position
Given user is NOT in a geo-restricted region
And user has an open position in Perps
When user taps the "Modify" button on the market details screen
Then the modify action sheet is opened
```
## **Screenshots/Recordings**
### **Before**
Geo-restricted users could tap Close/Modify buttons and proceed with the
actions.
### **After**
Geo-restricted users see the geo-block bottom sheet when tapping Close
or Modify buttons.
## **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
- [ ] 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.
[4d2533f](4d2533f)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Implements geo-restriction gating for position management on the Perps
market details screen.
>
> - Blocks `close` and `modify` actions when `isEligible` is false:
shows `geo_block` bottom sheet and tracks `PERPS_SCREEN_VIEWED` with
`SCREEN_TYPE` `geo_block_notif` and new sources `close_position_action`
/ `modify_position_action`
> - Updates `handleClosePosition` and `handleModifyPress` to include
eligibility checks and tracking
> - Extends analytics constants with `SOURCE.CLOSE_POSITION_ACTION` and
`SOURCE.MODIFY_POSITION_ACTION`
> - Adds tests verifying geo-block modal appears and navigation/sheets
don’t open for ineligible users on `close` and `modify`
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
59adc5d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com>1 parent ef19971 commit 5b84ef7
3 files changed
Lines changed: 142 additions & 2 deletions
File tree
- app/components/UI/Perps
- Views/PerpsMarketDetailsView
- constants
Lines changed: 111 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1372 | 1372 | | |
1373 | 1373 | | |
1374 | 1374 | | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
1375 | 1486 | | |
1376 | 1487 | | |
1377 | 1488 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
784 | 784 | | |
785 | 785 | | |
786 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
787 | 800 | | |
788 | | - | |
| 801 | + | |
789 | 802 | | |
790 | 803 | | |
791 | 804 | | |
792 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
793 | 819 | | |
794 | | - | |
| 820 | + | |
795 | 821 | | |
796 | 822 | | |
797 | 823 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
| |||
0 commit comments