@metamask-previews/assets-controller 6.4.0-preview-ef7075b96 → 7.0.0-preview-c4c6220ef
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 +6 -1
- package/dist/AssetsController.cjs +15 -69
- 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 -69
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/RpcDataSource.cjs +0 -1
- package/dist/data-sources/RpcDataSource.cjs.map +1 -1
- package/dist/data-sources/RpcDataSource.d.cts.map +1 -1
- package/dist/data-sources/RpcDataSource.d.mts.map +1 -1
- package/dist/data-sources/RpcDataSource.mjs +0 -1
- package/dist/data-sources/RpcDataSource.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [7.0.0]
|
|
11
|
+
|
|
10
12
|
### Added
|
|
11
13
|
|
|
12
14
|
- RPC token detection now uses the same endpoint as `TokenListController` (`token.api.cx.metamask.io/tokens/{chainId}`) instead of the v3 `tokens.api.cx.metamask.io/v3/chains/.../assets` host, with no client-side `first` cap and a shared TanStack Query cache ([#8727](https://github.com/MetaMask/core/pull/8727))
|
|
@@ -18,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
18
20
|
|
|
19
21
|
### Changed
|
|
20
22
|
|
|
23
|
+
- **BREAKING:** `AssetsController` now requires two additional messenger events from `NetworkController`: `NetworkController:networkAdded` and `NetworkController:networkRemoved` ([#8727](https://github.com/MetaMask/core/pull/8727))
|
|
24
|
+
- Consumers building restricted controller messengers must include both events in their allowed event set, otherwise TypeScript/action constraint checks will fail.
|
|
21
25
|
- Bump `@metamask/account-tree-controller` from `^7.2.0` to `^7.3.0` ([#8722](https://github.com/MetaMask/core/pull/8722))
|
|
22
26
|
- Bump `@metamask/keyring-controller` from `^25.4.0` to `^25.5.0` ([#8722](https://github.com/MetaMask/core/pull/8722))
|
|
23
27
|
- Bump `@metamask/permission-controller` from `^13.0.0` to `^13.1.0` ([#8722](https://github.com/MetaMask/core/pull/8722))
|
|
@@ -444,7 +448,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
444
448
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
445
449
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
446
450
|
|
|
447
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@
|
|
451
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.0.0...HEAD
|
|
452
|
+
[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.4.0...@metamask/assets-controller@7.0.0
|
|
448
453
|
[6.4.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.3.0...@metamask/assets-controller@6.4.0
|
|
449
454
|
[6.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.2.1...@metamask/assets-controller@6.3.0
|
|
450
455
|
[6.2.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@6.2.0...@metamask/assets-controller@6.2.1
|
|
@@ -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_emitTrace, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_lastKnownAccountIds, _AssetsController_getSelectedAccounts, _AssetsController_backendWebsocketDataSource, _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_updateActive, _AssetsController_handleAccountTreeStateChange, _AssetsController_registerActionHandlers, _AssetsController_handleActiveChainsUpdate, _AssetsController_executeMiddlewares, _AssetsController_getNativeAssetMap, _AssetsController_isNativeAsset, _AssetsController_resolveNativeAssetIds, _AssetsController_getNativeAssetIdsForEnabledChains, _AssetsController_getNativeAssetIdsForAccount, _AssetsController_ensureNativeBalancesDefaultZero, _AssetsController_ensureDefaultTrackedAssetsSeeded, _AssetsController_updateState, _AssetsController_getAssetsFromState, _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,
|
|
16
|
+
var _AssetsController_instances, _AssetsController_isEnabled, _AssetsController_isBasicFunctionality, _AssetsController_defaultUpdateInterval, _AssetsController_trace, _AssetsController_captureException, _AssetsController_firstInitFetchReported, _AssetsController_stateSizeReported, _AssetsController_emitTrace, _AssetsController_emitStateSizeTrace, _AssetsController_uiOpen, _AssetsController_keyringUnlocked, _AssetsController_controllerMutex, _AssetsController_activeSubscriptions, _AssetsController_enabledChains, _AssetsController_lastKnownAccountIds, _AssetsController_getSelectedAccounts, _AssetsController_backendWebsocketDataSource, _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_updateActive, _AssetsController_handleAccountTreeStateChange, _AssetsController_registerActionHandlers, _AssetsController_handleActiveChainsUpdate, _AssetsController_executeMiddlewares, _AssetsController_getNativeAssetMap, _AssetsController_isNativeAsset, _AssetsController_resolveNativeAssetIds, _AssetsController_getNativeAssetIdsForEnabledChains, _AssetsController_getNativeAssetIdsForAccount, _AssetsController_ensureNativeBalancesDefaultZero, _AssetsController_ensureDefaultTrackedAssetsSeeded, _AssetsController_updateState, _AssetsController_getAssetsFromState, _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_refreshAssetsAfterNetworkChange;
|
|
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");
|
|
@@ -1042,23 +1042,18 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1042
1042
|
this.messenger.subscribe('NetworkEnablementController:stateChange', ({ enabledNetworkMap }) => {
|
|
1043
1043
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleEnabledNetworksChanged).call(this, enabledNetworkMap).catch(console.error);
|
|
1044
1044
|
});
|
|
1045
|
-
// When a
|
|
1046
|
-
//
|
|
1047
|
-
//
|
|
1048
|
-
//
|
|
1049
|
-
//
|
|
1050
|
-
// NetworkEnablementController.
|
|
1045
|
+
// When a network is added or removed from NetworkController, refresh
|
|
1046
|
+
// assets across every data source so balances, prices, and metadata
|
|
1047
|
+
// stay consistent. On add we also seed default tracked assets (e.g.
|
|
1048
|
+
// mUSD on Monad) when the chain is in our defaults registry, so the
|
|
1049
|
+
// entries appear immediately without waiting for it to also be
|
|
1050
|
+
// enabled in NetworkEnablementController.
|
|
1051
1051
|
this.messenger.subscribe('NetworkController:networkAdded', (networkConfiguration) => {
|
|
1052
1052
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleNetworkAdded).call(this, networkConfiguration.chainId);
|
|
1053
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_refreshAssetsAfterNetworkChange).call(this);
|
|
1053
1054
|
});
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
// distinct from NetworkEnablementController disabling the chain, which
|
|
1057
|
-
// intentionally preserves history; removal is the user saying "this
|
|
1058
|
-
// network is gone for good", so leftover state would just bloat the
|
|
1059
|
-
// persisted store with entries the UI can never reach again.
|
|
1060
|
-
this.messenger.subscribe('NetworkController:networkRemoved', (networkConfiguration) => {
|
|
1061
|
-
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_handleNetworkRemoved).call(this, networkConfiguration.chainId);
|
|
1055
|
+
this.messenger.subscribe('NetworkController:networkRemoved', () => {
|
|
1056
|
+
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_refreshAssetsAfterNetworkChange).call(this);
|
|
1062
1057
|
});
|
|
1063
1058
|
// Client + Keyring lifecycle: only run when UI is open AND keyring is unlocked
|
|
1064
1059
|
this.messenger.subscribe('ClientController:stateChange', (isUiOpen) => {
|
|
@@ -1958,60 +1953,11 @@ async function _AssetsController_handleAccountGroupChanged() {
|
|
|
1958
1953
|
caipChainId,
|
|
1959
1954
|
});
|
|
1960
1955
|
__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_ensureDefaultTrackedAssetsSeeded).call(this, [caipChainId]);
|
|
1961
|
-
},
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
catch {
|
|
1967
|
-
return;
|
|
1968
|
-
}
|
|
1969
|
-
log('Network removed — purging chain state', {
|
|
1970
|
-
hexChainId,
|
|
1971
|
-
chainId: removedChainId,
|
|
1972
|
-
});
|
|
1973
|
-
const matches = (assetId) => {
|
|
1974
|
-
try {
|
|
1975
|
-
return extractChainId(assetId) === removedChainId;
|
|
1976
|
-
}
|
|
1977
|
-
catch {
|
|
1978
|
-
return false;
|
|
1979
|
-
}
|
|
1980
|
-
};
|
|
1981
|
-
this.update((state) => {
|
|
1982
|
-
for (const accountId of Object.keys(state.assetsBalance)) {
|
|
1983
|
-
const accountBalances = state.assetsBalance[accountId];
|
|
1984
|
-
for (const assetId of Object.keys(accountBalances)) {
|
|
1985
|
-
if (matches(assetId)) {
|
|
1986
|
-
delete accountBalances[assetId];
|
|
1987
|
-
}
|
|
1988
|
-
}
|
|
1989
|
-
if (Object.keys(accountBalances).length === 0) {
|
|
1990
|
-
delete state.assetsBalance[accountId];
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
const customAssets = state.customAssets;
|
|
1994
|
-
for (const accountId of Object.keys(customAssets)) {
|
|
1995
|
-
customAssets[accountId] = customAssets[accountId].filter((assetId) => !matches(assetId));
|
|
1996
|
-
if (customAssets[accountId].length === 0) {
|
|
1997
|
-
delete customAssets[accountId];
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
for (const assetId of Object.keys(state.assetsInfo)) {
|
|
2001
|
-
if (matches(assetId)) {
|
|
2002
|
-
delete state.assetsInfo[assetId];
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
for (const assetId of Object.keys(state.assetsPrice)) {
|
|
2006
|
-
if (matches(assetId)) {
|
|
2007
|
-
delete state.assetsPrice[assetId];
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
for (const assetId of Object.keys(state.assetPreferences)) {
|
|
2011
|
-
if (matches(assetId)) {
|
|
2012
|
-
delete state.assetPreferences[assetId];
|
|
2013
|
-
}
|
|
2014
|
-
}
|
|
1956
|
+
}, _AssetsController_refreshAssetsAfterNetworkChange = function _AssetsController_refreshAssetsAfterNetworkChange() {
|
|
1957
|
+
this.getAssets(__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this), {
|
|
1958
|
+
forceUpdate: true,
|
|
1959
|
+
}).catch((error) => {
|
|
1960
|
+
log('Failed to refresh assets after network change', { error });
|
|
2015
1961
|
});
|
|
2016
1962
|
};
|
|
2017
1963
|
//# sourceMappingURL=AssetsController.cjs.map
|