-
-
Notifications
You must be signed in to change notification settings - Fork 192
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 TokenDetectionController.detectTokens() used tokens states when passed networkClientId #3914
Merged
jiexi
merged 7 commits into
main
from
jl/mmp-3905/fix-detect-tokens-controller-token-list-polling
Feb 20, 2024
Merged
Fix TokenDetectionController.detectTokens() used tokens states when passed networkClientId #3914
jiexi
merged 7 commits into
main
from
jl/mmp-3905/fix-detect-tokens-controller-token-list-polling
Feb 20, 2024
Conversation
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
jiexi
changed the title
Jl/mmp 3905/fix detect tokens controller token list polling
Fix TokenDetectionController.detectTokens() used tokens states when passed networkClientId
Feb 9, 2024
MajorLift
previously approved these changes
Feb 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Definitely an improvement over the previous pattern.
mcmire
previously approved these changes
Feb 15, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
bergeron
previously approved these changes
Feb 15, 2024
3 tasks
MajorLift
added a commit
that referenced
this pull request
Feb 17, 2024
…ed to wrong network, and detection using `chainId` keyed states - See MetaMask/metamask-extension#22814 - See #3914
Co-authored-by: Jongsun Suh <[email protected]>
Co-authored-by: Jongsun Suh <[email protected]>
adonesky1
approved these changes
Feb 20, 2024
jiexi
deleted the
jl/mmp-3905/fix-detect-tokens-controller-token-list-polling
branch
February 20, 2024 17:55
MajorLift
added a commit
that referenced
this pull request
Feb 20, 2024
…ed to wrong network, and detection using `chainId` keyed states - See MetaMask/metamask-extension#22814 - See #3914
MajorLift
added a commit
that referenced
this pull request
Feb 20, 2024
…ed to wrong network, and detection using `chainId` keyed states - See MetaMask/metamask-extension#22814 - See #3914
MajorLift
added a commit
that referenced
this pull request
Feb 23, 2024
…ed to wrong network, and detection using `chainId` keyed states - See MetaMask/metamask-extension#22814 - See #3914
MajorLift
added a commit
that referenced
this pull request
Feb 27, 2024
…dates (#3923) ## Explanation As a preparatory step for fully replacing the extension `DetectTokensController` with the consolidated core repo `TokenDetectionController`, `TokenDetectionController` needs to be updated with changes made to the extension `DetectTokensController` since #1813 was closed. #### Diff of `DetectTokensController` state - [MetaMask/metamask-extension@`5d285f7be5f7be981995dfa725aad97d81cc990a..85cd1c89039e900b452edb704ec37e9ccbd3e76a`#diff-323d0cf464](https://github.com/MetaMask/metamask-extension/compare/5d285f7be5f7be981995dfa725aad97d81cc990a..85cd1c89039e900b452edb704ec37e9ccbd3e76a#diff-323d0cf46498be3850b971474905354ea5ccf7fa13745ad1e6eba59c5b586830) ### Differences from extension `DetectTokensController` - Refactors logic for retrieving `chainId`, `networkClientId` into `this.#getCorrectChainIdAndNetworkClientId` - Uses `getNetworkConfigurationByNetworkClientId` action instead of `getNetworkClientById` to retrieve `chainId`. - If `networkClientId` is not supplied to the method, or it's supplied but `getNetworkConfigurationByNetworkClientId` returns `undefined`, finds `chainId` from `providerConfig`. - `detectTokens` replaces `detectNewTokens` - `detectTokens` accepts options object `{ selectedAddress, networkClientId }` instead of `{ selectedAddress, chainId, networkClientId }`. - Does not throw error if `getBalancesInSingleCall` fails. Also does not exit early -- continues looping. - Passes lists of full `Token` types to `TokensController:addDetectedTokens` instead of objects containing only `{ address, decimals, symbol }`. - `#trackMetaMetricsEvents` is a private method instead of protected. - Passes string literals instead of extension shared constants into `_trackMetaMetricsEvent`. ## References - Partially implements #3916 - Blocking #3918 - Changes adopted from: - MetaMask/metamask-extension#22898 - MetaMask/metamask-extension#22814 - #3914 - MetaMask/metamask-extension#21437 - Blocking (Followed by) #3938 ## Changelog ### [`@metamask/assets-controllers`](https://github.com/MetaMask/core/pull/3923/files#diff-ee47d03d53776b8dd530799a8047f5e32e36e35765620aeb50b294adc3339fab) ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --------- Co-authored-by: jiexi <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
Currently,
detectTokens()
always uses the state for the globally selected network from theTokenListController
andTokensController
regardless of if/what networkClientId is passed in.This PR updates
detectTokens()
to use the chainId keyed states of theTokenListController
andTokensController
instead.References
Fixes: #3905
Changelog
@metamask/assets-controllers
TokenDetectionController.detectTokens()
now reads the chainId keyed state properties fromTokenListController
andTokensController
rather than incorrectly using the globally selected state properties when networkClientId is passedChecklist