diff --git a/packages/assets-controllers/src/TokenDetectionController.test.ts b/packages/assets-controllers/src/TokenDetectionController.test.ts index 1a25493407d..140d45a379b 100644 --- a/packages/assets-controllers/src/TokenDetectionController.test.ts +++ b/packages/assets-controllers/src/TokenDetectionController.test.ts @@ -1845,17 +1845,12 @@ describe('TokenDetectionController', () => { expect(callActionSpy).toHaveBeenLastCalledWith( 'TokensController:addDetectedTokens', Object.values(STATIC_MAINNET_TOKEN_LIST).map((token) => { - const newToken = { - ...token, + const { iconUrl, ...tokenMetadata } = token; + return { + ...tokenMetadata, image: token.iconUrl, isERC721: false, }; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - delete (newToken as any).erc20; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - delete (newToken as any).erc721; - delete newToken.iconUrl; - return newToken; }), { selectedAddress, diff --git a/packages/assets-controllers/src/TokenDetectionController.ts b/packages/assets-controllers/src/TokenDetectionController.ts index bb479b1f614..96136b13652 100644 --- a/packages/assets-controllers/src/TokenDetectionController.ts +++ b/packages/assets-controllers/src/TokenDetectionController.ts @@ -32,8 +32,8 @@ import type { AssetsContractController } from './AssetsContractController'; import { isTokenDetectionSupportedForNetwork } from './assetsUtil'; import type { GetTokenListState, + TokenListMap, TokenListStateChange, - TokenListToken, } from './TokenListController'; import type { Token } from './TokenRatesController'; import type { @@ -63,25 +63,23 @@ export function isEqualCaseInsensitive( return value1.toLowerCase() === value2.toLowerCase(); } -type LegacyToken = Omit< - Token, - 'aggregators' | 'image' | 'balanceError' | 'isERC721' -> & { +type LegacyToken = { name: string; - logo: string; + logo: `${string}.svg`; + symbol: string; + decimals: number; erc20?: boolean; erc721?: boolean; }; +type TokenDetectionMap = { + [P in keyof TokenListMap]: Omit; +}; + export const STATIC_MAINNET_TOKEN_LIST = Object.entries( contractMap, -).reduce< - Record< - string, - Partial & Pick - > ->((acc, [base, contract]) => { - const { logo, ...tokenMetadata } = contract; +).reduce((acc, [base, contract]) => { + const { logo, erc20, erc721, ...tokenMetadata } = contract; return { ...acc, [base.toLowerCase()]: { @@ -168,6 +166,8 @@ export class TokenDetectionController extends StaticIntervalPollingController< #networkClientIdAgainstWhichToDetect: NetworkClientId; + #tokenList: TokenDetectionMap = {}; + #disabled: boolean; #isUnlocked: boolean;