@metamask/assets-controllers 103.1.1 → 104.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +73 -54
  2. package/dist/AccountTrackerController.cjs +5 -3
  3. package/dist/AccountTrackerController.cjs.map +1 -1
  4. package/dist/AccountTrackerController.d.cts.map +1 -1
  5. package/dist/AccountTrackerController.d.mts.map +1 -1
  6. package/dist/AccountTrackerController.mjs +5 -3
  7. package/dist/AccountTrackerController.mjs.map +1 -1
  8. package/dist/AssetsContractController.cjs +1 -1
  9. package/dist/AssetsContractController.cjs.map +1 -1
  10. package/dist/AssetsContractController.d.cts +1 -1
  11. package/dist/AssetsContractController.d.cts.map +1 -1
  12. package/dist/AssetsContractController.d.mts +1 -1
  13. package/dist/AssetsContractController.d.mts.map +1 -1
  14. package/dist/AssetsContractController.mjs +1 -1
  15. package/dist/AssetsContractController.mjs.map +1 -1
  16. package/dist/MultichainAssetsController/MultichainAssetsController.cjs +150 -58
  17. package/dist/MultichainAssetsController/MultichainAssetsController.cjs.map +1 -1
  18. package/dist/MultichainAssetsController/MultichainAssetsController.d.cts +20 -3
  19. package/dist/MultichainAssetsController/MultichainAssetsController.d.cts.map +1 -1
  20. package/dist/MultichainAssetsController/MultichainAssetsController.d.mts +20 -3
  21. package/dist/MultichainAssetsController/MultichainAssetsController.d.mts.map +1 -1
  22. package/dist/MultichainAssetsController/MultichainAssetsController.mjs +150 -58
  23. package/dist/MultichainAssetsController/MultichainAssetsController.mjs.map +1 -1
  24. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.cjs.map +1 -1
  25. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.cts +1 -1
  26. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.cts.map +1 -1
  27. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.mts +1 -1
  28. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.d.mts.map +1 -1
  29. package/dist/MultichainAssetsRatesController/MultichainAssetsRatesController.mjs.map +1 -1
  30. package/dist/NftController.cjs +49 -39
  31. package/dist/NftController.cjs.map +1 -1
  32. package/dist/NftController.d.cts +12 -7
  33. package/dist/NftController.d.cts.map +1 -1
  34. package/dist/NftController.d.mts +12 -7
  35. package/dist/NftController.d.mts.map +1 -1
  36. package/dist/NftController.mjs +49 -39
  37. package/dist/NftController.mjs.map +1 -1
  38. package/dist/RatesController/RatesController.cjs.map +1 -1
  39. package/dist/RatesController/RatesController.d.cts.map +1 -1
  40. package/dist/RatesController/RatesController.d.mts.map +1 -1
  41. package/dist/RatesController/RatesController.mjs.map +1 -1
  42. package/dist/RatesController/types.cjs.map +1 -1
  43. package/dist/RatesController/types.d.cts +1 -1
  44. package/dist/RatesController/types.d.cts.map +1 -1
  45. package/dist/RatesController/types.d.mts +1 -1
  46. package/dist/RatesController/types.d.mts.map +1 -1
  47. package/dist/RatesController/types.mjs.map +1 -1
  48. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.cjs.map +1 -1
  49. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.cts +1 -1
  50. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.cts.map +1 -1
  51. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.mts +1 -1
  52. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.d.mts.map +1 -1
  53. package/dist/TokenSearchDiscoveryDataController/TokenSearchDiscoveryDataController.mjs.map +1 -1
  54. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs +1 -1
  55. package/dist/multi-chain-accounts-service/api-balance-fetcher.cjs.map +1 -1
  56. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs +1 -1
  57. package/dist/multi-chain-accounts-service/api-balance-fetcher.mjs.map +1 -1
  58. package/dist/multicall.cjs +220 -1
  59. package/dist/multicall.cjs.map +1 -1
  60. package/dist/multicall.d.cts +22 -0
  61. package/dist/multicall.d.cts.map +1 -1
  62. package/dist/multicall.d.mts +22 -0
  63. package/dist/multicall.d.mts.map +1 -1
  64. package/dist/multicall.mjs +218 -0
  65. package/dist/multicall.mjs.map +1 -1
  66. package/dist/rpc-service/rpc-balance-fetcher.cjs.map +1 -1
  67. package/dist/rpc-service/rpc-balance-fetcher.mjs.map +1 -1
  68. package/dist/selectors/token-selectors.cjs +1 -1
  69. package/dist/selectors/token-selectors.cjs.map +1 -1
  70. package/dist/selectors/token-selectors.d.cts +18 -18
  71. package/dist/selectors/token-selectors.d.cts.map +1 -1
  72. package/dist/selectors/token-selectors.d.mts +18 -18
  73. package/dist/selectors/token-selectors.d.mts.map +1 -1
  74. package/dist/selectors/token-selectors.mjs +1 -1
  75. package/dist/selectors/token-selectors.mjs.map +1 -1
  76. package/dist/token-prices-service/codefi-v2.cjs.map +1 -1
  77. package/dist/token-prices-service/codefi-v2.d.cts +1 -1
  78. package/dist/token-prices-service/codefi-v2.d.cts.map +1 -1
  79. package/dist/token-prices-service/codefi-v2.d.mts +1 -1
  80. package/dist/token-prices-service/codefi-v2.d.mts.map +1 -1
  81. package/dist/token-prices-service/codefi-v2.mjs.map +1 -1
  82. package/package.json +26 -25
