Skip to content

Commit 7402fc8

Browse files
committed
chore: align data fetch on stocks
1 parent 4863651 commit 7402fc8

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

app/components/Views/TrendingView/feeds/stocks/useStocksFeed.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { useMemo } from 'react';
12
import type { TrendingAsset } from '@metamask/assets-controllers';
23
import { useRwaTokens } from '../../../../UI/Trending/hooks/useRwaTokens/useRwaTokens';
34
import { useFeedRefresh } from '../../hooks/useFeedRefresh';
45
import type { RefreshConfig } from '../../hooks/useExploreRefresh';
56

7+
const ETHEREUM_CAIP_CHAIN_ID = 'eip155:1';
8+
69
interface UseStocksFeedOptions {
710
query?: string;
811
refresh?: RefreshConfig;
@@ -14,17 +17,22 @@ export interface UseStocksFeedResult {
1417
refetch: () => Promise<void>;
1518
}
1619

17-
/** Tokenized stocks (RWAs on Ethereum mainnet). */
20+
/** Tokenized stocks (RWAs). Only Ethereum mainnet tokens are shown in the section. */
1821
export const useStocksFeed = ({
1922
query,
2023
refresh,
2124
}: UseStocksFeedOptions = {}): UseStocksFeedResult => {
2225
const { data, isLoading, refetch } = useRwaTokens({
2326
searchQuery: query,
24-
...(query ? {} : { chainIds: ['eip155:1'] }),
2527
});
2628

29+
const ethereumData = useMemo(
30+
() =>
31+
data.filter((asset) => asset.assetId.startsWith(ETHEREUM_CAIP_CHAIN_ID)),
32+
[data],
33+
);
34+
2735
useFeedRefresh(refresh, refetch);
2836

29-
return { data, isLoading, refetch };
37+
return { data: ethereumData, isLoading, refetch };
3038
};

0 commit comments

Comments
 (0)