-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: token detection and import (#23798)
## **Description** Fixes issues with detecting and manually importing tokens, caused by recent controller changes. Hotfix for 11.14.0 This state publish had an undefined variable, and had the wrong function signature: <img width="597" alt="Screenshot 2024-03-28 at 6 04 41 PM" src="https://github.com/MetaMask/metamask-extension/assets/3500406/15cd8341-725b-49d8-bd4d-bf8539185214"> Which prevented the controllers from processing account switches. A test was failing because RPC requests were sent before onboarding. Delayed the enabling of token detection controller to `triggerNetworkrequests`. Also patching this fix for detection during account switch on mainnet when autodetection=off: MetaMask/core#4133 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/23798?quickstart=1) ## **Related issues** Fixes: - #23526 - #23612 ## **Manual testing steps** ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
Showing
4 changed files
with
78 additions
and
12 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
.yarn/patches/@metamask-assets-controllers-npm-26.0.0-17c0e9432c.patch
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"), |
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
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