Skip to content

Commit

Permalink
Fix detectTokens to remove redundant TokensController:getState ca…
Browse files Browse the repository at this point in the history
…lls for `ignoredTokens`
  • Loading branch information
MajorLift committed Feb 6, 2024
1 parent f47a4ce commit 8f21fc8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/assets-controllers/src/TokenDetectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) =>
Expand All @@ -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,
Expand Down

0 comments on commit 8f21fc8

Please sign in to comment.