@metamask-previews/assets-controller 14.0.3-preview-ea6a28c61 → 14.0.3-preview-e12b5ece6

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 +20 -1
  2. package/dist/AssetsController.cjs +4 -0
  3. package/dist/AssetsController.cjs.map +1 -1
  4. package/dist/AssetsController.d.cts +7 -0
  5. package/dist/AssetsController.d.cts.map +1 -1
  6. package/dist/AssetsController.d.mts +7 -0
  7. package/dist/AssetsController.d.mts.map +1 -1
  8. package/dist/AssetsController.mjs +4 -0
  9. package/dist/AssetsController.mjs.map +1 -1
  10. package/dist/data-sources/AccountsApiDataSource.cjs +9 -2
  11. package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
  12. package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
  13. package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
  14. package/dist/data-sources/AccountsApiDataSource.mjs +9 -2
  15. package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
  16. package/dist/data-sources/RpcDataSource.cjs +9 -0
  17. package/dist/data-sources/RpcDataSource.cjs.map +1 -1
  18. package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
  19. package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
  20. package/dist/data-sources/RpcDataSource.mjs +9 -0
  21. package/dist/data-sources/RpcDataSource.mjs.map +1 -1
  22. package/dist/middlewares/RpcFallbackMiddleware.cjs +142 -14
  23. package/dist/middlewares/RpcFallbackMiddleware.cjs.map +1 -1
  24. package/dist/middlewares/RpcFallbackMiddleware.d.cts +14 -6
  25. package/dist/middlewares/RpcFallbackMiddleware.d.cts.map +1 -1
  26. package/dist/middlewares/RpcFallbackMiddleware.d.mts +14 -6
  27. package/dist/middlewares/RpcFallbackMiddleware.d.mts.map +1 -1
  28. package/dist/middlewares/RpcFallbackMiddleware.mjs +142 -14
  29. package/dist/middlewares/RpcFallbackMiddleware.mjs.map +1 -1
  30. package/dist/selectors/balance.cjs +9 -4
  31. package/dist/selectors/balance.cjs.map +1 -1
  32. package/dist/selectors/balance.d.cts.map +1 -1
  33. package/dist/selectors/balance.d.mts.map +1 -1
  34. package/dist/selectors/balance.mjs +9 -4
  35. package/dist/selectors/balance.mjs.map +1 -1
  36. package/dist/types.cjs.map +1 -1
  37. package/dist/types.d.cts +8 -0
  38. package/dist/types.d.cts.map +1 -1
  39. package/dist/types.d.mts +8 -0
  40. package/dist/types.d.mts.map +1 -1
  41. package/dist/types.mjs.map +1 -1
  42. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -7,13 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `bypassServerCache` option to `getAssets` ([#10068](https://github.com/MetaMask/core/pull/10068))
13
+ - When true (only meaningful together with `forceUpdate`), the Accounts API request also bypasses the API's server-side 60s cache via a random `bypassServerCache` query param, instead of only the client-side query cache.
14
+
10
15
  ### Changed
11
16
 
17
+ - Bump `@metamask/phishing-controller` from `^17.4.0` to `^17.4.1` ([#10080](https://github.com/MetaMask/core/pull/10080))
12
18
  - **BREAKING:** `AssetsControllerMessenger` now requires `AccountTreeController:isInitialized`, `ClientController:getState`, and `KeyringController:isUnlocked` so lifecycle checks read controller state on demand instead of mirroring it from events ([#10059](https://github.com/MetaMask/core/pull/10059))
13
19
  - Hosts that restrict which actions flow through the `AssetsController` messenger must delegate these three actions
14
20
  - `AccountTreeController:stateChange` is no longer subscribed to; remove it from allowed events if your messenger wiring lists events explicitly
15
21
  - Revert to `selectedAccountGroupChange` for account-group switches; snap accounts added mid-session are picked up on restart ([#10059](https://github.com/MetaMask/core/pull/10059))
16
- - Bump `@metamask/transaction-controller` from `^69.6.1` to `^69.7.0` ([#10046](https://github.com/MetaMask/core/pull/10046))
22
+ - Bump `@metamask/transaction-controller` from `^69.6.1` to `^69.8.0` ([#10046](https://github.com/MetaMask/core/pull/10046), [#10080](https://github.com/MetaMask/core/pull/10080))
23
+ - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
24
+
25
+ ### Fixed
26
+
27
+ - Exclude assets that have no `assetsInfo` metadata from the aggregated balance selectors ([#10084](https://github.com/MetaMask/core/pull/10084))
28
+ - `getAggregatedBalanceForAccount`, `getAggregatedBalanceForAccountIds`, `calculateBalanceForAllWallets`, and `calculateBalanceChangeForAccountGroup` previously included such assets in `entries` (without `symbol`/`name`/`decimals`) and in fiat totals; a balance now only counts once its metadata is known
29
+ - Run `RpcFallbackMiddleware` on Accounts API poll updates (`handleAssetsUpdate`), not only in the forced `getAssets` fast pipeline, so a stale amount for tokens omitted from poll responses no longer survives between forced refreshes while the wallet sits open ([#10078](https://github.com/MetaMask/core/pull/10078))
30
+ - WebSocket, RPC, and Snap updates are excluded: WebSocket pushes are incremental single-asset updates where absence is not staleness, and RPC/Snap updates must not re-trigger RPC
31
+ - Fix stale balances shown right after a transaction confirms: the post-confirmation refresh now calls `getAssets` with `bypassServerCache: true`, since WebSocket events do not invalidate the Accounts API's server-side cache and a plain refetch within its 60s window returns the pre-transaction snapshot ([#10068](https://github.com/MetaMask/core/pull/10068))
32
+ - Fix stale balances surviving in state when the Accounts API returns no entry for an asset it does not index (or reports an untrusted `0`), which the `merge` update kept as the previous amount ([#10061](https://github.com/MetaMask/core/pull/10061))
33
+ - `RpcFallbackMiddleware` now re-reads EVM assets tracked in state (`assetsBalance` or `customAssets`) whose balance is empty in the current response, passing them to `RpcDataSource` as `customAssets`, in addition to its existing retry of chains in `response.errors`. Staking vault assets and assets on chains outside the request or the account's supported set are excluded.
34
+ - Balances from chains the RPC read itself failed on are discarded instead of merged, so a transient RPC failure can no longer overwrite a correct upstream balance with the failure stub's native `0` (or, previously, falsely clear the chain's error as "recovered"). The chain's error is kept only when it was already errored upstream.
35
+ - `RpcDataSource.assetsMiddleware` now propagates per-chain fetch errors onto the pipeline response (previously it only used them internally), which is what lets `RpcFallbackMiddleware` identify the failed chains.
17
36
 
18
37
  ## [14.0.3]
19
38
 
@@ -473,6 +473,7 @@ class AssetsController extends base_controller_1.BaseController {
473
473
  dataTypes,
474
474
  customAssets: customAssets.length > 0 ? customAssets : undefined,
475
475
  forceUpdate: true,
476
+ bypassServerCache: options?.bypassServerCache,
476
477
  assetsForPriceUpdate: options?.assetsForPriceUpdate,
477
478
  });
478
479
  // Fast pipeline: accountsApi + stakedBalance → detection → token + price.
@@ -1081,6 +1082,7 @@ class AssetsController extends base_controller_1.BaseController {
1081
1082
  // detection, so spam is never detected, enriched, priced or persisted.
1082
1083
  const shouldFilterOccurrences = sourceId === 'AccountActivityDataSource' &&
1083
1084
  __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this);
1085
+ const shouldRunRpcFallback = sourceId === 'AccountsApiDataSource';
1084
1086
  const enrichmentSources = [
1085
1087
  ...(shouldGraduateCustomAssets
1086
1088
  ? [__classPrivateFieldGet(this, _AssetsController_customAssetGraduationMiddleware, "f")]
@@ -1093,6 +1095,7 @@ class AssetsController extends base_controller_1.BaseController {
1093
1095
  },
1094
1096
  ]
1095
1097
  : []),
1098
+ ...(shouldRunRpcFallback ? [__classPrivateFieldGet(this, _AssetsController_rpcFallbackMiddleware, "f")] : []),
1096
1099
  __classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
1097
1100
  ];
1098
1101
  if (__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
@@ -1372,6 +1375,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
1372
1375
  this.getAssets([matchedAccount], {
1373
1376
  chainIds: [caipChainId],
1374
1377
  forceUpdate: true,
1378
+ bypassServerCache: true,
1375
1379
  }).catch((error) => {
1376
1380
  log('Failed to refresh assets after transaction event', { error });
1377
1381
  });