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

Upgrade TokenDetectionController to extend BaseControllerV2, StaticIntervalPollingController #3609

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
d595d0f
Define types for BaseControllerV2 migration
MajorLift Dec 1, 2023
56ca692
Upgrade `TokenDetectionController` to extend from `PollingController`
MajorLift Dec 1, 2023
25ae501
Replace event handlers with controller-messenger pattern
MajorLift Dec 1, 2023
d42cc0f
[token-list-controller] Export `TokenListControllerMessenger` and def…
MajorLift Dec 7, 2023
0a66c50
Explicitly enumerate package-level exports
MajorLift Dec 7, 2023
1b5b635
Move `TokenDetectionConfig` properties to private class fields in `To…
MajorLift Dec 7, 2023
94448cd
Define `controllerName`, `TokenDetectionState` as empty object, remov…
MajorLift Dec 7, 2023
bcfa0a1
Fix: unregister internal `getState` action handler in constructor as …
MajorLift Dec 7, 2023
b8dcf32
Fix `sliceOfTokensToDetect` logic to handle arbitrary number of `toke…
MajorLift Dec 7, 2023
a5ef650
Various fixes for controller upgrade
MajorLift Dec 8, 2023
72b3618
Adapt tests to align with upgraded `TokenDetectionController` API
MajorLift Dec 8, 2023
2f74472
Fix test to avoid using deprecated aurora network
MajorLift Dec 11, 2023
720dc69
Assume that `getTokensState` never returns `undefined`
MajorLift Dec 11, 2023
74f74ba
Remove unnecessary cleanup function calls
MajorLift Dec 11, 2023
7b3d4e4
Add jsdoc for test utility functions
MajorLift Dec 11, 2023
2bef9b8
Fix unnecessary `await`
MajorLift Dec 11, 2023
9c8491a
Use new network-controller action/event
MajorLift Dec 11, 2023
05ed86b
Fix tests
MajorLift Dec 11, 2023
8964e0d
Move `unregisterActionhandler` calls for `TokenDetectionController:ge…
MajorLift Dec 11, 2023
26509c1
Remove `disabled` class field entirely
MajorLift Dec 11, 2023
cb2bd08
Remove unnecessary `tokenDetect.start()` calls from tests
MajorLift Dec 11, 2023
9244803
Record CHANGELOG entries
MajorLift Dec 12, 2023
1274137
Reorder constructor assignments
MajorLift Dec 12, 2023
0c0476c
Await all `detectTokens()` calls
MajorLift Dec 12, 2023
8dc1fcd
Test fixes
MajorLift Dec 12, 2023
bb43ebb
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 12, 2023
fdb70d9
Add `deferPollingStart` property
MajorLift Dec 12, 2023
98e8d17
Fix test
MajorLift Dec 12, 2023
8ad12b5
Fix test to avoid implicitly calling `detectTokens()`
MajorLift Dec 12, 2023
5e94d13
Fix `#getCorrectChainId` and polygon network test to pull network con…
MajorLift Dec 12, 2023
a5ebc52
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 12, 2023
a2007f6
Update jest coverage thresholds
MajorLift Dec 12, 2023
3532bbc
Remove `deferPollingStart` constructor option
MajorLift Dec 12, 2023
6601dcc
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 12, 2023
322d074
Add controller types to package-level exports
MajorLift Dec 12, 2023
b60ada5
Update CHANGELOG records
MajorLift Dec 12, 2023
599da4d
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 12, 2023
6c22a3a
Update jest coverage thresholds
MajorLift Dec 12, 2023
a26d568
Mock action handler return value instead of registering multiple hand…
MajorLift Dec 13, 2023
85e3f10
Remove unregister action handler call in constructor and define `befo…
MajorLift Dec 13, 2023
e1a061a
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 13, 2023
b9cbcba
Revert "Fix `sliceOfTokensToDetect` logic to handle arbitrary number …
MajorLift Dec 13, 2023
4322102
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 13, 2023
fb7cbe2
set polygon network as rpc in test
MajorLift Dec 14, 2023
5d602a3
Fix test so that `preferencesStateChangeListener` triggers `detectTok…
MajorLift Dec 14, 2023
a41a218
Add `#networkClientId` class field and update using `seletedNetworkCl…
MajorLift Dec 14, 2023
7e52c7c
Update CHANGELOG to reflect 'Revert "Fix `sliceOfTokensToDetect` logi…
MajorLift Dec 14, 2023
e7dac31
Update jsdoc for class fields
MajorLift Dec 14, 2023
15f8922
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 14, 2023
15ea19c
Fix mistaken assignment of chainId to networkClientId property
MajorLift Dec 14, 2023
3e1416d
Revert "Add `#networkClientId` class field and update using `seletedN…
MajorLift Dec 14, 2023
123aff5
Revert "Fix test so that `preferencesStateChangeListener` triggers `d…
MajorLift Dec 14, 2023
7f2e58b
Fix test so that `preferencesStateChangeListener` triggers `detectTok…
MajorLift Dec 14, 2023
d32cdf4
Add `#networkClientId` class field and update using `seletedNetworkCl…
MajorLift Dec 14, 2023
9167cac
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 14, 2023
71d9967
Fix test by publishing `networkDidChange` event in `changeNetwork` he…
MajorLift Dec 14, 2023
0dda603
Add `#disabled` class field to ensure that passive token detection is…
MajorLift Dec 14, 2023
c5eec25
Adjust jest coverage thresholds
MajorLift Dec 14, 2023
1337d19
Update packages/assets-controllers/src/TokenDetectionController.test.ts
MajorLift Dec 15, 2023
41f85a1
Update packages/assets-controllers/CHANGELOG.md
MajorLift Dec 15, 2023
8c331fa
Edit test descriptions so that `getBalancesInSingleMock` is subject
MajorLift Dec 15, 2023
d40247e
Fix incorrect package-level export
MajorLift Dec 15, 2023
757ab04
[tokens-controller] Add actions `getState`, `addDetectedTokens` and e…
MajorLift Dec 15, 2023
44e92cb
Replace `getTokensState`, `addDetectedTokens` callbacks with messenge…
MajorLift Dec 15, 2023
4b0bda3
Make `detectTokens` take empty options object as default argument
MajorLift Dec 15, 2023
a007d15
Remove assignment to `#chainId` in `#getCorrectChainId`
MajorLift Dec 15, 2023
f5e6611
Edit test description
MajorLift Dec 15, 2023
b2a5af5
Update changelog
MajorLift Dec 15, 2023
eadf3ba
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 15, 2023
aa9e3ba
Adjust jest coverage thresholds
MajorLift Dec 15, 2023
f636e25
Revert "Fix incorrect package-level export"
MajorLift Dec 15, 2023
173168f
Use `getNetworkClientById` action in `#getCorrectChainId` method
MajorLift Dec 16, 2023
d81c23d
Replace `chainId` with `networkClientId` in constructor options.
MajorLift Dec 16, 2023
d9bd4b1
Remove `getNetworkConfigurationByClientId` handler from tests
MajorLift Dec 18, 2023
fefc64b
test: adjust `getNetworkClientById` handler to return polygon chainId
MajorLift Dec 18, 2023
73eccbf
test: remove unnecessary `.start()` calls
MajorLift Dec 18, 2023
5fe7674
Add `disabled` as constructor option and set it to block `#startPolli…
MajorLift Dec 18, 2023
116a227
Adjust jest coverage thresholds
MajorLift Dec 18, 2023
acd022f
Remove unused comment
MajorLift Dec 19, 2023
ee2154d
test: Restore publishes for `networkDidChange` event, mock polygon ne…
MajorLift Dec 20, 2023
cfbd787
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 20, 2023
21f9b8c
Adjust jest coverage thresholds
MajorLift Dec 20, 2023
de94761
Revert "[tokens-controller] Add actions `getState`, `addDetectedToken…
MajorLift Dec 20, 2023
4b6c1d2
test: Apply 'Revert "[tokens-controller] Add actions `getState`, `add…
MajorLift Dec 20, 2023
a951492
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 21, 2023
541f8f4
Adjust jest coverage threshold
MajorLift Dec 21, 2023
798bb09
Use `getNetworkConfigurationByNetworkClientId` to replace `getNetwork…
MajorLift Dec 21, 2023
1552041
Remove throw error in `_executePoll`
MajorLift Dec 21, 2023
2451982
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 21, 2023
6d020bc
Adjust jest coverage threshold
MajorLift Dec 21, 2023
05cf2bd
Set `disabled` to true by default and add `enable`, `disable` methods
MajorLift Dec 21, 2023
d8ced01
Revert "test: remove unnecessary `.start()` calls"
MajorLift Dec 21, 2023
16e8bad
test: Adjust tests to `disabled` being true by default
MajorLift Dec 21, 2023
f67bead
Update changelog
MajorLift Dec 21, 2023
8e1cdf5
Merge branch 'main' into 231201-token-detection-controller-basecontro…
MajorLift Dec 21, 2023
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
9 changes: 9 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- `TokenListController` now exports a `TokenListControllerMessenger` type ([#3609](https://github.com/MetaMask/core/pull/3609)).
- `TokenDetectionController` exports types `TokenDetectionControllerMessenger`, `TokenDetectionControllerActions`, `TokenDetectionControllerGetStateAction`, `TokenDetectionControllerEvents`, `TokenDetectionControllerStateChangeEvent` ([#3609](https://github.com/MetaMask/core/pull/3609)).
- Add `enable` and `disable` methods to `TokenDetectionController`, which control whether the controller is able to make polling requests or all of its network calls are blocked. ([#3609](https://github.com/MetaMask/core/pull/3609)).
- Note that if the controller is initiated without the `disabled` constructor option set to `false`, the `enable` method will need to be called before the controller can make polling requests in response to subscribed events.

### Changed
- **BREAKING:** `TokenDetectionController` is upgraded to extend `BaseControllerV2` and `StaticIntervalPollingController` ([#3609](https://github.com/MetaMask/core/pull/3609)).
- The constructor now expects an options object as its only argument, with required properties `messenger`, `networkClientId`, required callbacks `onPreferencesStateChange`, `getBalancesInSingleCall`, `addDetectedTokens`, `getTokenState`, `getPreferencesState`, and optional properties `disabled`, `interval`, `selectedAddress`.

## [22.0.0]
### Changed
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.2,
functions: 95.95,
lines: 96.25,
statements: 96.5,
branches: 88.36,
functions: 97.08,
lines: 97.23,
statements: 97.28,
},
},

Expand Down
Loading
Loading