-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[assets-controllers] Upgrade
TokensController
to fully utilize cont…
…roller-messenger pattern (#3690) ## Motivation Remove `TokenDetectionController` constructor callbacks for `TokensController`. - `TokensController` features should be exposed as messenger actions/events so that consumers don't need to import the entire class. - `TokensController` should use messenger action/events to consume external controller features instead of callbacks. ## Explanation - Replaces constructor options callbacks `onPreferencesStateChange`, `onNetworkDidChange`, `onTokenListStateChange`, `getNetworkClientById` with messenger actions (`NetworkController:getNetworkClientById`) and events (`PreferencesController:stateChange`, `NetworkController:networkDidChange`, `TokenListController:stateChange`). - Replaces tokens-controller callbacks in token-detection-controller and token-balances-controller with `TokensController:getState`, `TokensController:addDetectedTokens` actions and `TokensController:stateChange` event. ## References - Extracted from #3775 - Contributes to #3626 ## Changelog ### [`@metamask/assets-controllers`](https://github.com/MetaMask/core/pull/3690/files#diff-ee47d03d53776b8dd530799a8047f5e32e36e35765620aeb50b294adc3339fab) ### Added - `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, `TokensControllerStateChangeEvent`. ([#3690](#3690)) ### Changed - **BREAKING:** The `TokensState` type is now defined as a type alias rather than an interface. ([#3690](#3690)) - This is breaking because it could affect how this type is used with other types, such as `Json`, which does not support TypeScript interfaces. ### Removed - **BREAKING:** `TokenDetectionController` constructor no longer accepts options `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, `addDetectedTokens`. ([#3690](#3690), [#3775](#3775)) - **BREAKING:** `TokensController` constructor no longer accepts options `onPreferencesStateChange`, `onNetworkDidChange`, `onTokenListStateChange`, `getNetworkClientById`. ([#3690](#3690)) - **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress`. ([#3690](#3690)) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --------- Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
- Loading branch information
Showing
9 changed files
with
647 additions
and
501 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.