feat(ramps-controller): accept a JSON moneyHeadlessAllProviders payload carrying provider allowlists#9524
Draft
saustrie-consensys wants to merge 3 commits into
Draft
Conversation
…ad carrying provider allowlists
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
10 tasks
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
moneyHeadlessAllProvidersis currently a boolean remote flag: the literaltruewidens headless fiat auto-selection quoting to every provider class (#9409). Phase 2 of the Headless Buy all-providers work needs QA to force a specific provider mix (for example external-browser-only) without a client change per test configuration.This PR widens the flag's value contract so the same LaunchDarkly key can carry provider allowlists:
{ "enabled": true, "providerIds": ["/providers/x"], "surfaces": { "money": [...], "perps": [...], "predictions": [...] } }.isHeadlessAllProvidersEnabledreturnstruefor a payload whoseenabledis the literaltrue; every other previously-false value still resolves tofalse, and the boolean forms behave exactly as before.getHeadlessProviderAllowlist(remoteFeatureFlagState, surface?)(plusHEADLESS_ALLOWLIST_SURFACES/HeadlessAllowlistSurface) resolves the allowlist: a valid non-emptysurfaces[surface]entry overrides the top-levelproviderIds; absent, empty, or malformed levels fall through, ending at "no restriction". Unknown keys and non-string entries are ignored, in the same defensive-coercion style as the boolean read./providers/x) or bare form, case-insensitively, via a module-local normalizer used only for allowlist matching (provider ids still match as-is everywhere else; the v16 removal of id normalization is not reverted). If nothing survives,getQuotesreturns an emptysuccess[]withsorted/error/customActionspreserved.getQuotesgains an optionalsurfaceoption selecting the per-surface list. It is deliberately not part of the request cache key: the pick runs after the cached fetch, so an LD edit or a different surface re-applies over the cached raw response, and calls differing only insurfaceshare one service request (pinned by a test).RemoteFeatureFlagController:getStateread pergetQuotescall, so a flag edit during the awaited fetch cannot produce a mixed read.Backwards compatibility, and why this is a minor (not breaking) change: clients on earlier versions coerce any non-boolean value to
false(native-only), so serving the object payload can never turn widening on for a client that cannot parse it, and production servesfalseeverywhere today. No consumer needs code changes to keep working; boolean-only configurations see identical behavior. The documented "any non-boolean resolves to false" contract is widened, not changed, for the values it previously rejected.References
MetaMask/metamask-mobile(app/components/UI/Ramp/headless/PLAN_-_ALL_PROVIDERS_SUPPORT.md), revised to evolve the single existing flag instead of adding a companion flag.Checklist