Skip to content

feat(transaction-pay-controller): add route-based strategy resolution#8282

Open
pedronfigueiredo wants to merge 1 commit intomainfrom
codex/transaction-pay-route-feature-flags
Open

feat(transaction-pay-controller): add route-based strategy resolution#8282
pedronfigueiredo wants to merge 1 commit intomainfrom
codex/transaction-pay-route-feature-flags

Conversation

@pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Mar 24, 2026

Explanation

This change moves the generic confirmations_pay strategy-order routing logic into @metamask/transaction-pay-controller so clients no longer need to own the raw feature-flag parsing and ordered strategy resolution themselves. The controller now supports an optional getStrategyRouteContext callback for client-specific route derivation, while the package exposes getStrategyOrderForRouteFromFeatureFlags for non-controller consumers that still need to answer route-based flag questions from the same generic implementation.

This keeps the controller flexible for custom client overrides while standardizing the shared transactionType / chainId / tokenAddress routing policy in one place. As part of that, the transaction-pay feature-flag utilities now apply RemoteFeatureFlagController.localOverrides before resolving confirmations_pay, which matches how MetaMask Mobile already consumes those flags.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes how TransactionPayController selects pay strategies by introducing route-context-based feature-flag resolution and by applying localOverrides before remote flags, which can alter runtime strategy ordering for transactions and quote refreshes.

Overview
Adds route-based pay strategy resolution to TransactionPayController via an optional getStrategyRouteContext callback; when no explicit getStrategy/getStrategies is provided (or they return no valid strategies), the controller now derives an ordered strategy list using transactionType/chainId/tokenAddress routing overrides before falling back to the global strategyOrder.

Introduces getStrategyOrderForRoute/getStrategyOrderForRouteFromFeatureFlags helpers that normalize and validate routing configs (case-insensitive hex matching, dedupe/filter invalid entries, and drop disabled strategies), and updates feature-flag parsing to apply RemoteFeatureFlagController.localOverrides over remoteFeatureFlags. Public exports and tests are updated accordingly.

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

@pedronfigueiredo pedronfigueiredo self-assigned this Mar 24, 2026
@pedronfigueiredo pedronfigueiredo force-pushed the codex/transaction-pay-route-feature-flags branch 3 times, most recently from 5a81abc to b59a521 Compare March 24, 2026 14:53
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review March 24, 2026 15:04
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners March 24, 2026 15:04
@pedronfigueiredo pedronfigueiredo force-pushed the codex/transaction-pay-route-feature-flags branch 2 times, most recently from 5a2400d to 3d3dc21 Compare March 24, 2026 17:27
Copy link

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

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.

@pedronfigueiredo pedronfigueiredo force-pushed the codex/transaction-pay-route-feature-flags branch from 3d3dc21 to 85b9724 Compare March 24, 2026 17:45
routingConfig.payStrategies.across.enabled) ||
(strategy === TransactionPayStrategy.Relay &&
routingConfig.payStrategies.relay.enabled),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably avoid adding logic to this file and restrict it to code to fetch flag values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree. I will move the route-resolution helper out of feature-flags.ts and keep this file limited to fetching and normalizing raw confirmations_pay values.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants