@metamask-previews/assets-controller 13.1.1-preview-613132754 → 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 +0 -7
- package/dist/AssetsController.cjs +16 -39
- 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 -23
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.cjs +1 -6
- package/dist/data-sources/AccountActivityDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountActivityDataSource.mjs +1 -6
- package/dist/data-sources/AccountActivityDataSource.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/dist/data-sources/TokenDataSource.cjs +0 -119
- package/dist/data-sources/TokenDataSource.cjs.map +1 -1
- package/dist/data-sources/TokenDataSource.d.cts +0 -13
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
- package/dist/data-sources/TokenDataSource.d.mts +0 -13
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
- package/dist/data-sources/TokenDataSource.mjs +0 -119
- package/dist/data-sources/TokenDataSource.mjs.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.cjs +18 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.cjs.map +1 -1
- package/dist/middlewares/CustomAssetGraduationMiddleware.mjs +19 -2
- package/dist/middlewares/CustomAssetGraduationMiddleware.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.cts.map +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.mts.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/normalizeAssetId.cjs +1 -19
- package/dist/utils/normalizeAssetId.cjs.map +1 -1
- package/dist/utils/normalizeAssetId.d.cts +0 -10
- package/dist/utils/normalizeAssetId.d.cts.map +1 -1
- package/dist/utils/normalizeAssetId.d.mts +0 -10
- package/dist/utils/normalizeAssetId.d.mts.map +1 -1
- package/dist/utils/normalizeAssetId.mjs +0 -17
- package/dist/utils/normalizeAssetId.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,19 +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
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
|
-
- Apply occurrence-floor spam filtering to tokens received through account-activity (websocket) updates: new tokens are enriched with Token API occurrence counts before detection and dropped when below the per-chain suggested floor, and stub metadata of filtered-out assets is stripped from the pipeline response so spam tokens never persist to state ([#9803](https://github.com/MetaMask/core/pull/9803))
|
|
22
|
-
- Checksum the lower-case ERC-20 asset IDs delivered by `AccountActivityDataSource` before they enter the assets pipeline, so middleware comparisons against state (which keys assets by checksummed ID) no longer treat an existing holding as a brand-new asset — previously such balance updates could be re-detected, or dropped entirely by spam filtering, and never reach state ([#9803](https://github.com/MetaMask/core/pull/9803))
|
|
23
|
-
- 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))
|
|
24
|
-
|
|
25
18
|
## [13.1.1]
|
|
26
19
|
|
|
27
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];
|
|
@@ -1086,23 +1076,10 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
1086
1076
|
// those.
|
|
1087
1077
|
const shouldGraduateCustomAssets = sourceId === 'AccountsApiDataSource' ||
|
|
1088
1078
|
sourceId === 'AccountActivityDataSource';
|
|
1089
|
-
// Websocket updates can carry brand-new spam airdrops: enrich them
|
|
1090
|
-
// with Token API occurrences and drop below-floor tokens BEFORE
|
|
1091
|
-
// detection, so spam is never detected, enriched, priced or persisted.
|
|
1092
|
-
const shouldFilterOccurrences = sourceId === 'AccountActivityDataSource' &&
|
|
1093
|
-
__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this);
|
|
1094
1079
|
const enrichmentSources = [
|
|
1095
1080
|
...(shouldGraduateCustomAssets
|
|
1096
1081
|
? [__classPrivateFieldGet(this, _AssetsController_customAssetGraduationMiddleware, "f")]
|
|
1097
1082
|
: []),
|
|
1098
|
-
...(shouldFilterOccurrences
|
|
1099
|
-
? [
|
|
1100
|
-
{
|
|
1101
|
-
getName: () => 'OccurrenceFloorFilter',
|
|
1102
|
-
assetsMiddleware: __classPrivateFieldGet(this, _AssetsController_tokenDataSource, "f").occurrenceFilterMiddleware,
|
|
1103
|
-
},
|
|
1104
|
-
]
|
|
1105
|
-
: []),
|
|
1106
1083
|
__classPrivateFieldGet(this, _AssetsController_detectionMiddleware, "f"),
|
|
1107
1084
|
];
|
|
1108
1085
|
if (__classPrivateFieldGet(this, _AssetsController_isBasicFunctionality, "f").call(this)) {
|
|
@@ -1244,7 +1221,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1244
1221
|
queryApiClient.queryClient
|
|
1245
1222
|
.fetchQuery({
|
|
1246
1223
|
queryKey: NATIVE_ASSETS_QUERY_KEY,
|
|
1247
|
-
queryFn:
|
|
1224
|
+
queryFn: index_js_1.buildNativeAssetsFromApi,
|
|
1248
1225
|
staleTime: Infinity,
|
|
1249
1226
|
gcTime: Infinity,
|
|
1250
1227
|
})
|
|
@@ -1257,7 +1234,7 @@ _AssetsController_isEnabled = new WeakMap(), _AssetsController_isBasicFunctional
|
|
|
1257
1234
|
// #isNativeAsset, #resolveNativeAssetIds) have data available immediately.
|
|
1258
1235
|
// When fetchQuery resolves (currently instant, future: API), it overwrites
|
|
1259
1236
|
// this with potentially fresher data.
|
|
1260
|
-
const initialNativeAssetMap = (0,
|
|
1237
|
+
const initialNativeAssetMap = (0, index_js_1.buildNativeAssetsFromConstant)();
|
|
1261
1238
|
queryApiClient.setCachedData(NATIVE_ASSETS_QUERY_KEY, initialNativeAssetMap);
|
|
1262
1239
|
}, _AssetsController_initializeState = function _AssetsController_initializeState() {
|
|
1263
1240
|
const { enabledNetworkMap } = this.messenger.call('NetworkEnablementController:getState');
|
|
@@ -1627,7 +1604,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1627
1604
|
}
|
|
1628
1605
|
}, _AssetsController_normalizeAssetIdOrThrow = function _AssetsController_normalizeAssetIdOrThrow(assetId, methodName) {
|
|
1629
1606
|
try {
|
|
1630
|
-
return (0,
|
|
1607
|
+
return (0, index_js_1.normalizeAssetId)(assetId);
|
|
1631
1608
|
}
|
|
1632
1609
|
catch {
|
|
1633
1610
|
throw new Error(`AssetsController.${methodName}: invalid CAIP-19 assetId "${assetId}"`);
|
|
@@ -1648,7 +1625,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1648
1625
|
if (!chainFilter.has(assetId.split('/')[0])) {
|
|
1649
1626
|
continue;
|
|
1650
1627
|
}
|
|
1651
|
-
const normalizedAssetId = (0,
|
|
1628
|
+
const normalizedAssetId = (0, index_js_1.normalizeAssetId)(assetId);
|
|
1652
1629
|
if (prices[normalizedAssetId] ?? prices[assetId]) {
|
|
1653
1630
|
continue;
|
|
1654
1631
|
}
|
|
@@ -1879,7 +1856,7 @@ async function _AssetsController_executeMiddlewares(params) {
|
|
|
1879
1856
|
// exponent form is rewritten) so balances arriving before
|
|
1880
1857
|
// their metadata aren't lossily truncated.
|
|
1881
1858
|
const assetDecimals = metadata[assetId]?.decimals;
|
|
1882
|
-
const newAmount = (0,
|
|
1859
|
+
const newAmount = (0, index_js_1.normalizeAmountString)(balance.amount, assetDecimals);
|
|
1883
1860
|
effective[assetId] = { ...balance, amount: newAmount };
|
|
1884
1861
|
const oldAmount = previousBalance?.amount;
|
|
1885
1862
|
const isNewDefaultNativeZero = oldAmount === undefined &&
|