@metamask-previews/assets-controller 13.1.4-preview-a1017a8ee → 13.1.4-preview-c2ef75d18
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 +0 -9
- package/dist/AssetsController.cjs +48 -80
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +2 -2
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +2 -2
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +48 -80
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AbstractDataSource.cjs.map +1 -1
- package/dist/data-sources/AbstractDataSource.d.cts +0 -6
- package/dist/data-sources/AbstractDataSource.d.cts.map +1 -1
- package/dist/data-sources/AbstractDataSource.d.mts +0 -6
- package/dist/data-sources/AbstractDataSource.d.mts.map +1 -1
- package/dist/data-sources/AbstractDataSource.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +3 -11
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs +3 -11
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,15 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- **BREAKING:** Subscribe to `AccountTreeController:initialized` / `:uninitialized` (typed as `AccountTreeControllerInitializedEvent` / `AccountTreeControllerUninitializedEvent`) so asset tracking starts only after the account tree is fully built, instead of on intermediate `AccountTreeController:stateChange` events during `init()` or on unlock before the tree is ready ([#9892](https://github.com/MetaMask/core/pull/9892))
|
|
13
|
-
- Hosts that restrict which events flow through the `AssetsController` messenger must now also delegate `AccountTreeController:initialized` and `AccountTreeController:uninitialized`
|
|
14
|
-
- Reduce Accounts API calls on startup and refresh:
|
|
15
|
-
- Skip `AccountsApiDataSource` subscribe-time initial poll after a forced `getAssets` balance fetch
|
|
16
|
-
- Ignore init-time `AccountTreeController:selectedAccountGroupChange` (including same-group re-emits and events before tracking starts) so `:initialized` owns first start; only refresh on real group switches while tracking
|
|
17
|
-
- Skip Accounts API middleware when `dataTypes` does not include `balance` (e.g. price-only refreshes)
|
|
18
|
-
|
|
19
10
|
## [13.1.4]
|
|
20
11
|
|
|
21
12
|
### Changed
|
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_trace, _AssetsController_captureException, _AssetsController_firstInitFetchReported, _AssetsController_stateSizeReported, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked,
|
|
16
|
+
var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_trace, _AssetsController_captureException, _AssetsController_firstInitFetchReported, _AssetsController_stateSizeReported, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked, _AssetsController_controllerMutex, _AssetsController_accountRefreshMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_lastKnownAccountIds, _AssetsController_getSelectedAccounts, _AssetsController_accountActivityDataSource, _AssetsController_accountsApiDataSource, _AssetsController_snapDataSource, _AssetsController_rpcDataSource, _AssetsController_stakedBalanceDataSource, _AssetsController_allBalanceDataSources_get, _AssetsController_priceDataSource, _AssetsController_detectionMiddleware, _AssetsController_customAssetGraduationMiddleware, _AssetsController_rpcFallbackMiddleware, _AssetsController_tokenDataSource, _AssetsController_unsubscribeBasicFunctionality, _AssetsController_queryApiClient, _AssetsController_onActiveChainsUpdated, _AssetsController_initializeNativeAssetsMap, _AssetsController_initializeState, _AssetsController_extractEnabledChains, _AssetsController_normalizeChainReference, _AssetsController_subscribeToEvents, _AssetsController_onUnapprovedTransactionAdded, _AssetsController_onTransactionConfirmed, _AssetsController_updateActive, _AssetsController_handleAccountTreeStateChange, _AssetsController_runAccountTreeRefresh, _AssetsController_runStartupRefresh, _AssetsController_registerActionHandlers, _AssetsController_handleActiveChainsUpdate, _AssetsController_executeMiddlewares, _AssetsController_assertNonEmptyAccountId, _AssetsController_normalizeAssetIdOrThrow, _AssetsController_fetchMissingPricesWithoutCache, _AssetsController_getNativeAssetMap, _AssetsController_isNativeAsset, _AssetsController_getAssetType, _AssetsController_resolveNativeAssetIds, _AssetsController_getNativeAssetIdsForEnabledChains, _AssetsController_getNativeAssetIdsForAccount, _AssetsController_getSlowPipelineChainIds, _AssetsController_ensureNativeBalancesDefaultZero, _AssetsController_ensureDefaultTrackedAssetsSeeded, _AssetsController_updateState, _AssetsController_getAssetsFromState, _AssetsController_getAssetFromState, _AssetsController_shouldHideNativeToken, _AssetsController_tokenStandardToAssetType, _AssetsController_start, _AssetsController_stop, _AssetsController_subscribeAssets, _AssetsController_subscribeAssetsBalance, _AssetsController_subscribeRpcCustomAssetsSupplement, _AssetsController_unsubscribeBySubscriptionKey, _AssetsController_subscribeStakedBalance, _AssetsController_buildChainToAccountsMap, _AssetsController_subscribeDataSource, _AssetsController_unsubscribeDataSource, _AssetsController_buildDataRequest, _AssetsController_getEnabledChainsForAccount, _AssetsController_handleAccountGroupChanged, _AssetsController_handleEnabledNetworksChanged, _AssetsController_handleNetworkAdded, _AssetsController_refreshActiveChainsOnNetworkSwitch, _AssetsController_getSelectedEvmChainIdFromNetworkState, _AssetsController_handleNetworkDidChange, _AssetsController_refreshAssetsAfterNetworkChange, _AssetsController_refreshAssetsAfterNetworkAdded;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.AssetsController = exports.getDefaultAssetsControllerState = void 0;
|
|
19
19
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -309,11 +309,6 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
309
309
|
_AssetsController_uiOpen.set(this, false);
|
|
310
310
|
/** Whether the keyring is unlocked. Combined with #uiOpen for #updateActive. */
|
|
311
311
|
_AssetsController_keyringUnlocked.set(this, false);
|
|
312
|
-
/**
|
|
313
|
-
* Whether `AccountTreeController` has finished `init()`. Unlock / UI-open
|
|
314
|
-
* alone must not start fetches — the tree can still be mid-build.
|
|
315
|
-
*/
|
|
316
|
-
_AssetsController_accountTreeInitialized.set(this, false);
|
|
317
312
|
_AssetsController_controllerMutex.set(this, new async_mutex_1.Mutex());
|
|
318
313
|
/** Serializes account-switch fetch + subscribe to prevent overlapping races. */
|
|
319
314
|
_AssetsController_accountRefreshMutex.set(this, new async_mutex_1.Mutex());
|
|
@@ -1185,7 +1180,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
1185
1180
|
}
|
|
1186
1181
|
}
|
|
1187
1182
|
exports.AssetsController = AssetsController;
|
|
1188
|
-
_AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctionality = new WeakMap(), _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_trace = new WeakMap(), _AssetsController_captureException = new WeakMap(), _AssetsController_firstInitFetchReported = new WeakMap(), _AssetsController_stateSizeReported = new WeakMap(), _AssetsController_uiOpen = new WeakMap(), _AssetsController_keyringUnlocked = new WeakMap(),
|
|
1183
|
+
_AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctionality = new WeakMap(), _AssetsController_defaultUpdateInterval = new WeakMap(), _AssetsController_trace = new WeakMap(), _AssetsController_captureException = new WeakMap(), _AssetsController_firstInitFetchReported = new WeakMap(), _AssetsController_stateSizeReported = new WeakMap(), _AssetsController_uiOpen = new WeakMap(), _AssetsController_keyringUnlocked = new WeakMap(), _AssetsController_controllerMutex = new WeakMap(), _AssetsController_accountRefreshMutex = new WeakMap(), _AssetsController_activeSubscriptions = new WeakMap(), _AssetsController_enabledChains = new WeakMap(), _AssetsController_lastKnownAccountIds = new WeakMap(), _AssetsController_accountActivityDataSource = new WeakMap(), _AssetsController_accountsApiDataSource = new WeakMap(), _AssetsController_snapDataSource = new WeakMap(), _AssetsController_rpcDataSource = new WeakMap(), _AssetsController_stakedBalanceDataSource = new WeakMap(), _AssetsController_priceDataSource = new WeakMap(), _AssetsController_detectionMiddleware = new WeakMap(), _AssetsController_customAssetGraduationMiddleware = new WeakMap(), _AssetsController_rpcFallbackMiddleware = new WeakMap(), _AssetsController_tokenDataSource = new WeakMap(), _AssetsController_unsubscribeBasicFunctionality = new WeakMap(), _AssetsController_queryApiClient = new WeakMap(), _AssetsController_onActiveChainsUpdated = new WeakMap(), _AssetsController_instances = new WeakSet(), _AssetsController_emitStateSizeTrace = function _AssetsController_emitStateSizeTrace() {
|
|
1189
1184
|
if (!__classPrivateFieldGet(this, _AssetsController_trace, "f") || __classPrivateFieldGet(this, _AssetsController_stateSizeReported, "f")) {
|
|
1190
1185
|
return;
|
|
1191
1186
|
}
|
|
@@ -1298,13 +1293,16 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1298
1293
|
return reference;
|
|
1299
1294
|
}, _AssetsController_subscribeToEvents = function _AssetsController_subscribeToEvents() {
|
|
1300
1295
|
// Subscribe to account group changes (when user switches between account groups like Account 1 -> Account 2)
|
|
1301
|
-
this.messenger.subscribe('AccountTreeController:selectedAccountGroupChange', (groupId
|
|
1302
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleAccountGroupChanged).call(this, groupId
|
|
1296
|
+
this.messenger.subscribe('AccountTreeController:selectedAccountGroupChange', (groupId) => {
|
|
1297
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleAccountGroupChanged).call(this, groupId).catch(console.error);
|
|
1303
1298
|
});
|
|
1304
|
-
// Catch
|
|
1305
|
-
//
|
|
1306
|
-
//
|
|
1307
|
-
//
|
|
1299
|
+
// Catch the initial tree build. On returning users,
|
|
1300
|
+
// `selectedAccountGroupChange` does NOT fire when the persisted group
|
|
1301
|
+
// is unchanged, and `accountTreeChange` doesn't fire either (init()
|
|
1302
|
+
// rebuilds from persisted accounts without publishing it).
|
|
1303
|
+
// The base-controller `:stateChange` event is guaranteed to fire
|
|
1304
|
+
// when init() calls this.update(). #start() is idempotent so
|
|
1305
|
+
// repeated fires are safe.
|
|
1308
1306
|
this.messenger.subscribe('AccountTreeController:stateChange', () => {
|
|
1309
1307
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleAccountTreeStateChange).call(this);
|
|
1310
1308
|
});
|
|
@@ -1356,17 +1354,6 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1356
1354
|
this.messenger.subscribe('TransactionController:transactionConfirmed', (transactionMeta) => {
|
|
1357
1355
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_onTransactionConfirmed).call(this, transactionMeta);
|
|
1358
1356
|
});
|
|
1359
|
-
// Start tracking only after the account tree is fully built. Unlock can
|
|
1360
|
-
// happen before `AccountTreeController.init()`, and `:stateChange` fires
|
|
1361
|
-
// for intermediate mutations during that build.
|
|
1362
|
-
this.messenger.subscribe('AccountTreeController:initialized', () => {
|
|
1363
|
-
__classPrivateFieldSet(this, _AssetsController_accountTreeInitialized, true, "f");
|
|
1364
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateActive).call(this);
|
|
1365
|
-
});
|
|
1366
|
-
this.messenger.subscribe('AccountTreeController:uninitialized', () => {
|
|
1367
|
-
__classPrivateFieldSet(this, _AssetsController_accountTreeInitialized, false, "f");
|
|
1368
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_updateActive).call(this);
|
|
1369
|
-
});
|
|
1370
1357
|
}, _AssetsController_onUnapprovedTransactionAdded = function _AssetsController_onUnapprovedTransactionAdded(transactionMeta) {
|
|
1371
1358
|
const hexChainId = transactionMeta.chainId;
|
|
1372
1359
|
if (!hexChainId) {
|
|
@@ -1410,7 +1397,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1410
1397
|
log('Failed to refresh assets after transaction confirmed', { error });
|
|
1411
1398
|
});
|
|
1412
1399
|
}, _AssetsController_updateActive = function _AssetsController_updateActive() {
|
|
1413
|
-
const shouldRun = __classPrivateFieldGet(this, _AssetsController_uiOpen, "f") && __classPrivateFieldGet(this, _AssetsController_keyringUnlocked, "f")
|
|
1400
|
+
const shouldRun = __classPrivateFieldGet(this, _AssetsController_uiOpen, "f") && __classPrivateFieldGet(this, _AssetsController_keyringUnlocked, "f");
|
|
1414
1401
|
if (shouldRun) {
|
|
1415
1402
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_start).call(this);
|
|
1416
1403
|
}
|
|
@@ -1418,35 +1405,37 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1418
1405
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_stop).call(this);
|
|
1419
1406
|
}
|
|
1420
1407
|
}, _AssetsController_handleAccountTreeStateChange = function _AssetsController_handleAccountTreeStateChange() {
|
|
1421
|
-
const shouldRun = __classPrivateFieldGet(this, _AssetsController_uiOpen, "f") &&
|
|
1422
|
-
__classPrivateFieldGet(this, _AssetsController_keyringUnlocked, "f") &&
|
|
1423
|
-
__classPrivateFieldGet(this, _AssetsController_accountTreeInitialized, "f") &&
|
|
1424
|
-
__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").size > 0;
|
|
1408
|
+
const shouldRun = __classPrivateFieldGet(this, _AssetsController_uiOpen, "f") && __classPrivateFieldGet(this, _AssetsController_keyringUnlocked, "f");
|
|
1425
1409
|
if (!shouldRun) {
|
|
1426
1410
|
return;
|
|
1427
1411
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1412
|
+
if (__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").size > 0) {
|
|
1413
|
+
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
1414
|
+
const currentIds = new Set(accounts.map((a) => a.id));
|
|
1415
|
+
const accountsChanged = currentIds.size !== __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").size ||
|
|
1416
|
+
[...currentIds].some((id) => !__classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").has(id));
|
|
1417
|
+
if (!accountsChanged) {
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
const hasOverlap = [...currentIds].some((id) => __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").has(id));
|
|
1421
|
+
if (!hasOverlap && __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").size > 0) {
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
log('Account tree changed with new accounts, re-subscribing', {
|
|
1425
|
+
previousCount: __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").size,
|
|
1426
|
+
currentCount: currentIds.size,
|
|
1427
|
+
});
|
|
1428
|
+
const newAccounts = accounts.filter((account) => !__classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").has(account.id));
|
|
1429
|
+
__classPrivateFieldSet(this, _AssetsController_lastKnownAccountIds, currentIds, "f");
|
|
1430
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1431
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1432
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_runAccountTreeRefresh).call(this, accounts, newAccounts).catch((error) => {
|
|
1433
|
+
log('Failed to refresh assets after tree change', error);
|
|
1434
|
+
});
|
|
1434
1435
|
}
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
return;
|
|
1436
|
+
else {
|
|
1437
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_start).call(this);
|
|
1438
1438
|
}
|
|
1439
|
-
log('Account tree changed with new accounts, re-subscribing', {
|
|
1440
|
-
previousCount: __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").size,
|
|
1441
|
-
currentCount: currentIds.size,
|
|
1442
|
-
});
|
|
1443
|
-
const newAccounts = accounts.filter((account) => !__classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").has(account.id));
|
|
1444
|
-
__classPrivateFieldSet(this, _AssetsController_lastKnownAccountIds, currentIds, "f");
|
|
1445
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1446
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1447
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_runAccountTreeRefresh).call(this, accounts, newAccounts).catch((error) => {
|
|
1448
|
-
log('Failed to refresh assets after tree change', error);
|
|
1449
|
-
});
|
|
1450
1439
|
}, _AssetsController_runAccountTreeRefresh = async function _AssetsController_runAccountTreeRefresh(accounts, newAccounts = []) {
|
|
1451
1440
|
const releaseLock = await __classPrivateFieldGet(this, _AssetsController_accountRefreshMutex, "f").acquire();
|
|
1452
1441
|
try {
|
|
@@ -1454,7 +1443,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1454
1443
|
chainIds: [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")],
|
|
1455
1444
|
forceUpdate: true,
|
|
1456
1445
|
});
|
|
1457
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this
|
|
1446
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1458
1447
|
if (newAccounts.length > 0) {
|
|
1459
1448
|
await this.getAssets(newAccounts, {
|
|
1460
1449
|
chainIds: [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")],
|
|
@@ -1465,7 +1454,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1465
1454
|
}
|
|
1466
1455
|
catch (error) {
|
|
1467
1456
|
log('Failed to fetch assets after tree change', error);
|
|
1468
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this
|
|
1457
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1469
1458
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1470
1459
|
}
|
|
1471
1460
|
finally {
|
|
@@ -1488,15 +1477,14 @@ async function _AssetsController_runStartupRefresh(accounts) {
|
|
|
1488
1477
|
// and default tracked assets that were never returned by balance APIs.
|
|
1489
1478
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1490
1479
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1491
|
-
|
|
1492
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this, { skipInitialFetch: true });
|
|
1480
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1493
1481
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1494
1482
|
}
|
|
1495
1483
|
catch (error) {
|
|
1496
1484
|
log('Failed to fetch assets on startup', error);
|
|
1497
1485
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1498
1486
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1499
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this
|
|
1487
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1500
1488
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
1501
1489
|
}
|
|
1502
1490
|
finally {
|
|
@@ -2119,19 +2107,19 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
2119
2107
|
}
|
|
2120
2108
|
}
|
|
2121
2109
|
__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").clear();
|
|
2122
|
-
}, _AssetsController_subscribeAssets = function _AssetsController_subscribeAssets(
|
|
2110
|
+
}, _AssetsController_subscribeAssets = function _AssetsController_subscribeAssets() {
|
|
2123
2111
|
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
2124
2112
|
const enabledChains = [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")];
|
|
2125
2113
|
if (accounts.length === 0 || enabledChains.length === 0) {
|
|
2126
2114
|
return;
|
|
2127
2115
|
}
|
|
2128
2116
|
// Subscribe to balance updates (batched by data source)
|
|
2129
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssetsBalance).call(this, accounts, enabledChains
|
|
2117
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssetsBalance).call(this, accounts, enabledChains);
|
|
2130
2118
|
// Subscribe to staked balance updates (separate from regular balance chain-claiming)
|
|
2131
2119
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeStakedBalance).call(this, accounts, enabledChains);
|
|
2132
2120
|
// Subscribe to price updates for all assets held by selected accounts
|
|
2133
2121
|
this.subscribeAssetsPrice(accounts, enabledChains);
|
|
2134
|
-
}, _AssetsController_subscribeAssetsBalance = function _AssetsController_subscribeAssetsBalance(accounts, chainIds
|
|
2122
|
+
}, _AssetsController_subscribeAssetsBalance = function _AssetsController_subscribeAssetsBalance(accounts, chainIds) {
|
|
2135
2123
|
const chainToAccounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_buildChainToAccountsMap).call(this, accounts, new Set(chainIds));
|
|
2136
2124
|
const remainingChains = new Set(chainToAccounts.keys());
|
|
2137
2125
|
// When basic functionality is on, use all balance data sources; when off,
|
|
@@ -2168,12 +2156,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
2168
2156
|
return true;
|
|
2169
2157
|
});
|
|
2170
2158
|
if (accountsForSource.length > 0) {
|
|
2171
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeDataSource).call(this, source, accountsForSource, assignedChains
|
|
2172
|
-
...(options?.skipInitialFetch &&
|
|
2173
|
-
source === __classPrivateFieldGet(this, _AssetsController_accountsApiDataSource, "f")
|
|
2174
|
-
? { skipInitialFetch: true }
|
|
2175
|
-
: {}),
|
|
2176
|
-
});
|
|
2159
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeDataSource).call(this, source, accountsForSource, assignedChains);
|
|
2177
2160
|
}
|
|
2178
2161
|
}
|
|
2179
2162
|
// Supplemental RPC subscription for customAssets on chains another data
|
|
@@ -2252,7 +2235,6 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
2252
2235
|
accountCount: accounts.length,
|
|
2253
2236
|
chainCount: chains.length,
|
|
2254
2237
|
customAssetsOnly: options.customAssetsOnly === true,
|
|
2255
|
-
skipInitialFetch: options.skipInitialFetch === true,
|
|
2256
2238
|
});
|
|
2257
2239
|
const subscribeReq = {
|
|
2258
2240
|
request: __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_buildDataRequest).call(this, accounts, chains, {
|
|
@@ -2267,7 +2249,6 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
2267
2249
|
isUpdate,
|
|
2268
2250
|
onAssetsUpdate: (response, request) => this.handleAssetsUpdate(response, sourceId, request),
|
|
2269
2251
|
getAssetsState: () => this.state,
|
|
2270
|
-
...(options.skipInitialFetch === true ? { skipInitialFetch: true } : {}),
|
|
2271
2252
|
};
|
|
2272
2253
|
source.subscribe(subscribeReq).catch((error) => {
|
|
2273
2254
|
console.error(`[AssetsController] Failed to subscribe to '${sourceId}':`, error);
|
|
@@ -2357,27 +2338,15 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
2357
2338
|
// ============================================================================
|
|
2358
2339
|
// EVENT HANDLERS
|
|
2359
2340
|
// ============================================================================
|
|
2360
|
-
async function _AssetsController_handleAccountGroupChanged(groupId
|
|
2341
|
+
async function _AssetsController_handleAccountGroupChanged(groupId) {
|
|
2361
2342
|
// The selected account group can be empty during onboarding or wallet reset.
|
|
2362
2343
|
if (!groupId) {
|
|
2363
2344
|
return;
|
|
2364
2345
|
}
|
|
2365
|
-
// First start is owned by `AccountTreeController:initialized` / `#start`.
|
|
2366
|
-
// ATC also re-publishes `selectedAccountGroupChange` on every `init()`
|
|
2367
|
-
// (including when the group did not change) so late subscribers can catch
|
|
2368
|
-
// up — ignore those until we are already tracking.
|
|
2369
|
-
if (__classPrivateFieldGet(this, _AssetsController_activeSubscriptions, "f").size === 0) {
|
|
2370
|
-
return;
|
|
2371
|
-
}
|
|
2372
|
-
if (groupId === previousGroupId) {
|
|
2373
|
-
return;
|
|
2374
|
-
}
|
|
2375
2346
|
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
2376
2347
|
log('Account group changed', {
|
|
2377
2348
|
accountCount: accounts.length,
|
|
2378
2349
|
accountIds: accounts.map((a) => a.id),
|
|
2379
|
-
groupId,
|
|
2380
|
-
previousGroupId,
|
|
2381
2350
|
});
|
|
2382
2351
|
__classPrivateFieldSet(this, _AssetsController_lastKnownAccountIds, new Set(accounts.map((a) => a.id)), "f");
|
|
2383
2352
|
const releaseLock = await __classPrivateFieldGet(this, _AssetsController_accountRefreshMutex, "f").acquire();
|
|
@@ -2391,8 +2360,7 @@ async function _AssetsController_handleAccountGroupChanged(groupId, previousGrou
|
|
|
2391
2360
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
2392
2361
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
2393
2362
|
// Subscribe after seed so the price poll sees natives / defaults.
|
|
2394
|
-
|
|
2395
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this, { skipInitialFetch: true });
|
|
2363
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
2396
2364
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_fetchMissingPricesWithoutCache).call(this, accounts, [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")]);
|
|
2397
2365
|
}
|
|
2398
2366
|
finally {
|