@metamask-previews/assets-controller 2.3.0-preview-4183330c3 → 2.3.0-preview-efc1fb7

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.
package/CHANGELOG.md CHANGED
@@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
  - Bump `@metamask/assets-controllers` from `^100.2.0` to `^100.2.1` ([#8162](https://github.com/MetaMask/core/pull/8162))
15
15
  - Bump `@metamask/core-backend` from `^6.1.0` to `^6.1.1` ([#8162](https://github.com/MetaMask/core/pull/8162))
16
16
 
17
+ ### Fixed
18
+
19
+ - 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))
20
+ - 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))
21
+
17
22
  ## [2.3.0]
18
23
 
19
24
  ### Added
@@ -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) {