mirror of
https://github.com/vacp2p/linea-monorepo.git
synced 2026-01-08 15:13:50 -05:00
* fix: add gitattribute rules for woff2 files * feat: add lifi widget + fixes minor issues * fix: remove unused packages + clean constants declaration and config * fix: update dockerfile and github ci workflows * fix: env variable naming issue * fix: bridge mode alt value issue + remove button component
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { useMemo } from "react";
|
|
import { useChainStore, useTokenStore } from "@/stores";
|
|
import { ChainLayer, Token } from "@/types";
|
|
import { config } from "@/config";
|
|
import { USDC_SYMBOL } from "@/constants";
|
|
|
|
const useTokens = (): Token[] => {
|
|
const tokensList = useTokenStore((state) => state.tokensList);
|
|
const fromChain = useChainStore.useFromChain();
|
|
|
|
return useMemo(() => {
|
|
if (!fromChain) return [];
|
|
|
|
if (fromChain.testnet) {
|
|
if (fromChain.layer !== ChainLayer.L2) {
|
|
return tokensList.SEPOLIA.filter(
|
|
(token) => !token.type.includes("native") && (config.isCctpEnabled || token.symbol !== USDC_SYMBOL),
|
|
);
|
|
}
|
|
return config.isCctpEnabled
|
|
? tokensList.SEPOLIA
|
|
: tokensList.SEPOLIA.filter((token) => token.symbol !== USDC_SYMBOL);
|
|
}
|
|
|
|
if (fromChain.layer !== ChainLayer.L2) {
|
|
return tokensList.MAINNET.filter(
|
|
(token) => !token.type.includes("native") && (config.isCctpEnabled || token.symbol !== USDC_SYMBOL),
|
|
);
|
|
}
|
|
|
|
return config.isCctpEnabled
|
|
? tokensList.MAINNET
|
|
: tokensList.MAINNET.filter((token) => token.symbol !== USDC_SYMBOL);
|
|
}, [fromChain, tokensList.MAINNET, tokensList.SEPOLIA]);
|
|
};
|
|
|
|
export default useTokens;
|