Skip to content

feat: enable MM Pay provider fallback routing and Across strategy support on mobile#27751

Open
pedronfigueiredo wants to merge 5 commits intomainfrom
pnf/plan-provider-fallback-rollout
Open

feat: enable MM Pay provider fallback routing and Across strategy support on mobile#27751
pedronfigueiredo wants to merge 5 commits intomainfrom
pnf/plan-provider-fallback-rollout

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented Mar 20, 2026

Description

This PR enables MM Pay provider fallback routing and Across strategy support on mobile, so MM Pay flows can resolve an ordered provider list from confirmations_pay instead of being hardwired to Relay. It also updates mobile MM Pay consumers to recognize the new Across child transaction types used by Perps and Predict flows across activity, confirmation, history, notifications, and metrics surfaces.

The generic route-based confirmations_pay strategy resolution has now been standardized upstream in MetaMask/core#8282. On the mobile side, this PR narrows the routing API to MM Pay-specific wrappers that derive route context from transaction metadata and consume the shared routing behavior, while keeping compatibility with the currently published @metamask/transaction-pay-controller version until the newer core package is available in mobile.

Feature flag consumption remains mobile-driven through confirmations_pay and confirmations_pay_post_quote. Mobile continues to own the MM Pay route-context derivation, selector wiring, controller-init integration, and the transaction-type grouping needed to support Across-based Perps and Predict deposit flows without broadening unrelated UI behavior.

To enable provider fallback, confirmations_pay should define the global strategy order, per-strategy enablement, and any transaction-specific overrides. The schema looks like this:

  strategyOrder?: string[];

  strategyOverrides?: {
    default?: {
      default?: string[];
      chains?: Record<Hex, string[]>;
      tokens?: Record<Hex, Record<Hex, string[]>>;
    };
    transactionTypes?: Record<string, {
      default?: string[];
      chains?: Record<Hex, string[]>;
      tokens?: Record<Hex, Record<Hex, string[]>>;
    }>;
  };

  payStrategies?: {
    across?: {
      apiBase?: string;
      enabled?: boolean;
      fallbackGas?: {
        estimate?: number;
        max?: number;
      };
    };
    relay?: {
      enabled?: boolean;
      executeEnabled?: boolean;
      originGasOverhead?: string;
      pollingInterval?: number;
      pollingTimeout?: number;
    };

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Refs: MetaMask/core#8282

Manual testing steps

Feature: MM Pay provider fallback routing

  Scenario: MM Pay uses the configured global strategy order
    Given `confirmations_pay.strategyOrder` is set to `["across", "relay"]`
    And `confirmations_pay.payStrategies.across.enabled` is true
    And `confirmations_pay.payStrategies.relay.enabled` is true
    When the user opens a supported MM Pay confirmation flow
    Then mobile should resolve Across before Relay

  Scenario: MM Pay honors route-specific overrides
    Given `confirmations_pay.routingOverrides.overrides.perpsDeposit` contains a chain or token override for Relay
    When the user opens a matching Perps deposit confirmation
    Then mobile should resolve the overridden strategy order for that route

  Scenario: MM Pay post-quote routing uses destination context
    Given `confirmations_pay_post_quote` enables a supported withdraw flow
    When the user opens a post-quote withdrawal confirmation
    Then mobile should resolve MM Pay strategy selection using the destination chain and destination token

  Scenario: Across child transactions render correctly in mobile UI
    Given the user completes a Perps or Predict flow that creates an Across child transaction
    When the user views activity, progress, or transaction details
    Then the Across child transaction should be classified and rendered as the correct MM Pay flow step

Screenshots/Recordings

Before

N/A

After

N/A

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
Introduces new strategy-routing logic driven by remote feature flags and expands MM Pay transaction-type classification across UI, notifications, and metrics; incorrect routing or type grouping could impact payment flows and analytics attribution.

Overview
Enables MM Pay provider fallback routing on mobile by switching TransactionPayControllerInit from a hardcoded single getStrategy to a feature-flag-driven getStrategies, backed by new route/transaction helpers in util/transactions/transaction-pay-routing.

Unifies MM Pay transaction-type handling via a new util/transactions/metamask-pay module (use-case mapping, route type grouping, deposit/positive-transfer/detail type lists), and updates activity/history UI, notifications, gas-update logic, and analytics/metrics to recognize Across variants (e.g., perpsAcrossDeposit, predictAcrossDeposit) and to avoid misleading predictClaim amount display.

Adds metrics support for the Across strategy (mm_pay_strategy: 'across') and records optional execution latency (mm_pay_execution_latency), plus refactors token-transfer decoding into a shared transaction-pay-token-transfer utility; accompanying unit tests are expanded throughout.

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

@pedronfigueiredo pedronfigueiredo requested review from a team as code owners March 20, 2026 16:43
@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.

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from 8ec189d to aecc4b4 Compare March 20, 2026 17:30
@pedronfigueiredo pedronfigueiredo added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 20, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 20, 2026
@pedronfigueiredo pedronfigueiredo added team-confirmations Push issues to confirmations team and removed INVALID-PR-TEMPLATE PR's body doesn't match template labels Mar 20, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 20, 2026
@github-actions github-actions bot added the risk-high Extensive testing required · High bug introduction risk label Mar 20, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from aecc4b4 to f19f99c Compare March 23, 2026 12:09
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 23, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from f19f99c to a70e59e Compare March 23, 2026 13:16
@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 Mar 23, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from a70e59e to fde5817 Compare March 23, 2026 13:42
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 23, 2026
@pedronfigueiredo pedronfigueiredo self-assigned this Mar 23, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from fde5817 to 488f6a4 Compare March 23, 2026 14:06
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 23, 2026
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 23, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from 5fcd8f2 to 4df801b Compare March 23, 2026 18:31
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 23, 2026
};
}

