diff --git a/packages/assets-controller/CHANGELOG.md b/packages/assets-controller/CHANGELOG.md index dcd3b12289c..468d41ee955 100644 --- a/packages/assets-controller/CHANGELOG.md +++ b/packages/assets-controller/CHANGELOG.md @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `@metamask/keyring-snap-client` from `^8.2.0` to `^9.0.1` ([#8464](https://github.com/MetaMask/core/pull/8464)) - Bump `@metamask/transaction-controller` from `^64.2.0` to `^64.3.0` ([#8482](https://github.com/MetaMask/core/pull/8482)) +### Fixed + +- Exempt mUSD token from EVM ERC-20 minimum-occurrence spam filter so it is no longer incorrectly hidden ([#8541](https://github.com/MetaMask/core/pull/8541)) + ## [6.0.0] ### Added diff --git a/packages/assets-controller/src/data-sources/TokenDataSource.test.ts b/packages/assets-controller/src/data-sources/TokenDataSource.test.ts index e979dc1750d..6e0f51e51b2 100644 --- a/packages/assets-controller/src/data-sources/TokenDataSource.test.ts +++ b/packages/assets-controller/src/data-sources/TokenDataSource.test.ts @@ -779,6 +779,39 @@ describe('TokenDataSource', () => { ); }); + it.each([ + { occurrences: 1, label: 'low occurrences' }, + { occurrences: undefined, label: 'no occurrences' }, + ])('middleware keeps MUSD token despite $label', async ({ occurrences }) => { + const musdAsset = + 'eip155:1/erc20:0xaca92e438df0b2401ff60da7e4337b687a2435da' as Caip19AssetId; + + const { controller } = setupController({ + messenger: createTestMessenger(), + supportedNetworks: ['eip155:1'], + assetsResponse: [ + createMockAssetResponse(musdAsset, { + name: 'mUSD', + symbol: 'MUSD', + occurrences, + }), + ], + }); + + const next = jest.fn().mockResolvedValue(undefined); + const context = createMiddlewareContext({ + response: { + detectedAssets: { + 'mock-account-id': [musdAsset], + }, + }, + }); + + await controller.assetsMiddleware(context, next); + + expect(context.response.assetsInfo?.[musdAsset]).toBeDefined(); + }); + it('middleware filters out erc20 assets with missing occurrences', async () => { const noOccurrenceAsset = 'eip155:1/erc20:0x2222222222222222222222222222222222222222' as Caip19AssetId; diff --git a/packages/assets-controller/src/data-sources/TokenDataSource.ts b/packages/assets-controller/src/data-sources/TokenDataSource.ts index 9ee8041906c..23fc39d7fbf 100644 --- a/packages/assets-controller/src/data-sources/TokenDataSource.ts +++ b/packages/assets-controller/src/data-sources/TokenDataSource.ts @@ -49,6 +49,8 @@ enum CaipAssetNamespace { Token = 'token', } +const MUSD_ADDRESS_LOWERCASE = '0xaca92e438df0b2401ff60da7e4337b687a2435da'; + // ============================================================================ // OPTIONS // ============================================================================ @@ -419,7 +421,8 @@ export class TokenDataSource { evmErc20Ids.filter( (id) => customAssetIds.has(id) || - (occurrencesByAssetId.get(id) ?? 0) >= MIN_TOKEN_OCCURRENCES, + (occurrencesByAssetId.get(id) ?? 0) >= MIN_TOKEN_OCCURRENCES || + id.includes(`/erc20:${MUSD_ADDRESS_LOWERCASE}`), ), );