@metamask-previews/assets-controller 10.0.1-preview-168e306d9 → 10.0.1-preview-8980fa5
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 +8 -0
- package/dist/AssetsController.cjs +12 -4
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +12 -4
- package/dist/AssetsController.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ 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
|
+
- Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392))
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Fetch balances when switching account groups, enabling RPC-only networks, or after a new account is added to the account tree ([#9388](https://github.com/MetaMask/core/pull/9388))
|
|
17
|
+
|
|
10
18
|
## [10.0.1]
|
|
11
19
|
|
|
12
20
|
### Changed
|
|
@@ -1237,17 +1237,18 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1237
1237
|
previousCount: __classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").size,
|
|
1238
1238
|
currentCount: currentIds.size,
|
|
1239
1239
|
});
|
|
1240
|
+
const newAccounts = accounts.filter((account) => !__classPrivateFieldGet(this, _AssetsController_lastKnownAccountIds, "f").has(account.id));
|
|
1240
1241
|
__classPrivateFieldSet(this, _AssetsController_lastKnownAccountIds, currentIds, "f");
|
|
1241
1242
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureNativeBalancesDefaultZero).call(this);
|
|
1242
1243
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this);
|
|
1243
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_runAccountTreeRefresh).call(this, accounts).catch((error) => {
|
|
1244
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_runAccountTreeRefresh).call(this, accounts, newAccounts).catch((error) => {
|
|
1244
1245
|
log('Failed to refresh assets after tree change', error);
|
|
1245
1246
|
});
|
|
1246
1247
|
}
|
|
1247
1248
|
else {
|
|
1248
1249
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_start).call(this);
|
|
1249
1250
|
}
|
|
1250
|
-
}, _AssetsController_runAccountTreeRefresh = async function _AssetsController_runAccountTreeRefresh(accounts) {
|
|
1251
|
+
}, _AssetsController_runAccountTreeRefresh = async function _AssetsController_runAccountTreeRefresh(accounts, newAccounts = []) {
|
|
1251
1252
|
const releaseLock = await __classPrivateFieldGet(this, _AssetsController_accountRefreshMutex, "f").acquire();
|
|
1252
1253
|
try {
|
|
1253
1254
|
await this.getAssets(accounts, {
|
|
@@ -1255,6 +1256,12 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1255
1256
|
forceUpdate: true,
|
|
1256
1257
|
});
|
|
1257
1258
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1259
|
+
if (newAccounts.length > 0) {
|
|
1260
|
+
await this.getAssets(newAccounts, {
|
|
1261
|
+
chainIds: [...__classPrivateFieldGet(this, _AssetsController_enabledChains, "f")],
|
|
1262
|
+
forceUpdate: true,
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1258
1265
|
}
|
|
1259
1266
|
catch (error) {
|
|
1260
1267
|
log('Failed to fetch assets after tree change', error);
|
|
@@ -2141,8 +2148,9 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
2141
2148
|
// Refresh subscriptions for new chain set
|
|
2142
2149
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
2143
2150
|
// Do one-time fetch for newly enabled chains; merge so we keep existing chain balances
|
|
2144
|
-
|
|
2145
|
-
|
|
2151
|
+
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
2152
|
+
if (addedChains.length > 0 && accounts.length > 0) {
|
|
2153
|
+
await this.getAssets(accounts, {
|
|
2146
2154
|
chainIds: addedChains,
|
|
2147
2155
|
forceUpdate: true,
|
|
2148
2156
|
updateMode: 'merge',
|