@metamask-previews/assets-controller 5.0.0-preview-dff83af4c → 5.0.0-preview-6b4f746
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 +7 -0
- package/dist/AssetsController.cjs +22 -4
- 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 +22 -4
- package/dist/AssetsController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- `AssetsController` no longer silently skips asset fetching on startup for returning users ([#8412](https://github.com/MetaMask/core/pull/8412))
|
|
13
|
+
- 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.
|
|
14
|
+
- 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.
|
|
15
|
+
- `#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.
|
|
16
|
+
|
|
10
17
|
## [5.0.0]
|
|
11
18
|
|
|
12
19
|
### Changed
|
|
@@ -928,6 +928,16 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
928
928
|
this.messenger.subscribe('AccountTreeController:selectedAccountGroupChange', () => {
|
|
929
929
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleAccountGroupChanged).call(this).catch(console.error);
|
|
930
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
|
+
});
|
|
931
941
|
// Subscribe to network enablement changes (only enabledNetworkMap)
|
|
932
942
|
this.messenger.subscribe('NetworkEnablementController:stateChange', ({ enabledNetworkMap }) => {
|
|
933
943
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleEnabledNetworksChanged).call(this, enabledNetworkMap).catch(console.error);
|
|
@@ -1343,14 +1353,22 @@ async function _AssetsController_executeMiddlewares(sources, request, initialRes
|
|
|
1343
1353
|
return 'fungible';
|
|
1344
1354
|
}
|
|
1345
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
|
+
}
|
|
1346
1364
|
log('Starting asset tracking', {
|
|
1347
|
-
selectedAccountCount:
|
|
1348
|
-
enabledChainCount:
|
|
1365
|
+
selectedAccountCount: accounts.length,
|
|
1366
|
+
enabledChainCount: chainIds.length,
|
|
1349
1367
|
});
|
|
1350
1368
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1351
1369
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1352
|
-
this.getAssets(
|
|
1353
|
-
chainIds
|
|
1370
|
+
this.getAssets(accounts, {
|
|
1371
|
+
chainIds,
|
|
1354
1372
|
forceUpdate: true,
|
|
1355
1373
|
}).catch((error) => {
|
|
1356
1374
|
log('Failed to fetch assets', error);
|