Skip to content

Commit

Permalink
fix: clean-up token autodetection
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Nov 12, 2024
1 parent 25e3182 commit a7231df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ describe('TokenDetectionController', () => {
},
},

// Salim ....
async ({ controller, mockTokenListGetState, callActionSpy }) => {
mockMultiChainAccountsService();
mockTokenListGetState({
Expand Down Expand Up @@ -2350,7 +2349,6 @@ describe('TokenDetectionController', () => {
options: {
disabled: false,
getBalancesInSingleCall: mockGetBalancesInSingleCall,
// useAccountsAPI: true, // USING ACCOUNTS API
},
mocks: {
getSelectedAccount: selectedAccount,
Expand Down
16 changes: 7 additions & 9 deletions packages/assets-controllers/src/TokensController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,15 +503,13 @@ export class TokensController extends BaseController<
).configuration.chainId;
}

const newDetectedTokens =
interactingChainId &&
allDetectedTokens[interactingChainId]?.[this.#getSelectedAddress()]
? allDetectedTokens[interactingChainId]?.[
this.#getSelectedAddress()
].filter(
(token: Token) => !importedTokensMap[token.address.toLowerCase()],
)
: [];
const detectedTokensForGivenChain = interactingChainId
? allDetectedTokens?.[interactingChainId]?.[this.#getSelectedAddress()]
: [];

const newDetectedTokens = detectedTokensForGivenChain.filter(
(t) => !importedTokensMap[t.address.toLowerCase()],
);

const { newAllTokens, newAllDetectedTokens, newAllIgnoredTokens } =
this.#getNewAllTokensState({
Expand Down

0 comments on commit a7231df

Please sign in to comment.