@metamask-previews/assets-controller 8.0.0-preview-8e8c4f6f5 → 8.0.1-preview-e43dfcb

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
@@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [8.0.1]
11
+
10
12
  ### Fixed
11
13
 
12
- - Export `SnapControllerSnapInstalledEvent` from `AssetsControllerMessenger` allowed events type ([#8868](https://github.com/MetaMask/core/pull/8868))
14
+ - Add the previously declared `SnapControllerSnapInstalledEvent` to the `AssetsControllerMessenger` allowed events ([#8868](https://github.com/MetaMask/core/pull/8868))
15
+ - `addCustomAsset` now immediately seeds `assetsBalance` with a zero amount for the newly added asset, so the UI can render it before the next pipeline fetch ([#8872](https://github.com/MetaMask/core/pull/8872))
13
16
 
14
17
  ## [8.0.0]
15
18
 
@@ -518,7 +521,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
518
521
  - Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
519
522
  - Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
520
523
 
521
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@8.0.0...HEAD
524
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@8.0.1...HEAD
525
+ [8.0.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@8.0.0...@metamask/assets-controller@8.0.1
522
526
  [8.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.2...@metamask/assets-controller@8.0.0
523
527
  [7.1.2]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.1...@metamask/assets-controller@7.1.2
524
528
  [7.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.0...@metamask/assets-controller@7.1.1
@@ -596,6 +596,7 @@ class AssetsController extends base_controller_1.BaseController {
596
596
  const normalizedAssetId = (0, utils_2.normalizeAssetId)(assetId);
597
597
  log('Adding custom asset', { accountId, assetId: normalizedAssetId });
598
598
  this.update((state) => {
599
+ var _a;
599
600
  const customAssets = state.customAssets;
600
601
  if (!customAssets[accountId]) {
601
602
  customAssets[accountId] = [];
@@ -635,6 +636,11 @@ class AssetsController extends base_controller_1.BaseController {
635
636
  state.assetsInfo[normalizedAssetId] =
636
637
  assetMetadata;
637
638
  }
639
+ // Seed a zero balance so the UI can render the asset immediately,
640
+ // before the next pipeline fetch returns the real amount.
641
+ const balances = state.assetsBalance;
642
+ balances[accountId] ?? (balances[accountId] = {});
643
+ (_a = balances[accountId])[normalizedAssetId] ?? (_a[normalizedAssetId] = { amount: '0' });
638
644
  });
639
645
  // Fetch data for the newly added custom asset (merge to preserve other chains)
640
646
  const account = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this).find((a) => a.id === accountId);
@@ -642,6 +648,8 @@ class AssetsController extends base_controller_1.BaseController {
642
648
  const chainId = extractChainId(normalizedAssetId);
643
649
  await this.getAssets([account], {
644
650
  chainIds: [chainId],
651
+ dataTypes: ['balance', 'metadata', 'price'],
652
+ assetTypes: ['fungible'],
645
653
  forceUpdate: true,
646
654
  updateMode: 'merge',
647
655
  });