Skip to content
Draft
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
6 changes: 2 additions & 4 deletions packages/assets-controller/src/AssetsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
DataResponse,
FungibleAssetMetadata,
} from './types';
import { formatExchangeRatesForBridge } from './utils';
import { formatExchangeRatesForBridge, normalizeAssetId } from './utils';

jest.mock('./utils', () => {
const actual = jest.requireActual<typeof import('./utils')>('./utils');
Expand Down Expand Up @@ -269,12 +269,10 @@ describe('AssetsController', () => {
const defaultState = getDefaultAssetsControllerState();
const assetIds = Object.keys(defaultState.assetsInfo);
expect(assetIds.length).toBeGreaterThan(0);
// Every erc20 asset ID must contain at least one uppercase hex letter
// (EIP-55 checksum property) so that keys match normalizeAssetId output.
const erc20Ids = assetIds.filter((id) => id.includes('/erc20:'));
expect(erc20Ids.length).toBeGreaterThan(0);
for (const id of erc20Ids) {
expect(id).toMatch(/\/erc20:0x[0-9a-fA-F]*[A-F][0-9a-fA-F]*/u);
expect(id).toBe(normalizeAssetId(id as Caip19AssetId));
}
});
});
Expand Down
19 changes: 19 additions & 0 deletions packages/assets-controller/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ const MUSD_METADATA: FungibleAssetMetadata = {
decimals: 6,
};

/**
* Harcoded metadata for USDC on Arc (5042/0x13b2).
* USDC exists as both native (18 decimals) and ERC20 (6 decimals).
* We choose to force-hide the native version to avoid double listing using
* `CHAIN_IDS_WITH_NO_NATIVE_TOKEN`.
* In the meantime, the code below force-shows USDC the ERC20 token.
*/
const USDC_ON_ARC_ASSET_ID =
'eip155:5042/erc20:0x3600000000000000000000000000000000000000';

const USDC_ON_ARC_METADATA: FungibleAssetMetadata = {
type: 'erc20',
symbol: 'USDC',
name: 'USDC',
decimals: 6,
};

/**
* Build the CAIP-19 asset ID for the mUSD ERC-20 token on a given EVM
* chain.
Expand Down Expand Up @@ -59,6 +76,7 @@ export const DEFAULT_TRACKED_ASSETS_BY_CHAIN: ReadonlyMap<
['eip155:1' as ChainId, [musdAssetId('eip155:1' as ChainId)]],
['eip155:59144' as ChainId, [musdAssetId('eip155:59144' as ChainId)]],
['eip155:143' as ChainId, [musdAssetId('eip155:143' as ChainId)]],
['eip155:5042' as ChainId, [USDC_ON_ARC_ASSET_ID]],
]);

/**
Expand All @@ -79,6 +97,7 @@ export const DEFAULT_ASSET_METADATA: ReadonlyMap<string, AssetMetadata> =
[musdAssetId('eip155:1' as ChainId), MUSD_METADATA],
[musdAssetId('eip155:59144' as ChainId), MUSD_METADATA],
[musdAssetId('eip155:143' as ChainId), MUSD_METADATA],
[USDC_ON_ARC_ASSET_ID, USDC_ON_ARC_METADATA],
]);

/**
Expand Down
1 change: 1 addition & 0 deletions packages/controller-utils/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,5 @@ export const DAYS = DAY;
export const CHAIN_IDS_WITH_NO_NATIVE_TOKEN = [
'eip155:42431', // Tempo Testnet
'eip155:4217', // Tempo Mainnet
'eip155:5042', // Arc Mainnet
] as const;
Loading