Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: token list after switching networks #11718

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ class Engine {
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger: this.controllerMessenger.getRestricted({
name: 'TokenListController',
allowedActions: [],
allowedActions: [`${networkController.name}:getNetworkClientById`],
allowedEvents: [`${networkController.name}:stateChange`],
}),
});
Expand Down
22 changes: 22 additions & 0 deletions patches/@metamask+assets-controllers+31.0.0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,28 @@ index f7509a1..52bc67e 100644
var TokenBalancesController_default = TokenBalancesController;


diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-JUI3XNEF.js b/node_modules/@metamask/assets-controllers/dist/chunk-JUI3XNEF.js
index 44804c8..911a6e6 100644
--- a/node_modules/@metamask/assets-controllers/dist/chunk-JUI3XNEF.js
+++ b/node_modules/@metamask/assets-controllers/dist/chunk-JUI3XNEF.js
@@ -247,10 +247,15 @@ var TokenListController = class extends _pollingcontroller.StaticIntervalPolling
};
_onNetworkControllerStateChange = new WeakSet();
onNetworkControllerStateChange_fn = async function(networkControllerState) {
- if (this.chainId !== networkControllerState.providerConfig.chainId) {
+ const selectedNetworkClient = this.messagingSystem.call(
+ "NetworkController:getNetworkClientById",
+ networkControllerState.selectedNetworkClientId
+ );
+ const { chainId } = selectedNetworkClient.configuration;
+ if (this.chainId !== chainId) {
this.abortController.abort();
this.abortController = new AbortController();
- this.chainId = networkControllerState.providerConfig.chainId;
+ this.chainId = chainId;
if (this.state.preventPollingOnNetworkRestart) {
this.clearingTokenListData();
} else {
diff --git a/node_modules/@metamask/assets-controllers/dist/chunk-QFDTOEYR.js b/node_modules/@metamask/assets-controllers/dist/chunk-QFDTOEYR.js
index 5335fa5..ae37683 100644
--- a/node_modules/@metamask/assets-controllers/dist/chunk-QFDTOEYR.js
Expand Down
Loading