Skip to content

Comments

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

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

feat(transaction-pay): add ordered strategy fallback orchestration#7868
pedronfigueiredo wants to merge 3 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 retrieval and publish-path strategy selection; failures in ordering/validation or supports logic could lead to missing quotes or executing an unintended strategy.

Overview
Adds ordered pay-strategy orchestration for quote retrieval: TransactionPayController can now accept a getStrategies callback (or remote feature flag strategyOrder) and updateQuotes/refreshQuotes iterate strategies in order, skipping unsupported ones (supports) and falling back when quote/batch-tx retrieval fails or returns empty.

Strategy selection is hardened by validating strategy names (isTransactionPayStrategy), adding getStrategiesByName to resolve/skip unknown strategies, and changing the publish hook to execute the strategy encoded in the stored quote (quotes[0].strategy) rather than re-selecting at publish time. Docs/changelog and tests are updated accordingly.

Written by Cursor Bugbot for commit b6a43e3. 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
@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
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch 2 times, most recently from 1b1ae1f to d7d7490 Compare February 18, 2026 15:56
@pedronfigueiredo pedronfigueiredo force-pushed the cor-6992-extract-fallback-mechanism branch from d7d7490 to b6a43e3 Compare February 20, 2026 14:44
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.

});
continue;
}
}
Copy link

Choose a reason for hiding this comment

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

Source amounts strategy mismatch with fallback strategy selection

Medium Severity

The updateSourceAmounts call in #updateTransactionData uses getStrategy (returning the first strategy) to decide whether same-token quotes are required via isQuoteAlwaysRequired. But the new fallback loop in getQuotes may select a different strategy. For a Hyperliquid USDC deposit where the payment token matches the required token, if Bridge is first in the order, isQuoteAlwaysRequired returns false, the source amount is skipped, and no quote requests are built — so even when Relay (which does need that quote) is tried as fallback, requests is already empty and getQuotes returns early with no quotes.

Additional Locations (1)

Fix in Cursor Fix in Web

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