fix(transaction-pay-controller): subscribe to all asset event sources unconditionally#9427
Open
dan437 wants to merge 2 commits into
Open
fix(transaction-pay-controller): subscribe to all asset event sources unconditionally#9427dan437 wants to merge 2 commits into
dan437 wants to merge 2 commits into
Conversation
… unconditionally subscribeAssetChanges picked a single asset event source at construction time based on the assetsUnifyState feature flag: AssetsController when enabled, or the legacy Tokens/TokenRates/CurrencyRate controllers otherwise. On a fresh profile the flag hasn't loaded from remote config yet, so the controller subscribes to the legacy source. Once the flag turns on, reads switch to AssetsController, whose events were never subscribed to, so required tokens for in-flight transactions never re-parse and consuming UI can hang on a loading state indefinitely. Subscribe to all four sources unconditionally instead of branching on the flag. The handler is idempotent, so extra events from an inactive source are harmless no-ops.
7 tasks
Keep a Changelog orders sections as Added, Changed, Deprecated, Removed, Fixed, Security. Fixed was listed above Changed.
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
subscribeAssetChangespicked a single asset event source at controller construction time based on theassetsUnifyStateremote feature flag:AssetsController:stateChangewhen the flag is enabled, or the legacyTokensController/TokenRatesController/CurrencyRateControllerstate-change events otherwise.On a fresh profile the remote feature flags haven't loaded yet, so the controller subscribes to the legacy events. Once the flags load and
assetsUnifyStateturns on, all reads (viagetTokenInfo/getTokenFiatRate) switch over toAssetsController— but the controller is still only listening to the legacy events it picked at construction time. Required tokens for in-flight transactions then never get re-parsed, so consumers (e.g. a deposit/withdraw confirmation screen pollingtransactionDatafor its required tokens) can be stuck in a loading state indefinitely.This is a regression: the same class of issue was fixed previously by unconditionally subscribing to all sources, but a later refactor reintroduced the flag-gated branching.
Subscribes to all four sources unconditionally instead of branching on the flag.
buildHandler's work (re-parsing required tokens for transactions with unresolved tokens) is idempotent, so extra events firing from an inactive source are harmless no-ops.References
Checklist
Note
Low Risk
Targeted subscription logic fix with updated unit tests; slightly more messenger callbacks but handlers are idempotent.
Overview
Fixes in-flight Pay transactions that could never resolve required tokens when remote
assetsUnifyStateflips on after startup.subscribeAssetChangesno longer picks a single assetstateChangelistener at construction fromgetAssetsUnifyStateFeature. It now always subscribes toAssetsController,TokensController,TokenRatesController, andCurrencyRateController, with JSDoc explaining why the flag is unsafe for this choice. The handler stays idempotent, so duplicate subscriptions are safe.Tests drop the feature-flag mock and assert legacy per-source events still trigger updates alongside
AssetsController.Reviewed by Cursor Bugbot for commit 59277a0. Bugbot is set up for automated code reviews on this repo. Configure here.