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

[token-detection-controller] Consolidate with DetectTokensController from extension #3775

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2d31cce
[assets-controllers] Install `{accounts,keyring}-controller` as deps …
MajorLift Jan 11, 2024
ea96025
Define and apply `#restartTokenDetection` method
MajorLift Jan 11, 2024
8e204e6
Subscribe to `AccountsController:selectedAccountChange` event
MajorLift Jan 11, 2024
2485341
Define `#registerKeyringListeners`, `isActive` methods
MajorLift Jan 11, 2024
0f46fdc
Add `#trackMetaMetricsEvent` tracker property and call
MajorLift Jan 11, 2024
129c82e
Use legacy token list from contract-metadata repo to perform auto-det…
MajorLift Jan 11, 2024
33818aa
Exclude `detectedTokens` already stored in tokens-controller state fr…
MajorLift Jan 11, 2024
5df6b81
test: add actions, events, callbacks to test messenger
MajorLift Jan 12, 2024
3fd2138
test: Fix incorrect mock for `KeyringController:getState`
MajorLift Jan 17, 2024
78e9fde
test: adjust coverage thresholds
MajorLift Jan 17, 2024
adc8dca
Make `#isUnlocked` property non-optional
MajorLift Jan 17, 2024
7016835
Define `#registerEventListeners` constructor helper private method
MajorLift Jan 17, 2024
a44ccf7
Add yarn resolutions entry to resolve conflicting `@metamask/provider…
MajorLift Jan 19, 2024
3fbdffa
Add `@metamask/keyring-api` as devDep (for `InternalAccount` type in …
MajorLift Jan 20, 2024
b5bd0e8
Remove unused `NetworkControllerStateChange` event
MajorLift Jan 20, 2024
beacf9b
Replace preferences controller callbacks in constructor with `getStat…
MajorLift Jan 20, 2024
4b303b4
Minor refactors to event listeners for consistency
MajorLift Jan 20, 2024
ad11ac7
test: adjust action,event allowlist in `buildTokenDetectionController…
MajorLift Jan 20, 2024
c90de3e
test: add callbacks for all allowed actions, events as `WithControlle…
MajorLift Jan 20, 2024
1173eb9
test: adjust for removal of `getPreferencesState` callback
MajorLift Jan 20, 2024
2be2e24
Add CHANGELOG entries
MajorLift Jan 22, 2024
968c0c0
[assets-controllers] Bump `@metamask/kerying-api` to ^3.0.0 and remov…
MajorLift Jan 22, 2024
2db0081
Update packages/assets-controllers/CHANGELOG.md
MajorLift Jan 22, 2024
7c25f3c
Extract `findCaseInsensitiveMatch` helper function
MajorLift Jan 26, 2024
f1af71a
Use `networkClientId` instead of `chainId` in `#restartTokenDetection`
MajorLift Jan 26, 2024
907b4df
test: remove unnecessary action handler unregisters
MajorLift Jan 26, 2024
04df278
Changelog linter fix
MajorLift Jan 26, 2024
312e450
In networkDidChange event listener, detect tokens if `networkClientId…
MajorLift Jan 29, 2024
9a4ae93
In changelog, move new actions/events under "Added" heading
MajorLift Jan 31, 2024
91be385
Include `#stopPolling()` call in `KeyringController:lock` listener
MajorLift Feb 6, 2024
88eb7ca
Replace `detectTokens` with `#restartTokenDetection` in `networkDidCh…
MajorLift Feb 6, 2024
e01f993
test: adjust coverage thresholds
MajorLift Feb 6, 2024
4a944d8
Apply suggestions to CHANGELOG
MajorLift Feb 7, 2024
582b370
Merge branch 'main' into 230113-consolidate-TokenDetectionController-…
MajorLift Feb 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **BREAKING:** Adds `@metamask/accounts-controller` ^8.0.0 and `@metamask/keyring-controller` ^12.0.0 as dependencies and peer dependencies. ([#3775](https://github.com/MetaMask/core/pull/3775/)).
- **BREAKING:** `TokenDetectionController` newly subscribes to the `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`, `KeyringController:lock`, `KeyringController:unlock` events, and allows the `PreferencesController:getState` messenger action. ([#3775](https://github.com/MetaMask/core/pull/3775/))

### Changed

- **BREAKING:** `TokenDetectionController` is merged with `DetectTokensController` from the `metamask-extension` repo. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- **BREAKING:** `TokenDetectionController` now resets its polling interval to the default value of 3 minutes when token detection is triggered by external controller events `KeyringController:unlock`, `TokenListController:stateChange`, `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`.
- **BREAKING:** `TokenDetectionController` now refetches tokens on `NetworkController:networkDidChange` if the `networkClientId` is changed instead of `chainId`.
- **BREAKING:** `TokenDetectionController` cannot initiate polling or token detection if `KeyringController` state is locked.
- **BREAKING:** The `detectTokens` method now excludes tokens that are already included in the `TokensController`'s `detectedTokens` list from the batch of incoming tokens it sends to the `TokensController` `addDetectedTokens` method.
- **BREAKING:** The constructor for `TokenDetectionController` expects a new required proprerty `trackMetaMetricsEvent`, which defines the callback that is called in the `detectTokens` method.
- **BREAKING:** In Mainnet, even if the `PreferenceController`'s `useTokenDetection` option is set to false, automatic token detection is performed on the legacy token list (token data from the contract-metadata repo).

### Removed

- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `onPreferencesStateChange`, `getPreferencesState`. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- **BREAKING:** `TokenDetectionController` no longer allows the `NetworkController:stateChange` event. The `NetworkController:networkDidChange` event can be used instead. ([#3775](https://github.com/MetaMask/core/pull/3775/))

## [25.0.0]

### Added
Expand Down
8 changes: 4 additions & 4 deletions packages/assets-controllers/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, {
// An object that configures minimum threshold enforcement for coverage results
coverageThreshold: {
global: {
branches: 88.36,
functions: 97.08,
lines: 97.23,
statements: 97.28,
branches: 88.3,
functions: 95.32,
lines: 96.69,
statements: 96.7,
},
},

Expand Down
5 changes: 5 additions & 0 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@metamask/abi-utils": "^2.0.2",
"@metamask/accounts-controller": "^10.0.0",
"@metamask/approval-controller": "^5.1.2",
"@metamask/base-controller": "^4.1.1",
"@metamask/contract-metadata": "^2.4.0",
"@metamask/controller-utils": "^8.0.2",
"@metamask/eth-query": "^4.0.0",
"@metamask/keyring-controller": "^12.2.0",
"@metamask/metamask-eth-abis": "3.0.0",
"@metamask/network-controller": "^17.2.0",
"@metamask/polling-controller": "^5.0.0",
Expand All @@ -59,6 +61,7 @@
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^3.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
Expand All @@ -73,7 +76,9 @@
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/accounts-controller": "^10.0.0",
"@metamask/approval-controller": "^5.1.2",
"@metamask/keyring-controller": "^12.2.0",
"@metamask/network-controller": "^17.2.0",
"@metamask/preferences-controller": "^7.0.0"
},
Expand Down
Loading
Loading