Skip to content

chore(runway): cherry-pick fix(perps): geo-restrictions on ui#25392

Merged
joaoloureirop merged 1 commit intorelease/7.63.0from
cherry-pick-7-63-0-d87e9ea
Jan 29, 2026
Merged

chore(runway): cherry-pick fix(perps): geo-restrictions on ui#25392
joaoloureirop merged 1 commit intorelease/7.63.0from
cherry-pick-7-63-0-d87e9ea

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Jan 29, 2026

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

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

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

Written by Cursor Bugbot for commit 1698d05. This will update automatically on new commits. Configure here.

d87e9ea

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 entry: Fixed geo-restriction enforcement for perpetuals
trading flows including order book actions, position management,
stop-loss prompts, and close all positions

Fixes: #25374

```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)
```

Users in geo-blocked regions could access trading flows without
restriction

Geo-restriction modal appears for all trading flows when user is not
eligible

- [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.

- [ ] 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**
> Medium risk because it changes eligibility gating on core
trading/position-management actions and adds new analytics sources,
which could block legitimate users if eligibility state is wrong.
>
> **Overview**
> Adds geo-restriction checks (with `PERPS_SCREEN_VIEWED` tracking) to
additional Perps entry points so ineligible users are shown the
`geo_block` tooltip instead of proceeding.
>
> This gates actions in `PerpsOrderBookView` (Long/Short/Close/Modify),
`PerpsMarketDetailsView` (Auto-close/Adjust margin/Stop-loss prompt
actions), and bulk Close All from `PerpsTabView` and `PerpsHomeView`
(with a dedicated close-all geo-block modal state). Updates
`eventNames.ts` with new `SOURCE` values for these block points and
expands/adjusts tests and mocks to cover the new geo-block behaviors.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3aa982a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested a review from a team as a code owner January 29, 2026 15:58
@github-actions
Copy link
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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Jan 29, 2026
@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - base branch is not main (base: release/7.63.0)

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
77.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@joaoloureirop joaoloureirop added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jan 29, 2026
@joaoloureirop joaoloureirop enabled auto-merge (squash) January 29, 2026 18:53
@joaoloureirop joaoloureirop merged commit e36d829 into release/7.63.0 Jan 29, 2026
254 of 260 checks passed
@joaoloureirop joaoloureirop deleted the cherry-pick-7-63-0-d87e9ea branch January 29, 2026 18:53
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 30, 2026
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.63.0 on PR, as PR was cherry-picked in branch 7.63.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-L skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants