@metamask/assets-controller 4.0.0 → 5.0.1
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 +38 -1
- package/dist/AssetsController.cjs +90 -31
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +5 -5
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +5 -5
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +90 -31
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.cjs +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.cjs.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.cts +2 -2
- package/dist/data-sources/BackendWebsocketDataSource.d.cts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.d.mts +2 -2
- package/dist/data-sources/BackendWebsocketDataSource.d.mts.map +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.mjs +1 -1
- package/dist/data-sources/BackendWebsocketDataSource.mjs.map +1 -1
- package/dist/data-sources/PriceDataSource.cjs +63 -38
- package/dist/data-sources/PriceDataSource.cjs.map +1 -1
- package/dist/data-sources/PriceDataSource.d.cts +1 -1
- package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
- package/dist/data-sources/PriceDataSource.d.mts +1 -1
- package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
- package/dist/data-sources/PriceDataSource.mjs +63 -38
- package/dist/data-sources/PriceDataSource.mjs.map +1 -1
- package/dist/data-sources/RpcDataSource.cjs +28 -61
- package/dist/data-sources/RpcDataSource.cjs.map +1 -1
- package/dist/data-sources/RpcDataSource.d.cts +3 -4
- package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
- package/dist/data-sources/RpcDataSource.d.mts +3 -4
- package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
- package/dist/data-sources/RpcDataSource.mjs +29 -62
- package/dist/data-sources/RpcDataSource.mjs.map +1 -1
- package/dist/data-sources/SnapDataSource.cjs +1 -1
- package/dist/data-sources/SnapDataSource.cjs.map +1 -1
- package/dist/data-sources/SnapDataSource.d.cts +2 -2
- package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
- package/dist/data-sources/SnapDataSource.d.mts +2 -2
- package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
- package/dist/data-sources/SnapDataSource.mjs +1 -1
- package/dist/data-sources/SnapDataSource.mjs.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.cjs +10 -3
- package/dist/data-sources/StakedBalanceDataSource.cjs.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.d.cts +2 -2
- package/dist/data-sources/StakedBalanceDataSource.d.cts.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.d.mts +2 -2
- package/dist/data-sources/StakedBalanceDataSource.d.mts.map +1 -1
- package/dist/data-sources/StakedBalanceDataSource.mjs +10 -3
- package/dist/data-sources/StakedBalanceDataSource.mjs.map +1 -1
- package/dist/data-sources/TokenDataSource.cjs +62 -31
- package/dist/data-sources/TokenDataSource.cjs.map +1 -1
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
- package/dist/data-sources/TokenDataSource.mjs +63 -32
- package/dist/data-sources/TokenDataSource.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.cjs +67 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.cjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.cts +23 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.cts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.mts +23 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.d.mts.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.mjs +63 -0
- package/dist/data-sources/evm-rpc-services/clients/TokensApiClient.mjs.map +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.cjs +3 -1
- package/dist/data-sources/evm-rpc-services/clients/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.d.cts +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.d.mts +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/clients/index.mjs +1 -0
- package/dist/data-sources/evm-rpc-services/clients/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.cjs +2 -1
- package/dist/data-sources/evm-rpc-services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.cts +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.mts +1 -1
- package/dist/data-sources/evm-rpc-services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/index.mjs +1 -1
- package/dist/data-sources/evm-rpc-services/index.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs +47 -50
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts +12 -9
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts +12 -9
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs +47 -50
- package/dist/data-sources/evm-rpc-services/services/TokenDetector.mjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.cjs.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.cts +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.cts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.mts +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.d.mts.map +1 -1
- package/dist/data-sources/evm-rpc-services/services/index.mjs.map +1 -1
- package/dist/utils/formatStateForTransactionPay.cjs.map +1 -1
- package/dist/utils/formatStateForTransactionPay.d.cts +1 -1
- package/dist/utils/formatStateForTransactionPay.d.cts.map +1 -1
- package/dist/utils/formatStateForTransactionPay.d.mts +1 -1
- package/dist/utils/formatStateForTransactionPay.d.mts.map +1 -1
- package/dist/utils/formatStateForTransactionPay.mjs.map +1 -1
- package/package.json +21 -20
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.0.1]
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Bump `@metamask/transaction-controller` from `^64.0.0` to `^64.2.0` ([#8432](https://github.com/MetaMask/core/pull/8432), [#8447](https://github.com/MetaMask/core/pull/8447))
|
|
15
|
+
- Bump `@metamask/base-controller` from `^9.0.1` to `^9.1.0` ([#8457](https://github.com/MetaMask/core/pull/8457))
|
|
16
|
+
- Bump `@metamask/assets-controllers` from `^103.1.1` to `^104.0.0` ([#8466](https://github.com/MetaMask/core/pull/8466))
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- `AssetsController` no longer silently skips asset fetching on startup for returning users ([#8412](https://github.com/MetaMask/core/pull/8412))
|
|
21
|
+
- Previously, `#start()` was called at keyring unlock before `AccountTreeController.init()` had built the account tree, causing `#selectedAccounts` to return an empty array and all subscriptions and fetches to be skipped. `selectedAccountGroupChange` does not fire when the persisted selected group is unchanged, leaving the controller idle.
|
|
22
|
+
- Now subscribes to `AccountTreeController:stateChange` (the base-controller event guaranteed to fire when `init()` calls `this.update()`), so the controller re-evaluates its active state once accounts are available.
|
|
23
|
+
- `#start()` is now idempotent: it returns early when accounts or chains are not yet available, and when subscriptions are already active, preventing duplicate fetches from repeated events.
|
|
24
|
+
|
|
25
|
+
## [5.0.0]
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- **BREAKING:** `TokenDetector` now fetches the token list directly from the Tokens API (`/v3/chains/{chain}/assets`) via a new `TokensApiClient` instead of reading from `TokenListController:getState` ([#8385](https://github.com/MetaMask/core/pull/8385))
|
|
30
|
+
- `TokenDetectorMessenger` type has been removed; `TokenDetector` constructor now takes a `TokensApiClient` instance as its second argument
|
|
31
|
+
- `RpcDataSource` no longer requires `TokenListController:getState` — `GetTokenListState` has been removed from `RpcDataSourceAllowedActions` and `AssetsControllerAllowedActions`
|
|
32
|
+
- Unknown ERC-20 metadata is no longer looked up from the token list as a fallback in `RpcDataSource`; `TokenDataSource` handles enrichment downstream
|
|
33
|
+
- Split `getAssets` fetch pipeline into a fast awaited path and a parallel fire-and-forget background path to reduce perceived latency on unlock and onboarding ([#8383](https://github.com/MetaMask/core/pull/8383))
|
|
34
|
+
- Fast pipeline: AccountsApi + StakedBalance → Detection → Token + Price (awaited, committed to state immediately)
|
|
35
|
+
- Background pipeline: Snap + RPC run in parallel → Detection → Token + Price when basic functionality is enabled; when disabled (RPC-only mode), Token + Price are omitted (fire-and-forget merge)
|
|
36
|
+
- `handleAssetsUpdate` skips token/price enrichment and strips `metadata` / `price` from the effective request when basic functionality is disabled (RPC-only mode)
|
|
37
|
+
- `setSelectedCurrency` no longer triggers a price refresh via `getAssets` when basic functionality is disabled
|
|
38
|
+
- `PriceDataSource` now batches spot-price API requests in chunks of 50 using `reduceInBatchesSerially` to avoid DynamoDB batch-limit errors ([#8383](https://github.com/MetaMask/core/pull/8383))
|
|
39
|
+
- `TokenDataSource` now batches token metadata API requests in chunks of 50 using `reduceInBatchesSerially` to avoid DynamoDB batch-limit errors ([#8383](https://github.com/MetaMask/core/pull/8383))
|
|
40
|
+
- `PriceDataSource` filters out all synthetic `slip44:NUMBER-*` staking-position asset IDs before calling the Price API ([#8383](https://github.com/MetaMask/core/pull/8383))
|
|
41
|
+
- `TokenDataSource` filters EVM ERC-20 tokens by `occurrences >= 3` and treats missing occurrences as 0 ([#8383](https://github.com/MetaMask/core/pull/8383))
|
|
42
|
+
- Bump `@metamask/keyring-controller` from `^25.1.1` to `^25.2.0` ([#8363](https://github.com/MetaMask/core/pull/8363))
|
|
43
|
+
- Bump `@metamask/messenger` from `^1.0.0` to `^1.1.1` ([#8364](https://github.com/MetaMask/core/pull/8364), [#8373](https://github.com/MetaMask/core/pull/8373))
|
|
44
|
+
|
|
10
45
|
## [4.0.0]
|
|
11
46
|
|
|
12
47
|
### Changed
|
|
@@ -267,7 +302,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
267
302
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
268
303
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
269
304
|
|
|
270
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@
|
|
305
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@5.0.1...HEAD
|
|
306
|
+
[5.0.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@5.0.0...@metamask/assets-controller@5.0.1
|
|
307
|
+
[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@4.0.0...@metamask/assets-controller@5.0.0
|
|
271
308
|
[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@3.3.0...@metamask/assets-controller@4.0.0
|
|
272
309
|
[3.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@3.2.1...@metamask/assets-controller@3.3.0
|
|
273
310
|
[3.2.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@3.2.0...@metamask/assets-controller@3.2.1
|
|
@@ -263,7 +263,15 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
263
263
|
__classPrivateFieldSet(this, _AssetsController_trace, trace, "f");
|
|
264
264
|
const rpcConfig = rpcDataSourceConfig ?? {};
|
|
265
265
|
__classPrivateFieldSet(this, _AssetsController_onActiveChainsUpdated, (dataSourceName, chains, previousChains) => {
|
|
266
|
-
|
|
266
|
+
try {
|
|
267
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleActiveChainsUpdate).call(this, dataSourceName, chains, previousChains);
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
log('Failed to handle active chains update', {
|
|
271
|
+
dataSourceName,
|
|
272
|
+
error,
|
|
273
|
+
});
|
|
274
|
+
}
|
|
267
275
|
}, "f");
|
|
268
276
|
__classPrivateFieldSet(this, _AssetsController_backendWebsocketDataSource, new BackendWebsocketDataSource_1.BackendWebsocketDataSource({
|
|
269
277
|
messenger: this.messenger,
|
|
@@ -356,12 +364,18 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
356
364
|
forceUpdate: true,
|
|
357
365
|
assetsForPriceUpdate: options?.assetsForPriceUpdate,
|
|
358
366
|
});
|
|
359
|
-
|
|
367
|
+
// Fast pipeline: accountsApi + stakedBalance → detection → token + price.
|
|
368
|
+
// Snap and RPC are excluded here due to their latency (snap triggers account
|
|
369
|
+
// creation, RPC is slow on many chains). Results are committed to state
|
|
370
|
+
// immediately so the UI can display balances without waiting for them.
|
|
371
|
+
//
|
|
372
|
+
// Both the fast and background pipelines use 'merge' mode because neither
|
|
373
|
+
// alone represents the full set of data sources. Using 'full' in either
|
|
374
|
+
// would wipe balances from the sources handled by the other pipeline.
|
|
375
|
+
const fastSources = __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
360
376
|
? [
|
|
361
377
|
(0, ParallelMiddleware_1.createParallelBalanceMiddleware)([
|
|
362
378
|
__classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f"),
|
|
363
|
-
__classPrivateFieldGet(this, _AssetsController_snapDataSource, "f"),
|
|
364
|
-
__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f"),
|
|
365
379
|
__classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"),
|
|
366
380
|
]),
|
|
367
381
|
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
@@ -370,18 +384,33 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
370
384
|
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
371
385
|
]),
|
|
372
386
|
]
|
|
373
|
-
: [
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
387
|
+
: [__classPrivateFieldGet(this, _AssetsController_stakedBalanceDataSource, "f"), __classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f")];
|
|
388
|
+
const { response, durationByDataSource } = await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, fastSources, request);
|
|
389
|
+
// The fast pipeline only contains a subset of data sources (AccountsApi +
|
|
390
|
+
// StakedBalance), so it must always merge to avoid wiping Snap/RPC
|
|
391
|
+
// balances that the background pipeline hasn't yet replaced.
|
|
392
|
+
await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateState).call(this, { ...response, updateMode: 'merge' });
|
|
393
|
+
// Background pipeline: snap and RPC run in parallel after the fast path
|
|
394
|
+
// commits to state. Their balances are merged together before detection.
|
|
395
|
+
// Token + price enrichment matches the pre-split behavior: only when basic
|
|
396
|
+
// functionality is on (RPC-only mode must not call token/price APIs).
|
|
397
|
+
const slowSources = __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
398
|
+
? [__classPrivateFieldGet(this, _AssetsController_snapDataSource, "f"), __classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")]
|
|
399
|
+
: [__classPrivateFieldGet(this, _AssetsController_rpcDataSource, "f")];
|
|
400
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, [
|
|
401
|
+
(0, ParallelMiddleware_1.createParallelBalanceMiddleware)(slowSources),
|
|
402
|
+
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
403
|
+
...(__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
404
|
+
? [
|
|
405
|
+
(0, ParallelMiddleware_1.createParallelMiddleware)([
|
|
406
|
+
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
407
|
+
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
408
|
+
]),
|
|
409
|
+
]
|
|
410
|
+
: []),
|
|
411
|
+
], request)
|
|
412
|
+
.then(({ response: slowResponse }) => __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateState).call(this, { ...slowResponse, updateMode: 'merge' }))
|
|
413
|
+
.catch((error) => log('Background pipeline failed', { error }));
|
|
385
414
|
const durationMs = performance.now() - startTime;
|
|
386
415
|
// Emit trace for every full fetch (Assets Health dashboard)
|
|
387
416
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_emitTrace).call(this, TRACE_FULL_FETCH, {
|
|
@@ -648,6 +677,9 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
648
677
|
previousCurrency,
|
|
649
678
|
selectedCurrency,
|
|
650
679
|
});
|
|
680
|
+
if (!__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
651
683
|
this.getAssets(__classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get), {
|
|
652
684
|
forceUpdate: true,
|
|
653
685
|
dataTypes: ['price'],
|
|
@@ -722,7 +754,8 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
722
754
|
/**
|
|
723
755
|
* Handle assets updated from a data source.
|
|
724
756
|
* Called via the onAssetsUpdate callback passed in SubscriptionRequest when the controller subscribes to a data source.
|
|
725
|
-
*
|
|
757
|
+
* Runs detection, then (when basic functionality is enabled) token metadata and price enrichment before updating state.
|
|
758
|
+
* When basic functionality is disabled (RPC-only mode), only detection runs; token and price APIs are not used.
|
|
726
759
|
*
|
|
727
760
|
* @param response - The data response with updated assets
|
|
728
761
|
* @param sourceId - The data source ID reporting the update
|
|
@@ -735,19 +768,27 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
735
768
|
hasBalance: Boolean(response.assetsBalance),
|
|
736
769
|
hasPrice: Boolean(response.assetsPrice),
|
|
737
770
|
});
|
|
738
|
-
|
|
739
|
-
// Include 'metadata' in dataTypes so TokenDataSource runs to enrich detected assets
|
|
740
|
-
const { response: enrichedResponse } = await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, [
|
|
741
|
-
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
742
|
-
(0, ParallelMiddleware_1.createParallelMiddleware)([
|
|
743
|
-
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
744
|
-
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
745
|
-
]),
|
|
746
|
-
], request ?? {
|
|
771
|
+
const resolvedRequest = request ?? {
|
|
747
772
|
accountsWithSupportedChains: [],
|
|
748
773
|
chainIds: [],
|
|
749
774
|
dataTypes: ['balance', 'metadata', 'price'],
|
|
750
|
-
}
|
|
775
|
+
};
|
|
776
|
+
// RPC-only mode (basic functionality off): never run token/price APIs. Strip
|
|
777
|
+
// those data types so downstream middleware cannot treat them as requested.
|
|
778
|
+
const pipelineRequest = __classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)
|
|
779
|
+
? resolvedRequest
|
|
780
|
+
: {
|
|
781
|
+
...resolvedRequest,
|
|
782
|
+
dataTypes: resolvedRequest.dataTypes.filter((dt) => dt !== 'metadata' && dt !== 'price'),
|
|
783
|
+
};
|
|
784
|
+
const enrichmentSources = [__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f")];
|
|
785
|
+
if (__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
|
|
786
|
+
enrichmentSources.push((0, ParallelMiddleware_1.createParallelMiddleware)([
|
|
787
|
+
__classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f"),
|
|
788
|
+
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f"),
|
|
789
|
+
]));
|
|
790
|
+
}
|
|
791
|
+
const { response: enrichedResponse } = await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_executeMiddlewares).call(this, enrichmentSources, pipelineRequest, response);
|
|
751
792
|
await __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateState).call(this, enrichedResponse);
|
|
752
793
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_emitTrace).call(this, TRACE_UPDATE_PIPELINE, {
|
|
753
794
|
source: sourceId,
|
|
@@ -887,6 +928,16 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
887
928
|
this.messenger.subscribe('AccountTreeController:selectedAccountGroupChange', () => {
|
|
888
929
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleAccountGroupChanged).call(this).catch(console.error);
|
|
889
930
|
});
|
|
931
|
+
// Catch the initial tree build. On returning users,
|
|
932
|
+
// `selectedAccountGroupChange` does NOT fire when the persisted group
|
|
933
|
+
// is unchanged, and `accountTreeChange` doesn't fire either (init()
|
|
934
|
+
// rebuilds from persisted accounts without publishing it).
|
|
935
|
+
// The base-controller `:stateChange` event is guaranteed to fire
|
|
936
|
+
// when init() calls this.update(). #start() is idempotent so
|
|
937
|
+
// repeated fires are safe.
|
|
938
|
+
this.messenger.subscribe('AccountTreeController:stateChange', () => {
|
|
939
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateActive).call(this);
|
|
940
|
+
});
|
|
890
941
|
// Subscribe to network enablement changes (only enabledNetworkMap)
|
|
891
942
|
this.messenger.subscribe('NetworkEnablementController:stateChange', ({ enabledNetworkMap }) => {
|
|
892
943
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleEnabledNetworksChanged).call(this, enabledNetworkMap).catch(console.error);
|
|
@@ -1302,14 +1353,22 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1302
1353
|
return 'fungible';
|
|
1303
1354
|
}
|
|
1304
1355
|
}, _AssetsController_start = function _AssetsController_start() {
|
|
1356
|
+
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "a", _AssetsController_selectedAccounts_get);
|
|
1357
|
+
const chainIds = [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")];
|
|
1358
|
+
if (accounts.length === 0 || chainIds.length === 0) {
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
if (__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").size > 0) {
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1305
1364
|
log('Starting asset tracking', {
|
|
1306
|
-
selectedAccountCount:
|
|
1307
|
-
enabledChainCount:
|
|
1365
|
+
selectedAccountCount: accounts.length,
|
|
1366
|
+
enabledChainCount: chainIds.length,
|
|
1308
1367
|
});
|
|
1309
1368
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1310
1369
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1311
|
-
this.getAssets(
|
|
1312
|
-
chainIds
|
|
1370
|
+
this.getAssets(accounts, {
|
|
1371
|
+
chainIds,
|
|
1313
1372
|
forceUpdate: true,
|
|
1314
1373
|
}).catch((error) => {
|
|
1315
1374
|
log('Failed to fetch assets', error);
|