@metamask-previews/assets-controller 13.1.1-preview-316ba6af0 → 13.1.1-preview-e57e5c3dc
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 +1 -6
- package/dist/AssetsController.cjs +16 -26
- 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 +0 -10
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +0 -13
- 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 +0 -13
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -9,17 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
-
- Bump `@metamask/transaction-controller` from `^69.5.0` to `^69.5.1` ([#9798](https://github.com/MetaMask/core/pull/9798))
|
|
13
12
|
- Bump `@metamask/account-tree-controller` from `^7.6.0` to `^7.6.1` ([#9791](https://github.com/MetaMask/core/pull/9791))
|
|
14
|
-
- Bump `@metamask/accounts-controller` from `^39.0.6` to `^39.
|
|
13
|
+
- Bump `@metamask/accounts-controller` from `^39.0.6` to `^39.0.7` ([#9791](https://github.com/MetaMask/core/pull/9791))
|
|
15
14
|
- Bump `@metamask/keyring-controller` from `^27.1.0` to `^27.1.1` ([#9791](https://github.com/MetaMask/core/pull/9791))
|
|
16
15
|
- Bump `@metamask/network-enablement-controller` from `^6.0.2` to `^6.0.3` ([#9791](https://github.com/MetaMask/core/pull/9791))
|
|
17
16
|
- Bump `@metamask/assets-controllers` from `^111.0.0` to `^111.1.0` ([#9793](https://github.com/MetaMask/core/pull/9793))
|
|
18
17
|
|
|
19
|
-
### Fixed
|
|
20
|
-
|
|
21
|
-
- Preserve pooled-staking balances across Accounts API chain-slice updates (e.g. network switch / `replaceCoveredChainBalances`): exclude staking contract asset IDs from `AccountsApiDataSource` v5/v6 balance processing, and keep prior staked amounts when a merge replace omits them so Accounts API cannot reset staked ETH to missing/0 ([#9753](https://github.com/MetaMask/core/pull/9753))
|
|
22
|
-
|
|
23
18
|
## [13.1.1]
|
|
24
19
|
|
|
25
20
|
### Changed
|
|
@@ -24,7 +24,6 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
24
24
|
const lodash_1 = require("lodash");
|
|
25
25
|
const AccountActivityDataSource_js_1 = require("./data-sources/AccountActivityDataSource.cjs");
|
|
26
26
|
const AccountsApiDataSource_js_1 = require("./data-sources/AccountsApiDataSource.cjs");
|
|
27
|
-
const index_js_1 = require("./data-sources/evm-rpc-services/index.cjs");
|
|
28
27
|
const assets_js_1 = require("./data-sources/evm-rpc-services/utils/assets.cjs");
|
|
29
28
|
const PriceDataSource_js_1 = require("./data-sources/PriceDataSource.cjs");
|
|
30
29
|
const RpcDataSource_js_1 = require("./data-sources/RpcDataSource.cjs");
|
|
@@ -41,7 +40,7 @@ const RpcFallbackMiddleware_js_1 = require("./middlewares/RpcFallbackMiddleware.
|
|
|
41
40
|
const healAssetsInfoMetadata_js_1 = require("./migrations/healAssetsInfoMetadata.cjs");
|
|
42
41
|
const constants_js_1 = require("./utils/constants.cjs");
|
|
43
42
|
const customAssetsRpcSupplement_js_1 = require("./utils/customAssetsRpcSupplement.cjs");
|
|
44
|
-
const
|
|
43
|
+
const index_js_1 = require("./utils/index.cjs");
|
|
45
44
|
const trace_js_1 = require("./utils/trace.cjs");
|
|
46
45
|
const NATIVE_ASSETS_QUERY_KEY = ['nativeAssets'];
|
|
47
46
|
/** Stable empty map so memoized formatters are not busted by `?? {}` identity churn. */
|
|
@@ -170,14 +169,14 @@ function normalizeResponse(response) {
|
|
|
170
169
|
if (response.assetsInfo) {
|
|
171
170
|
normalized.assetsInfo = {};
|
|
172
171
|
for (const [assetId, metadata] of Object.entries(response.assetsInfo)) {
|
|
173
|
-
const normalizedId = (0,
|
|
172
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
174
173
|
normalized.assetsInfo[normalizedId] = metadata;
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
176
|
if (response.assetsPrice) {
|
|
178
177
|
normalized.assetsPrice = {};
|
|
179
178
|
for (const [assetId, price] of Object.entries(response.assetsPrice)) {
|
|
180
|
-
const normalizedId = (0,
|
|
179
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
181
180
|
normalized.assetsPrice[normalizedId] = price;
|
|
182
181
|
}
|
|
183
182
|
}
|
|
@@ -186,7 +185,7 @@ function normalizeResponse(response) {
|
|
|
186
185
|
for (const [accountId, balances] of Object.entries(response.assetsBalance)) {
|
|
187
186
|
normalized.assetsBalance[accountId] = {};
|
|
188
187
|
for (const [assetId, balance] of Object.entries(balances)) {
|
|
189
|
-
const normalizedId = (0,
|
|
188
|
+
const normalizedId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
190
189
|
normalized.assetsBalance[accountId][normalizedId] = balance;
|
|
191
190
|
}
|
|
192
191
|
}
|
|
@@ -195,7 +194,7 @@ function normalizeResponse(response) {
|
|
|
195
194
|
if (response.detectedAssets) {
|
|
196
195
|
normalized.detectedAssets = {};
|
|
197
196
|
for (const [accountId, assetIds] of Object.entries(response.detectedAssets)) {
|
|
198
|
-
normalized.detectedAssets[accountId] = assetIds.map((assetId) => (0,
|
|
197
|
+
normalized.detectedAssets[accountId] = assetIds.map((assetId) => (0, index_js_1.normalizeAssetId)(assetId));
|
|
199
198
|
}
|
|
200
199
|
}
|
|
201
200
|
// Preserve errors (chain IDs don't need normalization)
|
|
@@ -238,15 +237,6 @@ function mergeAccountBalances(previousBalances, accountBalances, customAssetIds,
|
|
|
238
237
|
next[customId] = prev ?? { amount: '0' };
|
|
239
238
|
}
|
|
240
239
|
}
|
|
241
|
-
// Staked vault balances are owned by StakedBalanceDataSource. When an
|
|
242
|
-
// Accounts API (or other) chain-slice replace omits them, keep the prior
|
|
243
|
-
// on-chain staked amount instead of clearing it to missing/0.
|
|
244
|
-
for (const [assetId, balance] of Object.entries(previousBalances)) {
|
|
245
|
-
if ((0, index_js_1.isStakingContractAssetId)(assetId) &&
|
|
246
|
-
!Object.prototype.hasOwnProperty.call(next, assetId)) {
|
|
247
|
-
next[assetId] = balance;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
240
|
return next;
|
|
251
241
|
}
|
|
252
242
|
// ============================================================================
|
|
@@ -756,7 +746,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
756
746
|
*/
|
|
757
747
|
getExchangeRatesForBridge() {
|
|
758
748
|
const { networkConfigurationsByChainId } = this.messenger.call('NetworkController:getState');
|
|
759
|
-
return (0,
|
|
749
|
+
return (0, index_js_1.formatExchangeRatesForBridge)({
|
|
760
750
|
assetsInfo: this.state.assetsInfo,
|
|
761
751
|
assetsPrice: this.state.assetsPrice,
|
|
762
752
|
selectedCurrency: this.state.selectedCurrency,
|
|
@@ -776,7 +766,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
776
766
|
getStateForTransactionPay() {
|
|
777
767
|
const accounts = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this);
|
|
778
768
|
const { networkConfigurationsByChainId } = this.messenger.call('NetworkController:getState');
|
|
779
|
-
return (0,
|
|
769
|
+
return (0, index_js_1.formatStateForTransactionPay)({
|
|
780
770
|
assetsBalance: this.state.assetsBalance,
|
|
781
771
|
assetsInfo: this.state.assetsInfo,
|
|
782
772
|
assetsPrice: this.state.assetsPrice,
|
|
@@ -803,7 +793,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
803
793
|
* @param pendingMetadata - Optional token metadata from the UI (pendingTokens format).
|
|
804
794
|
*/
|
|
805
795
|
async addCustomAsset(accountId, assetId, pendingMetadata) {
|
|
806
|
-
const normalizedAssetId = (0,
|
|
796
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
807
797
|
log('Adding custom asset', { accountId, assetId: normalizedAssetId });
|
|
808
798
|
this.update((state) => {
|
|
809
799
|
var _a;
|
|
@@ -875,7 +865,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
875
865
|
* @param assetId - The CAIP-19 asset ID to remove.
|
|
876
866
|
*/
|
|
877
867
|
removeCustomAsset(accountId, assetId) {
|
|
878
|
-
const normalizedAssetId = (0,
|
|
868
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
879
869
|
log('Removing custom asset', { accountId, assetId: normalizedAssetId });
|
|
880
870
|
this.update((state) => {
|
|
881
871
|
if (state.customAssets[accountId]) {
|
|
@@ -910,7 +900,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
910
900
|
* @param assetId - The CAIP-19 asset ID to hide.
|
|
911
901
|
*/
|
|
912
902
|
hideAsset(assetId) {
|
|
913
|
-
const normalizedAssetId = (0,
|
|
903
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
914
904
|
log('Hiding asset', { assetId: normalizedAssetId });
|
|
915
905
|
this.update((state) => {
|
|
916
906
|
if (!state.assetPreferences[normalizedAssetId]) {
|
|
@@ -925,7 +915,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
925
915
|
* @param assetId - The CAIP-19 asset ID to unhide.
|
|
926
916
|
*/
|
|
927
917
|
unhideAsset(assetId) {
|
|
928
|
-
const normalizedAssetId = (0,
|
|
918
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
929
919
|
log('Unhiding asset', { assetId: normalizedAssetId });
|
|
930
920
|
this.update((state) => {
|
|
931
921
|
const prefs = state.assetPreferences[normalizedAssetId];
|
|
@@ -1231,7 +1221,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1231
1221
|
queryApiClient.queryClient
|
|
1232
1222
|
.fetchQuery({
|
|
1233
1223
|
queryKey: NATIVE_ASSETS_QUERY_KEY,
|
|
1234
|
-
queryFn:
|
|
1224
|
+
queryFn: index_js_1.buildNativeAssetsFromApi,
|
|
1235
1225
|
staleTime: Infinity,
|
|
1236
1226
|
gcTime: Infinity,
|
|
1237
1227
|
})
|
|
@@ -1244,7 +1234,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1244
1234
|
// #isNativeAsset, #resolveNativeAssetIds) have data available immediately.
|
|
1245
1235
|
// When fetchQuery resolves (currently instant, future: API), it overwrites
|
|
1246
1236
|
// this with potentially fresher data.
|
|
1247
|
-
const initialNativeAssetMap = (0,
|
|
1237
|
+
const initialNativeAssetMap = (0, index_js_1.buildNativeAssetsFromConstant)();
|
|
1248
1238
|
queryApiClient.setCachedData(NATIVE_ASSETS_QUERY_KEY, initialNativeAssetMap);
|
|
1249
1239
|
}, _AssetsController_initializeState = function _AssetsController_initializeState() {
|
|
1250
1240
|
const { enabledNetworkMap } = this.messenger.call('NetworkEnablementController:getState');
|
|
@@ -1614,7 +1604,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1614
1604
|
}
|
|
1615
1605
|
}, _AssetsController_normalizeAssetIdOrThrow = function _AssetsController_normalizeAssetIdOrThrow(assetId, methodName) {
|
|
1616
1606
|
try {
|
|
1617
|
-
return (0,
|
|
1607
|
+
return (0, index_js_1.normalizeAssetId)(assetId);
|
|
1618
1608
|
}
|
|
1619
1609
|
catch {
|
|
1620
1610
|
throw new Error(`AssetsController.${methodName}: invalid CAIP-19 assetId "${assetId}"`);
|
|
@@ -1635,7 +1625,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1635
1625
|
if (!chainFilter.has(assetId.split('/')[0])) {
|
|
1636
1626
|
continue;
|
|
1637
1627
|
}
|
|
1638
|
-
const normalizedAssetId = (0,
|
|
1628
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
1639
1629
|
if (prices[normalizedAssetId] ?? prices[assetId]) {
|
|
1640
1630
|
continue;
|
|
1641
1631
|
}
|
|
@@ -1866,7 +1856,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1866
1856
|
// exponent form is rewritten) so balances arriving before
|
|
1867
1857
|
// their metadata aren't lossily truncated.
|
|
1868
1858
|
const assetDecimals = metadata[assetId]?.decimals;
|
|
1869
|
-
const newAmount = (0,
|
|
1859
|
+
const newAmount = (0, index_js_1.normalizeAmountString)(balance.amount, assetDecimals);
|
|
1870
1860
|
effective[assetId] = { ...balance, amount: newAmount };
|
|
1871
1861
|
const oldAmount = previousBalance?.amount;
|
|
1872
1862
|
const isNewDefaultNativeZero = oldAmount === undefined &&
|