Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve token search logic and clean up console log #1132

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading