@metamask-previews/assets-controller 9.0.2-preview-8633f7f2a → 9.0.2-preview-9de9aa4
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 -10
- package/dist/AssetsController.cjs +15 -6
- 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 +15 -6
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/PriceDataSource.cjs +13 -64
- package/dist/data-sources/PriceDataSource.cjs.map +1 -1
- package/dist/data-sources/PriceDataSource.d.cts +0 -13
- package/dist/data-sources/PriceDataSource.d.cts.map +1 -1
- package/dist/data-sources/PriceDataSource.d.mts +0 -13
- package/dist/data-sources/PriceDataSource.d.mts.map +1 -1
- package/dist/data-sources/PriceDataSource.mjs +13 -64
- package/dist/data-sources/PriceDataSource.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/utils/dedupingBatchFetcher.cjs +0 -157
- package/dist/utils/dedupingBatchFetcher.cjs.map +0 -1
- package/dist/utils/dedupingBatchFetcher.d.cts +0 -65
- package/dist/utils/dedupingBatchFetcher.d.cts.map +0 -1
- package/dist/utils/dedupingBatchFetcher.d.mts +0 -65
- package/dist/utils/dedupingBatchFetcher.d.mts.map +0 -1
- package/dist/utils/dedupingBatchFetcher.mjs +0 -153
- package/dist/utils/dedupingBatchFetcher.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,16 +7,6 @@ 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 `priceFreshnessTtlMs` option to `PriceDataSourceConfig` controlling how long a fetched price is considered fresh before it is re-fetched (defaults to the poll interval, 60 000 ms) ([#9189](https://github.com/MetaMask/core/pull/9189))
|
|
13
|
-
- Add `PriceDataSource.invalidatePriceCache()` to force the next fetch to bypass the freshness cache; `AssetsController` now calls it when the selected currency changes so cached prices in the previous currency are refreshed ([#9189](https://github.com/MetaMask/core/pull/9189))
|
|
14
|
-
|
|
15
|
-
### Fixed
|
|
16
|
-
|
|
17
|
-
- Deduplicate price fetches in `PriceDataSource` so overlapping triggers (enrichment middleware, subscription polls, and manual refreshes) no longer issue duplicate price API requests for the same asset; assets fetched within the freshness TTL are skipped and concurrent in-flight fetches are joined ([#9189](https://github.com/MetaMask/core/pull/9189))
|
|
18
|
-
- Remove a redundant one-time balance fetch in `AssetsController` when the enabled network list changes, since subscription refresh and the enabled-networks handler already cover those fetches ([#9189](https://github.com/MetaMask/core/pull/9189))
|
|
19
|
-
|
|
20
10
|
## [9.0.2]
|
|
21
11
|
|
|
22
12
|
### Changed
|
|
@@ -748,8 +748,6 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
748
748
|
if (!__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
|
|
749
749
|
return;
|
|
750
750
|
}
|
|
751
|
-
// Currency changed — old cached prices are in the wrong currency.
|
|
752
|
-
__classPrivateFieldGet(this, _AssetsController_priceDataSource, "f").invalidatePriceCache();
|
|
753
751
|
this.getAssets(__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this), {
|
|
754
752
|
forceUpdate: true,
|
|
755
753
|
dataTypes: ['price'],
|
|
@@ -1159,12 +1157,23 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1159
1157
|
const addedChains = activeChains.filter((ch) => !previousSet.has(ch));
|
|
1160
1158
|
const removedChains = previous.filter((ch) => !activeChains.includes(ch));
|
|
1161
1159
|
if (addedChains.length > 0 || removedChains.length > 0) {
|
|
1162
|
-
// Refresh subscriptions to use updated data source availability
|
|
1163
|
-
// No one-time fetch needed here — #handleEnabledNetworksChanged
|
|
1164
|
-
// handles fetches when the user enables a network, and
|
|
1165
|
-
// #subscribeAssets re-subscribes with the correct chain assignment.
|
|
1160
|
+
// Refresh subscriptions to use updated data source availability
|
|
1166
1161
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_subscribeAssets).call(this);
|
|
1167
1162
|
}
|
|
1163
|
+
// If chains were added and we have selected accounts, do one-time fetch
|
|
1164
|
+
if (addedChains.length > 0 && __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this).length > 0) {
|
|
1165
|
+
const addedEnabledChains = addedChains.filter((chain) => __classPrivateFieldGet(this, _AssetsController_enabledChains, "f").has(chain));
|
|
1166
|
+
if (addedEnabledChains.length > 0) {
|
|
1167
|
+
log('Fetching balances for newly added chains', { addedEnabledChains });
|
|
1168
|
+
this.getAssets(__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this), {
|
|
1169
|
+
chainIds: addedEnabledChains,
|
|
1170
|
+
forceUpdate: true,
|
|
1171
|
+
updateMode: 'merge',
|
|
1172
|
+
}).catch((error) => {
|
|
1173
|
+
log('Failed to fetch balance for added chains', { error });
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1168
1177
|
}, _AssetsController_executeMiddlewares =
|
|
1169
1178
|
// ============================================================================
|
|
1170
1179
|
// MIDDLEWARE EXECUTION
|