Skip to content

Commit

Permalink
refactor: improve token search logic and clean up console log
Browse files Browse the repository at this point in the history
  • Loading branch information
vuonghuuhung committed Jan 14, 2025
1 parent 71678b6 commit 9c3b7de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 11 additions & 6 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,16 @@ const Balance: React.FC<BalanceProps> = () => {

useGetFeeConfig();
useEffect(() => {
if (!searchTokenAddress) return setTokens([otherChainTokenCommon, oraichainTokensCommon]);

(async () => {
try {
if (!searchTokenAddress) return setTokens([otherChainTokenCommon, oraichainTokensCommon]);

const foundTokens = [otherChainTokenCommon, oraichainTokensCommon].map((childTokens) =>
childTokens.filter((t) => t.name.includes(searchTokenAddress.toUpperCase()))
childTokens.filter((t) =>
[t.name.toUpperCase(), t.contractAddress?.toUpperCase(), t.denom?.toUpperCase()].includes(
searchTokenAddress.toUpperCase()
)
)
);

if (foundTokens.every((t) => t.length === 0)) {
Expand Down Expand Up @@ -647,9 +651,10 @@ const Balance: React.FC<BalanceProps> = () => {
let newToToken = to;

if (toNetworkChainId && (!toToken || toToken?.chainId !== toNetworkChainId)) {
newToToken = [...otherChainTokens, ...oraichainTokens].find(
(flat) => flat.chainId === toNetworkChainId && flat.coinGeckoId === from.coinGeckoId
);
newToToken = [...otherChainTokenCommon, ...oraichainTokensCommon].find((flat) => {
return flat.chainId === toNetworkChainId && flat.coinGeckoId === from.coinGeckoId;
});

assert(newToToken, 'Cannot find newToToken token that matches from token to bridge!');
}

Expand Down
2 changes: 0 additions & 2 deletions src/pages/Pools/components/OverviewPool/OverviewPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import styles from './OverviewPool.module.scss';
export const OverviewPool = ({ poolDetailData }: { poolDetailData: PoolDetail }) => {
const theme = useTheme();

console.log(poolDetailData);

const { pairAmountInfoData } = useGetPairInfo(poolDetailData);
const { token1, token2 } = poolDetailData;

Expand Down

0 comments on commit 9c3b7de

Please sign in to comment.