-
Notifications
You must be signed in to change notification settings - Fork 5k
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
refactor: Replace DetectTokensController
with core monorepo's TokenDetectionController
#22928
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
TokenDetectionController
from coreDetectTokensController
with consolidated TokenDetectionController
from core
6081fd9
to
9bf4d14
Compare
9bf4d14
to
da7270a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Ignoring: Next stepsWhat is new author?A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package. Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights. Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
da7270a
to
96e8576
Compare
DetectTokensController
with consolidated TokenDetectionController
from coreDetectTokensController
with consolidated TokenDetectionController
from core repo
This comment was marked as resolved.
This comment was marked as resolved.
5ce8858
to
4dc3ab4
Compare
c6a3a05
to
5d43932
Compare
…ccounts-controller`, `@metamask/keyring-controller`
…s` into `TokenDetectionController` and `detectTokens`
5c99b14
to
4f6a160
Compare
This comment has been minimized.
This comment has been minimized.
b669ccf
to
b825ed4
Compare
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
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!
I'm not super familiar with the controller messaging patterns to determine if they're all correct. But I don't see anything that looks wrong! 🚀 |
This comment was marked as duplicate.
This comment was marked as duplicate.
3957631
to
d038ff9
Compare
Builds ready [17dde59]
Page Load Metrics (1048 ± 461 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
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.
Looks good!
Description
This commit replaces
DetectTokensController
with the core repo'sTokenDetectionController
.This represents the final step of Shared Libraries' initiative to a) consolidate the core repo's
TokenDetectionController
, the extension'sDetectTokensController
, and relevant mobile patches to@metamask/assets-controllers
, with the goal of b) migrating both extension and mobile to use the consolidated controller in core.This also represents a full conversion to TypeScript for
DetectTokensController
and its unit tests.Related issues
DetectTokensController
with consolidatedTokenDetectionController
from core repo #23127TokenDetectionController
up-to-date and release new version ofassets-controllers
core#3916DetectTokensController
updates core#3923@metamask/assets-controllers
v26)Manual testing steps
Changelog
metamask-extension
MetamaskController
class:preferencesControllerMessenger
instance which only allows thePreferencesController:getState
action andPreferencesController:stateChange
event.PreferencesController:stateChange
event.PreferencesController
:messenger
as an optional constructor options object property.PreferencesController:getState
action handler.toChecksumHexAddress
from@metamask/controller-utils
with imports from the internalshared/modules/hexstring-utils
module.@metamask/assets-controllers
to^26.0.0
.@metamask/accounts-controller
to^11.0.0
.@metamask/keyring-controller
to^13.0.0
.@metamask/polling-controller
as a dependency.test-yarn-dedupe
CI run.@metamask/controller-utils
to^8.0.4
.TokenDetectionController
(compared toDetectTokensController
)BREAKING: Inherit from
StaticIntervalPollingController
instead ofStaticIntervalPollingControllerOnly
Constructor and class fields:
preferences
,network
,tokenList
,tokensController
,assetsContractController
,getCurrentSelectedAccount
,getNetworkClientById
as constructor options, and add required optiongetBalancesInSingleCall
.disableLegacyInterval
class field and constructor option.#restartTokenDetection
always resets polling interval to default regardless of whether legacy or new polling is being used.#disabled
private class field, which blocks all network requests if set to true, and adddisabled
as an optional constructor option, which defaults to 'true' if omitted.isOpen
class field, and replace by addingenable
,disable
public methods.selectedAddress
. If omitted, its value is populated by calling theAccountsController:getSelectedAccount
action.Messenger:
PreferencesController:stateChange
,AccountsController:selectedAccountChange
,KeyringController:lock
,KeyringController:unlock
events.AccountsController:getSelectedAccount
,NetworkController:getNetworkClientById
,NetworkController:getNetworkConfigurationByNetworkClientId
,NetworkController:getState
,KeyringController:getState
,PreferencesController:getState
,TokenListController:getState
,TokensController:getState
, andTokensController:addDetectedTokens
.BREAKING:
detectTokens
replaces thedetectNewTokens
method.selectedAddress
,networkClientId
, removing thechainId
option.Token
types toTokensController:addDetectedTokens
instead of objects containing only{ address, decimals, symbol }
.detectTokens
was limited to two batches, with the first batch being limited to 1000 tokens.getBalancesInSingleCall
callback fails, it does not throw an error or exit early, and the method continues processing the next batch of tokens.BREAKING:
#restartTokenDetection
is a private method instead of public.BREAKING: Replace the
getChainIdFromNetworkStore
method with the private method#getCorrectChainIdAndNetworkClientId
.BREAKING:
#trackMetaMetricsEvents
is a private method instead of protected._trackMetaMetricsEvent
.TokensController
NetworkController:getNetworkClientById
messenger action.NetworkController:networkDidChange
,PreferencesController:stateChange
,TokenListController:stateChange
events.NetworkController:stateChange
event.Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist