From 33100748ada0de2a1d14b9c2618119f252bb3d55 Mon Sep 17 00:00:00 2001 From: salimtb Date: Thu, 21 Nov 2024 11:04:18 +0100 Subject: [PATCH] fix: fix and clean up --- ...ts-controllers-npm-44.1.0-012aa448d8.patch | 36 +++++++++++++++++++ app/scripts/metamask-controller.js | 10 ------ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch b/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch index 0b4ad4e76514..faf388c89741 100644 --- a/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch +++ b/.yarn/patches/@metamask-assets-controllers-npm-44.1.0-012aa448d8.patch @@ -33,3 +33,39 @@ index e7eaad2cfa8b233c4fd42a51f745233a1cc5c387..bf8ec7819f678c2f185d6a85d7e3ea81 /** * The list of currencies that can be supplied as the `vsCurrency` parameter to * the `/spot-prices` endpoint, in lowercase form. +diff --git a/dist/TokenDetectionController.cjs b/dist/TokenDetectionController.cjs +index 8fd5efde7a3c24080f8a43f79d10300e8c271245..a3c334ac7dd2e5698e6b54a73491b7145c2a9010 100644 +--- a/dist/TokenDetectionController.cjs ++++ b/dist/TokenDetectionController.cjs +@@ -250,17 +250,20 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_ + } + }); + this.messagingSystem.subscribe('AccountsController:selectedEvmAccountChange', +- // TODO: Either fix this lint violation or explain why it's necessary to ignore. +- // eslint-disable-next-line @typescript-eslint/no-misused-promises +- async (selectedAccount) => { +- const isSelectedAccountIdChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAccountId, "f") !== selectedAccount.id; +- if (isSelectedAccountIdChanged) { +- __classPrivateFieldSet(this, _TokenDetectionController_selectedAccountId, selectedAccount.id, "f"); +- await __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { +- selectedAddress: selectedAccount.address, +- }); +- } +- }); ++ // TODO: Either fix this lint violation or explain why it's necessary to ignore. ++ // eslint-disable-next-line @typescript-eslint/no-misused-promises ++ async (selectedAccount) => { ++ const { networkConfigurationsByChainId } = this.messagingSystem.call('NetworkController:getState'); ++ const chainIds = Object.keys(networkConfigurationsByChainId); ++ const isSelectedAccountIdChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAccountId, "f") !== selectedAccount.id; ++ if (isSelectedAccountIdChanged) { ++ __classPrivateFieldSet(this, _TokenDetectionController_selectedAccountId, selectedAccount.id, "f"); ++ await __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { ++ selectedAddress: selectedAccount.address, ++ chainIds, ++ }); ++ } ++ }); + }, _TokenDetectionController_stopPolling = function _TokenDetectionController_stopPolling() { + if (__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f")) { + clearInterval(__classPrivateFieldGet(this, _TokenDetectionController_intervalId, "f")); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 8e916bdf0810..0d0344d4e7e3 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2917,7 +2917,6 @@ export default class MetamaskController extends EventEmitter { this.controllerMessenger.subscribe( `${this.accountsController.name}:selectedAccountChange`, async (account) => { - console.log('ACCOUNT CHANGED ....'); if (account.address && account.address !== lastSelectedAddress) { lastSelectedAddress = account.address; await this._onAccountChange(account.address); @@ -6915,15 +6914,6 @@ export default class MetamaskController extends EventEmitter { }; async _onAccountChange(newAddress) { - const networkConfigurations = - this.networkController.state.networkConfigurationsByChainId; - - const chainIds = Object.keys(networkConfigurations); - - await this.tokenDetectionController.detectTokens({ - selectedAddress: newAddress, - chainIds, - }); const permittedAccountsMap = getPermittedAccountsByOrigin( this.permissionController.state, );