@metamask/assets-controller 2.3.0 → 2.4.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 (42) hide show
  1. package/CHANGELOG.md +19 -1
  2. package/dist/AssetsController.cjs +20 -1
  3. package/dist/AssetsController.cjs.map +1 -1
  4. package/dist/AssetsController.d.cts.map +1 -1
  5. package/dist/AssetsController.d.mts.map +1 -1
  6. package/dist/AssetsController.mjs +20 -1
  7. package/dist/AssetsController.mjs.map +1 -1
  8. package/dist/data-sources/RpcDataSource.cjs +102 -18
  9. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  10. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  11. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  12. package/dist/data-sources/RpcDataSource.mjs +102 -18
  13. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  14. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs +1 -1
  15. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.cjs.map +1 -1
  16. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.cts +1 -1
  17. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.cts.map +1 -1
  18. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.mts +1 -1
  19. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.d.mts.map +1 -1
  20. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.mjs +1 -1
  21. package/dist/data-sources/evm-rpc-services/services/BalanceFetcher.mjs.map +1 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +1 -1
  24. package/dist/index.d.cts.map +1 -1
  25. package/dist/index.d.mts +1 -1
  26. package/dist/index.d.mts.map +1 -1
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/utils/formatExchangeRatesForBridge.cjs +17 -1
  29. package/dist/utils/formatExchangeRatesForBridge.cjs.map +1 -1
  30. package/dist/utils/formatExchangeRatesForBridge.d.cts +4 -32
  31. package/dist/utils/formatExchangeRatesForBridge.d.cts.map +1 -1
  32. package/dist/utils/formatExchangeRatesForBridge.d.mts +4 -32
  33. package/dist/utils/formatExchangeRatesForBridge.d.mts.map +1 -1
  34. package/dist/utils/formatExchangeRatesForBridge.mjs +17 -1
  35. package/dist/utils/formatExchangeRatesForBridge.mjs.map +1 -1
  36. package/dist/utils/index.cjs.map +1 -1
  37. package/dist/utils/index.d.cts +1 -1
  38. package/dist/utils/index.d.cts.map +1 -1
  39. package/dist/utils/index.d.mts +1 -1
  40. package/dist/utils/index.d.mts.map +1 -1
  41. package/dist/utils/index.mjs.map +1 -1
  42. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.4.0]
11
+
12
+ ### Changed
13
+
14
+ - Bump `@metamask/network-enablement-controller` from `^4.2.0` to `^5.0.0` ([#8225](https://github.com/MetaMask/core/pull/8225))
15
+ - Bump `@metamask/permission-controller` from `^12.2.0` to `^12.2.1` ([#8225](https://github.com/MetaMask/core/pull/8225))
16
+ - `BridgeExchangeRatesFormat` type now uses canonical `@metamask/assets-controllers` state types instead of locally-defined bridge rate entry types ([#8175](https://github.com/MetaMask/core/pull/8175))
17
+ - Bump `@metamask/account-tree-controller` from `^5.0.0` to `^5.0.1` ([#8162](https://github.com/MetaMask/core/pull/8162))
18
+ - Bump `@metamask/assets-controllers` from `^100.2.0` to `^101.0.0` ([#8162](https://github.com/MetaMask/core/pull/8162), [#8225](https://github.com/MetaMask/core/pull/8225))
19
+ - Bump `@metamask/core-backend` from `^6.1.0` to `^6.1.1` ([#8162](https://github.com/MetaMask/core/pull/8162))
20
+ - Bump `@metamask/transaction-controller` from `^62.21.0` to `^63.0.0` ([#8217](https://github.com/MetaMask/core/pull/8217), [#8225](https://github.com/MetaMask/core/pull/8225))
21
+
22
+ ### Fixed
23
+
24
+ - Preserve custom asset metadata (symbol, name, decimals, image) in `AssetsController` when the API returns an empty response for an unknown token, preventing incorrect balance calculations and display for user-deployed tokens added via `wallet_watchAsset` ([#8202](https://github.com/MetaMask/core/pull/8202))
25
+ - Include custom asset token addresses in `RpcDataSource` balance fetches so that on-chain balances are retrieved immediately after token import via `addCustomAsset` ([#8202](https://github.com/MetaMask/core/pull/8202))
26
+
10
27
  ## [2.3.0]
11
28
 
12
29
  ### Added
@@ -158,7 +175,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
158
175
  - Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
159
176
  - Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
160
177
 
161
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.3.0...HEAD
178
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.4.0...HEAD
179
+ [2.4.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.3.0...@metamask/assets-controller@2.4.0
162
180
  [2.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.2.0...@metamask/assets-controller@2.3.0
163
181
  [2.2.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.1.0...@metamask/assets-controller@2.2.0
164
182
  [2.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@2.0.2...@metamask/assets-controller@2.1.0
@@ -966,7 +966,26 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
966
966
  if (!(0, lodash_1.isEqual)(previousState.assetsInfo[key], value)) {
967
967
  changedMetadata.push(key);
968
968
  }
969
- metadata[key] = value;
969
+ const existing = metadata[key];
970
+ const incoming = value;
971
+ // When the API returns no symbol or name for this token, it has no
972
+ // real knowledge of it (e.g. a user-deployed token not indexed by
973
+ // the API). Preserve richer metadata already in state (e.g. from
974
+ // pendingMetadata set by addCustomAsset) so that the correct
975
+ // decimals/symbol/name/image are not overwritten with empty values.
976
+ if (existing && !incoming.symbol && !incoming.name) {
977
+ metadata[key] = {
978
+ ...existing,
979
+ ...incoming,
980
+ symbol: existing.symbol,
981
+ name: existing.name,
982
+ decimals: existing.decimals ?? incoming.decimals,
983
+ image: existing.image ?? incoming.image,
984
+ };
985
+ }
986
+ else {
987
+ metadata[key] = value;
988
+ }
970
989
  }
971
990
  }
972
991
  if (normalizedResponse.assetsBalance) {