export function resolveMetaMaskPayStrategies(
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 Mar 24, 2026

Choose a reason for hiding this comment

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

If this is generic based on transactionType, why is all this exposed to the client and not handled in the controller?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The idea was to based this off the original transaction pay controller API, in which TransactionPayController only knows about strategies and exposes getStrategies (previously getStrategy) specifically so the embedding client can decide the configuration. The transactionType usage is entirely optional, for defining transactionType level overrides.

Is there a chance we might want to configure the strategy selection and ordering on a client basis in the future? Or would you prefer we move the configuration to the controller?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should support the clients overriding with custom logic.

But if we're just using our generic feature flags in our own confirmations_pay flag, that can all be standardised in the controller?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Extracted into this PR

transactionMeta.type === TransactionType.perpsDeposit ||
transactionMeta.type === TransactionType.perpsDepositAndOrder
) {
if (hasPerpsDepositTransactionType(transactionMeta)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ideally we avoid any code-owner changes in the initial PR, plus this is specific to the top level intent types, and not the nested deposit types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Separated into this PR

TransactionType.predictDeposit,
TransactionType.predictWithdraw,
];
const NEW_TRANSACTION_DETAILS_TYPES = [...MM_PAY_DETAIL_TRANSACTION_TYPES];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also here, good to move the constant, but should we defer to a separate PR for smaller code-owner PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Separated into this PR

@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 24, 2026
@metamaskbot metamaskbot removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 24, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/plan-provider-fallback-rollout branch from 06f9650 to b31331a Compare March 24, 2026 15:25
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 24, 2026
@github-actions github-actions bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 25, 2026
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-high Extensive testing required · High bug introduction risk labels Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps, @PerformancePredict
  • Risk Level: medium
  • AI Confidence: 82%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR introduces significant changes to MetaMask Pay transaction routing and strategy selection for Perps and Predictions flows:

  1. SmokePerps (primary): The TransactionPayController now uses feature-flag-driven strategy routing instead of always returning Relay. New perpsAcrossDeposit and perpsRelayDeposit transaction types are added. The getTransactionActionKey now handles all perps deposit types. Transaction details UI (hero, summary, details) updated to use centralized type helpers. NotificationManager now skips notifications for relay/across deposit types. These changes directly affect the Perps Add Funds flow.

  2. SmokePredictions (primary): Same routing changes apply to Predict deposit/withdraw flows. New predictAcrossDeposit and predictRelayDeposit types added. getTransactionActionKey updated for predict types. Transaction details UI updated. These changes directly affect Predictions position opening/closing flows.

  3. SmokeWalletPlatform (required by SmokePerps/SmokePredictions): Per tag descriptions, SmokePerps and SmokePredictions require SmokeWalletPlatform (Trending section). Also, transaction history display changes (TransactionElement/utils.js now uses MM_PAY_POSITIVE_TRANSFER_TRANSACTION_TYPES which includes relay/across types) affect the Activities tab.

  4. SmokeConfirmations (required by SmokePerps/SmokePredictions): Per tag descriptions, SmokePerps and SmokePredictions require SmokeConfirmations since deposits are on-chain transactions. The confirmation flow is also affected by the strategy routing changes in TransactionPayController.

The changes are medium risk - they refactor existing logic and add new transaction types for Across strategy support, but the core flows remain the same. The feature flag gating means Across strategy won't activate unless explicitly enabled, reducing regression risk for existing flows.

Performance Test Selection:
The TransactionPayController strategy routing changes and new transaction type handling could affect the performance of Perps and Predictions flows. The controller now makes additional calls to RemoteFeatureFlagController to determine strategies, and the new routing logic adds computation for each transaction. The @PerformancePreps tag covers perps market loading and add funds flow, while @PerformancePredict covers prediction market flows - both directly affected by the strategy routing changes.

View GitHub Actions results

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@github-actions
Copy link
Copy Markdown
Contributor

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

@sonarqubecloud
Copy link
Copy Markdown

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

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed risk-medium Moderate testing recommended · Possible bug introduction risk size-XL team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants