Skip to content

feat(transaction-pay): add ordered strategy fallback orchestration#7868

Open
pedronfigueiredo wants to merge 2 commits intomainfrom
cor-6992-extract-fallback-mechanism
Open

feat(transaction-pay): add ordered strategy fallback orchestration#7868
pedronfigueiredo wants to merge 2 commits intomainfrom
cor-6992-extract-fallback-mechanism

Conversation

@pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Feb 9, 2026

Explanation

As per preemptive validation on #7806

  • Adds ordered strategy retrieval via TransactionPayController:getStrategies while preserving existing getStrategy behavior.
  • Adds compatibility filtering (supports(...)) during strategy selection.
  • Implements quote fallback orchestration:
    • try next strategy when quote retrieval fails
    • try next strategy when quote list is empty
    • skip unsupported strategies
  • Implements publish-hook fallback orchestration:
    • execute primary strategy from existing quote strategy
    • on execution failure, rebuild quote requests and try next compatible strategy
    • throw original primary error if all fallback attempts fail

References

Addresses https://github.com/MetaMask/MetaMask-planning/issues/6992

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 core quote selection/refresh and publish-hook execution paths, so strategy ordering and fallback behavior could alter which provider is used and when quotes clear/update, despite added unit coverage.

Overview
TransactionPayController now supports an ordered getStrategies callback (with validation) and falls back to a remote feature flag strategyOrder (defaulting to Relay) when callbacks are missing/invalid.

Quote retrieval is refactored to iterate strategies in order via getStrategiesByName, optionally skip incompatible strategies via new PayStrategy.supports, and automatically fall through to the next strategy when quotes are empty, quote fetching fails, or batch-transaction generation fails.

Quote refreshing and the publish hook are updated to carry/consume this strategy orchestration: refresh flows receive the strategy list provider, and TransactionPayPublishHook executes using the strategy encoded in the first stored quote rather than re-resolving strategy from the transaction. Tests/docs/changelog are updated accordingly.

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

@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 6 times, most recently from 23573ac to 55549a1 Compare February 9, 2026 11:34
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from 55549a1 to e2818b3 Compare February 9, 2026 13:32
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from e2818b3 to 5158351 Compare February 9, 2026 13:48
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 3 times, most recently from c450bc6 to 782bc16 Compare February 9, 2026 14:27
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from 9b2de51 to 44ee983 Compare February 12, 2026 11:02
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from 44ee983 to eeca0ed Compare February 12, 2026 13:47
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 2 times, most recently from 9cd0f37 to a6c9af9 Compare February 13, 2026 10:47
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from a6c9af9 to df9f104 Compare February 16, 2026 10:20
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.

@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 2 times, most recently from 35e9f3f to 08bac6a Compare February 16, 2026 10:27
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from 08bac6a to 26c090a Compare February 16, 2026 10:51
max?: number;
};
relayQuoteUrl?: string;
strategyOrder?: string[];
Copy link
Member

Choose a reason for hiding this comment

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

Minor, alphabetical.

): NamedStrategy[] {
return strategyNames.flatMap((strategyName) => {
try {
return [
Copy link
Member

Choose a reason for hiding this comment

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

Minor, if we're returning a single entry in the array, why do we need flatMap rather than map?


#getStrategiesWithFallback(
transaction: TransactionMeta,
): [TransactionPayStrategy, ...TransactionPayStrategy[]] {
Copy link
Member

Choose a reason for hiding this comment

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

Still confused by this type, wouldn't it just be TransactionPayStrategy[] and we get the first entry for the existing getStrategy messenger action?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants