Skip to content

Replace DetectTokensController with consolidated TokenDetectionController from core repo #23127

@MajorLift

Description

@MajorLift

What is this about?

The core repo TokenDetectionController has been consolidated with the extension DetectTokensController as of MetaMask/core#1812.

Once these changes are released, the extension-side DetectTokensController will be replaced.

Breaking Changes to be introduced by TokenDetectionController

  • Extends StaticIntervalPollingController instead of StaticIntervalPollingControllerOnly

  • Constructor options:

    • Removes getCurrentSelectedAccount, getNetworkClientById callbacks as constructor options. Uses corresponding messenger actions instead.
    • Removes disableLegacyInterval class field and constructor option.
      • Instead has disabled option, which blocks all network requests.
  • Adds enable, disable public methods.

  • #restartTokenDetection is a private method.

    • #restartTokenDetection accepts options object { selectedAddress, networkClientId } instead of { selectedAddress, chainId }
    • #restartTokenDetection always resets polling interval to default regardless of whether legacy or new polling is being used.
    • Removes the getChainIdFromNetworkStore public method and replaces internally with #getCorrectChainIdAndNetworkClientId.
  • Uses NetworkController:getNetworkConfigurationByNetworkClientId action instead of NetworkController:getNetworkClientById action to get correct 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 { accountAddress, 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.

Scenario

No response

Design

No response

Technical Details

No response

Threat Modeling Framework

No response

Acceptance Criteria

No response

Stakeholder review needed before the work gets merged

  • Engineering (needed in most cases)
  • Design
  • Product
  • QA (automation tests are required to pass before merging PRs but not all changes are covered by automation tests - please review if QA is needed beyond automation tests)
  • Security
  • Legal
  • Marketing
  • Management (please specify)
  • Other (please specify)

References

Metadata

Metadata

Assignees

Labels

release-11.14.0Issue or pull request that will be included in release 11.14.0

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions