diff --git a/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch b/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch new file mode 100644 index 000000000000..a84784cded69 --- /dev/null +++ b/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch @@ -0,0 +1,24 @@ +diff --git a/dist/TokenDetectionController.js b/dist/TokenDetectionController.js +index 9aa09140d47424217eac118aebca9031e5d2a236..8100c432e7e01dbefcb5f53db3c58e51f120a51d 100644 +--- a/dist/TokenDetectionController.js ++++ b/dist/TokenDetectionController.js +@@ -230,8 +230,7 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_ + const isDetectionChangedFromPreferences = __classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f") !== useTokenDetection; + __classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, newSelectedAddress, "f"); + __classPrivateFieldSet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, useTokenDetection, "f"); +- if (useTokenDetection && +- (isSelectedAddressChanged || isDetectionChangedFromPreferences)) { ++ if (isSelectedAddressChanged || isDetectionChangedFromPreferences) { + yield __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { + selectedAddress: __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f"), + }); +@@ -239,8 +238,7 @@ _TokenDetectionController_intervalId = new WeakMap(), _TokenDetectionController_ + })); + this.messagingSystem.subscribe('AccountsController:selectedAccountChange', ({ address: newSelectedAddress }) => __awaiter(this, void 0, void 0, function* () { + const isSelectedAddressChanged = __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f") !== newSelectedAddress; +- if (isSelectedAddressChanged && +- __classPrivateFieldGet(this, _TokenDetectionController_isDetectionEnabledFromPreferences, "f")) { ++ if (isSelectedAddressChanged) { + __classPrivateFieldSet(this, _TokenDetectionController_selectedAddress, newSelectedAddress, "f"); + yield __classPrivateFieldGet(this, _TokenDetectionController_instances, "m", _TokenDetectionController_restartTokenDetection).call(this, { + selectedAddress: __classPrivateFieldGet(this, _TokenDetectionController_selectedAddress, "f"), diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 3279b6acb348..9ed0cfe6b8d1 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -510,8 +510,8 @@ export default class MetamaskController extends EventEmitter { const preferencesMessenger = this.controllerMessenger.getRestricted({ name: 'PreferencesController', - allowedActions: ['PreferencesController:getState'], - allowedEvents: ['PreferencesController:stateChange'], + allowedActions: [], + allowedEvents: [], }); this.preferencesController = new PreferencesController({ @@ -2209,6 +2209,7 @@ export default class MetamaskController extends EventEmitter { triggerNetworkrequests() { this.accountTracker.start(); this.txController.startIncomingTransactionPolling(); + this.tokenDetectionController.enable(); if (this.preferencesController.store.getState().useCurrencyRateCheck) { this.currencyRateController.startPollingByNetworkClientId( this.networkController.state.selectedNetworkClientId, @@ -2222,6 +2223,7 @@ export default class MetamaskController extends EventEmitter { stopNetworkRequests() { this.accountTracker.stop(); this.txController.stopIncomingTransactionPolling(); + this.tokenDetectionController.disable(); if (this.preferencesController.store.getState().useCurrencyRateCheck) { this.currencyRateController.stopAllPolling(); } @@ -2500,8 +2502,9 @@ export default class MetamaskController extends EventEmitter { // TODO: Remove once the preferences controller has been replaced with the core monorepo implementation this.controllerMessenger.publish( - `${this.preferencesController.name}:stateChange`, - [state, []], + 'PreferencesController:stateChange', + state, + [], ); }); @@ -3733,6 +3736,8 @@ export default class MetamaskController extends EventEmitter { this.txController.clearUnapprovedTransactions(); + this.tokenDetectionController.enable(); + // create new vault const vault = await this.keyringController.createNewVaultAndRestore( password, @@ -5652,11 +5657,6 @@ export default class MetamaskController extends EventEmitter { */ set isClientOpen(open) { this._isClientOpen = open; - if (open) { - this.tokenDetectionController.enable(); - } else { - this.tokenDetectionController.disable(); - } } /* eslint-enable accessor-pairs */ diff --git a/package.json b/package.json index bb40d53a51d3..baf130d2ad55 100644 --- a/package.json +++ b/package.json @@ -268,7 +268,7 @@ "@metamask/address-book-controller": "^3.1.7", "@metamask/announcement-controller": "^5.0.1", "@metamask/approval-controller": "^6.0.0", - "@metamask/assets-controllers": "^26.0.0", + "@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch", "@metamask/base-controller": "^4.1.0", "@metamask/browser-passworder": "^4.3.0", "@metamask/contract-metadata": "^2.3.1", diff --git a/yarn.lock b/yarn.lock index 6f72a64dcc01..69600ed3e2e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3998,7 +3998,7 @@ __metadata: languageName: node linkType: hard -"@metamask/assets-controllers@npm:^26.0.0": +"@metamask/assets-controllers@npm:26.0.0": version: 26.0.0 resolution: "@metamask/assets-controllers@npm:26.0.0" dependencies: @@ -4040,6 +4040,48 @@ __metadata: languageName: node linkType: hard +"@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch": + version: 26.0.0 + resolution: "@metamask/assets-controllers@patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch::version=26.0.0&hash=cf1d54" + dependencies: + "@ethereumjs/util": "npm:^8.1.0" + "@ethersproject/address": "npm:^5.7.0" + "@ethersproject/bignumber": "npm:^5.7.0" + "@ethersproject/contracts": "npm:^5.7.0" + "@ethersproject/providers": "npm:^5.7.0" + "@metamask/abi-utils": "npm:^2.0.2" + "@metamask/accounts-controller": "npm:^11.0.0" + "@metamask/approval-controller": "npm:^5.1.3" + "@metamask/base-controller": "npm:^4.1.1" + "@metamask/contract-metadata": "npm:^2.4.0" + "@metamask/controller-utils": "npm:^8.0.4" + "@metamask/eth-query": "npm:^4.0.0" + "@metamask/keyring-controller": "npm:^13.0.0" + "@metamask/metamask-eth-abis": "npm:3.0.0" + "@metamask/network-controller": "npm:^17.2.1" + "@metamask/polling-controller": "npm:^5.0.1" + "@metamask/preferences-controller": "npm:^8.0.0" + "@metamask/rpc-errors": "npm:^6.2.1" + "@metamask/utils": "npm:^8.3.0" + "@types/bn.js": "npm:^5.1.5" + "@types/uuid": "npm:^8.3.0" + async-mutex: "npm:^0.2.6" + bn.js: "npm:^5.2.1" + cockatiel: "npm:^3.1.2" + lodash: "npm:^4.17.21" + multiformats: "npm:^9.5.2" + single-call-balance-checker-abi: "npm:^1.0.0" + uuid: "npm:^8.3.2" + peerDependencies: + "@metamask/accounts-controller": ^11.0.0 + "@metamask/approval-controller": ^5.1.2 + "@metamask/keyring-controller": ^13.0.0 + "@metamask/network-controller": ^17.2.0 + "@metamask/preferences-controller": ^8.0.0 + checksum: 44e0ce87c9a2e4e161771c212460947629502ad6e72542e87a29a3de6e9c6665190396a2ae7d8206e57ad091cb80ad6634dfbfd254632a5ee6833c496f1ad0ad + languageName: node + linkType: hard + "@metamask/auto-changelog@npm:^2.1.0": version: 2.6.1 resolution: "@metamask/auto-changelog@npm:2.6.1" @@ -24683,7 +24725,7 @@ __metadata: "@metamask/address-book-controller": "npm:^3.1.7" "@metamask/announcement-controller": "npm:^5.0.1" "@metamask/approval-controller": "npm:^6.0.0" - "@metamask/assets-controllers": "npm:^26.0.0" + "@metamask/assets-controllers": "patch:@metamask/assets-controllers@npm%3A26.0.0#~/.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch" "@metamask/auto-changelog": "npm:^2.1.0" "@metamask/base-controller": "npm:^4.1.0" "@metamask/browser-passworder": "npm:^4.3.0"