diff --git a/components/page/bridge/hooks/useGetFee.ts b/components/page/bridge/hooks/useGetFee.ts index 94f2a21..0a27bc5 100644 --- a/components/page/bridge/hooks/useGetFee.ts +++ b/components/page/bridge/hooks/useGetFee.ts @@ -7,7 +7,19 @@ import { TonbridgeBridgeClient } from "@oraichain/tonbridge-contracts-sdk"; import { useEffect, useState } from "react"; import { useWalletsTonCache } from "@/stores/token/selector"; -const useGetFee = ({ token }: { token: TokenType }) => { +const useGetFee = ({ + token, + fromNetwork, + toNetwork, +}: { + token: TokenType; + fromNetwork: { + id: string; + }; + toNetwork: { + id: string; + }; +}) => { const oraiAddress = useAuthOraiAddress(); const [bridgeFee, setBridgeFee] = useState(0); const [tokenFee, setTokenFee] = useState(0); @@ -17,6 +29,10 @@ const useGetFee = ({ token }: { token: TokenType }) => { useEffect(() => { (async () => { try { + if (![fromNetwork.id, toNetwork.id].includes("Ton")) { + return setTokenFee(0); + } + if (token) { const tokenInTon = TonTokenList( process.env.NEXT_PUBLIC_ENV as Environment @@ -59,10 +75,14 @@ const useGetFee = ({ token }: { token: TokenType }) => { } } })(); - }, [token, oraiAddress, walletsTon]); + }, [token, oraiAddress, walletsTon, fromNetwork.id, toNetwork.id]); useEffect(() => { (async () => { + if (![fromNetwork.id, toNetwork.id].includes("Ton")) { + return setBridgeFee(0); + } + if (token) { const tokenInTon = TonTokenList( process.env.NEXT_PUBLIC_ENV as Environment @@ -92,7 +112,7 @@ const useGetFee = ({ token }: { token: TokenType }) => { ); } })(); - }, [token, oraiAddress, walletsTon]); + }, [token, oraiAddress, walletsTon, fromNetwork.id, toNetwork.id]); return { bridgeFee, diff --git a/components/page/bridge/index.tsx b/components/page/bridge/index.tsx index 00a2458..0b8101a 100644 --- a/components/page/bridge/index.tsx +++ b/components/page/bridge/index.tsx @@ -138,6 +138,8 @@ const Bridge = () => { const { bridgeFee, tokenFee } = useGetFee({ token, + fromNetwork, + toNetwork, }); const { handleUpdateQueryURL } = useFillNetwork({ @@ -920,7 +922,9 @@ const Bridge = () => { denom: token?.symbol, }; - let newIsInsufficientBalance = false; + // FIXME: default when isTonSource is false and isTonDestination is false + // osmosis <-> oraichain + let newIsInsufficientBalance = true; if (isTonSource) { newIsInsufficientBalance = @@ -930,7 +934,9 @@ const Bridge = () => { newValidateAmount.status = numAmount > bridgeFee + 1; newValidateAmount.minAmount = bridgeFee + 1; } - } else if (isTonDestination) { + } + + if (isTonDestination) { newIsInsufficientBalance = numAmount > toDisplay(amountsTon[token?.denom] || "0", token?.decimal); @@ -1231,14 +1237,16 @@ const Bridge = () => { {token?.symbol} - {token && !!!validateAmount.status && ( -
- - More than {validateAmount.minAmount} {validateAmount.denom} is - required to execute this transaction. - -
- )} + {token && + !!!validateAmount.status && + [toNetwork.id, fromNetwork.id].includes("Ton") && ( +
+ + More than {validateAmount.minAmount} {validateAmount.denom}{" "} + is required to execute this transaction. + +
+ )}