diff --git a/packages/assets-controllers/src/TokenDetectionController.ts b/packages/assets-controllers/src/TokenDetectionController.ts index f1ec0cbbeb9..c416d1412a8 100644 --- a/packages/assets-controllers/src/TokenDetectionController.ts +++ b/packages/assets-controllers/src/TokenDetectionController.ts @@ -465,7 +465,9 @@ export class TokenDetectionController extends StaticIntervalPollingController< ? STATIC_MAINNET_TOKEN_LIST : tokenList; - const { tokens, detectedTokens } = this.#getTokensState(); + const { tokens, detectedTokens, ignoredTokens } = this.messagingSystem.call( + 'TokensController:getState', + ); const tokensToDetect: string[] = []; for (const tokenAddress of Object.keys(tokenListUsed)) { @@ -505,11 +507,9 @@ export class TokenDetectionController extends StaticIntervalPollingController< tokensSlice, ); const tokensToAdd: Token[] = []; - const eventTokensDetails = []; + const eventTokensDetails: string[] = []; + let ignored; for (const tokenAddress of Object.keys(balances)) { - let ignored; - /* istanbul ignore else */ - const { ignoredTokens } = this.#getTokensState(); if (ignoredTokens.length) { ignored = ignoredTokens.find( (ignoredTokenAddress) => @@ -524,7 +524,7 @@ export class TokenDetectionController extends StaticIntervalPollingController< if (ignored === undefined) { const { decimals, symbol, aggregators, iconUrl, name } = - tokenList[caseInsensitiveTokenKey]; + tokenListUsed[caseInsensitiveTokenKey]; eventTokensDetails.push(`${symbol} - ${tokenAddress}`); tokensToAdd.push({ address: tokenAddress,