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 detection and import #23798

Merged
merged 12 commits into from
Apr 5, 2024
Merged

fix: token detection and import #23798

merged 12 commits into from
Apr 5, 2024

Conversation

bergeron
Copy link
Contributor

@bergeron bergeron commented Mar 29, 2024

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:

Screenshot 2024-03-28 at 6 04 41 PM

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

Related issues

Fixes:

Manual testing steps

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • 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 format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@bergeron bergeron marked this pull request as ready for review March 29, 2024 01:14
@bergeron bergeron requested a review from a team as a code owner March 29, 2024 01:14
salimtb
salimtb previously approved these changes Mar 29, 2024
@salimtb
Copy link
Contributor

salimtb commented Mar 29, 2024

@bergeron can you check why your e2e tests are failing ?

@salimtb salimtb self-requested a review March 29, 2024 10:01
@MajorLift
Copy link
Contributor

MajorLift commented Mar 29, 2024

Probably unrelated to the bugs, but I noticed another error related to the preferences-controller that was introduced in #22928.

diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 89905caaef..ddecaf42f5 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -500,8 +500,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({

@bergeron
Copy link
Contributor Author

Test failing because we're sending RPC requests before onboarding finishes. Test was recently added while detection was broken. Will see if I can delay the controller's start.

@bergeron bergeron changed the title fix: preferences controller messaging fix: token detection and import Apr 1, 2024
Copy link

codecov bot commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 69.03%. Comparing base (f29a78e) to head (2f5c68b).

Files Patch % Lines
app/scripts/metamask-controller.js 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #23798      +/-   ##
===========================================
+ Coverage    68.99%   69.03%   +0.04%     
===========================================
  Files         1164     1164              
  Lines        44515    44491      -24     
  Branches     11890    11888       -2     
===========================================
  Hits         30711    30711              
+ Misses       13804    13780      -24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Collaborator

Builds ready [f402e0f]
Page Load Metrics (1192 ± 583 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint8259218511153
domContentLoaded167735189
load67299411921215583
domInteractive167735189
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -82 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [6ffbb8c]
Page Load Metrics (355 ± 304 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint671641052211
domContentLoaded96231168
load531969355633304
domInteractive96231168
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -45 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link

socket-security bot commented Apr 3, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@types/[email protected] None 0 5.96 kB types

🚮 Removed packages: npm/@types/[email protected]

View full report↗︎

@metamaskbot
Copy link
Collaborator

Builds ready [2f5c68b]
Page Load Metrics (631 ± 449 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint712731264622
domContentLoaded106029147
load582407631934449
domInteractive106029147
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -45 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: -18 Bytes (-0.00%)

bergeron added a commit to MetaMask/core that referenced this pull request Apr 3, 2024
## Explanation

During account change, the token detection trigger was guarded by the
`useTokenDetection` setting. But on mainnet, detection should run
against the static token list even if the setting is disabled. So remove
the guard.

## References

MetaMask/metamask-extension#23798

## Changelog

### `@metamask/assets-controllers`

- **FIXED**: Token detection during account change 

## Checklist

- [ ] I've updated the test suite for new or updated code as appropriate
- [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
Copy link
Contributor

@MajorLift MajorLift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for making these fixes.

@bergeron bergeron merged commit f327149 into develop Apr 5, 2024
72 checks passed
@bergeron bergeron deleted the bergeron-patch-1 branch April 5, 2024 19:38
@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2024
@metamaskbot metamaskbot added the release-11.15.0 Issue or pull request that will be included in release 11.15.0 label Apr 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.15.0 Issue or pull request that will be included in release 11.15.0 team-assets
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants