Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/assets-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ enum CaipAssetNamespace {
Token = 'token',
}

const MUSD_ADDRESS_LOWERCASE = '0xaca92e438df0b2401ff60da7e4337b687a2435da';

// ============================================================================
// OPTIONS
// ============================================================================
Expand Down Expand Up @@ -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}`),
),
);

Expand Down
Loading