@metamask-previews/assets-controller 10.1.0-preview-d52465c2b → 10.1.0-preview-186382c0a

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 (28) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/AssetsController.cjs +2 -8
  3. package/dist/AssetsController.cjs.map +1 -1
  4. package/dist/AssetsController.d.cts +14 -1
  5. package/dist/AssetsController.d.cts.map +1 -1
  6. package/dist/AssetsController.d.mts +14 -1
  7. package/dist/AssetsController.d.mts.map +1 -1
  8. package/dist/AssetsController.mjs +2 -8
  9. package/dist/AssetsController.mjs.map +1 -1
  10. package/dist/data-sources/AccountsApiDataSource.cjs +6 -4
  11. package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
  12. package/dist/data-sources/AccountsApiDataSource.mjs +6 -4
  13. package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
  14. package/dist/data-sources/BackendWebsocketDataSource.cjs +98 -38
  15. package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
  16. package/dist/data-sources/BackendWebsocketDataSource.d.cts +8 -0
  17. package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
  18. package/dist/data-sources/BackendWebsocketDataSource.d.mts +8 -0
  19. package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
  20. package/dist/data-sources/BackendWebsocketDataSource.mjs +98 -38
  21. package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
  22. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs +54 -13
  23. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.cjs.map +1 -1
  24. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.cts.map +1 -1
  25. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.d.mts.map +1 -1
  26. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs +54 -13
  27. package/dist/data-sources/evm-rpc-services/clients/MulticallClient.mjs.map +1 -1
  28. package/package.json +4 -4
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
+ ### Added
11
+
12
+ - Add `webSocketEnabledNamespaces` constructor option to gate non-EVM account-activity balances (e.g. Solana) behind a feature flag ([#9430](https://github.com/MetaMask/core/pull/9430))
13
+ - The getter returns the non-EVM CAIP namespaces (e.g. `['solana']`, and later `['solana', 'bip122']` for Tron) served over WebSocket. EVM (`eip155`) is always served over WebSocket.
14
+ - For each enabled namespace (while the WebSocket is connected), `BackendWebsocketDataSource` claims that namespace's chains and streams real-time balances for them; disabled namespaces are left unclaimed and unsubscribed so the `SnapDataSource` serves them.
15
+ - When the WebSocket is down, those chains are released, so the `SnapDataSource` takes over as a fallback.
16
+ - When a chain (or a whole non-EVM namespace, e.g. Solana) is reported down via `system-notifications`, it is excluded from the WebSocket source's claimable chains and automatically falls back to the `SnapDataSource` until it recovers.
17
+ - Defaults to none (`() => []`; EVM only).
18
+
19
+ ### Changed
20
+
21
+ - `AccountsApiDataSource` now documents that it serves EVM chains only; non-EVM chains (e.g. Solana) are served by the WebSocket source when enabled, otherwise by the Snap source ([#9430](https://github.com/MetaMask/core/pull/9430))
22
+ - `MulticallClient` memoizes `balanceOf` and `getEthBalance` call encodings per account address when building multicall batches, reducing redundant ABI encoding for wallets with many tokens ([#9425](https://github.com/MetaMask/core/pull/9425))
23
+ - Bump `@metamask/transaction-controller` from `^68.2.2` to `^68.3.0` ([#9421](https://github.com/MetaMask/core/pull/9421))
24
+ - Bump `@metamask/keyring-api` from `^23.3.0` to `^23.5.0` ([#9390](https://github.com/MetaMask/core/pull/9390))
25
+ - Bump `@metamask/keyring-snap-client` from `^9.0.2` to `^9.2.0` ([#9390](https://github.com/MetaMask/core/pull/9390))
26
+
10
27
  ## [10.1.0]
11
28
 
12
29
  ### Added
@@ -260,7 +260,7 @@ function mergeAccountBalances(previousBalances, accountBalances, customAssetIds,
260
260
  * - The controller does NOT manage polling - it simply receives pushed updates
261
261
  */
262
262
  class AssetsController extends base_controller_1.BaseController {
263
- constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, isEnabled = () => true, isBasicFunctionality, subscribeToBasicFunctionalityChange, queryApiClient, rpcDataSourceConfig, trace, captureException, accountsApiDataSourceConfig, priceDataSourceConfig, stakedBalanceDataSourceConfig, isOnboarded, tempMigrateAssetsInfoMetadataAssets3346, }) {
263
+ constructor({ messenger, state = {}, defaultUpdateInterval = DEFAULT_POLLING_INTERVAL_MS, isEnabled = () => true, isBasicFunctionality, subscribeToBasicFunctionalityChange, webSocketEnabledNamespaces, queryApiClient, rpcDataSourceConfig, trace, captureException, accountsApiDataSourceConfig, priceDataSourceConfig, stakedBalanceDataSourceConfig, isOnboarded, tempMigrateAssetsInfoMetadataAssets3346, }) {
264
264
  super({
265
265
  name: CONTROLLER_NAME,
266
266
  messenger,
@@ -353,6 +353,7 @@ class AssetsController extends base_controller_1.BaseController {
353
353
  queryApiClient,
354
354
  onActiveChainsUpdated: __classPrivateFieldGet(this, _AssetsController_onActiveChainsUpdated, "f"),
355
355
  getAssetType: (assetId) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getAssetType).call(this, assetId),
356
+ getWebSocketEnabledNamespaces: webSocketEnabledNamespaces ?? (() => []),
356
357
  }), "f");
357
358
  __classPrivateFieldSet(this, _AssetsController_accountsApiDataSource, new AccountsApiDataSource_1.AccountsApiDataSource({
358
359
  queryApiClient,
@@ -2107,25 +2108,19 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
2107
2108
  // EVENT HANDLERS
2108
2109
  // ============================================================================
2109
2110
  async function _AssetsController_handleAccountGroupChanged() {
2110
- const gutoStart = Date.now();
2111
- console.log('[GUTO PERFORMANCE LOG] AssetsController.#handleAccountGroupChanged START');
2112
2111
  const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
2113
2112
  log('Account group changed', {
2114
2113
  accountCount: accounts.length,
2115
2114
  accountIds: accounts.map((a) => a.id),
2116
2115
  });
2117
2116
  __classPrivateFieldSet(this, _AssetsController_lastKnownAccountIds, new Set(accounts.map((a) => a.id)), "f");
2118
- const gutoMutexStart = Date.now();
2119
2117
  const releaseLock = await __classPrivateFieldGet(this, _AssetsController_accountRefreshMutex, "f").acquire();
2120
- console.log(`[GUTO PERFORMANCE LOG] AssetsController accountRefreshMutex wait took ${Date.now() - gutoMutexStart}ms`);
2121
2118
  try {
2122
2119
  if (accounts.length > 0) {
2123
- const gutoGetAssetsStart = Date.now();
2124
2120
  await this.getAssets(accounts, {
2125
2121
  chainIds: [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")],
2126
2122
  forceUpdate: true,
2127
2123
  });
2128
- console.log(`[GUTO PERFORMANCE LOG] AssetsController.getAssets (accounts=${accounts.length}, chains=${__classPrivateFieldGet(this, _AssetsController_enabledChains, "f").size}) took ${Date.now() - gutoGetAssetsStart}ms`);
2129
2124
  }
2130
2125
  // Subscribe after fetch so WS notifications can recover state
2131
2126
  __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
@@ -2135,7 +2130,6 @@ async function _AssetsController_handleAccountGroupChanged() {
2135
2130
  finally {
2136
2131
  releaseLock();
2137
2132
  }
2138
- console.log(`[GUTO PERFORMANCE LOG] AssetsController.#handleAccountGroupChanged END (total) took ${Date.now() - gutoStart}ms`);
2139
2133
  }, _AssetsController_handleEnabledNetworksChanged = async function _AssetsController_handleEnabledNetworksChanged(enabledNetworkMap) {
2140
2134
  const previousChains = __classPrivateFieldGet(this, _AssetsController_enabledChains, "f");
2141
2135
  __classPrivateFieldSet(this, _AssetsController_enabledChains, __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_extractEnabledChains).call(this, enabledNetworkMap), "f");