Skip to content

chore(runway): cherry-pick fix(perps): enforce geo-block and compliance gate on Market Insights Long/Short actions#28688

Merged
joaoloureirop merged 5 commits intorelease/7.72.1from
cherry-pick-7-72-1-90f34c6
Apr 10, 2026
Merged

chore(runway): cherry-pick fix(perps): enforce geo-block and compliance gate on Market Insights Long/Short actions#28688
joaoloureirop merged 5 commits intorelease/7.72.1from
cherry-pick-7-72-1-90f34c6

Conversation

@runway-github
Copy link
Copy Markdown
Contributor

@runway-github runway-github bot commented Apr 10, 2026

Description

The MarketInsightsView (AI summaries page) Long/Short buttons
navigated directly to PerpsOrderRedirect without checking
geo-eligibility or running the compliance gate. This allowed users in
restricted regions to bypass restrictions and open perps positions from
the Market Insights entry point, even though every other entry point
(Market Details, Order Book, Token Details) correctly blocked them.

Changes:

  • Wrapped handlePerpsDirectionPress in the compliance gate() and
    added the isEligible geo-check before navigation, matching the pattern
    in PerpsMarketDetailsView and AssetOverviewContent
  • Renders the PerpsBottomSheetTooltip geo-block modal ("Perps
    unavailable in your region") when the user is ineligible
  • Added MARKET_INSIGHTS to PERPS_EVENT_VALUE.SOURCE for proper
    geo-block analytics attribution
  • Updated existing tests and added a new test case for the ineligible
    scenario

Changelog

CHANGELOG entry: Fixed a bug where users in restricted regions could
open perps positions from the Market Insights page

Related issues

Fixes:

Manual testing steps

Feature: Perps geo-block enforcement on Market Insights

  Scenario: Restricted user taps Long on Market Insights
    Given the user is in a geo-restricted region
    And the user navigates to Market Insights for a perps asset (e.g. ETH)

    When the user taps the "Long" button
    Then the "Perps unavailable in your region" modal is shown
    And the user is NOT navigated to the order screen

  Scenario: Restricted user taps Short on Market Insights
    Given the user is in a geo-restricted region
    And the user navigates to Market Insights for a perps asset

    When the user taps the "Short" button
    Then the "Perps unavailable in your region" modal is shown
    And the user is NOT navigated to the order screen

  Scenario: Eligible user taps Long on Market Insights
    Given the user is NOT in a geo-restricted region
    And the user navigates to Market Insights for a perps asset

    When the user taps the "Long" button
    Then the user is navigated to the order screen as expected

Screenshots/Recordings

N/A — behavior matches existing geo-block modal shown on other Perps
entry points.

Before

Tapping Long/Short on Market Insights in a restricted region navigated
to the order screen (bypassing restrictions).

After

Simulator Screenshot - iPhone 17
Pro Max - 2026-04-10 at 17 46 41

Tapping Long/Short on Market Insights in a restricted region shows the
geo-block modal and blocks navigation.

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
Touches Perps eligibility/compliance gating and navigation from
MarketInsightsView, so mistakes could reintroduce a restriction bypass
or block eligible users; changes are localized and covered by updated
tests.

Overview
Prevents the Market Insights Perps Long/Short CTAs from navigating
directly to order flow without restrictions by wrapping the action in
the compliance gate() and checking selectPerpsEligibility first.

When ineligible, it now tracks a geo-block screen view with source
PERPS_EVENT_VALUE.SOURCE.MARKET_INSIGHTS and shows the
PerpsBottomSheetTooltip in a modal instead of navigating. Tests were
updated to handle async gated presses and a new test asserts the
ineligible geo-block behavior; the Perps view test renderer also ensures
extra routes get the same Perps providers.

Reviewed by Cursor Bugbot for commit
8ed8908. Bugbot is set up for automated
code reviews on this repo. Configure
here.


Co-authored-by: Javier Garcia Vera javier.vera@consensys.net
Co-authored-by: javiergarciavera 76975121+javiergarciavera@users.noreply.github.com
Co-authored-by: Alejandro Garcia alejandro.garcia@consensys.net
Co-authored-by: Nicholas Gambino nicholas.gambino@consensys.net 90f34c6

michalconsensys and others added 2 commits April 10, 2026 20:42
…Long/Short actions cp-7.72.1 (#28678)

The `MarketInsightsView` (AI summaries page) Long/Short buttons
navigated directly to `PerpsOrderRedirect` without checking
geo-eligibility or running the compliance gate. This allowed users in
restricted regions to bypass restrictions and open perps positions from
the Market Insights entry point, even though every other entry point
(Market Details, Order Book, Token Details) correctly blocked them.

**Changes:**
- Wrapped `handlePerpsDirectionPress` in the compliance `gate()` and
added the `isEligible` geo-check before navigation, matching the pattern
in `PerpsMarketDetailsView` and `AssetOverviewContent`
- Renders the `PerpsBottomSheetTooltip` geo-block modal ("Perps
unavailable in your region") when the user is ineligible
- Added `MARKET_INSIGHTS` to `PERPS_EVENT_VALUE.SOURCE` for proper
geo-block analytics attribution
- Updated existing tests and added a new test case for the ineligible
scenario

CHANGELOG entry: Fixed a bug where users in restricted regions could
open perps positions from the Market Insights page

Fixes:

```gherkin
Feature: Perps geo-block enforcement on Market Insights

  Scenario: Restricted user taps Long on Market Insights
    Given the user is in a geo-restricted region
    And the user navigates to Market Insights for a perps asset (e.g. ETH)

    When the user taps the "Long" button
    Then the "Perps unavailable in your region" modal is shown
    And the user is NOT navigated to the order screen

  Scenario: Restricted user taps Short on Market Insights
    Given the user is in a geo-restricted region
    And the user navigates to Market Insights for a perps asset

    When the user taps the "Short" button
    Then the "Perps unavailable in your region" modal is shown
    And the user is NOT navigated to the order screen

  Scenario: Eligible user taps Long on Market Insights
    Given the user is NOT in a geo-restricted region
    And the user navigates to Market Insights for a perps asset

    When the user taps the "Long" button
    Then the user is navigated to the order screen as expected
```

N/A — behavior matches existing geo-block modal shown on other Perps
entry points.

Tapping Long/Short on Market Insights in a restricted region navigated
to the order screen (bypassing restrictions).

<img width="1320" height="2868" alt="Simulator Screenshot - iPhone 17
Pro Max - 2026-04-10 at 17 46 41"
src="https://github.com/user-attachments/assets/6d9e4b9f-2d69-4b4a-9bd2-13ee053bc26d"
/>

Tapping Long/Short on Market Insights in a restricted region shows the
geo-block modal and blocks navigation.

- [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**
> Touches Perps eligibility/compliance gating and navigation from
`MarketInsightsView`, so mistakes could reintroduce a restriction bypass
or block eligible users; changes are localized and covered by updated
tests.
>
> **Overview**
> Prevents the Market Insights Perps `Long`/`Short` CTAs from navigating
directly to order flow without restrictions by wrapping the action in
the compliance `gate()` and checking `selectPerpsEligibility` first.
>
> When ineligible, it now tracks a geo-block screen view with source
`PERPS_EVENT_VALUE.SOURCE.MARKET_INSIGHTS` and shows the
`PerpsBottomSheetTooltip` in a modal instead of navigating. Tests were
updated to handle async gated presses and a new test asserts the
ineligible geo-block behavior; the Perps view test renderer also ensures
extra routes get the same Perps providers.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
8ed8908. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Javier Garcia Vera <javier.vera@consensys.net>
Co-authored-by: javiergarciavera <76975121+javiergarciavera@users.noreply.github.com>
Co-authored-by: Alejandro Garcia <alejandro.garcia@consensys.net>
Co-authored-by: Nicholas Gambino <nicholas.gambino@consensys.net>
@runway-github runway-github bot requested a review from a team as a code owner April 10, 2026 18:47
@github-actions
Copy link
Copy Markdown
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 Apr 10, 2026
@github-actions github-actions bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
Copy link
Copy Markdown
Member

@gambinish gambinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Android and LGTM ✅

@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes introduce geo-eligibility gating on the Perps Long/Short buttons in MarketInsightsView. When a user is not eligible (geo-blocked), a PerpsBottomSheetTooltip modal is shown instead of navigating to the Perps order flow. Key impacts:

  1. SmokePerps (primary): MarketInsightsView is navigated to from PerpsMarketDetailsView (confirmed via grep). The geo-block modal is a new UI path in the Perps flow. The existing perps-add-funds.spec.ts E2E test exercises the Perps feature and should validate the overall Perps flow still works correctly.

  2. SmokeWalletPlatform (required by SmokePerps tag description): Perps is a section inside the Trending tab. Changes to Perps views affect Trending, so SmokeWalletPlatform must be included per the tag dependency rules.

  3. SmokeConfirmations (required by SmokePerps tag description): Add Funds deposits are on-chain transactions, so SmokeConfirmations must be included per the tag dependency rules.

The changes are scoped to:

  • A new analytics event source constant (MARKET_INSIGHTS in eventNames.ts)
  • Geo-eligibility check + modal in MarketInsightsView
  • Test renderer infrastructure for component-view tests (not Detox E2E)
  • Unit tests for the new behavior

No changes to navigation infrastructure, Engine, controllers, or shared components that would affect other test suites (SmokeAccounts, SmokeIdentity, SmokeTrade, SmokeNetworkAbstractions, etc.).

Performance Test Selection:
The changes add a Redux selector call (selectPerpsEligibility) and a conditional modal render to MarketInsightsView. These are lightweight operations triggered only on user interaction (button press), not on initial render or data loading. No performance-sensitive paths (list rendering, app startup, balance loading, swap flows) are affected. Performance tests are not warranted.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@joaoloureirop joaoloureirop merged commit 9eb5752 into release/7.72.1 Apr 10, 2026
87 of 89 checks passed
@joaoloureirop joaoloureirop deleted the cherry-pick-7-72-1-90f34c6 branch April 10, 2026 20:13
@github-actions github-actions bot locked and limited conversation to collaborators Apr 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants