Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,12 @@
},
"packages/assets-controllers/src/TokenDetectionController.test.ts": {
"no-restricted-syntax": {
"count": 2
"count": 1
}
},
"packages/assets-controllers/src/TokenDetectionController.ts": {
"no-restricted-syntax": {
"count": 6
"count": 3
}
},
"packages/assets-controllers/src/TokenListController.test.ts": {
Expand Down Expand Up @@ -475,7 +475,7 @@
"count": 6
},
"no-restricted-syntax": {
"count": 4
"count": 3
}
},
"packages/assets-controllers/src/TokensController.ts": {
Expand All @@ -486,7 +486,7 @@
"count": 1
},
"@typescript-eslint/prefer-optional-chain": {
"count": 4
"count": 3
},
"id-length": {
"count": 1
Expand All @@ -498,7 +498,7 @@
"count": 1
},
"no-restricted-syntax": {
"count": 2
"count": 1
},
"require-atomic-updates": {
"count": 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "960.0.0",
"version": "963.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down
8 changes: 8 additions & 0 deletions packages/account-tree-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Expose missing public `AccountTreeController` methods through its messenger ([#8716](https://github.com/MetaMask/core/pull/8716))
- The following actions are now available:
- `AccountTreeController:init`
- `AccountTreeController:reinit`
- Corresponding action types are available as well.

## [7.2.0]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,29 @@

import type { AccountTreeController } from './AccountTreeController';

/**
* Initialize the controller's state.
*
* It constructs the initial state of the account tree (tree nodes, nodes
* names, metadata, etc..) and will automatically update the controller's
* state with it.
*/
export type AccountTreeControllerInitAction = {
type: `AccountTreeController:init`;
handler: AccountTreeController['init'];
};

/**
* Re-initialize the controller's state.
*
* This is done in one single (atomic) `update` block to avoid having a temporary
* cleared state. Use this when you need to force a full re-init even if already initialized.
*/
export type AccountTreeControllerReinitAction = {
type: `AccountTreeController:reinit`;
handler: AccountTreeController['reinit'];
};

/**
* Gets the account wallet object from its ID.
*
Expand Down Expand Up @@ -180,6 +203,8 @@ export type AccountTreeControllerSyncWithUserStorageAtLeastOnceAction = {
* Union of all AccountTreeController action types.
*/
export type AccountTreeControllerMethodActions =
| AccountTreeControllerInitAction
| AccountTreeControllerReinitAction
| AccountTreeControllerGetAccountWalletObjectAction
| AccountTreeControllerGetAccountWalletObjectsAction
| AccountTreeControllerGetAccountsFromSelectedAccountGroupAction
Expand Down
2 changes: 2 additions & 0 deletions packages/account-tree-controller/src/AccountTreeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const MESSENGER_EXPOSED_METHODS = [
'clearState',
'syncWithUserStorage',
'syncWithUserStorageAtLeastOnce',
'init',
'reinit',
] as const;

const accountTreeControllerMetadata: StateMetadata<AccountTreeControllerState> =
Expand Down
2 changes: 2 additions & 0 deletions packages/account-tree-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export type {
AccountTreeControllerClearStateAction,
AccountTreeControllerSyncWithUserStorageAction,
AccountTreeControllerSyncWithUserStorageAtLeastOnceAction,
AccountTreeControllerInitAction,
AccountTreeControllerReinitAction,
} from './AccountTreeController-method-action-types';

export type { AccountContext } from './AccountTreeController';
Expand Down
11 changes: 10 additions & 1 deletion packages/assets-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [6.4.0]

### Added

- Expose missing `AssetsController:setSelectedCurrency` action through its messenger ([#8719](https://github.com/MetaMask/core/pull/8719))
- Corresponding action type is available as well.

### Changed

- Bump `@metamask/transaction-controller` from `^65.0.0` to `^65.1.0` ([#8691](https://github.com/MetaMask/core/pull/8691))
- Bump `@metamask/network-enablement-controller` from `^5.0.2` to `^5.1.0` ([#8665](https://github.com/MetaMask/core/pull/8665))
- Bump `@metamask/keyring-controller` from `^25.3.0` to `^25.4.0` ([#8665](https://github.com/MetaMask/core/pull/8665))
- Bump `@metamask/accounts-controller` from `^37.2.0` to `^38.0.0` ([#8665](https://github.com/MetaMask/core/pull/8665))
- Bump `@metamask/account-tree-controller` from `^7.1.0` to `^7.2.0` ([#8665](https://github.com/MetaMask/core/pull/8665))
- Bump `@metamask/assets-controllers` from `^105.1.0` to `^106.0.0` ([#8721](https://github.com/MetaMask/core/pull/8721))

## [6.3.0]

Expand Down Expand Up @@ -412,7 +420,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.3.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.4.0...HEAD
[6.4.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.3.0...@metamask/assets-controller@6.4.0
[6.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.2.1...@metamask/assets-controller@6.3.0
[6.2.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.2.0...@metamask/assets-controller@6.2.1
[6.2.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.1.0...@metamask/assets-controller@6.2.0
Expand Down
4 changes: 2 additions & 2 deletions packages/assets-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/assets-controller",
"version": "6.3.0",
"version": "6.4.0",
"description": "Tracks assets balances/prices and handles token detection across all digital assets",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -58,7 +58,7 @@
"@ethersproject/providers": "^5.7.0",
"@metamask/account-tree-controller": "^7.2.0",
"@metamask/accounts-controller": "^38.0.0",
"@metamask/assets-controllers": "^105.1.0",
"@metamask/assets-controllers": "^106.0.0",
"@metamask/base-controller": "^9.1.0",
"@metamask/client-controller": "^1.0.1",
"@metamask/controller-utils": "^11.20.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ export type AssetsControllerUnhideAssetAction = {
handler: AssetsController['unhideAsset'];
};

/**
* Set the current currency.
*
* @param selectedCurrency - The ISO 4217 currency code to set.
*/
export type AssetsControllerSetSelectedCurrencyAction = {
type: `AssetsController:setSelectedCurrency`;
handler: AssetsController['setSelectedCurrency'];
};

/**
* Union of all AssetsController action types.
*/
Expand All @@ -129,4 +139,5 @@ export type AssetsControllerMethodActions =
| AssetsControllerRemoveCustomAssetAction
| AssetsControllerGetCustomAssetsAction
| AssetsControllerHideAssetAction
| AssetsControllerUnhideAssetAction;
| AssetsControllerUnhideAssetAction
| AssetsControllerSetSelectedCurrencyAction;
4 changes: 4 additions & 0 deletions packages/assets-controller/src/AssetsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const MESSENGER_EXPOSED_METHODS = [
'getCustomAssets',
'hideAsset',
'unhideAsset',
'setSelectedCurrency',
] as const;

/** Default polling interval hint for data sources (30 seconds) */
Expand Down Expand Up @@ -3165,5 +3166,8 @@ export class AssetsController extends BaseController<
this.messenger.unregisterActionHandler('AssetsController:getCustomAssets');
this.messenger.unregisterActionHandler('AssetsController:hideAsset');
this.messenger.unregisterActionHandler('AssetsController:unhideAsset');
this.messenger.unregisterActionHandler(
'AssetsController:setSelectedCurrency',
);
}
}
1 change: 1 addition & 0 deletions packages/assets-controller/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type {
AssetsControllerUnhideAssetAction,
AssetsControllerGetExchangeRatesForBridgeAction,
AssetsControllerGetStateForTransactionPayAction,
AssetsControllerSetSelectedCurrencyAction,
} from './AssetsController-method-action-types';

// Core types
Expand Down
18 changes: 17 additions & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [106.0.0]

### Added

- Add `TokenListService`, a shared service for fetching and caching the token list per chain ([#8700](https://github.com/MetaMask/core/pull/8700))
- Wraps `@tanstack/query-core` to cache results in-memory for 4 hours per chain ID, matching `TokenListController`'s existing threshold.
- Multiple controllers sharing the same `TokenListService` instance share the same cache: only one HTTP request is made per chain per 4-hour window regardless of how many callers invoke `fetchTokensByChainId`.
- Exported from the package as `TokenListService` and `buildTokenListMap`.
- Add `@tanstack/query-core` `^5.62.16` as a direct dependency ([#8700](https://github.com/MetaMask/core/pull/8700))
- Expose missing public `AccountTrackerController` methods through its messenger ([#8693](https://github.com/MetaMask/core/pull/8693))
- The following actions are now available:
- `AccountTrackerController:refresh`
Expand All @@ -22,6 +29,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **BREAKING:** `TokenDetectionController` now requires a `tokenListService: TokenListService` constructor option ([#8700](https://github.com/MetaMask/core/pull/8700))
- Token list data is fetched directly from `TokenListService` instead of reading `TokenListController` state on each detection pass.
- `GetTokenListState` has been removed from `AllowedActions` and `TokenListStateChange` has been removed from `AllowedEvents` on `TokenDetectionControllerMessenger`.
- **BREAKING:** `TokensController` now requires a `tokenListService: TokenListService` constructor option ([#8700](https://github.com/MetaMask/core/pull/8700))
- `TokenListStateChange` has been removed from `AllowedEvents` on `TokensControllerMessenger`.
- Token `name` and `rwaData` enrichment now happens once at controller initialization instead of reactively on every `TokenListController:stateChange` event.
- Bump `@metamask/transaction-controller` from `^65.0.0` to `^65.1.0` ([#8691](https://github.com/MetaMask/core/pull/8691))
- Switch the default mUSD asset from upfront `allTokens` state seeding to detection-based discovery on Ethereum mainnet (`0x1`), Linea (`0xe708`), and Monad mainnet (`0x8f`) ([#8688](https://github.com/MetaMask/core/pull/8688))
- `TokenDetectionController` now merges mUSD into the in-memory token list cache for these chains so it is treated as a regular detection candidate, replacing the previous `start()`-time `TokensController:addTokens` call and the per-event re-seed runs.
Expand All @@ -34,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- `TokenDetectionController` no longer restarts token detection when `TokenListController` publishes a `stateChange` event ([#8700](https://github.com/MetaMask/core/pull/8700))
- Detection is still triggered on wallet unlock, account change, network change, and preference changes; the extra restart that occurred whenever `TokenListController` refreshed its cache is gone.
- Stop seeding mUSD directly into `TokensController` state and remove the related event subscriptions ([#8688](https://github.com/MetaMask/core/pull/8688))
- `TokensController` no longer subscribes to `KeyringController:unlock`, `AccountsController:accountAdded`, `AccountsController:selectedEvmAccountChange`, `NetworkController:networkAdded`, or `NetworkController:stateChange` for mUSD seeding purposes.
- `TokensControllerMessenger` no longer requires `NetworkControllerNetworkAddedEvent`, `AccountsControllerAccountAddedEvent`, or `KeyringControllerUnlockEvent` as allowed events.
Expand Down Expand Up @@ -3028,7 +3043,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@105.1.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@106.0.0...HEAD
[106.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@105.1.0...@metamask/assets-controllers@106.0.0
[105.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@105.0.0...@metamask/assets-controllers@105.1.0
[105.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@104.3.0...@metamask/assets-controllers@105.0.0
[104.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@104.2.0...@metamask/assets-controllers@104.3.0
Expand Down
3 changes: 2 additions & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/assets-controllers",
"version": "105.1.0",
"version": "106.0.0",
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -87,6 +87,7 @@
"@metamask/storage-service": "^1.0.1",
"@metamask/transaction-controller": "^65.1.0",
"@metamask/utils": "^11.9.0",
"@tanstack/query-core": "^5.62.16",
"@types/bn.js": "^5.1.5",
"@types/uuid": "^8.3.0",
"async-mutex": "^0.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type TokenDetectionControllerStopAction = {
};

/**
* For each token in the token list provided by the TokenListController, checks the token's balance for the selected account address on the active network.
* For each token in the token list provided by the TokenListService, checks the token's balance for the selected account address on the active network.
* On mainnet, if token detection is disabled in preferences, ERC20 token auto detection will be triggered for each contract address in the legacy token list from the @metamask/contract-metadata repo.
*
* @param options - Options for token detection.
Expand Down
Loading
Loading