Skip to content

fix(transaction-pay-controller): subscribe to all asset event sources unconditionally#9427

Open
dan437 wants to merge 2 commits into
mainfrom
conf-1633-subscribe-asset-changes
Open

fix(transaction-pay-controller): subscribe to all asset event sources unconditionally#9427
dan437 wants to merge 2 commits into
mainfrom
conf-1633-subscribe-asset-changes

Conversation

@dan437

@dan437 dan437 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Explanation

subscribeAssetChanges picked a single asset event source at controller construction time based on the assetsUnifyState remote feature flag: AssetsController:stateChange when the flag is enabled, or the legacy TokensController/TokenRatesController/CurrencyRateController state-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 assetsUnifyState turns on, all reads (via getTokenInfo/getTokenFiatRate) switch over to AssetsController — 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 polling transactionData for 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

  • Related to a downstream fix in the MetaMask extension for a stuck loading skeleton on the Perps deposit confirmation screen.

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

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 assetsUnifyState flips on after startup.

subscribeAssetChanges no longer picks a single asset stateChange listener at construction from getAssetsUnifyStateFeature. It now always subscribes to AssetsController, TokensController, TokenRatesController, and CurrencyRateController, 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.

… 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.
Keep a Changelog orders sections as Added, Changed, Deprecated,
Removed, Fixed, Security. Fixed was listed above Changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant