Skip to content

Commit

Permalink
Add tokenlist filtering by chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofilipenunes committed Oct 29, 2024
1 parent 162fb15 commit 0024a40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libs/tokens/token.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Token {
symbol: string;
balance?: string;
isSuspicious?: boolean;
chainId?: number;
}

export interface TokenList {
Expand Down
7 changes: 7 additions & 0 deletions src/libs/tokens/tokenHelperFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ export const fetchTokenLists = async () => {
? await tokenParserMap[parser](result)
: result;

const filteredTokens = parsedResult.tokens.filter(
(token) =>
token?.chainId === undefined ||
token?.chainId === config.network.chainId
);

return {
...parsedResult,
tokens: filteredTokens,
logoURI: getLogoByURI(parsedResult.logoURI),
};
})
Expand Down

0 comments on commit 0024a40

Please sign in to comment.