Skip to content

Commit 4f01e3c

Browse files
authored
chore: upgrade assets controllers to v94.1.0 (MetaMask#24005)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** upgrade assets controllers to v94.1.0 <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: bump assets controllers to v94.1.0 ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Upgrade assets-controllers to v94.1.0 and align token balance/detection controller initialization and messengers (add isOnboarded, remove platform/useAccountsAPI, update delegated actions/events). > > - **Dependencies** > - Bump `@metamask/assets-controllers` to `^94.1.0`. > - **Engine Controllers** > - `token-balances-controller-init` > - Add `isOnboarded` option using `selectCompletedOnboarding`. > - Update tests to expect `isOnboarded`. > - `token-detection-controller-init` > - Remove `platform` and `useAccountsAPI` options. > - Update tests to match new constructor args. > - **Messengers** > - `token-balances-controller-messenger` > - Actions: add `TokenDetectionController:addDetectedTokensViaPolling`, `...:addDetectedTokensViaWs`, `...:detectTokens`, `KeyringController:getState`. > - Events: add `KeyringController:lock`, `KeyringController:unlock`, `TransactionController:transactionConfirmed`, `TransactionController:incomingTransactionsReceived`. > - `token-detection-controller-messenger` > - Actions: add `AccountsController:getAccount`; remove `AuthenticationController:getBearerToken`. > - Events: no net new events; ordering adjusted. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8462734. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 03b341a commit 4f01e3c

8 files changed

Lines changed: 29 additions & 22 deletions

app/core/Engine/controllers/token-balances-controller-init.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ describe('TokenBalancesControllerInit', () => {
7474
queryMultipleAccounts: expect.any(Boolean),
7575
accountsApiChainIds: expect.any(Function),
7676
platform: 'mobile',
77+
isOnboarded: expect.any(Function),
7778
});
7879
});
7980

@@ -92,6 +93,7 @@ describe('TokenBalancesControllerInit', () => {
9293
queryMultipleAccounts: expect.any(Boolean),
9394
accountsApiChainIds: expect.any(Function),
9495
platform: 'mobile',
96+
isOnboarded: expect.any(Function),
9597
});
9698
});
9799

@@ -111,6 +113,7 @@ describe('TokenBalancesControllerInit', () => {
111113
queryMultipleAccounts: expect.any(Boolean),
112114
accountsApiChainIds: expect.any(Function),
113115
platform: 'mobile',
116+
isOnboarded: expect.any(Function),
114117
});
115118
});
116119
});

app/core/Engine/controllers/token-balances-controller-init.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import { TokenBalancesControllerInitMessenger } from '../messengers/token-balances-controller-messenger';
77
import { selectAssetsAccountApiBalancesEnabled } from '../../../selectors/featureFlagController/assetsAccountApiBalances';
88
import { selectBasicFunctionalityEnabled } from '../../../selectors/settings';
9+
import { selectCompletedOnboarding } from '../../../selectors/onboarding';
910