package/CHANGELOG.md CHANGED
@@ -7,6 +7,44 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [104.1.0]
11
+
12
+ ### Added
13
+
14
+ - `MultichainAssetsController`: periodic Blockaid re-scan of stored SPL-style `token:` assets (default once per day) so tokens that become malicious after a prior scan are dropped; use constructor option `blockaidTokenRescanInterval` (ms), or `0` to disable. ([#8400](https://github.com/MetaMask/core/pull/8400))
15
+
16
+ ### Changed
17
+
18
+ - Bump `@metamask/account-tree-controller` from `^7.0.0` to `^7.1.0` ([#8472](https://github.com/MetaMask/core/pull/8472))
19
+ - Bump `@metamask/transaction-controller` from `^64.2.0` to `^64.3.0` ([#8482](https://github.com/MetaMask/core/pull/8482))
20
+ - Bump `@metamask/keyring-api` from `^21.6.0` to `^23.0.1` ([#8464](https://github.com/MetaMask/core/pull/8464))
21
+
22
+ ### Fixed
23
+
24
+ - `MultichainAssetsController`: fungible `token:` assets from automatic detection are no longer added when Blockaid bulk scan fails, returns empty, or omits that address (previously fail open); an explicit non-malicious per-token result from `PhishingController:bulkScanTokens` is now required before add. ([#8400](https://github.com/MetaMask/core/pull/8400))
25
+ - Fix `AccountTrackerController` wiping existing balances on other chains when syncing accounts for a chain that has no state entry yet ([#8505](https://github.com/MetaMask/core/pull/8505))
26
+
27
+ ## [104.0.0]
28
+
29
+ ### Changed
30
+
31
+ - **BREAKING:** `NftController` no longer uses the `AssetsContractController:getERC721OwnerOf` and `AssetsContractController:getERC1155BalanceOf` messenger actions for ownership checks; these have been removed from `AllowedActions` ([#8281](https://github.com/MetaMask/core/pull/8281))
32
+ - Consumers that construct the `NftController` messenger and register handlers for these two actions must remove them from their allowed actions list.
33
+ - **BREAKING:** `checkAndUpdateSingleNftOwnershipStatus` no longer accepts a `batch` boolean as its second argument; the signature is now `(nft, networkClientId, { userAddress }?)` ([#8281](https://github.com/MetaMask/core/pull/8281), [#8435](https://github.com/MetaMask/core/pull/8435))
34
+ - The method now always writes the updated NFT to state and returns it. Remove the `batch` argument from all call sites.
35
+ - **BREAKING:** `checkAndUpdateAllNftsOwnershipStatus` now removes NFTs confirmed as unowned from state instead of setting `isCurrentlyOwned: false` on them ([#8281](https://github.com/MetaMask/core/pull/8281))
36
+ - The `isCurrentlyOwned: false` flag was originally used to power a "Previously Owned" NFTs section in MetaMask, which is no longer supported. NFTs that are confirmed as no longer owned are now removed from state immediately rather than being retained with a stale flag.
37
+ - `NftController` NFT ownership checks (`isNftOwner`, `checkAndUpdateSingleNftOwnershipStatus`, `checkAndUpdateAllNftsOwnershipStatus`) now use Multicall3 to batch ERC-721 `ownerOf` and ERC-1155 `balanceOf` calls into fewer RPC requests, falling back to individual calls on unsupported chains ([#8281](https://github.com/MetaMask/core/pull/8281))
38
+ - Bump `@metamask/accounts-controller` from `^37.1.1` to `^37.2.0` ([#8363](https://github.com/MetaMask/core/pull/8363))
39
+ - Bump `@metamask/keyring-controller` from `^25.1.1` to `^25.2.0` ([#8363](https://github.com/MetaMask/core/pull/8363))
40
+ - Bump `@metamask/messenger` from `^1.0.0` to `^1.1.1` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373))
41
+ - Bump `@metamask/transaction-controller` from `^64.0.0` to `^64.2.0` ([#8432](https://github.com/MetaMask/core/pull/8432), [#8447](https://github.com/MetaMask/core/pull/8447))
42
+ - Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
43
+
44
+ ### Fixed
45
+
46
+ - Restore `checkAndUpdateSingleNftOwnershipStatus` to `NftController` to fix a regression where consumers (e.g. the MetaMask extension) that call this method individually were broken by its removal in [#8281](https://github.com/MetaMask/core/pull/8281) ([#8435](https://github.com/MetaMask/core/pull/8435))
47
+
10
48
  ## [103.1.1]
11
49
 
12
50
  ### Changed
@@ -50,7 +88,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
50
88
  ### Added
51
89
 
52
90
  - Add Tempo Mainnet (`4217`/`0x1079`) and Tempo Moderato Testnet (`42431`/`0xa5bf`) support ([#8258](https://github.com/MetaMask/core/pull/8258))
53
-
54
91
  - Add `0x1079` and `0xa5bf` to `SPOT_PRICES_SUPPORT_INFO` in `codefi-v2.ts`
55
92
  - Add `0x1079` and `0xa5bf` to `chainIdToNativeTokenAddress` in `codefi-v2.ts`
56
93
  - Add `0xa5bf` (only Tempo Testnet) to `MULTICALL_CONTRACT_BY_CHAINID` in `multicall.ts`
@@ -185,7 +222,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
185
222
  ### Changed
186
223
 
187
224
  - Bump `@metamask/network-enablement-controller` from `^4.1.2` to `^4.2.0` ([#8107](https://github.com/MetaMask/core/pull/8107))
188
- - Bump `@metamask/transaction-controller` from `^62.18.0` to `^62.20.0` ([#8031](https://github.com/MetaMask/core/pull/8031) [#8104](https://github.com/MetaMask/core/pull/8104))
225
+ - Bump `@metamask/transaction-controller` from `^62.18.0` to `^62.20.0` ([#8031](https://github.com/MetaMask/core/pull/8031), [#8104](https://github.com/MetaMask/core/pull/8104))
189
226
 
190
227
  ### Fixed
191
228
 
@@ -260,9 +297,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
260
297
 
261
298
  - Bump `@metamask/accounts-controller` from `^35.0.2` to `^36.0.0` ([#7897](https://github.com/MetaMask/core/pull/7897))
262
299
  - Bump `@metamask/keyring-api` from `^21.0.0` to `^21.5.0` ([#7857](https://github.com/MetaMask/core/pull/7857))
263
- - Bump `@metamask/account-tree-controller` from `^4.0.0` to `^4.1.1` ([#7869](https://github.com/MetaMask/core/pull/7869)), ([#7897](https://github.com/MetaMask/core/pull/7897))
264
- - Bump `@metamask/multichain-account-service` from `^5.1.0` to `^7.0.0` ([#7869](https://github.com/MetaMask/core/pull/7869)), ([#7897](https://github.com/MetaMask/core/pull/7897))
265
- - Bump `@metamask/transaction-controller` from `^62.15.0` to `^62.17.0` ([#7872](https://github.com/MetaMask/core/pull/7872)), ([#7897](https://github.com/MetaMask/core/pull/7897))
300
+ - Bump `@metamask/account-tree-controller` from `^4.0.0` to `^4.1.1` ([#7869](https://github.com/MetaMask/core/pull/7869), [#7897](https://github.com/MetaMask/core/pull/7897))
301
+ - Bump `@metamask/multichain-account-service` from `^5.1.0` to `^7.0.0` ([#7869](https://github.com/MetaMask/core/pull/7869), [#7897](https://github.com/MetaMask/core/pull/7897))
302
+ - Bump `@metamask/transaction-controller` from `^62.15.0` to `^62.17.0` ([#7872](https://github.com/MetaMask/core/pull/7872), [#7897](https://github.com/MetaMask/core/pull/7897))
266
303
  - Bump `@metamask/phishing-controller` from `^16.1.0` to `^16.2.0` ([#7883](https://github.com/MetaMask/core/pull/7883))
267
304
  - Optimize Price API performance by deduplicating concurrent API calls ([#7811](https://github.com/MetaMask/core/pull/7811))
268
305
  - Add in-flight promise caching for `fetchSupportedNetworks()` to prevent duplicate concurrent requests
@@ -272,13 +309,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
272
309
 
273
310
  ### Fixed
274
311
 
275
- - Remove `Tempo Testnet` multicall address ([#7858](https://github.com/MetaMask/core/pull/7858)).
312
+ - Remove `Tempo Testnet` multicall address. ([#7858](https://github.com/MetaMask/core/pull/7858))
276
313
 
277
314
  ## [99.3.0]
278
315
 
279
316
  ### Added
280
317
 
281
- - Add optional `rwaData` support when adding tokens in `TokensController` ([#7804](https://github.com/MetaMask/core/pull/7804)).
318
+ - Add optional `rwaData` support when adding tokens in `TokensController`. ([#7804](https://github.com/MetaMask/core/pull/7804))
282
319
 
283
320
  ### Changed
284
321
 
@@ -729,7 +766,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
729
766
  - **BREAKING:** Added constructor argument `tokenPricesService` in `currencyRateController` ([#6863](https://github.com/MetaMask/core/pull/6863))
730
767
  - Added `fetchExchangeRates` function to fetch exchange rates from price-api ([#6863](https://github.com/MetaMask/core/pull/6863))
731
768
  - Added `ignoreAssets` to allow ignoring assets for non-EVM chains ([#6981](https://github.com/MetaMask/core/pull/6981))
732
-
733
769
  - Added `searchTokens` function to search for tokens across multiple networks using CAIP format chain IDs ([#7004](https://github.com/MetaMask/core/pull/7004))
734
770
 
735
771
  ### Changed
@@ -909,8 +945,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
909
945
  - **BREAKING:** Rename `openSeaEnabled` to `displayNftMedia` in `NftController` ([#4774](https://github.com/MetaMask/core/pull/4774))
910
946
  - Ensure compatibility for extension preferences controller state
911
947
  - **BREAKING:** Remove `setApiKey` function and `openSeaApiKey` from `NftController` since opensea is not used anymore for NFT data ([#4774](https://github.com/MetaMask/core/pull/4774))
912
- - Bump `@metamask/phishing-controller` from `^13.1.0` to `^14.0.0` ([#6716](https://github.com/MetaMask/core/pull/6716), [#6629](https://github.com/MetaMask/core/pull/6716))
913
- - Bump `@metamask/preferences-controller` from `^19.0.0` to `^20.0.0` ([#6716](https://github.com/MetaMask/core/pull/6716), [#6629](https://github.com/MetaMask/core/pull/6716))
948
+ - Bump `@metamask/phishing-controller` from `^13.1.0` to `^14.0.0` ([#6716](https://github.com/MetaMask/core/pull/6716), [#6629](https://github.com/MetaMask/core/pull/6629))
949
+ - Bump `@metamask/preferences-controller` from `^19.0.0` to `^20.0.0` ([#6716](https://github.com/MetaMask/core/pull/6716), [#6629](https://github.com/MetaMask/core/pull/6629))
914
950
 
915
951
  ## [76.0.0]
916
952
 
@@ -982,9 +1018,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
982
1018
  ### Fixed
983
1019
 
984
1020
  - Fix values returned from multicall fetcher to use the correct BN type, not BigNumber ([#6411](https://github.com/MetaMask/core/pull/6411))
985
-
986
1021
  - Ensure every access to the state of `AccountTrackerController` is done with a checksumed address ([#6411](https://github.com/MetaMask/core/pull/6411))
987
-
988
1022
  - Ensure the balance passed to update `AccountTrackerController:updateNativeBalances` is of type `Hex` ([#6411](https://github.com/MetaMask/core/pull/6411))
989
1023
 
990
1024
  ## [74.3.0]
@@ -1022,22 +1056,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1022
1056
  ### Changed
1023
1057
 
1024
1058
  - Bump `@metamask/base-controller` from `^8.1.0` to `^8.2.0` ([#6355](https://github.com/MetaMask/core/pull/6355))
1025
-
1026
1059
  - Add new `accountId` field to the `Asset` type ([#6358](https://github.com/MetaMask/core/pull/6358))
1027
1060
 
1028
1061
  ### Fixed
1029
1062
 
1030
1063
  - Uses `InternalAccount['type']` for the `Asset['type']` property ([#6358](https://github.com/MetaMask/core/pull/6358))
1031
-
1032
1064
  - Ensure that the evm addresses used to fetch balances from AccountTrackerController state is lowercase, in order to account for discrepancies between clients ([#6358](https://github.com/MetaMask/core/pull/6358))
1033
-
1034
1065
  - Prevents mutation of memoized fields used inside selectors ([#6358](https://github.com/MetaMask/core/pull/6358))
1035
-
1036
1066
  - Fix duplicate token balance entries caused by case-sensitive address comparison in `TokenBalancesController.updateBalances` ([#6354](https://github.com/MetaMask/core/pull/6354))
1037
-
1038
1067
  - Normalize token addresses to proper EIP-55 checksum format before using as object keys to prevent the same token from appearing multiple times with different cases
1039
1068
  - Add comprehensive unit tests for token address normalization scenarios
1040
-
1041
1069
  - Fix TokenBalancesController timeout handling by replacing `safelyExecuteWithTimeout` with proper `Promise.race` implementation ([#6365](https://github.com/MetaMask/core/pull/6365))
1042
1070
  - Replace `safelyExecuteWithTimeout` which was silently swallowing timeout errors with direct `Promise.race` that properly throws
1043
1071
  - Reduce RPC timeout from 3 minutes to 15 seconds for better responsiveness and batch size
@@ -1273,11 +1301,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1273
1301
  ### Added
1274
1302
 
1275
1303
  - **BREAKING:** Add event listener for `AccountsController:accountRemoved` on `TokenBalancesController` to remove token balances for the removed account ([#5726](https://github.com/MetaMask/core/pull/5726))
1276
-
1277
1304
  - **BREAKING:** Add event listener for `AccountsController:accountRemoved` on `TokensController` to remove tokens for the removed account ([#5726](https://github.com/MetaMask/core/pull/5726))
1278
-
1279
1305
  - **BREAKING:** Add `listAccounts` action to `TokensController` ([#5726](https://github.com/MetaMask/core/pull/5726))
1280
-
1281
1306
  - **BREAKING:** Add `listAccounts` action to `TokenBalancesController` ([#5726](https://github.com/MetaMask/core/pull/5726))
1282
1307
 
1283
1308
  ### Changed
@@ -1427,8 +1452,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1427
1452
 
1428
1453
  ### Fixed
1429
1454
 
1430
- - Update token rate request key to handle when new tokens are detected inside the `TokenRatesController` ([#5531](https://github.com/MetaMask/core/pull/5311)))
1431
- - Update `CurrencyRateController` to prevent undefined or empty currencies from being queried ([#5458](https://github.com/MetaMask/core/pull/5458)))
1455
+ - Update token rate request key to handle when new tokens are detected inside the `TokenRatesController`) ([#5531](https://github.com/MetaMask/core/pull/5531))
1456
+ - Update `CurrencyRateController` to prevent undefined or empty currencies from being queried) ([#5458](https://github.com/MetaMask/core/pull/5458))
1432
1457
 
1433
1458
  ## [55.0.1]
1434
1459
 
@@ -1580,9 +1605,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1580
1605
  - `cockatiel` should still be in the dependency tree because it's now a dependency of `@metamask/controller-utils`
1581
1606
  - Re-introduce `@metamask/keyring-api` as a runtime dependency ([#5206](https://github.com/MetaMask/core/pull/5206))
1582
1607
  - This was required since the introduction of the `MultichainBalancesController`.
1583
- - Bump `@metamask/keyring-api` from `^14.0.0` to `^16.1.0` ([#5190](https://github.com/MetaMask/core/pull/5190)), ([#5208](https://github.com/MetaMask/core/pull/5208))
1584
- - Bump `@metamask/keyring-internal-api` from `^2.0.1` to `^4.0.1` ([#5190](https://github.com/MetaMask/core/pull/5190)), ([#5208](https://github.com/MetaMask/core/pull/5208))
1585
- - Bump `@metamask/keyring-snap-client` from `^3.0.0` to `^3.0.3` ([#5190](https://github.com/MetaMask/core/pull/5190)), ([#5208](https://github.com/MetaMask/core/pull/5208))
1608
+ - Bump `@metamask/keyring-api` from `^14.0.0` to `^16.1.0`, ([#5190](https://github.com/MetaMask/core/pull/5190), [#5208](https://github.com/MetaMask/core/pull/5208))
1609
+ - Bump `@metamask/keyring-internal-api` from `^2.0.1` to `^4.0.1`, ([#5190](https://github.com/MetaMask/core/pull/5190), [#5208](https://github.com/MetaMask/core/pull/5208))
1610
+ - Bump `@metamask/keyring-snap-client` from `^3.0.0` to `^3.0.3`, ([#5190](https://github.com/MetaMask/core/pull/5190), [#5208](https://github.com/MetaMask/core/pull/5208))
1586
1611
 
1587
1612
  ## [46.0.1]
1588
1613
 
@@ -1610,7 +1635,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1610
1635
  ### Changed
1611
1636
 
1612
1637
  - **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^20.0.0` to `^21.0.0` ([#5140](https://github.com/MetaMask/core/pull/5140))
1613
- - Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.1` ([#5079](https://github.com/MetaMask/core/pull/5079)), ([#5135](https://github.com/MetaMask/core/pull/5135))
1638
+ - Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.1`, ([#5079](https://github.com/MetaMask/core/pull/5079), [#5135](https://github.com/MetaMask/core/pull/5135))
1614
1639
  - Bump `@metamask/keyring-api` from `^12.0.0` to `^13.0.0` ([#5066](https://github.com/MetaMask/core/pull/5066))
1615
1640
  - Bump `@metamask/utils` to `^11.0.1` ([#5080](https://github.com/MetaMask/core/pull/5080))
1616
1641
  - Bump `@metamask/rpc-errors` to `^7.0.2` ([#5080](https://github.com/MetaMask/core/pull/5080))
@@ -1674,9 +1699,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1674
1699
 
1675
1700
  ### Changed
1676
1701
 
1677
- - **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))
1678
- - **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^19.0.0` to `^20.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))
1679
- - **BREAKING:** Bump `@metamask/preferences-controller` peer dependency from `^14.0.0` to `^15.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))
1702
+ - **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4956](https://github.com/MetaMask/core/pull/4956))
1703
+ - **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^19.0.0` to `^20.0.0` ([#4956](https://github.com/MetaMask/core/pull/4956))
1704
+ - **BREAKING:** Bump `@metamask/preferences-controller` peer dependency from `^14.0.0` to `^15.0.0` ([#4956](https://github.com/MetaMask/core/pull/4956))
1680
1705
 
1681
1706
  ## [44.1.0]
1682
1707
 
@@ -1689,7 +1714,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1689
1714
  ### Changed
1690
1715
 
1691
1716
  - Fixes an issue where the token detection was unnecessarily falling back to an RPC approach, causing redundant detections. ([#4928](https://github.com/MetaMask/core/pull/4928))
1692
-
1693
1717
  - Fixes an issue where `TokensController.addTokens` was not respecting the network client id passed to it. ([#4940](https://github.com/MetaMask/core/pull/4940))
1694
1718
 
1695
1719
  ## [44.0.0]
@@ -1697,13 +1721,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1697
1721
  ### Changed
1698
1722
 
1699
1723
  - **BREAKING**: The `TokenBalancesController` state is now across all chains and accounts under the field `tokenBalances`, as a mapping from account address -> chain id -> token address -> balance. ([#4782](https://github.com/MetaMask/core/pull/4782))
1700
-
1701
1724
  - **BREAKING**: The `TokenBalancesController` now extends `StaticIntervalPollingController`, and the new polling API `startPolling` must be used to initiate polling (`startPolling`, `stopPollingByPollingToken`). ([#4782](https://github.com/MetaMask/core/pull/4782))
1702
-
1703
1725
  - **BREAKING**: `TokenBalancesController` now requires subscriptions to the `PreferencesController:stateChange` and `NetworkController:stateChange` events. And access to the `NetworkController:getNetworkClientById`, `NetworkController:getState`, `TokensController:getState`, and `PreferencesController:getState` actions. ([#4782](https://github.com/MetaMask/core/pull/4782))
1704
-
1705
1726
  - **BREAKING**: `TokensController` requires a subscription to the `NetworkController:stateChange` event. It now now removes state for chain IDs when their network is removed. ([#4782](https://github.com/MetaMask/core/pull/4782))
1706
-
1707
1727
  - `TokenRatesController` now removes state for chain IDs when their network is removed. ([#4782](https://github.com/MetaMask/core/pull/4782))
1708
1728
 
1709
1729
  ## [43.1.1]
@@ -1797,7 +1817,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1797
1817
  ### Changed
1798
1818
 
1799
1819
  - Parallelization of detected tokens with balance ([#4697](https://github.com/MetaMask/core/pull/4697))
1800
- - Bump accounts related packages ([#4713](https://github.com/MetaMask/core/pull/4713)), ([#4728](https://github.com/MetaMask/core/pull/4728))
1820
+ - Bump accounts related packages, ([#4713](https://github.com/MetaMask/core/pull/4713), [#4728](https://github.com/MetaMask/core/pull/4728))
1801
1821
  - Those packages are now built slightly differently and are part of the [accounts monorepo](https://github.com/MetaMask/accounts).
1802
1822
  - Bump `@metamask/keyring-api` from `^8.1.0` to `^8.1.4`
1803
1823
 
@@ -1813,7 +1833,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1813
1833
  ["Are the Types Wrong?"](https://arethetypeswrong.github.io/) tool as
1814
1834
  ["masquerading as CJS"](https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md).
1815
1835
  All of the ATTW checks now pass.
1816
- - Remove chunk files ([#4648](https://github.com/MetaMask/core/pull/4648)).
1836
+ - Remove chunk files. ([#4648](https://github.com/MetaMask/core/pull/4648))
1817
1837
  - Previously, the build tool we used to generate JavaScript files extracted
1818
1838
  common code to "chunk" files. While this was intended to make this package
1819
1839
  more tree-shakeable, it also made debugging more difficult for our
@@ -2190,7 +2210,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2190
2210
  ### Added
2191
2211
 
2192
2212
  - `CodefiTokenPricesServiceV2` exports `SUPPORTED_CHAIN_IDS`, an array of chain IDs supported by Codefi Price API V2. ([#4079](https://github.com/MetaMask/core/pull/4079))
2193
-
2194
2213
  - Added `tokenURI` key to `compareNftMetadata` function to compare nft metadata entries with. ([#3856](https://github.com/MetaMask/core/pull/3856))
2195
2214
 
2196
2215
  ## [27.1.0]
@@ -2229,15 +2248,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2229
2248
 
2230
2249
  ### Added
2231
2250
 
2232
- - **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))
2233
- - `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, and `TokensControllerStateChangeEvent` ([#3690](https://github.com/MetaMask/core/pull/3690/))
2251
+ - **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))
2252
+ - `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, and `TokensControllerStateChangeEvent` ([#3690](https://github.com/MetaMask/core/pull/3690))
2234
2253
 
2235
2254
  ### Changed
2236
2255
 
2237
- - **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))
2256
+ - **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))
2238
2257
  - **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))
2239
2258
  - **BREAKING:** Bump `@metamask/preferences-controller` dependency and peer dependency to `^8.0.0` ([#4007](https://github.com/MetaMask/core/pull/4007))
2240
- - **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))
2259
+ - **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))
2241
2260
  - **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`.
2242
2261
  - **BREAKING:** `TokenDetectionController` now refetches tokens on `NetworkController:networkDidChange` if the `networkClientId` is changed instead of `chainId`.
2243
2262
  - **BREAKING:** `TokenDetectionController` cannot initiate polling or token detection if `KeyringController` state is locked.
@@ -2261,11 +2280,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2261
2280
 
2262
2281
  ### Removed
2263
2282
 
2264
- - **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))
2265
- - **BREAKING:** `TokenDetectionController` no longer allows the `NetworkController:stateChange` event. ([#3775](https://github.com/MetaMask/core/pull/3775/))
2283
+ - **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))
2284
+ - **BREAKING:** `TokenDetectionController` no longer allows the `NetworkController:stateChange` event. ([#3775](https://github.com/MetaMask/core/pull/3775))
2266
2285
  - The `NetworkController:networkDidChange` event can be used instead.
2267
- - **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))
2268
- - **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress` ([#3690](https://github.com/MetaMask/core/pull/3690/))
2286
+ - **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))
2287
+ - **BREAKING:** `TokenBalancesController` constructor no longer accepts options `onTokensStateChange`, `getSelectedAddress` ([#3690](https://github.com/MetaMask/core/pull/3690))
2269
2288
 
2270
2289
  ### Fixed
2271
2290
 
@@ -2323,9 +2342,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
2342
  - Add `onBreak` handler to `CodefiTokenPricesServiceV2` ([#3677](https://github.com/MetaMask/core/pull/3677))
2324
2343
  - This allows listening for "circuit breaks", which can indicate an outage. Useful for metrics.
2325
2344
  - Add `fetchTokenContractExchangeRates` utility method ([#3657](https://github.com/MetaMask/core/pull/3657))
2326
- - `TokenListController` now exports a `TokenListControllerMessenger` type ([#3609](https://github.com/MetaMask/core/pull/3609)).
2327
- - `TokenDetectionController` exports types `TokenDetectionControllerMessenger`, `TokenDetectionControllerActions`, `TokenDetectionControllerGetStateAction`, `TokenDetectionControllerEvents`, `TokenDetectionControllerStateChangeEvent` ([#3609](https://github.com/MetaMask/core/pull/3609)).
2328
- - Add `enable` and `disable` methods to `TokenDetectionController`, which control whether the controller is able to make polling requests or all of its network calls are blocked. ([#3609](https://github.com/MetaMask/core/pull/3609)).
2345
+ - `TokenListController` now exports a `TokenListControllerMessenger` type. ([#3609](https://github.com/MetaMask/core/pull/3609))
2346
+ - `TokenDetectionController` exports types `TokenDetectionControllerMessenger`, `TokenDetectionControllerActions`, `TokenDetectionControllerGetStateAction`, `TokenDetectionControllerEvents`, `TokenDetectionControllerStateChangeEvent`. ([#3609](https://github.com/MetaMask/core/pull/3609))
2347
+ - Add `enable` and `disable` methods to `TokenDetectionController`, which control whether the controller is able to make polling requests or all of its network calls are blocked.. ([#3609](https://github.com/MetaMask/core/pull/3609))
2329
2348
  - Note that if the controller is initiated without the `disabled` constructor option set to `false`, the `enable` method will need to be called before the controller can make polling requests in response to subscribed events.
2330
2349
 
2331
2350
  ### Changed
@@ -2334,7 +2353,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2334
2353
  - **BREAKING:** Bump `@metamask/network-controller` dependency and peer dependency from `^17.0.0` to `^17.1.0` ([#3695](https://github.com/MetaMask/core/pull/3695))
2335
2354
  - **BREAKING:** Bump `@metamask/preferences-controller` dependency and peer dependency from `^5.0.0` to `^5.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695))
2336
2355
  - **BREAKING:** Update `OpenSeaV2Contract` type, renaming `supply` to `total_supply` ([#3692](https://github.com/MetaMask/core/pull/3692))
2337
- - **BREAKING:** `TokenDetectionController` is upgraded to extend `BaseControllerV2` and `StaticIntervalPollingController` ([#3609](https://github.com/MetaMask/core/pull/3609)).
2356
+ - **BREAKING:** `TokenDetectionController` is upgraded to extend `BaseControllerV2` and `StaticIntervalPollingController`. ([#3609](https://github.com/MetaMask/core/pull/3609))
2338
2357
  - The constructor now expects an options object as its only argument, with required properties `messenger`, `networkClientId`, required callbacks `onPreferencesStateChange`, `getBalancesInSingleCall`, `addDetectedTokens`, `getTokenState`, `getPreferencesState`, and optional properties `disabled`, `interval`, `selectedAddress`.
2339
2358
  - Bump `@metamask/base-controller` to `^4.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695))
2340
2359
  - Bump `@metamask/polling-controller` to `^4.0.0` ([#3695](https://github.com/MetaMask/core/pull/3695))
@@ -2360,7 +2379,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2360
2379
 
2361
2380
  ### Added
2362
2381
 
2363
- - Add `CodefiTokenPricesServiceV2` ([#3600](https://github.com/MetaMask/core/pull/3600), [#3655](https://github.com/MetaMask/core/pull/3655), [#3655](https://github.com/MetaMask/core/pull/3655))
2382
+ - Add `CodefiTokenPricesServiceV2` ([#3600](https://github.com/MetaMask/core/pull/3600), [#3655](https://github.com/MetaMask/core/pull/3655))
2364
2383
  - This class can be used for the new `tokenPricesService` argument for TokenRatesController. It uses a MetaMask API to fetch prices for tokens instead of CoinGecko.
2365
2384
  - The `CodefiTokenPricesServiceV2` will retry if the token price update fails
2366
2385
  - We retry each request up to 3 times using a randomized exponential backoff strategy
@@ -2903,9 +2922,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2903
2922
  ### Added
2904
2923
 
2905
2924
  - Initial release
2906
-
2907
2925
  - As a result of converting our shared controllers repo into a monorepo ([#831](https://github.com/MetaMask/core/pull/831)), we've created this package from select parts of [`@metamask/controllers` v33.0.0](https://github.com/MetaMask/core/tree/v33.0.0), namely:
2908
-
2909
2926
  - Everything in `src/assets`
2910
2927
  - Asset-related functions from `src/util.ts` and accompanying tests
2911
2928
 
@@ -2915,7 +2932,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2915
2932
 
2916
2933
  - Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))
2917
2934
 
2918
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@103.1.1...HEAD
2935
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@104.1.0...HEAD
2936
+ [104.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@104.0.0...@metamask/assets-controllers@104.1.0
2937
+ [104.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@103.1.1...@metamask/assets-controllers@104.0.0
2919
2938
  [103.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@103.1.0...@metamask/assets-controllers@103.1.1
2920
2939
  [103.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@103.0.0...@metamask/assets-controllers@103.1.0
2921
2940
  [103.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@102.0.0...@metamask/assets-controllers@103.0.0
@@ -424,9 +424,11 @@ _AccountTrackerController_refreshMutex = new WeakMap(), _AccountTrackerControlle
424
424
  const oldAddresses = existing.filter((address) => !addresses.includes(address));
425
425
  Object.keys(accountsByChainId).forEach((chainId) => {
426
426
  newAddresses.forEach((address) => {
427
- accountsByChainId[chainId][address] = {
428
- balance: '0x0',
429
- };
427
+ if (!accountsByChainId[chainId][address]) {
428
+ accountsByChainId[chainId][address] = {
429
+ balance: '0x0',
430
+ };
431
+ }
430
432
  });
431
433
  });
432
434
  Object.keys(accountsByChainId).forEach((chainId) => {