metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

Add networkClientId to DetectTokensController.detectNewTokens()

Open jiexi opened this issue 1 year ago • 3 comments

Description

Currently networkClientId token based polling in the DetectTokensController does not make the getBalancesInSingleCall contract call with the provider for the networkClientId. This is because networkClientId is not being passed from _executePoll to getBalancesInSingleCall.

This PR adds an optional networkClientId param to detectNewTokens which is used to:

  • make getBalancesInSingleCall calls with the correct provider
  • override the chainId argument if also passed

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2097

Manual testing steps

Nothing should change as this does not affect the current single globally selected network flow and the multichain polling for this has not been integrated yet.

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • [x] I’ve followed MetaMask Coding Standards.
  • [x] I've clearly explained what problem this PR is solving and how it is solved.
  • [x] I've linked related issues
  • [ ] I've included manual testing steps
  • [ ] I've included screenshots/recordings if applicable
  • [x] I’ve included tests if applicable
  • [ ] I’ve documented my code using JSDoc format if applicable
  • [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • [x] I’ve properly set the pull request status:
    • [x] In case it's not yet "ready for review", I've set it to "draft".
    • [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

jiexi avatar Feb 09 '24 22:02 jiexi

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.

github-actions[bot] avatar Feb 09 '24 22:02 github-actions[bot]

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (34df597) 68.54% compared to head (2cd0d7a) 68.54%.

Files Patch % Lines
app/scripts/controllers/detect-tokens.js 62.50% 3 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #22898      +/-   ##
===========================================
- Coverage    68.54%   68.54%   -0.00%     
===========================================
  Files         1088     1088              
  Lines        42900    42904       +4     
  Branches     11418    11419       +1     
===========================================
+ Hits         29403    29405       +2     
- Misses       13497    13499       +2     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 13 '24 19:02 codecov[bot]

Builds ready [2cd0d7a]
Page Load Metrics (989 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1603482084019
domContentLoaded1469492110
load88112789899948
domInteractive1469492110
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 47 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 13 '24 20:02 metamaskbot