Open
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. 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
What is the current state of things and why does it need to change?
The bridge controller currently reads exchange rates only from the legacy assets stack:
MultichainAssetsRatesController,TokenRatesController, andCurrencyRateController. We want to support the new@metamask/assets-controller, which exposes a single bridge-oriented API (AssetsController:getExchangeRatesForBridge) and will eventually replace the old controllers for bridge/swap flows.What is the solution your changes offer and how does it work?
Optional
getUseAssetsControllerForRatesThe
BridgeControllerconstructor now accepts an optionalgetUseAssetsControllerForRates?: () => boolean. When this function is provided and returnstrue, the controller usesAssetsController:getExchangeRatesForBridgefor all exchange-rate lookups and for the currency used when fetching asset prices. When it is not provided or returnsfalse, behavior is unchanged and the legacy controllers are used.Selector and type alignment
ExchangeRateSourcesForLookupand the internal selector logic were updated so they accept both the legacy controller state shape and the shape returned bygetExchangeRatesForBridge. Types from@metamask/assets-controllersare used where possible; the bridge format is supported via optional/union types so a single selector works for both code paths.Are there any changes whose purpose might not be obvious to those unfamiliar with the domain?
Record<Hex, …>vsRecord<string, …>) and uses narrow casts when indexing, so that the same selectors work whether the host uses the new assets-controller or the legacy controllers.getUseAssetsControllerForRatesis a function (not a boolean) so the host can decide at call time (e.g. from a feature flag or config) without re-creating the controller.If your primary goal was to update one package but you found you had to update another one along the way, why did you do so?
Only
@metamask/bridge-controllerwas changed. It already depended on@metamask/assets-controllerfor theAssetsControllerGetExchangeRatesForBridgeActiontype; no other packages were modified.If you had to upgrade a dependency, why did you do so?
No dependency upgrades were made in this PR.
References
getUseAssetsControllerForRates(e.g. returning the value of a feature flag) when constructingBridgeController.Checklist
Note
Medium Risk
Changes how bridge exchange rates and selected currency are sourced when an optional constructor flag is enabled, which can affect quote pricing/metrics if the new rates shape differs or is incomplete. Default behavior remains unchanged, reducing rollout risk.
Overview
Adds an optional
BridgeControllerconstructor hook,getUseAssetsControllerForRates, to switch exchange-rate lookups from the legacy rate controllers toAssetsController:getExchangeRatesForBridge(including using itscurrentCurrencyfor price fetches).Updates exchange-rate selector typing/logic (
ExchangeRateSourcesForLookupandgetExchangeRateByChainIdAndAddress) to accept both the legacy state shape and the AssetsController bridge rates shape, and adds test coverage validating the correct controller calls for each path. Also wires in@metamask/assets-controlleras a dependency/TS project reference and documents the option in the changelog.Written by Cursor Bugbot for commit 0d44fa4. This will update automatically on new commits. Configure here.