@metamask-previews/assets-controller 14.0.3-preview-64bce4b11 → 14.0.3-preview-1cf7cc7b3

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
@@ -11,10 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  - Bump `@metamask/transaction-controller` from `^69.6.1` to `^69.7.0` ([#10046](https://github.com/MetaMask/core/pull/10046))
13
13
 
14
- ### Fixed
15
-
16
- - Fix stale ARC USDC/EURC balances after confirmed swaps by running an authoritative RPC balance refresh for post-transaction asset updates ([#10058](https://github.com/MetaMask/core/pull/10058))
17
-
18
14
  ## [14.0.3]
19
15
 
20
16
  ### Changed
@@ -473,27 +473,9 @@ class AssetsController extends base_controller_1.BaseController {
473
473
  }
474
474
  // Collect custom assets for all requested accounts
475
475
  const customAssets = [];
476
- const chainIdSet = new Set(chainIds);
477
476
  for (const account of accounts) {
478
477
  const accountCustomAssets = this.getCustomAssets(account.id);
479
478
  customAssets.push(...accountCustomAssets);
480
- // When refreshing after a confirmed transaction, also include graduated
481
- // tokens — ERC-20s currently in assetsBalance but removed from
482
- // customAssets by CustomAssetGraduationMiddleware. The Accounts API
483
- // indexes incoming transfers (received tokens) slower than outgoing
484
- // ones, so without a direct RPC query the "to" token in a swap keeps
485
- // the stale API-cached balance until the next polling cycle.
486
- if (options?.postTransaction) {
487
- const stateBalances = this.state.assetsBalance[account.id] ?? {};
488
- for (const assetId of Object.keys(stateBalances)) {
489
- const assetChainId = assetId.split('/')[0];
490
- if (chainIdSet.has(assetChainId) &&
491
- !(0, index_js_1.isStakingContractAssetId)(assetId) &&
492
- !customAssets.includes(assetId)) {
493
- customAssets.push(assetId);
494
- }
495
- }
496
- }
497
479
  }
498
480
  if (options?.forceUpdate) {
499
481
  // Pipeline spans only on unlock/first-init fetch; later forceUpdates pass
@@ -592,15 +574,11 @@ class AssetsController extends base_controller_1.BaseController {
592
574
  __classPrivateFieldSet(this, _AssetsController_firstInitFetchReported, true, "f");
593
575
  // Background (slow) lane — flattened sibling of the fast lane (not nested
594
576
  // inside its withTrace callback). Still fire-and-forget so UI is not blocked.
595
- const slowPipelineChainIds = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSlowPipelineChainIds).call(this, chainIds, response, { forceAll: options?.postTransaction === true });
577
+ const slowPipelineChainIds = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSlowPipelineChainIds).call(this, chainIds, response);
596
578
  if (slowPipelineChainIds.length > 0) {
597
- let slowSources;
598
- if (options?.postTransaction || !__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
599
- slowSources = [__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")];
600
- }
601
- else {
602
- slowSources = [__classPrivateFieldGet(this, _AssetsController_snapDataSource, "f"), __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")];
603
- }
579
+ const slowSources = __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
580
+ ? [__classPrivateFieldGet(this, _AssetsController_snapDataSource, "f"), __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")]
581
+ : [__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")];
604
582
  const slowRequest = { ...request, chainIds: slowPipelineChainIds };
605
583
  (0, trace_js_1.withTrace)({
606
584
  name: TRACE_BACKGROUND_FETCH,
@@ -1382,9 +1360,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
1382
1360
  // RpcDataSource also listens for transactionConfirmed, but only refreshes
1383
1361
  // chains it owns via an active subscription.
1384
1362
  this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
1385
- __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_refreshAssetsForTransaction).call(this, transactionMeta, {
1386
- postTransaction: true,
1387
- });
1363
+ __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_refreshAssetsForTransaction).call(this, transactionMeta);
1388
1364
  });
1389
1365
  // Start tracking only after the account tree is fully built. Unlock can
1390
1366
  // happen before `AccountTreeController.init()`, and `:stateChange` fires
@@ -1397,20 +1373,17 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
1397
1373
  __classPrivateFieldSet(this, _AssetsController_accountTreeInitialized, false, "f");
1398
1374
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateActive).call(this);
1399
1375
  });
1400
- }, _AssetsController_refreshAssetsForTransaction = function _AssetsController_refreshAssetsForTransaction(transactionMeta, options) {
1376
+ }, _AssetsController_refreshAssetsForTransaction = function _AssetsController_refreshAssetsForTransaction(transactionMeta) {
1401
1377
  const hexChainId = transactionMeta.chainId;
1402
1378
  if (!hexChainId) {
1403
1379
  return;
1404
1380
  }
1405
1381
  const caipChainId = `eip155:${parseInt(hexChainId, 16)}`;
1406
1382
  // AccountActivity pushes live balance updates for its active chains; a
1407
- // pre-confirmation force getAssets would be redundant and can race the
1408
- // WebSocket path. After confirmation, still run the post-transaction RPC
1409
- // pass because AccountActivity may update only part of a swap pair.
1410
- if (!options?.postTransaction &&
1411
- __classPrivateFieldGet(this, _AssetsController_accountActivityDataSource, "f")
1412
- .getActiveChainsSync()
1413
- .includes(caipChainId)) {
1383
+ // force getAssets would be redundant and can race the WebSocket path.
1384
+ if (__classPrivateFieldGet(this, _AssetsController_accountActivityDataSource, "f")
1385
+ .getActiveChainsSync()
1386
+ .includes(caipChainId)) {
1414
1387
  return;
1415
1388
  }
1416
1389
  const fromAddress = transactionMeta.txParams.from?.toLowerCase();
@@ -1424,7 +1397,6 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
1424
1397
  this.getAssets([matchedAccount], {
1425
1398
  chainIds: [caipChainId],
1426
1399
  forceUpdate: true,
1427
- postTransaction: options?.postTransaction,
1428
1400
  }).catch((error) => {
1429
1401
  log('Failed to refresh assets after transaction event', { error });
1430
1402
  });
@@ -1775,11 +1747,7 @@ async function _AssetsController_executeMiddlewares(params) {
1775
1747
  return __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_resolveNativeAssetIds).call(this, __classPrivateFieldGet(this, _AssetsController_enabledChains, "f"));
1776
1748
  }, _AssetsController_getNativeAssetIdsForAccount = function _AssetsController_getNativeAssetIdsForAccount(account) {
1777
1749
  return __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_resolveNativeAssetIds).call(this, __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getEnabledChainsForAccount).call(this, account));
1778
- }, _AssetsController_getSlowPipelineChainIds = function _AssetsController_getSlowPipelineChainIds(chainIds, fastResponse, options) {
1779
- // Post-transaction: always run RPC to override potentially stale Accounts API data.
1780
- if (options?.forceAll) {
1781
- return chainIds;
1782
- }
1750
+ }, _AssetsController_getSlowPipelineChainIds = function _AssetsController_getSlowPipelineChainIds(chainIds, fastResponse) {
1783
1751
  const accountsApiChains = new Set(__classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f").getActiveChainsSync());
1784
1752
  return chainIds.filter((chainId) => {
1785
1753
  if (fastResponse.errors?.[chainId]) {