1011
/**
1112
* Initialize the token balances controller.
@@ -34,6 +35,7 @@ export const tokenBalancesControllerInit: ControllerInitFunction<
3435
engine: { backgroundState: persistedState as EngineState },
3536
}) as `0x${string}`[],
3637
platform: 'mobile',
38+
isOnboarded: () => selectCompletedOnboarding(getState()),
3739
});
3840

3941
return {

app/core/Engine/controllers/token-detection-controller-init.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ describe('TokenDetectionControllerInit', () => {
4646
const controllerMock = jest.mocked(TokenDetectionController);
4747
expect(controllerMock).toHaveBeenCalledWith({
4848
messenger: expect.any(Object),
49-
platform: 'mobile',
50-
useAccountsAPI: true,
5149
disabled: false,
5250
getBalancesInSingleCall: expect.any(Function),
5351
useTokenDetection: expect.any(Function),

app/core/Engine/controllers/token-detection-controller-init.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ export const tokenDetectionControllerInit: ControllerInitFunction<
2727

2828
const controller = new TokenDetectionController({
2929
messenger: controllerMessenger,
30-
platform: 'mobile',
31-
useAccountsAPI: true,
3230
disabled: false,
3331
getBalancesInSingleCall: initMessenger.call.bind(
3432
initMessenger,

app/core/Engine/messengers/token-balances-controller-messenger.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,33 @@ export function getTokenBalancesControllerMessenger(
2828
});
2929
rootMessenger.delegate({
3030
actions: [
31-
'NetworkController:getNetworkClientById',
3231
'NetworkController:getState',
33-
'TokensController:getState',
32+
'NetworkController:getNetworkClientById',
3433
'PreferencesController:getState',
34+
'TokensController:getState',
35+
'TokenDetectionController:addDetectedTokensViaPolling',
36+
'TokenDetectionController:addDetectedTokensViaWs',
37+
'TokenDetectionController:detectTokens',
3538
'AccountsController:getSelectedAccount',
3639
'AccountsController:listAccounts',
3740
'AccountTrackerController:getState',
3841
'AccountTrackerController:updateNativeBalances',
3942
'AccountTrackerController:updateStakedBalances',
40-
'TokenDetectionController:addDetectedTokensViaWs',
43+
'KeyringController:getState',
4144
'AuthenticationController:getBearerToken',
4245
],
4346
events: [
44-
'TokensController:stateChange',
45-
'PreferencesController:stateChange',
4647
'NetworkController:stateChange',
48+
'PreferencesController:stateChange',
49+
'TokensController:stateChange',
4750
'KeyringController:accountRemoved',
51+
'KeyringController:lock',
52+
'KeyringController:unlock',
4853
'AccountActivityService:balanceUpdated',
4954
'AccountActivityService:statusChanged',
5055
'AccountsController:selectedEvmAccountChange',
56+
'TransactionController:transactionConfirmed',
57+
'TransactionController:incomingTransactionsReceived',
5158
],
5259
messenger,
5360
});

app/core/Engine/messengers/token-detection-controller-messenger.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,26 @@ export function getTokenDetectionControllerMessenger(
3030
});
3131
rootMessenger.delegate({
3232
actions: [
33+
'AccountsController:getAccount',
3334
'AccountsController:getSelectedAccount',
35+
'KeyringController:getState',
3436
'NetworkController:getNetworkClientById',
3537
'NetworkController:getNetworkConfigurationByNetworkClientId',
3638
'NetworkController:getState',
37-
'KeyringController:getState',
38-
'PreferencesController:getState',
39-
'TokenListController:getState',
4039
'TokensController:getState',
4140
'TokensController:addDetectedTokens',
42-
'AccountsController:getAccount',
41+
'TokenListController:getState',
42+
'PreferencesController:getState',
4343
'TokensController:addTokens',
4444
'NetworkController:findNetworkClientIdByChainId',
45-
'AuthenticationController:getBearerToken',
4645
],
4746
events: [
47+
'AccountsController:selectedEvmAccountChange',
4848
'KeyringController:lock',
4949
'KeyringController:unlock',
50-
'PreferencesController:stateChange',
5150
'NetworkController:networkDidChange',
5251
'TokenListController:stateChange',
53-
'AccountsController:selectedEvmAccountChange',
52+
'PreferencesController:stateChange',
5453
'TransactionController:transactionConfirmed',
5554
],
5655
messenger,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"@metamask/address-book-controller": "^7.0.0",
199199
"@metamask/app-metadata-controller": "^2.0.0",
200200
"@metamask/approval-controller": "^8.0.0",
201-
"@metamask/assets-controllers": "^94.0.0",
201+
"@metamask/assets-controllers": "^94.1.0",
202202
"@metamask/base-controller": "^9.0.0",
203203
"@metamask/bitcoin-wallet-snap": "^1.8.0",
204204
"@metamask/bridge-controller": "^64.1.0",

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7186,9 +7186,9 @@ __metadata:
71867186
languageName: node
71877187
linkType: hard
71887188

7189-
"@metamask/assets-controllers@npm:^94.0.0":
7190-
version: 94.0.0
7191-
resolution: "@metamask/assets-controllers@npm:94.0.0"
7189+
"@metamask/assets-controllers@npm:^94.1.0":
7190+
version: 94.1.0
7191+
resolution: "@metamask/assets-controllers@npm:94.1.0"
71927192
dependencies:
71937193
"@ethereumjs/util": "npm:^9.1.0"
71947194
"@ethersproject/abi": "npm:^5.7.0"
@@ -7236,7 +7236,7 @@ __metadata:
72367236
peerDependencies:
72377237
"@metamask/providers": ^22.0.0
72387238
webextension-polyfill: ^0.10.0 || ^0.11.0 || ^0.12.0
7239-
checksum: 10/86324e75db4adffbfc7c4f93138de25242360578e3aa0fd26f78ef84d4390fb04042cb1582d64139754de60f315a9b8a8458850c65b0b764b95eb6435f3bb054
7239+
checksum: 10/80f0fb88d55fd747540f141154a59eb9b49df8546d81881bb7f9683d92b462b73ede18fced3f9c4a551da3037b8f27886f1ec297d55e9a4eeb2f1c18b8ea65e7
72407240
languageName: node
72417241
linkType: hard
72427242

@@ -34207,7 +34207,7 @@ __metadata:
3420734207
"@metamask/address-book-controller": "npm:^7.0.0"
3420834208
"@metamask/app-metadata-controller": "npm:^2.0.0"
3420934209
"@metamask/approval-controller": "npm:^8.0.0"
34210-
"@metamask/assets-controllers": "npm:^94.0.0"
34210+
"@metamask/assets-controllers": "npm:^94.1.0"
3421134211
"@metamask/auto-changelog": "npm:^5.3.0"
3421234212
"@metamask/base-controller": "npm:^9.0.0"
3421334213
"@metamask/bitcoin-wallet-snap": "npm:^1.8.0"

0 commit comments

Comments
 (0)