From a680605b7a95fb97c330841ad78a6ecc25095398 Mon Sep 17 00:00:00 2001 From: sahar-fehri Date: Mon, 4 Mar 2024 13:43:12 +0100 Subject: [PATCH 1/4] fix: update usage of OP goerli to OP Sepolia (#3999) ## Explanation This PR replaces the reference to OP goerli to OP sepolia. It also renames the variable `OPTIMISM_TESTNET` to `OPTIMISM_SEPOLIA`. Renaming the variable and switching to Sepolia is a breaking change, please use Sepolia and `OPTIMISM_SEPOLIA` instead of `OPTIMISM_TESTNET`. ## References * Fixes https://github.com/MetaMask/mobile-planning/issues/1569 * Related to [#67890](https://github.com/MetaMask/metamask-mobile/pull/8784) ## Changelog ### `@metamask/transaction-controller` **Removed** - **BREAKING**: Renamed `OPTIMISM_TESTNET` to `OPTIMISM_SEPOLIA` and updated the chainId accordingly. - **BREAKING**: Updated the etherscan subdomain that was for OPTIMISM_TESTNET from goerli to sepolia. ### `@metamask/preferences-controller` **Removed** - **BREAKING**: Renamed `OPTIMISM_TESTNET` to `OPTIMISM_SEPOLIA` and updated the chainId accordingly. ### `@metamask/name-controller` **Removed** - **BREAKING**: Renamed `OPTIMISM_TESTNET` to `OPTIMISM_SEPOLIA` and updated the chainId accordingly. - **BREAKING**: updated the etherscan subdomain for OPTIMISM_TESTNET from goerli to sepolia ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- packages/name-controller/src/constants.ts | 6 +++--- .../preferences-controller/src/PreferencesController.ts | 2 +- packages/preferences-controller/src/constants.ts | 2 +- packages/transaction-controller/src/constants.ts | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/name-controller/src/constants.ts b/packages/name-controller/src/constants.ts index 6a5b4767f5..0c1e930c43 100644 --- a/packages/name-controller/src/constants.ts +++ b/packages/name-controller/src/constants.ts @@ -6,7 +6,7 @@ export const CHAIN_IDS = { BSC: '0x38', BSC_TESTNET: '0x61', OPTIMISM: '0xa', - OPTIMISM_TESTNET: '0x1a4', + OPTIMISM_SEPOLIA: '0xaa37dc', POLYGON: '0x89', POLYGON_TESTNET: '0x13881', AVALANCHE: '0xa86a', @@ -58,9 +58,9 @@ export const ETHERSCAN_SUPPORTED_NETWORKS = { domain: DEFAULT_ETHERSCAN_DOMAIN, subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`, }, - [CHAIN_IDS.OPTIMISM_TESTNET]: { + [CHAIN_IDS.OPTIMISM_SEPOLIA]: { domain: DEFAULT_ETHERSCAN_DOMAIN, - subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`, + subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`, }, [CHAIN_IDS.POLYGON]: { domain: 'polygonscan.com', diff --git a/packages/preferences-controller/src/PreferencesController.ts b/packages/preferences-controller/src/PreferencesController.ts index b7e53e5d69..540d841c8c 100644 --- a/packages/preferences-controller/src/PreferencesController.ts +++ b/packages/preferences-controller/src/PreferencesController.ts @@ -178,7 +178,7 @@ export function getDefaultPreferencesState() { [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC]: true, [ETHERSCAN_SUPPORTED_CHAIN_IDS.BSC_TESTNET]: true, [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM]: true, - [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_TESTNET]: true, + [ETHERSCAN_SUPPORTED_CHAIN_IDS.OPTIMISM_SEPOLIA]: true, [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON]: true, [ETHERSCAN_SUPPORTED_CHAIN_IDS.POLYGON_TESTNET]: true, [ETHERSCAN_SUPPORTED_CHAIN_IDS.AVALANCHE]: true, diff --git a/packages/preferences-controller/src/constants.ts b/packages/preferences-controller/src/constants.ts index 2fd321a5a9..e546c999ec 100644 --- a/packages/preferences-controller/src/constants.ts +++ b/packages/preferences-controller/src/constants.ts @@ -4,7 +4,7 @@ export const ETHERSCAN_SUPPORTED_CHAIN_IDS = { BSC: '0x38', BSC_TESTNET: '0x61', OPTIMISM: '0xa', - OPTIMISM_TESTNET: '0x1a4', + OPTIMISM_SEPOLIA: '0xaa37dc', POLYGON: '0x89', POLYGON_TESTNET: '0x13881', AVALANCHE: '0xa86a', diff --git a/packages/transaction-controller/src/constants.ts b/packages/transaction-controller/src/constants.ts index d35ff04335..2b73c35f01 100644 --- a/packages/transaction-controller/src/constants.ts +++ b/packages/transaction-controller/src/constants.ts @@ -4,7 +4,7 @@ export const CHAIN_IDS = { BSC: '0x38', BSC_TESTNET: '0x61', OPTIMISM: '0xa', - OPTIMISM_TESTNET: '0x1a4', + OPTIMISM_SEPOLIA: '0xaa37dc', POLYGON: '0x89', POLYGON_TESTNET: '0x13881', AVALANCHE: '0xa86a', @@ -58,9 +58,9 @@ export const ETHERSCAN_SUPPORTED_NETWORKS = { domain: DEFAULT_ETHERSCAN_DOMAIN, subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-optimistic`, }, - [CHAIN_IDS.OPTIMISM_TESTNET]: { + [CHAIN_IDS.OPTIMISM_SEPOLIA]: { domain: DEFAULT_ETHERSCAN_DOMAIN, - subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-goerli-optimistic`, + subdomain: `${DEFAULT_ETHERSCAN_SUBDOMAIN_PREFIX}-sepolia-optimistic`, }, [CHAIN_IDS.POLYGON]: { domain: 'polygonscan.com', @@ -106,5 +106,5 @@ export const ETHERSCAN_SUPPORTED_NETWORKS = { export const GAS_BUFFER_CHAIN_OVERRIDES = { [CHAIN_IDS.OPTIMISM]: 1, - [CHAIN_IDS.OPTIMISM_TESTNET]: 1, + [CHAIN_IDS.OPTIMISM_SEPOLIA]: 1, }; From 34bf8f08fc48aacc12ee6a4478ad04f92032de53 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Mon, 4 Mar 2024 12:21:29 -0500 Subject: [PATCH 2/4] [token-detection-controller] Refactor `detectTokens` method (#3938) ## Explanation Adds refactors and cosmetic, typing fixes to #3923. - Extracts three methods from `TokenDetectionController`'s `detectTokens` method: - `#getCorrectChainIdAndNetworkClientId` - `#getTokenListAndSlicesOfTokensToDetect` - `#addDetectedTokens` - Maintains distinction between class fields `#selectedAddress`, `#networkClientId` and corresponding parameters used in `detectTokens` and its helper methods, so that `detectTokens` method can be used independently of polling/passive detection. - [Refactor `#getCorrectChainIdAndNetworkClientId`](https://github.com/MetaMask/core/pull/3938/commits/c75fb3bd37ddf2715ed250bdd2c2331a54008b72) to remove `findNetworkClientIdByChainId` which might return inconsistent/unexpected results, and replace it with `getState`, `getNetworkClientById` - [Add missing method return types](https://github.com/MetaMask/core/pull/3938/commits/5c2e8879fd4dea4a99125d0ffe9a29b4aef0cd21) - [Type networkClientId as `NetworkClientId`](https://github.com/MetaMask/core/pull/3938/commits/05be5d2e842c516217871f62cfd7f66de0590fa1) - [Fix excess properties from legacy token list, define `LegacyToken`, `TokenDetectionMap`](https://github.com/MetaMask/core/pull/3938/commits/ea4c5b883b4663a3369d0f76222abbe55baaca55) - Removes `#chainId` class field. ## References - Closes https://github.com/MetaMask/core/issues/1614 - Fixes https://github.com/MetaMask/core/issues/3661 - Blocked by (Follows from) #3923 - Blocking #3916 - Blocking #3918 ## Changelog ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --------- Co-authored-by: Brian Bergeron Co-authored-by: Elliot Winkler --- packages/assets-controllers/CHANGELOG.md | 7 +- packages/assets-controllers/jest.config.js | 8 +- .../src/TokenDetectionController.test.ts | 130 +++++----- .../src/TokenDetectionController.ts | 245 ++++++++++-------- 4 files changed, 203 insertions(+), 187 deletions(-) diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index 2c6d29df14..916278a425 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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 messenger actions `AccountsController:getSelectedAccount`, `NetworkController:findNetworkClientIdByChainId`, `NetworkController:getNetworkConfigurationByNetworkClientId`, `NetworkController:getProviderConfig`, `KeyringController:getState`, `PreferencesController:getState`, `TokenListController:getState`, `TokensController:getState`, `TokensController:addDetectedTokens`. ([#3775](https://github.com/MetaMask/core/pull/3775/)), ([#3923](https://github.com/MetaMask/core/pull/3923/)) +- **BREAKING:** `TokenDetectionController` newly subscribes to the `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`, `KeyringController:lock`, `KeyringController:unlock` events, and allows messenger actions `AccountsController:getSelectedAccount`, `NetworkController:getNetworkClientById`, `NetworkController:getNetworkConfigurationByNetworkClientId`, `NetworkController:getState`, `KeyringController:getState`, `PreferencesController:getState`, `TokenListController:getState`, `TokensController:getState`, `TokensController:addDetectedTokens`. ([#3775](https://github.com/MetaMask/core/pull/3775/), [#3923](https://github.com/MetaMask/core/pull/3923/), [#3938](https://github.com/MetaMask/core/pull/3938)) - `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, `TokensControllerStateChangeEvent`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) ### Changed @@ -25,11 +25,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The constructor option `selectedAddress` no longer defaults to `''` if omitted. Instead, the correct address is assigned using the `AccountsController:getSelectedAccount` messenger action. - **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). - **BREAKING:** The `TokensState` type is now defined as a type alias rather than an interface. ([#3690](https://github.com/MetaMask/core/pull/3690/)) - - This is breaking because it could affect how this type is used with other types, such as `Json`, which does not support TypeScript interfaces. + - `TokensState` now extends the `Record` types, and it has an index signature of `string`, making it compatible with the `BaseControllerV2` state object constraint of `Record`. + - The `detectTokens` method can now process an arbitrary number of tokens in batches of 1000. ([#3938](https://github.com/MetaMask/core/pull/3938)) ### Removed -- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, `addDetectedTokens`. ([#3690](https://github.com/MetaMask/core/pull/3690/), [#3775](https://github.com/MetaMask/core/pull/3775/)) +- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `networkClientId`, `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, `addDetectedTokens`. ([#3690](https://github.com/MetaMask/core/pull/3690/), [#3775](https://github.com/MetaMask/core/pull/3775/), [#3938](https://github.com/MetaMask/core/pull/3938)) - **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/)) - **BREAKING:** `TokensController` constructor no longer accepts options `onPreferencesStateChange`, `onNetworkDidChange`, `onTokenListStateChange`, `getNetworkClientById`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) - **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) diff --git a/packages/assets-controllers/jest.config.js b/packages/assets-controllers/jest.config.js index ecc2975e25..e927d0100d 100644 --- a/packages/assets-controllers/jest.config.js +++ b/packages/assets-controllers/jest.config.js @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, { // An object that configures minimum threshold enforcement for coverage results coverageThreshold: { global: { - branches: 88.58, - functions: 96.98, - lines: 97.35, - statements: 97.4, + branches: 88.67, + functions: 97, + lines: 97.36, + statements: 97.41, }, }, diff --git a/packages/assets-controllers/src/TokenDetectionController.test.ts b/packages/assets-controllers/src/TokenDetectionController.test.ts index 81d82ce848..b30e755c87 100644 --- a/packages/assets-controllers/src/TokenDetectionController.test.ts +++ b/packages/assets-controllers/src/TokenDetectionController.test.ts @@ -12,10 +12,11 @@ import type { NetworkState, NetworkConfiguration, NetworkController, - ProviderConfig, NetworkClientId, } from '@metamask/network-controller'; import { defaultState as defaultNetworkState } from '@metamask/network-controller'; +import type { AutoManagedNetworkClient } from '@metamask/network-controller/src/create-auto-managed-network-client'; +import type { CustomNetworkClientConfiguration } from '@metamask/network-controller/src/types'; import { getDefaultPreferencesState, type PreferencesState, @@ -142,9 +143,9 @@ function buildTokenDetectionControllerMessenger( allowedActions: [ 'AccountsController:getSelectedAccount', 'KeyringController:getState', - 'NetworkController:findNetworkClientIdByChainId', + 'NetworkController:getNetworkClientById', 'NetworkController:getNetworkConfigurationByNetworkClientId', - 'NetworkController:getProviderConfig', + 'NetworkController:getState', 'TokensController:getState', 'TokensController:addDetectedTokens', 'TokenListController:getState', @@ -271,10 +272,13 @@ describe('TokenDetectionController', () => { { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.goerli, }, }, - async ({ controller }) => { + async ({ controller, mockNetworkState }) => { + mockNetworkState({ + ...defaultNetworkState, + selectedNetworkClientId: NetworkType.goerli, + }); await controller.start(); expect(mockGetBalancesInSingleCall).not.toHaveBeenCalled(); @@ -291,7 +295,6 @@ describe('TokenDetectionController', () => { { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -339,19 +342,26 @@ describe('TokenDetectionController', () => { { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: 'polygon', selectedAddress, }, }, async ({ controller, - mockGetProviderConfig, mockTokenListGetState, + mockNetworkState, + mockGetNetworkClientById, callActionSpy, }) => { - mockGetProviderConfig({ - chainId: '0x89', - } as unknown as ProviderConfig); + mockNetworkState({ + ...defaultNetworkState, + selectedNetworkClientId: 'polygon', + }); + mockGetNetworkClientById( + () => + ({ + configuration: { chainId: '0x89' }, + } as unknown as AutoManagedNetworkClient), + ); mockTokenListGetState({ ...getDefaultTokenListState(), @@ -399,7 +409,6 @@ describe('TokenDetectionController', () => { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, interval, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -459,7 +468,6 @@ describe('TokenDetectionController', () => { { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -510,8 +518,6 @@ describe('TokenDetectionController', () => { { options: { getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, - selectedAddress: '', }, }, async ({ controller, mockTokenListGetState, callActionSpy }) => { @@ -569,7 +575,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, }, @@ -625,7 +630,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -680,7 +684,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, isKeyringUnlocked: false, @@ -738,7 +741,6 @@ describe('TokenDetectionController', () => { options: { disabled: true, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, }, @@ -805,7 +807,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, }, @@ -863,7 +864,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -931,7 +931,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, }, @@ -979,7 +978,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1031,7 +1029,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, isKeyringUnlocked: false, @@ -1080,7 +1077,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, isKeyringUnlocked: false, @@ -1142,7 +1138,6 @@ describe('TokenDetectionController', () => { options: { disabled: true, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress: firstSelectedAddress, }, }, @@ -1190,7 +1185,6 @@ describe('TokenDetectionController', () => { options: { disabled: true, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1258,7 +1252,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1315,7 +1308,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1367,7 +1359,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1415,7 +1406,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, isKeyringUnlocked: false, @@ -1466,7 +1456,6 @@ describe('TokenDetectionController', () => { options: { disabled: true, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1526,7 +1515,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1583,7 +1571,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1619,7 +1606,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, isKeyringUnlocked: false, @@ -1668,7 +1654,6 @@ describe('TokenDetectionController', () => { options: { disabled: true, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1725,7 +1710,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1792,15 +1776,19 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.goerli, selectedAddress, }, }, async ({ controller, + mockNetworkState, triggerPreferencesStateChange, callActionSpy, }) => { + mockNetworkState({ + ...defaultNetworkState, + selectedNetworkClientId: NetworkType.goerli, + }); triggerPreferencesStateChange({ ...getDefaultPreferencesState(), useTokenDetection: false, @@ -1832,7 +1820,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1852,17 +1839,12 @@ describe('TokenDetectionController', () => { expect(callActionSpy).toHaveBeenLastCalledWith( 'TokensController:addDetectedTokens', Object.values(STATIC_MAINNET_TOKEN_LIST).map((token) => { - const newToken = { - ...token, + const { iconUrl, ...tokenMetadata } = token; + return { + ...tokenMetadata, image: token.iconUrl, isERC721: false, }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - delete (newToken as any).erc20; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - delete (newToken as any).erc721; - delete newToken.iconUrl; - return newToken; }), { selectedAddress, @@ -1883,7 +1865,6 @@ describe('TokenDetectionController', () => { options: { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -1938,7 +1919,6 @@ describe('TokenDetectionController', () => { disabled: false, getBalancesInSingleCall: mockGetBalancesInSingleCall, trackMetaMetricsEvent: mockTrackMetaMetricsEvent, - networkClientId: NetworkType.mainnet, selectedAddress, }, }, @@ -2002,9 +1982,9 @@ type WithControllerCallback = ({ mockTokensGetState, mockTokenListGetState, mockPreferencesGetState, - mockFindNetworkClientIdByChainId, + mockGetNetworkClientById, mockGetNetworkConfigurationByNetworkClientId, - mockGetProviderConfig, + mockNetworkState, callActionSpy, triggerKeyringUnlock, triggerKeyringLock, @@ -2019,13 +1999,15 @@ type WithControllerCallback = ({ mockTokensGetState: (state: TokensState) => void; mockTokenListGetState: (state: TokenListState) => void; mockPreferencesGetState: (state: PreferencesState) => void; - mockFindNetworkClientIdByChainId: ( - handler: (chainId: Hex) => NetworkClientId, + mockGetNetworkClientById: ( + handler: ( + networkClientId: NetworkClientId, + ) => AutoManagedNetworkClient, ) => void; mockGetNetworkConfigurationByNetworkClientId: ( - handler: (networkClientId: string) => NetworkConfiguration, + handler: (networkClientId: NetworkClientId) => NetworkConfiguration, ) => void; - mockGetProviderConfig: (config: ProviderConfig) => void; + mockNetworkState: (state: NetworkState) => void; callActionSpy: jest.SpyInstance; triggerKeyringUnlock: () => void; triggerKeyringLock: () => void; @@ -2076,10 +2058,20 @@ async function withController( isUnlocked: isKeyringUnlocked ?? true, } as KeyringControllerState), ); - const mockFindNetworkClientIdByChainId = jest.fn(); + const mockGetNetworkClientById = jest.fn< + ReturnType, + Parameters + >(); controllerMessenger.registerActionHandler( - 'NetworkController:findNetworkClientIdByChainId', - mockFindNetworkClientIdByChainId.mockReturnValue(NetworkType.mainnet), + 'NetworkController:getNetworkClientById', + mockGetNetworkClientById.mockImplementation(() => { + return { + configuration: { chainId: '0x1' }, + provider: {}, + destroy: {}, + blockTracker: {}, + } as unknown as AutoManagedNetworkClient; + }), ); const mockGetNetworkConfigurationByNetworkClientId = jest.fn< ReturnType, @@ -2093,13 +2085,10 @@ async function withController( }, ), ); - const mockGetProviderConfig = jest.fn(); + const mockNetworkState = jest.fn(); controllerMessenger.registerActionHandler( - 'NetworkController:getProviderConfig', - mockGetProviderConfig.mockReturnValue({ - type: NetworkType.mainnet, - chainId: '0x1', - } as unknown as ProviderConfig), + 'NetworkController:getState', + mockNetworkState.mockReturnValue({ ...defaultNetworkState }), ); const mockTokensState = jest.fn(); controllerMessenger.registerActionHandler( @@ -2130,7 +2119,6 @@ async function withController( const callActionSpy = jest.spyOn(controllerMessenger, 'call'); const controller = new TokenDetectionController({ - networkClientId: NetworkType.mainnet, getBalancesInSingleCall: jest.fn(), trackMetaMetricsEvent: jest.fn(), messenger: buildTokenDetectionControllerMessenger(controllerMessenger), @@ -2154,10 +2142,12 @@ async function withController( mockTokenListGetState: (state: TokenListState) => { mockTokenListState.mockReturnValue(state); }, - mockFindNetworkClientIdByChainId: ( - handler: (chainId: Hex) => NetworkClientId, + mockGetNetworkClientById: ( + handler: ( + networkClientId: NetworkClientId, + ) => AutoManagedNetworkClient, ) => { - mockFindNetworkClientIdByChainId.mockImplementation(handler); + mockGetNetworkClientById.mockImplementation(handler); }, mockGetNetworkConfigurationByNetworkClientId: ( handler: (networkClientId: NetworkClientId) => NetworkConfiguration, @@ -2166,8 +2156,8 @@ async function withController( handler, ); }, - mockGetProviderConfig: (config: ProviderConfig) => { - mockGetProviderConfig.mockReturnValue(config); + mockNetworkState: (state: NetworkState) => { + mockNetworkState.mockReturnValue(state); }, callActionSpy, triggerKeyringUnlock: () => { diff --git a/packages/assets-controllers/src/TokenDetectionController.ts b/packages/assets-controllers/src/TokenDetectionController.ts index d4d1cd8d2c..bda6be6f5f 100644 --- a/packages/assets-controllers/src/TokenDetectionController.ts +++ b/packages/assets-controllers/src/TokenDetectionController.ts @@ -16,9 +16,9 @@ import type { } from '@metamask/keyring-controller'; import type { NetworkClientId, - NetworkControllerFindNetworkClientIdByChainIdAction, + NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, - NetworkControllerGetProviderConfigAction, + NetworkControllerGetStateAction, NetworkControllerNetworkDidChangeEvent, } from '@metamask/network-controller'; import { StaticIntervalPollingController } from '@metamask/polling-controller'; @@ -32,8 +32,8 @@ import type { AssetsContractController } from './AssetsContractController'; import { isTokenDetectionSupportedForNetwork } from './assetsUtil'; import type { GetTokenListState, + TokenListMap, TokenListStateChange, - TokenListToken, } from './TokenListController'; import type { Token } from './TokenRatesController'; import type { @@ -63,25 +63,23 @@ export function isEqualCaseInsensitive( return value1.toLowerCase() === value2.toLowerCase(); } -type LegacyToken = Omit< - Token, - 'aggregators' | 'image' | 'balanceError' | 'isERC721' -> & { +type LegacyToken = { name: string; - logo: string; + logo: `${string}.svg`; + symbol: string; + decimals: number; erc20?: boolean; erc721?: boolean; }; +type TokenDetectionMap = { + [P in keyof TokenListMap]: Omit; +}; + export const STATIC_MAINNET_TOKEN_LIST = Object.entries( contractMap, -).reduce< - Record< - string, - Partial & Pick - > ->((acc, [base, contract]) => { - const { logo, ...tokenMetadata } = contract; +).reduce((acc, [base, contract]) => { + const { logo, erc20, erc721, ...tokenMetadata } = contract; return { ...acc, [base.toLowerCase()]: { @@ -107,9 +105,9 @@ export type TokenDetectionControllerActions = export type AllowedActions = | AccountsControllerGetSelectedAccountAction - | NetworkControllerFindNetworkClientIdByChainIdAction + | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetNetworkConfigurationByNetworkClientId - | NetworkControllerGetProviderConfigAction + | NetworkControllerGetStateAction | GetTokenListState | KeyringControllerGetStateAction | PreferencesControllerGetStateAction @@ -141,7 +139,6 @@ export type TokenDetectionControllerMessenger = RestrictedControllerMessenger< /** * Controller that passively polls on a set interval for Tokens auto detection * @property intervalId - Polling interval used to fetch new token rates - * @property chainId - The chain ID of the current network * @property selectedAddress - Vault selected address * @property networkClientId - The network client ID of the current selected network * @property disabled - Boolean to track if network requests are blocked @@ -156,12 +153,12 @@ export class TokenDetectionController extends StaticIntervalPollingController< > { #intervalId?: ReturnType; - #chainId: Hex; - #selectedAddress: string; #networkClientId: NetworkClientId; + #tokenList: TokenDetectionMap = {}; + #disabled: boolean; #isUnlocked: boolean; @@ -189,13 +186,11 @@ export class TokenDetectionController extends StaticIntervalPollingController< * @param options.messenger - The controller messaging system. * @param options.disabled - If set to true, all network requests are blocked. * @param options.interval - Polling interval used to fetch new token rates - * @param options.networkClientId - The selected network client ID of the current network * @param options.selectedAddress - Vault selected address * @param options.getBalancesInSingleCall - Gets the balances of a list of tokens for the given address. * @param options.trackMetaMetricsEvent - Sets options for MetaMetrics event tracking. */ constructor({ - networkClientId, selectedAddress, interval = DEFAULT_INTERVAL, disabled = true, @@ -203,7 +198,6 @@ export class TokenDetectionController extends StaticIntervalPollingController< trackMetaMetricsEvent, messenger, }: { - networkClientId: NetworkClientId; selectedAddress?: string; interval?: number; disabled?: boolean; @@ -229,21 +223,20 @@ export class TokenDetectionController extends StaticIntervalPollingController< this.#disabled = disabled; this.setIntervalLength(interval); - this.#networkClientId = networkClientId; this.#selectedAddress = selectedAddress ?? this.messagingSystem.call('AccountsController:getSelectedAccount') .address; - const { chainId } = - this.#getCorrectChainIdAndNetworkClientId(networkClientId); - this.#chainId = chainId; + + const { chainId, networkClientId } = + this.#getCorrectChainIdAndNetworkClientId(); + this.#networkClientId = networkClientId; const { useTokenDetection: defaultUseTokenDetection } = this.messagingSystem.call('PreferencesController:getState'); this.#isDetectionEnabledFromPreferences = defaultUseTokenDetection; - this.#isDetectionEnabledForNetwork = isTokenDetectionSupportedForNetwork( - this.#chainId, - ); + this.#isDetectionEnabledForNetwork = + isTokenDetectionSupportedForNetwork(chainId); this.#getBalancesInSingleCall = getBalancesInSingleCall; @@ -329,7 +322,6 @@ export class TokenDetectionController extends StaticIntervalPollingController< const { chainId: newChainId } = this.#getCorrectChainIdAndNetworkClientId(selectedNetworkClientId); - this.#chainId = newChainId; this.#isDetectionEnabledForNetwork = isTokenDetectionSupportedForNetwork(newChainId); @@ -346,30 +338,29 @@ export class TokenDetectionController extends StaticIntervalPollingController< /** * Allows controller to make active and passive polling requests */ - enable() { + enable(): void { this.#disabled = false; } /** * Blocks controller from making network calls */ - disable() { + disable(): void { this.#disabled = true; } /** * Internal isActive state - * - * @type {object} + * @type {boolean} */ - get isActive() { + get isActive(): boolean { return !this.#disabled && this.#isUnlocked; } /** * Start polling for detected tokens. */ - async start() { + async start(): Promise { this.enable(); await this.#startPolling(); } @@ -377,12 +368,12 @@ export class TokenDetectionController extends StaticIntervalPollingController< /** * Stop polling for detected tokens. */ - stop() { + stop(): void { this.disable(); this.#stopPolling(); } - #stopPolling() { + #stopPolling(): void { if (this.#intervalId) { clearInterval(this.#intervalId); } @@ -418,21 +409,23 @@ export class TokenDetectionController extends StaticIntervalPollingController< }; } } - const { chainId } = this.messagingSystem.call( - 'NetworkController:getProviderConfig', + const { selectedNetworkClientId } = this.messagingSystem.call( + 'NetworkController:getState', ); - const newNetworkClientId = this.messagingSystem.call( - 'NetworkController:findNetworkClientIdByChainId', - chainId, + const { + configuration: { chainId }, + } = this.messagingSystem.call( + 'NetworkController:getNetworkClientById', + selectedNetworkClientId, ); return { chainId, - networkClientId: newNetworkClientId, + networkClientId: selectedNetworkClientId, }; } async _executePoll( - networkClientId: string, + networkClientId: NetworkClientId, options: { address: string }, ): Promise { if (!this.isActive) { @@ -455,7 +448,10 @@ export class TokenDetectionController extends StaticIntervalPollingController< async #restartTokenDetection({ selectedAddress, networkClientId, - }: { selectedAddress?: string; networkClientId?: string } = {}) { + }: { + selectedAddress?: string; + networkClientId?: NetworkClientId; + } = {}): Promise { await this.detectTokens({ networkClientId, selectedAddress, @@ -484,15 +480,14 @@ export class TokenDetectionController extends StaticIntervalPollingController< const addressAgainstWhichToDetect = selectedAddress ?? this.#selectedAddress; - const { - chainId: chainIdAgainstWhichToDetect, - networkClientId: networkClientIdAgainstWhichToDetect, - } = this.#getCorrectChainIdAndNetworkClientId(networkClientId); + const { chainId, networkClientId: selectedNetworkClientId } = + this.#getCorrectChainIdAndNetworkClientId(networkClientId); + const chainIdAgainstWhichToDetect = chainId; + const networkClientIdAgainstWhichToDetect = selectedNetworkClientId; if (!isTokenDetectionSupportedForNetwork(chainIdAgainstWhichToDetect)) { return; } - if ( !this.#isDetectionEnabledFromPreferences && chainIdAgainstWhichToDetect !== ChainId.mainnet @@ -505,12 +500,30 @@ export class TokenDetectionController extends StaticIntervalPollingController< const { tokensChainsCache } = this.messagingSystem.call( 'TokenListController:getState', ); - const tokenList = - tokensChainsCache[chainIdAgainstWhichToDetect]?.data ?? {}; - const tokenListUsed = isTokenDetectionInactiveInMainnet + this.#tokenList = isTokenDetectionInactiveInMainnet ? STATIC_MAINNET_TOKEN_LIST - : tokenList; + : tokensChainsCache[chainIdAgainstWhichToDetect]?.data ?? {}; + + for (const tokensSlice of this.#getSlicesOfTokensToDetect({ + chainId: chainIdAgainstWhichToDetect, + selectedAddress: addressAgainstWhichToDetect, + })) { + await this.#addDetectedTokens({ + tokensSlice, + selectedAddress: addressAgainstWhichToDetect, + networkClientId: networkClientIdAgainstWhichToDetect, + chainId: chainIdAgainstWhichToDetect, + }); + } + } + #getSlicesOfTokensToDetect({ + chainId, + selectedAddress, + }: { + chainId: Hex; + selectedAddress: string; + }): string[][] { const { allTokens, allDetectedTokens, allIgnoredTokens } = this.messagingSystem.call('TokensController:getState'); const [tokensAddresses, detectedTokensAddresses, ignoredTokensAddresses] = [ @@ -518,12 +531,13 @@ export class TokenDetectionController extends StaticIntervalPollingController< allDetectedTokens, allIgnoredTokens, ].map((tokens) => - ( - tokens[chainIdAgainstWhichToDetect]?.[addressAgainstWhichToDetect] ?? [] - ).map((value) => (typeof value === 'string' ? value : value.address)), + (tokens[chainId]?.[selectedAddress] ?? []).map((value) => + typeof value === 'string' ? value : value.address, + ), ); + const tokensToDetect: string[] = []; - for (const tokenAddress of Object.keys(tokenListUsed)) { + for (const tokenAddress of Object.keys(this.#tokenList)) { if ( [ tokensAddresses, @@ -539,60 +553,71 @@ export class TokenDetectionController extends StaticIntervalPollingController< tokensToDetect.push(tokenAddress); } } + const slicesOfTokensToDetect = []; - slicesOfTokensToDetect[0] = tokensToDetect.slice(0, 1000); - slicesOfTokensToDetect[1] = tokensToDetect.slice( - 1000, - tokensToDetect.length - 1, - ); - for (const tokensSlice of slicesOfTokensToDetect) { - if (tokensSlice.length === 0) { - break; + for (let i = 0, size = 1000; i < tokensToDetect.length; i += size) { + slicesOfTokensToDetect.push(tokensToDetect.slice(i, i + size)); + } + + return slicesOfTokensToDetect; + } + + async #addDetectedTokens({ + tokensSlice, + selectedAddress, + networkClientId, + chainId, + }: { + tokensSlice: string[]; + selectedAddress: string; + networkClientId: NetworkClientId; + chainId: Hex; + }): Promise { + await safelyExecute(async () => { + const balances = await this.#getBalancesInSingleCall( + selectedAddress, + tokensSlice, + networkClientId, + ); + + const tokensWithBalance: Token[] = []; + const eventTokensDetails: string[] = []; + for (const nonZeroTokenAddress of Object.keys(balances)) { + const { decimals, symbol, aggregators, iconUrl, name } = + this.#tokenList[nonZeroTokenAddress]; + eventTokensDetails.push(`${symbol} - ${nonZeroTokenAddress}`); + tokensWithBalance.push({ + address: nonZeroTokenAddress, + decimals, + symbol, + aggregators, + image: iconUrl, + isERC721: false, + name, + }); } - await safelyExecute(async () => { - const balances = await this.#getBalancesInSingleCall( - addressAgainstWhichToDetect, - tokensSlice, - networkClientIdAgainstWhichToDetect, + if (tokensWithBalance.length) { + this.#trackMetaMetricsEvent({ + event: 'Token Detected', + category: 'Wallet', + properties: { + tokens: eventTokensDetails, + token_standard: 'ERC20', + asset_type: 'TOKEN', + }, + }); + + await this.messagingSystem.call( + 'TokensController:addDetectedTokens', + tokensWithBalance, + { + selectedAddress, + chainId, + }, ); - const tokensWithBalance: Token[] = []; - const eventTokensDetails: string[] = []; - for (const nonZeroTokenAddress of Object.keys(balances)) { - const { decimals, symbol, aggregators, iconUrl, name } = - tokenListUsed[nonZeroTokenAddress]; - eventTokensDetails.push(`${symbol} - ${nonZeroTokenAddress}`); - tokensWithBalance.push({ - address: nonZeroTokenAddress, - decimals, - symbol, - aggregators, - image: iconUrl, - isERC721: false, - name, - }); - } - if (tokensWithBalance.length) { - this.#trackMetaMetricsEvent({ - event: 'Token Detected', - category: 'Wallet', - properties: { - tokens: eventTokensDetails, - token_standard: 'ERC20', - asset_type: 'TOKEN', - }, - }); - await this.messagingSystem.call( - 'TokensController:addDetectedTokens', - tokensWithBalance, - { - selectedAddress: addressAgainstWhichToDetect, - chainId: chainIdAgainstWhichToDetect, - }, - ); - } - }); - } + } + }); } } From a24869b8e7e518f6682058d3eda4c41f0317ccc8 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Mon, 4 Mar 2024 11:31:04 -0700 Subject: [PATCH 3/4] Release 123.0.0 (#4007) Co-authored-by: Jongsun Suh --- package.json | 4 +- packages/accounts-controller/CHANGELOG.md | 14 +- packages/accounts-controller/package.json | 6 +- packages/address-book-controller/package.json | 2 +- packages/approval-controller/CHANGELOG.md | 9 +- packages/approval-controller/package.json | 2 +- packages/assets-controllers/CHANGELOG.md | 48 ++++-- packages/assets-controllers/package.json | 22 +-- packages/composable-controller/package.json | 2 +- packages/controller-utils/CHANGELOG.md | 9 +- packages/controller-utils/package.json | 2 +- packages/ens-controller/package.json | 4 +- packages/eth-json-rpc-provider/package.json | 2 +- packages/gas-fee-controller/CHANGELOG.md | 14 +- packages/gas-fee-controller/package.json | 8 +- packages/json-rpc-engine/CHANGELOG.md | 9 +- packages/json-rpc-engine/package.json | 2 +- .../json-rpc-middleware-stream/package.json | 2 +- packages/keyring-controller/CHANGELOG.md | 27 +++- packages/keyring-controller/package.json | 4 +- packages/logging-controller/CHANGELOG.md | 9 +- packages/logging-controller/package.json | 4 +- packages/message-manager/CHANGELOG.md | 10 +- packages/message-manager/package.json | 4 +- packages/network-controller/CHANGELOG.md | 12 +- packages/network-controller/package.json | 6 +- packages/permission-controller/package.json | 6 +- .../permission-log-controller/package.json | 2 +- packages/phishing-controller/package.json | 2 +- packages/polling-controller/CHANGELOG.md | 10 +- packages/polling-controller/package.json | 6 +- packages/preferences-controller/CHANGELOG.md | 25 ++- packages/preferences-controller/package.json | 8 +- .../queued-request-controller/package.json | 8 +- .../selected-network-controller/package.json | 4 +- packages/signature-controller/CHANGELOG.md | 15 +- packages/signature-controller/package.json | 14 +- packages/transaction-controller/CHANGELOG.md | 18 ++- packages/transaction-controller/package.json | 10 +- .../user-operation-controller/CHANGELOG.md | 17 +- .../user-operation-controller/package.json | 20 +-- yarn.lock | 148 +++++++++--------- 42 files changed, 367 insertions(+), 183 deletions(-) diff --git a/package.json b/package.json index 56ba95383a..27308c73fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/core-monorepo", - "version": "122.0.0", + "version": "123.0.0", "private": true, "description": "Monorepo for packages shared between MetaMask clients", "repository": { @@ -51,7 +51,7 @@ "@metamask/eslint-config-nodejs": "^12.1.0", "@metamask/eslint-config-typescript": "^12.1.0", "@metamask/eth-json-rpc-provider": "^2.3.2", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/utils": "^8.3.0", "@types/jest": "^27.4.1", "@types/node": "^16.18.54", diff --git a/packages/accounts-controller/CHANGELOG.md b/packages/accounts-controller/CHANGELOG.md index 32d412cf74..585d352310 100644 --- a/packages/accounts-controller/CHANGELOG.md +++ b/packages/accounts-controller/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [11.0.0] + +### Changed + +- **BREAKING:** Bump `@metamask/keyring-controller` peer dependency to `^13.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Replace `ethereumjs-util` with `@ethereumjs/util` and `ethereum-cryptography` ([#3943](https://github.com/MetaMask/core/pull/3943)) + +### Fixed + +- Update `keyringTypeToName` to return the correct name for custody keyrings ([#3899](https://github.com/MetaMask/core/pull/3899)) + ## [10.0.0] ### Changed @@ -115,7 +126,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release ([#1637](https://github.com/MetaMask/core/pull/1637)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@10.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@11.0.0...HEAD +[11.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@10.0.0...@metamask/accounts-controller@11.0.0 [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@9.0.0...@metamask/accounts-controller@10.0.0 [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@8.0.0...@metamask/accounts-controller@9.0.0 [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@7.0.1...@metamask/accounts-controller@8.0.0 diff --git a/packages/accounts-controller/package.json b/packages/accounts-controller/package.json index 2f8c461048..f6eb4c7c5e 100644 --- a/packages/accounts-controller/package.json +++ b/packages/accounts-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/accounts-controller", - "version": "10.0.0", + "version": "11.0.0", "description": "Manages internal accounts", "keywords": [ "MetaMask", @@ -45,7 +45,7 @@ }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/snaps-controllers": "^4.0.0", "@types/jest": "^27.4.1", "@types/readable-stream": "^2.3.0", @@ -56,7 +56,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/snaps-controllers": "^4.0.0" }, "engines": { diff --git a/packages/address-book-controller/package.json b/packages/address-book-controller/package.json index 183fee7959..29a762950b 100644 --- a/packages/address-book-controller/package.json +++ b/packages/address-book-controller/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/utils": "^8.3.0" }, "devDependencies": { diff --git a/packages/approval-controller/CHANGELOG.md b/packages/approval-controller/CHANGELOG.md index 064c7412da..99c4e4c59b 100644 --- a/packages/approval-controller/CHANGELOG.md +++ b/packages/approval-controller/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.1.3] + +### Changed + +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3954](https://github.com/MetaMask/core/pull/3954)) + ## [5.1.2] ### Changed @@ -157,7 +163,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.1.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.1.3...HEAD +[5.1.3]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.1.2...@metamask/approval-controller@5.1.3 [5.1.2]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.1.1...@metamask/approval-controller@5.1.2 [5.1.1]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.1.0...@metamask/approval-controller@5.1.1 [5.1.0]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.0.0...@metamask/approval-controller@5.1.0 diff --git a/packages/approval-controller/package.json b/packages/approval-controller/package.json index 595615312c..0bd1278fb7 100644 --- a/packages/approval-controller/package.json +++ b/packages/approval-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/approval-controller", - "version": "5.1.2", + "version": "5.1.3", "description": "Manages requests that require user approval", "keywords": [ "MetaMask", diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index 916278a425..cf742a46b9 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -7,33 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [26.0.0] + ### 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 messenger actions `AccountsController:getSelectedAccount`, `NetworkController:getNetworkClientById`, `NetworkController:getNetworkConfigurationByNetworkClientId`, `NetworkController:getState`, `KeyringController:getState`, `PreferencesController:getState`, `TokenListController:getState`, `TokensController:getState`, `TokensController:addDetectedTokens`. ([#3775](https://github.com/MetaMask/core/pull/3775/), [#3923](https://github.com/MetaMask/core/pull/3923/), [#3938](https://github.com/MetaMask/core/pull/3938)) -- `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, `TokensControllerStateChangeEvent`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) +- **BREAKING:** `TokenDetectionController` newly subscribes to the `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`, `KeyringController:lock`, and `KeyringController:unlock` events, and allows messenger actions `AccountsController:getSelectedAccount`, `NetworkController:getNetworkClientById`, `NetworkController:getNetworkConfigurationByNetworkClientId`, `NetworkController:getState`, `KeyringController:getState`, `PreferencesController:getState`, `TokenListController:getState`, `TokensController:getState`, and `TokensController:addDetectedTokens` ([#3775](https://github.com/MetaMask/core/pull/3775/), [#3923](https://github.com/MetaMask/core/pull/3923/), [#3938](https://github.com/MetaMask/core/pull/3938)) +- `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, and `TokensControllerStateChangeEvent` ([#3690](https://github.com/MetaMask/core/pull/3690/)) ### Changed -- **BREAKING:** `TokenDetectionController` is merged with `DetectTokensController` from the `metamask-extension` repo. ([#3775](https://github.com/MetaMask/core/pull/3775/), [#3923](https://github.com/MetaMask/core/pull/3923)), ([#3938](https://github.com/MetaMask/core/pull/3938)) +- **BREAKING:** Add `@metamask/accounts-controller` `^11.0.0` as dependency and peer dependency ([#3775](https://github.com/MetaMask/core/pull/3775/), [#4007](https://github.com/MetaMask/core/pull/4007)) +- **BREAKING:** Add `@metamask/keyring-controller` `^13.0.0` as dependency and peer dependency ([#3775](https://github.com/MetaMask/core/pull/3775), [#4007](https://github.com/MetaMask/core/pull/4007)) +- **BREAKING:** Bump `@metamask/preferences-controller` dependency and peer dependency to `^8.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- **BREAKING:** `TokenDetectionController` is merged with `DetectTokensController` from the `metamask-extension` repo ([#3775](https://github.com/MetaMask/core/pull/3775/), [#3923](https://github.com/MetaMask/core/pull/3923)), ([#3938](https://github.com/MetaMask/core/pull/3938)) - **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 input option `accountAddress` has been renamed to `selectedAddress`. - **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. - - The constructor option `selectedAddress` no longer defaults to `''` if omitted. Instead, the correct address is assigned using the `AccountsController:getSelectedAccount` messenger action. + - **BREAKING:** The constructor for `TokenDetectionController` expects a new required property `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). - **BREAKING:** The `TokensState` type is now defined as a type alias rather than an interface. ([#3690](https://github.com/MetaMask/core/pull/3690/)) - - `TokensState` now extends the `Record` types, and it has an index signature of `string`, making it compatible with the `BaseControllerV2` state object constraint of `Record`. - - The `detectTokens` method can now process an arbitrary number of tokens in batches of 1000. ([#3938](https://github.com/MetaMask/core/pull/3938)) + - This is breaking because it could affect how this type is used with other types, such as `Json`, which does not support TypeScript interfaces. + - The constructor option `selectedAddress` no longer defaults to `''` if omitted. Instead, the correct address is assigned using the `AccountsController:getSelectedAccount` messenger action. +- **BREAKING:** Change type of `provider` property in `AssetsContractController` from `any` to `Provider` from `@metamask/network-controller` ([#3818](https://github.com/MetaMask/core/pull/3818)) +- **BREAKING:** Change type of `provider` property in `TokensController` from `any` to `Provider` from `@metamask/network-controller` ([#3818](https://github.com/MetaMask/core/pull/3818)) +- Bump `@metamask/approval-controller` to `^5.1.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/ethjs-unit` to `^0.3.0` ([#3897](https://github.com/MetaMask/core/pull/3897)) +- Bump `@metamask/network-controller` to `^17.2.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/polling-controller` to `^5.0.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3970](https://github.com/MetaMask/core/pull/3970), [#3954](https://github.com/MetaMask/core/pull/3954)) +- Replace `ethereumjs-util` with `@ethereumjs/util` and `bn.js` ([#3943](https://github.com/MetaMask/core/pull/3943)) +- Update `CodefiTokenPricesServiceV2` so that requests to the price API now use the `No-Cache` HTTP header ([#3939](https://github.com/MetaMask/core/pull/3939)) ### Removed -- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `networkClientId`, `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, `addDetectedTokens`. ([#3690](https://github.com/MetaMask/core/pull/3690/), [#3775](https://github.com/MetaMask/core/pull/3775/), [#3938](https://github.com/MetaMask/core/pull/3938)) -- **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/)) -- **BREAKING:** `TokensController` constructor no longer accepts options `onPreferencesStateChange`, `onNetworkDidChange`, `onTokenListStateChange`, `getNetworkClientById`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) -- **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress`. ([#3690](https://github.com/MetaMask/core/pull/3690/)) +- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `networkClientId`, `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, or `addDetectedTokens` ([#3690](https://github.com/MetaMask/core/pull/3690/), [#3775](https://github.com/MetaMask/core/pull/3775/), [#3938](https://github.com/MetaMask/core/pull/3938)) +- **BREAKING:** `TokenDetectionController` no longer allows the `NetworkController:stateChange` event. ([#3775](https://github.com/MetaMask/core/pull/3775/)) + - The `NetworkController:networkDidChange` event can be used instead. +- **BREAKING:** `TokenDetectionController` constructor no longer accepts options `networkClientId`, `onPreferencesStateChange`, `getPreferencesState`, `getTokensState`, or `addDetectedTokens` ([#3690](https://github.com/MetaMask/core/pull/3690/), [#3775](https://github.com/MetaMask/core/pull/3775/), [#3938](https://github.com/MetaMask/core/pull/3938)) +- **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress` ([#3690](https://github.com/MetaMask/core/pull/3690/)) + +### Fixed + +- `TokenDetectionController.detectTokens()` now reads the chain ID keyed state properties from `TokenListController` and `TokensController` rather than incorrectly using the globally selected state properties when a network client ID is passed ([#3914](https://github.com/MetaMask/core/pull/3914)) +- Fix `PreferencesController` state listener in `NftDetectionController` so that NFT detection is not run when any preference changes, but only when NFT detection is enabled ([#3917](https://github.com/MetaMask/core/pull/3917)) +- Fix `isTokenListSupportedForNetwork` so that it returns false for chain 1337 ([#3777](https://github.com/MetaMask/core/pull/3777)) + - When used in combination with `TokensController`, this makes it possible to import an ERC-20 token on a locally run chain. ## [25.0.0] @@ -676,7 +697,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@25.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@26.0.0...HEAD +[26.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@25.0.0...@metamask/assets-controllers@26.0.0 [25.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@24.0.0...@metamask/assets-controllers@25.0.0 [24.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@23.1.0...@metamask/assets-controllers@24.0.0 [23.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@23.0.0...@metamask/assets-controllers@23.1.0 diff --git a/packages/assets-controllers/package.json b/packages/assets-controllers/package.json index c1a5fb41fb..2846da7774 100644 --- a/packages/assets-controllers/package.json +++ b/packages/assets-controllers/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/assets-controllers", - "version": "25.0.0", + "version": "26.0.0", "description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)", "keywords": [ "MetaMask", @@ -37,17 +37,17 @@ "@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/accounts-controller": "^11.0.0", + "@metamask/approval-controller": "^5.1.3", "@metamask/base-controller": "^4.1.1", "@metamask/contract-metadata": "^2.4.0", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-query": "^4.0.0", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/metamask-eth-abis": "3.0.0", - "@metamask/network-controller": "^17.2.0", - "@metamask/polling-controller": "^5.0.0", - "@metamask/preferences-controller": "^7.0.0", + "@metamask/network-controller": "^17.2.1", + "@metamask/polling-controller": "^5.0.1", + "@metamask/preferences-controller": "^8.0.0", "@metamask/rpc-errors": "^6.2.1", "@metamask/utils": "^8.3.0", "@types/bn.js": "^5.1.5", @@ -78,11 +78,11 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/accounts-controller": "^10.0.0", + "@metamask/accounts-controller": "^11.0.0", "@metamask/approval-controller": "^5.1.2", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/network-controller": "^17.2.0", - "@metamask/preferences-controller": "^7.0.0" + "@metamask/preferences-controller": "^8.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/composable-controller/package.json b/packages/composable-controller/package.json index 53ad6a93be..6a1771ab08 100644 --- a/packages/composable-controller/package.json +++ b/packages/composable-controller/package.json @@ -36,7 +36,7 @@ }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", "immer": "^9.0.6", diff --git a/packages/controller-utils/CHANGELOG.md b/packages/controller-utils/CHANGELOG.md index 93094f9a8e..a7d30f9003 100644 --- a/packages/controller-utils/CHANGELOG.md +++ b/packages/controller-utils/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [8.0.4] + +### Changed + +- Replace `ethereumjs-util` with `@ethereumjs/util` ([#3943](https://github.com/MetaMask/core/pull/3943)) + ## [8.0.3] ### Changed @@ -270,7 +276,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.4...HEAD +[8.0.4]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.3...@metamask/controller-utils@8.0.4 [8.0.3]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.2...@metamask/controller-utils@8.0.3 [8.0.2]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.1...@metamask/controller-utils@8.0.2 [8.0.1]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@8.0.0...@metamask/controller-utils@8.0.1 diff --git a/packages/controller-utils/package.json b/packages/controller-utils/package.json index 50c115bf0a..7a5637dde8 100644 --- a/packages/controller-utils/package.json +++ b/packages/controller-utils/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controller-utils", - "version": "8.0.3", + "version": "8.0.4", "description": "Data and convenience functions shared by multiple packages", "keywords": [ "MetaMask", diff --git a/packages/ens-controller/package.json b/packages/ens-controller/package.json index 6d549e6e9e..c10a70e436 100644 --- a/packages/ens-controller/package.json +++ b/packages/ens-controller/package.json @@ -33,14 +33,14 @@ "dependencies": { "@ethersproject/providers": "^5.7.0", "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/utils": "^8.3.0", "ethereum-ens-network-map": "^1.0.2", "punycode": "^2.1.1" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", - "@metamask/network-controller": "^17.2.0", + "@metamask/network-controller": "^17.2.1", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", "jest": "^27.5.1", diff --git a/packages/eth-json-rpc-provider/package.json b/packages/eth-json-rpc-provider/package.json index 64416e7289..da4f010715 100644 --- a/packages/eth-json-rpc-provider/package.json +++ b/packages/eth-json-rpc-provider/package.json @@ -38,7 +38,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/safe-event-emitter": "^3.0.0", "@metamask/utils": "^8.3.0" }, diff --git a/packages/gas-fee-controller/CHANGELOG.md b/packages/gas-fee-controller/CHANGELOG.md index b790744e2c..5cced2c700 100644 --- a/packages/gas-fee-controller/CHANGELOG.md +++ b/packages/gas-fee-controller/CHANGELOG.md @@ -7,11 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -## [13.0.1] +## [13.0.2] ### Changed +- Replace `ethereumjs-util` with `bn.js` ([#3943](https://github.com/MetaMask/core/pull/3943)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) - Bump `@metamask/ethjs-unit` to `^0.3.0` ([#3897](https://github.com/MetaMask/core/pull/3897)) +- Bump `@metamask/network-controller` to `^17.2.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/polling-controller` to `^5.0.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) + +## [13.0.1] + +### Changed + - Bump `@metamask/controller-utils` to `^8.0.3` ([#3915](https://github.com/MetaMask/core/pull/3915)) ## [13.0.0] @@ -208,7 +217,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@13.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@13.0.2...HEAD +[13.0.2]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@13.0.1...@metamask/gas-fee-controller@13.0.2 [13.0.1]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@13.0.0...@metamask/gas-fee-controller@13.0.1 [13.0.0]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@12.0.0...@metamask/gas-fee-controller@13.0.0 [12.0.0]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@11.0.0...@metamask/gas-fee-controller@12.0.0 diff --git a/packages/gas-fee-controller/package.json b/packages/gas-fee-controller/package.json index 13d171bc8e..1cbfd70927 100644 --- a/packages/gas-fee-controller/package.json +++ b/packages/gas-fee-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/gas-fee-controller", - "version": "13.0.1", + "version": "13.0.2", "description": "Periodically calculates gas fee estimates based on various gas limits as well as other data displayed on transaction confirm screens", "keywords": [ "MetaMask", @@ -32,11 +32,11 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-query": "^4.0.0", "@metamask/ethjs-unit": "^0.3.0", - "@metamask/network-controller": "^17.2.0", - "@metamask/polling-controller": "^5.0.0", + "@metamask/network-controller": "^17.2.1", + "@metamask/polling-controller": "^5.0.1", "@metamask/utils": "^8.3.0", "@types/bn.js": "^5.1.5", "@types/uuid": "^8.3.0", diff --git a/packages/json-rpc-engine/CHANGELOG.md b/packages/json-rpc-engine/CHANGELOG.md index b5095f973f..47b88c7a8b 100644 --- a/packages/json-rpc-engine/CHANGELOG.md +++ b/packages/json-rpc-engine/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.3.3] + +### Changed + +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3954](https://github.com/MetaMask/core/pull/3954)) + ## [7.3.2] ### Changed @@ -131,7 +137,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 This change may affect consumers that depend on the eager execution of middleware _during_ request processing, _outside of_ middleware functions and request handlers. - In general, it is a bad practice to work with state that depends on middleware execution, while the middleware are executing. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.3.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.3.3...HEAD +[7.3.3]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.3.2...@metamask/json-rpc-engine@7.3.3 [7.3.2]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.3.1...@metamask/json-rpc-engine@7.3.2 [7.3.1]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.3.0...@metamask/json-rpc-engine@7.3.1 [7.3.0]: https://github.com/MetaMask/core/compare/@metamask/json-rpc-engine@7.2.0...@metamask/json-rpc-engine@7.3.0 diff --git a/packages/json-rpc-engine/package.json b/packages/json-rpc-engine/package.json index 1b550619f7..760f85ed74 100644 --- a/packages/json-rpc-engine/package.json +++ b/packages/json-rpc-engine/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/json-rpc-engine", - "version": "7.3.2", + "version": "7.3.3", "description": "A tool for processing JSON-RPC messages", "keywords": [ "MetaMask", diff --git a/packages/json-rpc-middleware-stream/package.json b/packages/json-rpc-middleware-stream/package.json index 15e00f2a4c..d161a1297e 100644 --- a/packages/json-rpc-middleware-stream/package.json +++ b/packages/json-rpc-middleware-stream/package.json @@ -31,7 +31,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/safe-event-emitter": "^3.0.0", "@metamask/utils": "^8.3.0", "readable-stream": "^3.6.2" diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index 7105f0a045..a6a3abf0b3 100644 --- a/packages/keyring-controller/CHANGELOG.md +++ b/packages/keyring-controller/CHANGELOG.md @@ -7,12 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [13.0.0] + +### Added + +- Add `isCustodyKeyring` function ([#3899](https://github.com/MetaMask/core/pull/3899)) +- Add `keyringBuilderFactory` utility function ([#3830](https://github.com/MetaMask/core/pull/3830)) +- Add `GenericEncryptor`, `ExportableKeyEncryptor`, and `SerializedKeyring` types ([#3830](https://github.com/MetaMask/core/pull/3830)) + +### Changed + +- Replace `ethereumjs-util` with `@ethereumjs/util` ([#3943](https://github.com/MetaMask/core/pull/3943)) +- Bump `@metamask/message-manager` to `^7.3.9` ([#4007](https://github.com/MetaMask/core/pull/4007)) + ### Removed - **BREAKING:** Remove callbacks `updateIdentities`, `syncIdentities`, `setSelectedAddress`, `setAccountLabel` from constructor options of the `KeyringController` class. These were previously used to update `PreferencesController` state, but are now replaced with `PreferencesController`'s subscription to the `KeyringController:stateChange` event. ([#3853](https://github.com/MetaMask/core/pull/3853)) - - Class methods `addNewAccount`, `addNewAccountForKeyring`, `createNewVaultAndRestore`, `createNewVaultAndKeychain`, `importAccountWithStrategy`, `restoreQRKeyring`, `unlockQRHardwareWalletAccount`, `forgetQRDevice` no longer directly updates `PreferencesController` state by calling the `updateIdentities` callback. - - Class method `submitPassword` no longer directly updates `PreferencesController` state by calling the `syncIdentities` callback. - - Class method `unlockQRHardwareWalletAccount` no longer directly updates `PreferencesController` state by calling the `setAccountLabel`, `setSelectedAddress` callbacks. + - Methods `addNewAccount`, `addNewAccountForKeyring`, `createNewVaultAndRestore`, `createNewVaultAndKeychain`, `importAccountWithStrategy`, `restoreQRKeyring`, `unlockQRHardwareWalletAccount`, and `forgetQRDevice` no longer directly update `PreferencesController` state by calling the `updateIdentities` callback. + - Method `submitPassword` no longer directly updates `PreferencesController` state by calling the `syncIdentities` callback. + - Method `unlockQRHardwareWalletAccount` no longer directly updates `PreferencesController` state by calling the `setAccountLabel` or `setSelectedAddress` callbacks. +- Remove `@metamask/eth-keyring-controller` dependency, and transfer dependencies to this package instead ([#3830](https://github.com/MetaMask/core/pull/3830)) + - `@metamask/eth-hd-keyring` + - `@metamask/eth-simple-keyring` + - `@metamask/eth-sig-util` + - `@metamask/browser-passworder` ## [12.2.0] @@ -358,7 +376,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@12.2.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@13.0.0...HEAD +[13.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@12.2.0...@metamask/keyring-controller@13.0.0 [12.2.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@12.1.0...@metamask/keyring-controller@12.2.0 [12.1.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@12.0.0...@metamask/keyring-controller@12.1.0 [12.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@11.0.0...@metamask/keyring-controller@12.0.0 diff --git a/packages/keyring-controller/package.json b/packages/keyring-controller/package.json index d32e460276..8742579b03 100644 --- a/packages/keyring-controller/package.json +++ b/packages/keyring-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/keyring-controller", - "version": "12.2.0", + "version": "13.0.0", "description": "Stores identities seen in the wallet and manages interactions such as signing", "keywords": [ "MetaMask", @@ -39,7 +39,7 @@ "@metamask/eth-sig-util": "^7.0.1", "@metamask/eth-simple-keyring": "^6.0.1", "@metamask/keyring-api": "^3.0.0", - "@metamask/message-manager": "^7.3.8", + "@metamask/message-manager": "^7.3.9", "@metamask/utils": "^8.3.0", "async-mutex": "^0.2.6", "ethereumjs-wallet": "^1.0.1", diff --git a/packages/logging-controller/CHANGELOG.md b/packages/logging-controller/CHANGELOG.md index 4e4dbb99a1..39694ce31f 100644 --- a/packages/logging-controller/CHANGELOG.md +++ b/packages/logging-controller/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.3] + +### Changed + +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) + ## [2.0.2] ### Changed @@ -62,7 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial Release - Add logging controller ([#1089](https://github.com/MetaMask/core.git/pull/1089)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.3...HEAD +[2.0.3]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.2...@metamask/logging-controller@2.0.3 [2.0.2]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.1...@metamask/logging-controller@2.0.2 [2.0.1]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.0...@metamask/logging-controller@2.0.1 [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.4...@metamask/logging-controller@2.0.0 diff --git a/packages/logging-controller/package.json b/packages/logging-controller/package.json index 231a5389c9..ec08157015 100644 --- a/packages/logging-controller/package.json +++ b/packages/logging-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/logging-controller", - "version": "2.0.2", + "version": "2.0.3", "description": "Manages logging data to assist users and support staff", "keywords": [ "MetaMask", @@ -32,7 +32,7 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/packages/message-manager/CHANGELOG.md b/packages/message-manager/CHANGELOG.md index 4630649276..e42ff71b9b 100644 --- a/packages/message-manager/CHANGELOG.md +++ b/packages/message-manager/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.3.9] + +### Changed + +- Remove dependency `ethereumjs-util` ([#3943](https://github.com/MetaMask/core/pull/3943)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) + ## [7.3.8] ### Changed @@ -202,7 +209,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.8...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.9...HEAD +[7.3.9]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.8...@metamask/message-manager@7.3.9 [7.3.8]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.7...@metamask/message-manager@7.3.8 [7.3.7]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.6...@metamask/message-manager@7.3.7 [7.3.6]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.5...@metamask/message-manager@7.3.6 diff --git a/packages/message-manager/package.json b/packages/message-manager/package.json index fa08815781..e21021ba18 100644 --- a/packages/message-manager/package.json +++ b/packages/message-manager/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/message-manager", - "version": "7.3.8", + "version": "7.3.9", "description": "Stores and manages interactions with signing requests", "keywords": [ "MetaMask", @@ -32,7 +32,7 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-sig-util": "^7.0.1", "@metamask/utils": "^8.3.0", "@types/uuid": "^8.3.0", diff --git a/packages/network-controller/CHANGELOG.md b/packages/network-controller/CHANGELOG.md index 9afe5c62d7..adff2f519e 100644 --- a/packages/network-controller/CHANGELOG.md +++ b/packages/network-controller/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [17.2.1] + +### Changed + +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/eth-json-rpc-middleware` to `^12.1.0` ([#3829](https://github.com/MetaMask/core/pull/3829)) +- Bump `@metamask/json-rpc-engine` to `^7.3.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3970](https://github.com/MetaMask/core/pull/3970), [#3954](https://github.com/MetaMask/core/pull/3954)) + ## [17.2.0] ### Changed @@ -423,7 +432,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.2.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.2.1...HEAD +[17.2.1]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.2.0...@metamask/network-controller@17.2.1 [17.2.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.1.0...@metamask/network-controller@17.2.0 [17.1.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.0.0...@metamask/network-controller@17.1.0 [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@16.0.0...@metamask/network-controller@17.0.0 diff --git a/packages/network-controller/package.json b/packages/network-controller/package.json index d11899ef96..f1f9403d9a 100644 --- a/packages/network-controller/package.json +++ b/packages/network-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/network-controller", - "version": "17.2.0", + "version": "17.2.1", "description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object", "keywords": [ "MetaMask", @@ -32,12 +32,12 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-json-rpc-infura": "^9.0.0", "@metamask/eth-json-rpc-middleware": "^12.1.0", "@metamask/eth-json-rpc-provider": "^2.3.2", "@metamask/eth-query": "^4.0.0", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/rpc-errors": "^6.2.1", "@metamask/swappable-obj-proxy": "^2.2.0", "@metamask/utils": "^8.3.0", diff --git a/packages/permission-controller/package.json b/packages/permission-controller/package.json index 326cc29992..e6e9dd3e49 100644 --- a/packages/permission-controller/package.json +++ b/packages/permission-controller/package.json @@ -32,8 +32,8 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/controller-utils": "^8.0.4", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/rpc-errors": "^6.2.1", "@metamask/utils": "^8.3.0", "@types/deep-freeze-strict": "^1.1.0", @@ -42,7 +42,7 @@ "nanoid": "^3.1.31" }, "devDependencies": { - "@metamask/approval-controller": "^5.1.2", + "@metamask/approval-controller": "^5.1.3", "@metamask/auto-changelog": "^3.4.4", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", diff --git a/packages/permission-log-controller/package.json b/packages/permission-log-controller/package.json index c13d4b61e0..45da9f3ec3 100644 --- a/packages/permission-log-controller/package.json +++ b/packages/permission-log-controller/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/utils": "^8.3.0" }, "devDependencies": { diff --git a/packages/phishing-controller/package.json b/packages/phishing-controller/package.json index e9b5ac5c70..41210937b5 100644 --- a/packages/phishing-controller/package.json +++ b/packages/phishing-controller/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@types/punycode": "^2.1.0", "eth-phishing-detect": "^1.2.0", "punycode": "^2.1.1" diff --git a/packages/polling-controller/CHANGELOG.md b/packages/polling-controller/CHANGELOG.md index 749cd964f4..50fe0554db 100644 --- a/packages/polling-controller/CHANGELOG.md +++ b/packages/polling-controller/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.1] + +### Changed + +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/network-controller` to `^17.2.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) + ## [5.0.0] ### Changed @@ -88,7 +95,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@5.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@5.0.1...HEAD +[5.0.1]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@5.0.0...@metamask/polling-controller@5.0.1 [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@4.0.0...@metamask/polling-controller@5.0.0 [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@3.0.0...@metamask/polling-controller@4.0.0 [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@2.0.0...@metamask/polling-controller@3.0.0 diff --git a/packages/polling-controller/package.json b/packages/polling-controller/package.json index 06591d8e21..bafad31dcb 100644 --- a/packages/polling-controller/package.json +++ b/packages/polling-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/polling-controller", - "version": "5.0.0", + "version": "5.0.1", "description": "Polling Controller is the base for controllers that polling by networkClientId", "keywords": [ "MetaMask", @@ -32,8 +32,8 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", - "@metamask/network-controller": "^17.2.0", + "@metamask/controller-utils": "^8.0.4", + "@metamask/network-controller": "^17.2.1", "@metamask/utils": "^8.3.0", "@types/uuid": "^8.3.0", "fast-json-stable-stringify": "^2.1.0", diff --git a/packages/preferences-controller/CHANGELOG.md b/packages/preferences-controller/CHANGELOG.md index f06725af8d..9daf692da7 100644 --- a/packages/preferences-controller/CHANGELOG.md +++ b/packages/preferences-controller/CHANGELOG.md @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [8.0.0] + +### Changed + +- **BREAKING:** Bump `@metamask/keyring-controller` dependency and peer dependency to `^13.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- **BREAKING:** Remove support for Optimism Goerli, add support for Optimism Sepolia ([#3999](https://github.com/MetaMask/core/pull/3999)) + - Replace `OPTIMISM_TESTNET` with `OPTIMISM_SEPOLIA` in `ETHERSCAN_SUPPORTED_CHAIN_IDS` and `EtherscanSupportedChains`. + - Replace `0x1a4` with `0xaa37dc` in `EtherscanSupportedHexChainId`. + - Replace `0x1a4` with `0xaa37dc` in default `showIncomingTransactions` state. + - Update `setEnabledNetworkIncomingTransactions` to ignore a chain ID of `0x1a4`; add support for `0xaa37dc` instead. + - You will likely want to write a migration to transfer the value of `0x1a4` for `0xaa37dc` for the `showIncomingTransactions` state property. +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) + +### Removed + +- **BREAKING:** Move `syncIdentities` to private, as it's only used internally to update state on `KeyringController:stateChange` event ([#3976](https://github.com/MetaMask/core/pull/3976)) +- **BREAKING:** Remove `updateIdentities`, as it's not in use anymore ([#3976](https://github.com/MetaMask/core/pull/3976)) + +### Fixed + +- Fix KeyringController state listener to not sync identities when the wallet is locked (which clears the list of accounts) to avoid setting the selected address to `undefined` ([#3946](https://github.com/MetaMask/core/pull/3946)) + ## [7.0.0] ### Changed @@ -157,7 +179,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@7.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@8.0.0...HEAD +[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@7.0.0...@metamask/preferences-controller@8.0.0 [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@6.0.0...@metamask/preferences-controller@7.0.0 [6.0.0]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@5.0.1...@metamask/preferences-controller@6.0.0 [5.0.1]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@5.0.0...@metamask/preferences-controller@5.0.1 diff --git a/packages/preferences-controller/package.json b/packages/preferences-controller/package.json index 0bb1f968e7..68666c034e 100644 --- a/packages/preferences-controller/package.json +++ b/packages/preferences-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/preferences-controller", - "version": "7.0.0", + "version": "8.0.0", "description": "Manages user-configurable settings for MetaMask", "keywords": [ "MetaMask", @@ -32,11 +32,11 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3" + "@metamask/controller-utils": "^8.0.4" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.4", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", "jest": "^27.5.1", @@ -47,7 +47,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/keyring-controller": "^12.2.0" + "@metamask/keyring-controller": "^13.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/queued-request-controller/package.json b/packages/queued-request-controller/package.json index 7f55e35559..fe7b37d5b1 100644 --- a/packages/queued-request-controller/package.json +++ b/packages/queued-request-controller/package.json @@ -32,16 +32,16 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", - "@metamask/json-rpc-engine": "^7.3.2", + "@metamask/controller-utils": "^8.0.4", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/rpc-errors": "^6.2.1", "@metamask/swappable-obj-proxy": "^2.2.0", "@metamask/utils": "^8.3.0" }, "devDependencies": { - "@metamask/approval-controller": "^5.1.2", + "@metamask/approval-controller": "^5.1.3", "@metamask/auto-changelog": "^3.4.4", - "@metamask/network-controller": "^17.2.0", + "@metamask/network-controller": "^17.2.1", "@metamask/selected-network-controller": "^9.0.0", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", diff --git a/packages/selected-network-controller/package.json b/packages/selected-network-controller/package.json index d66b9e80c2..cee2428667 100644 --- a/packages/selected-network-controller/package.json +++ b/packages/selected-network-controller/package.json @@ -32,8 +32,8 @@ }, "dependencies": { "@metamask/base-controller": "^4.1.1", - "@metamask/json-rpc-engine": "^7.3.2", - "@metamask/network-controller": "^17.2.0", + "@metamask/json-rpc-engine": "^7.3.3", + "@metamask/network-controller": "^17.2.1", "@metamask/permission-controller": "^8.0.1", "@metamask/swappable-obj-proxy": "^2.2.0", "@metamask/utils": "^8.3.0" diff --git a/packages/signature-controller/CHANGELOG.md b/packages/signature-controller/CHANGELOG.md index 6bd9da30a6..aa89c774a4 100644 --- a/packages/signature-controller/CHANGELOG.md +++ b/packages/signature-controller/CHANGELOG.md @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [13.0.0] + +### Changed + +- **BREAKING:** Bump `@metamask/keyring-controller` dependency and peer dependency to `^13.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/approval-controller` to `^5.1.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/logging-controller` to `^2.0.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/message-manager` to `^7.3.9` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3954](https://github.com/MetaMask/core/pull/3954)) +- Remove dependency `ethereumjs-util` ([#3943](https://github.com/MetaMask/core/pull/3943)) + ## [12.0.0] ### Changed @@ -189,7 +201,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial release ([#1214](https://github.com/MetaMask/core/pull/1214)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@12.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@13.0.0...HEAD +[13.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@12.0.0...@metamask/signature-controller@13.0.0 [12.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@11.0.0...@metamask/signature-controller@12.0.0 [11.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@10.0.0...@metamask/signature-controller@11.0.0 [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@9.0.0...@metamask/signature-controller@10.0.0 diff --git a/packages/signature-controller/package.json b/packages/signature-controller/package.json index 7dd707175c..a712754fd1 100644 --- a/packages/signature-controller/package.json +++ b/packages/signature-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/signature-controller", - "version": "12.0.0", + "version": "13.0.0", "description": "Processes signing requests in order to sign arbitrary and typed data", "keywords": [ "MetaMask", @@ -31,12 +31,12 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/approval-controller": "^5.1.2", + "@metamask/approval-controller": "^5.1.3", "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", - "@metamask/keyring-controller": "^12.2.0", - "@metamask/logging-controller": "^2.0.2", - "@metamask/message-manager": "^7.3.8", + "@metamask/controller-utils": "^8.0.4", + "@metamask/keyring-controller": "^13.0.0", + "@metamask/logging-controller": "^2.0.3", + "@metamask/message-manager": "^7.3.9", "@metamask/rpc-errors": "^6.2.1", "@metamask/utils": "^8.3.0", "lodash": "^4.17.21" @@ -53,7 +53,7 @@ }, "peerDependencies": { "@metamask/approval-controller": "^5.1.2", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/logging-controller": "^2.0.2" }, "engines": { diff --git a/packages/transaction-controller/CHANGELOG.md b/packages/transaction-controller/CHANGELOG.md index 1b2d5bb272..cbb4d0b531 100644 --- a/packages/transaction-controller/CHANGELOG.md +++ b/packages/transaction-controller/CHANGELOG.md @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [24.0.0] + +### Added + +- Add `normalizeTransactionParams` method ([#3990](https://github.com/MetaMask/core/pull/3990)) + +### Changed + +- **BREAKING**: Remove support for retrieving transactions via Etherscan for Optimism Goerli; add support for Optimism Sepolia instead ([#3999](https://github.com/MetaMask/core/pull/3999)) +- Normalize `data` property into an even length hex string ([#3990](https://github.com/MetaMask/core/pull/3990)) +- Bump `@metamask/approval-controller` to `^5.1.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/gas-fee-controller` to `^13.0.2` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/network-controller` to `^17.2.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) + ## [23.1.0] ### Added @@ -543,7 +558,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.1.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@24.0.0...HEAD +[24.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.1.0...@metamask/transaction-controller@24.0.0 [23.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@23.0.0...@metamask/transaction-controller@23.1.0 [23.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@22.0.0...@metamask/transaction-controller@23.0.0 [22.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@21.2.0...@metamask/transaction-controller@22.0.0 diff --git a/packages/transaction-controller/package.json b/packages/transaction-controller/package.json index 554490c014..1078b6c197 100644 --- a/packages/transaction-controller/package.json +++ b/packages/transaction-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/transaction-controller", - "version": "23.1.0", + "version": "24.0.0", "description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation", "keywords": [ "MetaMask", @@ -35,13 +35,13 @@ "@ethereumjs/tx": "^4.2.0", "@ethereumjs/util": "^8.1.0", "@ethersproject/abi": "^5.7.0", - "@metamask/approval-controller": "^5.1.2", + "@metamask/approval-controller": "^5.1.3", "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-query": "^4.0.0", - "@metamask/gas-fee-controller": "^13.0.1", + "@metamask/gas-fee-controller": "^13.0.2", "@metamask/metamask-eth-abis": "^3.0.0", - "@metamask/network-controller": "^17.2.0", + "@metamask/network-controller": "^17.2.1", "@metamask/rpc-errors": "^6.2.1", "@metamask/utils": "^8.3.0", "async-mutex": "^0.2.6", diff --git a/packages/user-operation-controller/CHANGELOG.md b/packages/user-operation-controller/CHANGELOG.md index da5d35b23d..900548d584 100644 --- a/packages/user-operation-controller/CHANGELOG.md +++ b/packages/user-operation-controller/CHANGELOG.md @@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.0] + +### Changed + +- **BREAKING:** Bump `@metamask/keyring-controller` dependency and peer dependency to `^13.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- **BREAKING:** Bump `@metamask/transaction-controller` dependency and peer dependency to `^24.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/approval-controller` to `^5.1.3` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/controller-utils` to `^8.0.4` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/gas-fee-controller` to `^13.0.2` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/network-controller` to `^17.2.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Bump `@metamask/rpc-errors` to `^6.2.1` ([#3954](https://github.com/MetaMask/core/pull/3954)) +- Bump `@metamask/polling-controller` to `^5.0.1` ([#4007](https://github.com/MetaMask/core/pull/4007)) +- Replace `ethereumjs-util` with `bn.js` ([#3943](https://github.com/MetaMask/core/pull/3943)) + ## [4.0.0] ### Changed @@ -49,7 +63,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial Release ([#3749](https://github.com/MetaMask/core/pull/3749)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@4.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@5.0.0...HEAD +[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@4.0.0...@metamask/user-operation-controller@5.0.0 [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@3.0.0...@metamask/user-operation-controller@4.0.0 [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@2.0.0...@metamask/user-operation-controller@3.0.0 [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/user-operation-controller@1.0.0...@metamask/user-operation-controller@2.0.0 diff --git a/packages/user-operation-controller/package.json b/packages/user-operation-controller/package.json index 9f1a4aea20..2abc6bd3b3 100644 --- a/packages/user-operation-controller/package.json +++ b/packages/user-operation-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/user-operation-controller", - "version": "4.0.0", + "version": "5.0.0", "description": "Creates user operations and manages their life cycle", "keywords": [ "MetaMask", @@ -32,16 +32,16 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/approval-controller": "^5.1.2", + "@metamask/approval-controller": "^5.1.3", "@metamask/base-controller": "^4.1.1", - "@metamask/controller-utils": "^8.0.3", + "@metamask/controller-utils": "^8.0.4", "@metamask/eth-query": "^4.0.0", - "@metamask/gas-fee-controller": "^13.0.1", - "@metamask/keyring-controller": "^12.2.0", - "@metamask/network-controller": "^17.2.0", - "@metamask/polling-controller": "^5.0.0", + "@metamask/gas-fee-controller": "^13.0.2", + "@metamask/keyring-controller": "^13.0.0", + "@metamask/network-controller": "^17.2.1", + "@metamask/polling-controller": "^5.0.1", "@metamask/rpc-errors": "^6.2.1", - "@metamask/transaction-controller": "^23.1.0", + "@metamask/transaction-controller": "^24.0.0", "@metamask/utils": "^8.3.0", "bn.js": "^5.2.1", "immer": "^9.0.6", @@ -62,9 +62,9 @@ "peerDependencies": { "@metamask/approval-controller": "^5.1.2", "@metamask/gas-fee-controller": "^13.0.0", - "@metamask/keyring-controller": "^12.2.0", + "@metamask/keyring-controller": "^13.0.0", "@metamask/network-controller": "^17.2.0", - "@metamask/transaction-controller": "^23.0.0" + "@metamask/transaction-controller": "^24.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/yarn.lock b/yarn.lock index 21fd97142e..8a1e46d275 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1477,7 +1477,7 @@ __metadata: languageName: node linkType: hard -"@metamask/accounts-controller@^10.0.0, @metamask/accounts-controller@workspace:packages/accounts-controller": +"@metamask/accounts-controller@^11.0.0, @metamask/accounts-controller@workspace:packages/accounts-controller": version: 0.0.0-use.local resolution: "@metamask/accounts-controller@workspace:packages/accounts-controller" dependencies: @@ -1486,7 +1486,7 @@ __metadata: "@metamask/base-controller": ^4.1.1 "@metamask/eth-snap-keyring": ^2.1.1 "@metamask/keyring-api": ^3.0.0 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/snaps-controllers": ^4.0.0 "@metamask/snaps-sdk": ^1.3.2 "@metamask/snaps-utils": ^5.1.2 @@ -1503,7 +1503,7 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/snaps-controllers": ^4.0.0 languageName: unknown linkType: soft @@ -1525,7 +1525,7 @@ __metadata: dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -1553,7 +1553,7 @@ __metadata: languageName: unknown linkType: soft -"@metamask/approval-controller@^5.1.1, @metamask/approval-controller@^5.1.2, @metamask/approval-controller@workspace:packages/approval-controller": +"@metamask/approval-controller@^5.1.1, @metamask/approval-controller@^5.1.3, @metamask/approval-controller@workspace:packages/approval-controller": version: 0.0.0-use.local resolution: "@metamask/approval-controller@workspace:packages/approval-controller" dependencies: @@ -1583,20 +1583,20 @@ __metadata: "@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/accounts-controller": ^11.0.0 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 "@metamask/contract-metadata": ^2.4.0 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-query": ^4.0.0 "@metamask/ethjs-provider-http": ^0.3.0 "@metamask/keyring-api": ^3.0.0 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/metamask-eth-abis": 3.0.0 - "@metamask/network-controller": ^17.2.0 - "@metamask/polling-controller": ^5.0.0 - "@metamask/preferences-controller": ^7.0.0 + "@metamask/network-controller": ^17.2.1 + "@metamask/polling-controller": ^5.0.1 + "@metamask/preferences-controller": ^8.0.0 "@metamask/rpc-errors": ^6.2.1 "@metamask/utils": ^8.3.0 "@types/bn.js": ^5.1.5 @@ -1621,11 +1621,11 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/accounts-controller": ^10.0.0 + "@metamask/accounts-controller": ^11.0.0 "@metamask/approval-controller": ^5.1.2 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/network-controller": ^17.2.0 - "@metamask/preferences-controller": ^7.0.0 + "@metamask/preferences-controller": ^8.0.0 languageName: unknown linkType: soft @@ -1711,7 +1711,7 @@ __metadata: dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -1732,7 +1732,7 @@ __metadata: languageName: node linkType: hard -"@metamask/controller-utils@^8.0.1, @metamask/controller-utils@^8.0.3, @metamask/controller-utils@workspace:packages/controller-utils": +"@metamask/controller-utils@^8.0.1, @metamask/controller-utils@^8.0.4, @metamask/controller-utils@workspace:packages/controller-utils": version: 0.0.0-use.local resolution: "@metamask/controller-utils@workspace:packages/controller-utils" dependencies: @@ -1770,7 +1770,7 @@ __metadata: "@metamask/eslint-config-nodejs": ^12.1.0 "@metamask/eslint-config-typescript": ^12.1.0 "@metamask/eth-json-rpc-provider": ^2.3.2 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 "@types/node": ^16.18.54 @@ -1833,8 +1833,8 @@ __metadata: "@ethersproject/providers": ^5.7.0 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/network-controller": ^17.2.0 + "@metamask/controller-utils": ^8.0.4 + "@metamask/network-controller": ^17.2.1 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -1948,7 +1948,7 @@ __metadata: resolution: "@metamask/eth-json-rpc-provider@workspace:packages/eth-json-rpc-provider" dependencies: "@metamask/auto-changelog": ^3.4.4 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/safe-event-emitter": ^3.0.0 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 @@ -2114,17 +2114,17 @@ __metadata: languageName: node linkType: hard -"@metamask/gas-fee-controller@^13.0.1, @metamask/gas-fee-controller@workspace:packages/gas-fee-controller": +"@metamask/gas-fee-controller@^13.0.2, @metamask/gas-fee-controller@workspace:packages/gas-fee-controller": version: 0.0.0-use.local resolution: "@metamask/gas-fee-controller@workspace:packages/gas-fee-controller" dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-query": ^4.0.0 "@metamask/ethjs-unit": ^0.3.0 - "@metamask/network-controller": ^17.2.0 - "@metamask/polling-controller": ^5.0.0 + "@metamask/network-controller": ^17.2.1 + "@metamask/polling-controller": ^5.0.1 "@metamask/utils": ^8.3.0 "@types/bn.js": ^5.1.5 "@types/jest": ^27.4.1 @@ -2146,7 +2146,7 @@ __metadata: languageName: unknown linkType: soft -"@metamask/json-rpc-engine@^7.1.1, @metamask/json-rpc-engine@^7.3.1, @metamask/json-rpc-engine@^7.3.2, @metamask/json-rpc-engine@workspace:packages/json-rpc-engine": +"@metamask/json-rpc-engine@^7.1.1, @metamask/json-rpc-engine@^7.3.1, @metamask/json-rpc-engine@^7.3.3, @metamask/json-rpc-engine@workspace:packages/json-rpc-engine": version: 0.0.0-use.local resolution: "@metamask/json-rpc-engine@workspace:packages/json-rpc-engine" dependencies: @@ -2170,7 +2170,7 @@ __metadata: resolution: "@metamask/json-rpc-middleware-stream@workspace:packages/json-rpc-middleware-stream" dependencies: "@metamask/auto-changelog": ^3.4.4 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/safe-event-emitter": ^3.0.0 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 @@ -2232,7 +2232,7 @@ __metadata: languageName: node linkType: hard -"@metamask/keyring-controller@^12.2.0, @metamask/keyring-controller@workspace:packages/keyring-controller": +"@metamask/keyring-controller@^13.0.0, @metamask/keyring-controller@workspace:packages/keyring-controller": version: 0.0.0-use.local resolution: "@metamask/keyring-controller@workspace:packages/keyring-controller" dependencies: @@ -2249,7 +2249,7 @@ __metadata: "@metamask/eth-sig-util": ^7.0.1 "@metamask/eth-simple-keyring": ^6.0.1 "@metamask/keyring-api": ^3.0.0 - "@metamask/message-manager": ^7.3.8 + "@metamask/message-manager": ^7.3.9 "@metamask/scure-bip39": ^2.1.1 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 @@ -2268,13 +2268,13 @@ __metadata: languageName: unknown linkType: soft -"@metamask/logging-controller@^2.0.2, @metamask/logging-controller@workspace:packages/logging-controller": +"@metamask/logging-controller@^2.0.3, @metamask/logging-controller@workspace:packages/logging-controller": version: 0.0.0-use.local resolution: "@metamask/logging-controller@workspace:packages/logging-controller" dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 jest: ^27.5.1 @@ -2286,13 +2286,13 @@ __metadata: languageName: unknown linkType: soft -"@metamask/message-manager@^7.3.8, @metamask/message-manager@workspace:packages/message-manager": +"@metamask/message-manager@^7.3.9, @metamask/message-manager@workspace:packages/message-manager": version: 0.0.0-use.local resolution: "@metamask/message-manager@workspace:packages/message-manager" dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-sig-util": ^7.0.1 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 @@ -2333,19 +2333,19 @@ __metadata: languageName: unknown linkType: soft -"@metamask/network-controller@^17.2.0, @metamask/network-controller@workspace:packages/network-controller": +"@metamask/network-controller@^17.2.1, @metamask/network-controller@workspace:packages/network-controller": version: 0.0.0-use.local resolution: "@metamask/network-controller@workspace:packages/network-controller" dependencies: "@json-rpc-specification/meta-schema": ^1.0.6 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-json-rpc-infura": ^9.0.0 "@metamask/eth-json-rpc-middleware": ^12.1.0 "@metamask/eth-json-rpc-provider": ^2.3.2 "@metamask/eth-query": ^4.0.0 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/rpc-errors": ^6.2.1 "@metamask/swappable-obj-proxy": ^2.2.0 "@metamask/utils": ^8.3.0 @@ -2421,11 +2421,11 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/permission-controller@workspace:packages/permission-controller" dependencies: - "@metamask/approval-controller": ^5.1.2 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/controller-utils": ^8.0.4 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/rpc-errors": ^6.2.1 "@metamask/utils": ^8.3.0 "@types/deep-freeze-strict": ^1.1.0 @@ -2469,7 +2469,7 @@ __metadata: dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/json-rpc-engine": ^7.3.2 + "@metamask/json-rpc-engine": ^7.3.3 "@metamask/utils": ^8.3.0 "@types/deep-freeze-strict": ^1.1.0 "@types/jest": ^27.4.1 @@ -2490,7 +2490,7 @@ __metadata: dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@types/jest": ^27.4.1 "@types/punycode": ^2.1.0 deepmerge: ^4.2.2 @@ -2506,14 +2506,14 @@ __metadata: languageName: unknown linkType: soft -"@metamask/polling-controller@^5.0.0, @metamask/polling-controller@workspace:packages/polling-controller": +"@metamask/polling-controller@^5.0.1, @metamask/polling-controller@workspace:packages/polling-controller": version: 0.0.0-use.local resolution: "@metamask/polling-controller@workspace:packages/polling-controller" dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/network-controller": ^17.2.0 + "@metamask/controller-utils": ^8.0.4 + "@metamask/network-controller": ^17.2.1 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 "@types/uuid": ^8.3.0 @@ -2541,14 +2541,14 @@ __metadata: languageName: node linkType: hard -"@metamask/preferences-controller@^7.0.0, @metamask/preferences-controller@workspace:packages/preferences-controller": +"@metamask/preferences-controller@^8.0.0, @metamask/preferences-controller@workspace:packages/preferences-controller": version: 0.0.0-use.local resolution: "@metamask/preferences-controller@workspace:packages/preferences-controller" dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/controller-utils": ^8.0.4 + "@metamask/keyring-controller": ^13.0.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 jest: ^27.5.1 @@ -2558,7 +2558,7 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 languageName: unknown linkType: soft @@ -2586,12 +2586,12 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/queued-request-controller@workspace:packages/queued-request-controller" dependencies: - "@metamask/approval-controller": ^5.1.2 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/json-rpc-engine": ^7.3.2 - "@metamask/network-controller": ^17.2.0 + "@metamask/controller-utils": ^8.0.4 + "@metamask/json-rpc-engine": ^7.3.3 + "@metamask/network-controller": ^17.2.1 "@metamask/rpc-errors": ^6.2.1 "@metamask/selected-network-controller": ^9.0.0 "@metamask/swappable-obj-proxy": ^2.2.0 @@ -2671,8 +2671,8 @@ __metadata: dependencies: "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/json-rpc-engine": ^7.3.2 - "@metamask/network-controller": ^17.2.0 + "@metamask/json-rpc-engine": ^7.3.3 + "@metamask/network-controller": ^17.2.1 "@metamask/permission-controller": ^8.0.1 "@metamask/swappable-obj-proxy": ^2.2.0 "@metamask/utils": ^8.3.0 @@ -2697,13 +2697,13 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/signature-controller@workspace:packages/signature-controller" dependencies: - "@metamask/approval-controller": ^5.1.2 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 - "@metamask/keyring-controller": ^12.2.0 - "@metamask/logging-controller": ^2.0.2 - "@metamask/message-manager": ^7.3.8 + "@metamask/controller-utils": ^8.0.4 + "@metamask/keyring-controller": ^13.0.0 + "@metamask/logging-controller": ^2.0.3 + "@metamask/message-manager": ^7.3.9 "@metamask/rpc-errors": ^6.2.1 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 @@ -2716,7 +2716,7 @@ __metadata: typescript: ~4.8.4 peerDependencies: "@metamask/approval-controller": ^5.1.2 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/logging-controller": ^2.0.2 languageName: unknown linkType: soft @@ -2895,7 +2895,7 @@ __metadata: languageName: node linkType: hard -"@metamask/transaction-controller@^23.1.0, @metamask/transaction-controller@workspace:packages/transaction-controller": +"@metamask/transaction-controller@^24.0.0, @metamask/transaction-controller@workspace:packages/transaction-controller": version: 0.0.0-use.local resolution: "@metamask/transaction-controller@workspace:packages/transaction-controller" dependencies: @@ -2904,15 +2904,15 @@ __metadata: "@ethereumjs/tx": ^4.2.0 "@ethereumjs/util": ^8.1.0 "@ethersproject/abi": ^5.7.0 - "@metamask/approval-controller": ^5.1.2 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-query": ^4.0.0 "@metamask/ethjs-provider-http": ^0.3.0 - "@metamask/gas-fee-controller": ^13.0.1 + "@metamask/gas-fee-controller": ^13.0.2 "@metamask/metamask-eth-abis": ^3.0.0 - "@metamask/network-controller": ^17.2.0 + "@metamask/network-controller": ^17.2.1 "@metamask/rpc-errors": ^6.2.1 "@metamask/utils": ^8.3.0 "@types/bn.js": ^5.1.5 @@ -2945,17 +2945,17 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/user-operation-controller@workspace:packages/user-operation-controller" dependencies: - "@metamask/approval-controller": ^5.1.2 + "@metamask/approval-controller": ^5.1.3 "@metamask/auto-changelog": ^3.4.4 "@metamask/base-controller": ^4.1.1 - "@metamask/controller-utils": ^8.0.3 + "@metamask/controller-utils": ^8.0.4 "@metamask/eth-query": ^4.0.0 - "@metamask/gas-fee-controller": ^13.0.1 - "@metamask/keyring-controller": ^12.2.0 - "@metamask/network-controller": ^17.2.0 - "@metamask/polling-controller": ^5.0.0 + "@metamask/gas-fee-controller": ^13.0.2 + "@metamask/keyring-controller": ^13.0.0 + "@metamask/network-controller": ^17.2.1 + "@metamask/polling-controller": ^5.0.1 "@metamask/rpc-errors": ^6.2.1 - "@metamask/transaction-controller": ^23.1.0 + "@metamask/transaction-controller": ^24.0.0 "@metamask/utils": ^8.3.0 "@types/jest": ^27.4.1 bn.js: ^5.2.1 @@ -2972,9 +2972,9 @@ __metadata: peerDependencies: "@metamask/approval-controller": ^5.1.2 "@metamask/gas-fee-controller": ^13.0.0 - "@metamask/keyring-controller": ^12.2.0 + "@metamask/keyring-controller": ^13.0.0 "@metamask/network-controller": ^17.2.0 - "@metamask/transaction-controller": ^23.0.0 + "@metamask/transaction-controller": ^24.0.0 languageName: unknown linkType: soft From e387b176a19b58109db53990d90a9dc455e3e8fa Mon Sep 17 00:00:00 2001 From: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:52:40 +0100 Subject: [PATCH 4/4] refactor(controller-utils): replace `any` with types for type safety (#3975) ## Explanation The current implementation uses any type for parameters in certain utility functions within controller-utils, which lacks type safety and can lead to runtime errors if incorrect values are passed. This approach needs to change to ensure the reliability and maintainability of the codebase. ## References - Fixes #3717 ## Changelog ### `@metamask/controller-utils` #### Fixed - **BREAKING**: Replaced any type with BN for BNToHex and fractionBN functions to enhance type safety. - **BREAKING**: Replaced any type with unknown in logOrRethrowError. - **BREAKING**: Replaced any type with string in isNetworkType. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate --- .../src/AccountTrackerController.ts | 15 ++++---- packages/controller-utils/src/types.test.ts | 2 ++ packages/controller-utils/src/types.ts | 6 ++-- packages/controller-utils/src/util.ts | 36 +++++++++---------- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/packages/assets-controllers/src/AccountTrackerController.ts b/packages/assets-controllers/src/AccountTrackerController.ts index 5aa65496c0..6c8479dc2b 100644 --- a/packages/assets-controllers/src/AccountTrackerController.ts +++ b/packages/assets-controllers/src/AccountTrackerController.ts @@ -1,9 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { - BNToHex, - query, - safelyExecuteWithTimeout, -} from '@metamask/controller-utils'; +import { query, safelyExecuteWithTimeout } from '@metamask/controller-utils'; import EthQuery from '@metamask/eth-query'; import type { Provider } from '@metamask/eth-query'; import type { @@ -272,9 +268,12 @@ export class AccountTrackerController extends StaticIntervalPollingControllerV1< const accountsForChain = { ...accountsByChainId[chainId] }; for (const address of accountsToUpdate) { - accountsForChain[address] = { - balance: BNToHex(await this.getBalanceFromChain(address, ethQuery)), - }; + const balance = await this.getBalanceFromChain(address, ethQuery); + if (balance) { + accountsForChain[address] = { + balance, + }; + } } this.update({ diff --git a/packages/controller-utils/src/types.test.ts b/packages/controller-utils/src/types.test.ts index ddac15c499..8d1de7df7c 100644 --- a/packages/controller-utils/src/types.test.ts +++ b/packages/controller-utils/src/types.test.ts @@ -2,7 +2,9 @@ import { isNetworkType, NetworkType } from './types'; describe('types', () => { it('isNetworkType', () => { + // @ts-expect-error We are intentionally passing bad input. expect(isNetworkType({})).toBe(false); + // @ts-expect-error We are intentionally passing bad input. expect(isNetworkType(1)).toBe(false); expect(isNetworkType('test')).toBe(false); expect(isNetworkType('mainnet')).toBe(true); diff --git a/packages/controller-utils/src/types.ts b/packages/controller-utils/src/types.ts index 248d7623b9..1cfad3a3e1 100644 --- a/packages/controller-utils/src/types.ts +++ b/packages/controller-utils/src/types.ts @@ -28,10 +28,8 @@ export type NetworkType = (typeof NetworkType)[keyof typeof NetworkType]; * @param val - the value to check whether it is NetworkType or not. * @returns boolean indicating whether or not the argument is NetworkType. */ -// TODO: Replace `any` with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function isNetworkType(val: any): val is NetworkType { - return Object.values(NetworkType).includes(val); +export function isNetworkType(val: string): val is NetworkType { + return Object.values(NetworkType).includes(val as NetworkType); } /** diff --git a/packages/controller-utils/src/util.ts b/packages/controller-utils/src/util.ts index 2721befb3d..d512142ce6 100644 --- a/packages/controller-utils/src/util.ts +++ b/packages/controller-utils/src/util.ts @@ -44,9 +44,7 @@ export function isSafeChainId(chainId: Hex): boolean { * @param inputBn - BN instance to convert to a hex string. * @returns A '0x'-prefixed hex string. */ -// TODO: Replace `any` with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function BNToHex(inputBn: any) { +export function BNToHex(inputBn: BN) { return add0x(inputBn.toString(16)); } @@ -59,9 +57,7 @@ export function BNToHex(inputBn: any) { * @returns Product of the multiplication. */ export function fractionBN( - // TODO: Replace `any` with type - // eslint-disable-next-line @typescript-eslint/no-explicit-any - targetBN: any, + targetBN: BN, numerator: number | string, denominator: number | string, ) { @@ -539,25 +535,27 @@ export function isValidJson(value: unknown): value is Json { * @param error - Caught error that we should either rethrow or log to console * @param codesToCatch - array of error codes for errors we want to catch and log in a particular context */ -// TODO: Replace `any` with type -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function logOrRethrowError(error: any, codesToCatch: number[] = []) { +function logOrRethrowError(error: unknown, codesToCatch: number[] = []) { if (!error) { return; } - const includesErrorCodeToCatch = codesToCatch.some((code) => - error.message?.includes(`Fetch failed with status '${code}'`), - ); + if (error instanceof Error) { + const includesErrorCodeToCatch = codesToCatch.some((code) => + error.message.includes(`Fetch failed with status '${code}'`), + ); - if ( - error instanceof Error && - (includesErrorCodeToCatch || - error.message?.includes('Failed to fetch') || - error === TIMEOUT_ERROR) - ) { - console.error(error); + if ( + includesErrorCodeToCatch || + error.message.includes('Failed to fetch') || + error === TIMEOUT_ERROR + ) { + console.error(error); + } else { + throw error; + } } else { + // eslint-disable-next-line @typescript-eslint/no-throw-literal throw error; } }