From 046c15cd8f3c6f3bb06c0f4b3f6e318385dd96c0 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 28 Jun 2024 20:52:17 +0300 Subject: [PATCH] fixes --- components/transfer.tsx | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/components/transfer.tsx b/components/transfer.tsx index 5f0e602..d8c7e5e 100644 --- a/components/transfer.tsx +++ b/components/transfer.tsx @@ -70,8 +70,14 @@ const Transfer = () => { const omnichainSwapContractAddress = "0xb459F14260D1dc6484CE56EB0826be317171e91F" const { isLoading, pendingChainId, switchNetwork } = useSwitchNetwork() - const { balances, bitcoinAddress, setInbounds, inbounds, fees } = - useContext(AppContext) + const { + balances, + balancesLoading, + bitcoinAddress, + setInbounds, + inbounds, + fees, + } = useContext(AppContext) const { chain } = useNetwork() const signer = useEthersSigner() @@ -122,6 +128,7 @@ const Transfer = () => { const toGas = d.coin_type === "Gas" const toERC20 = d.coin_type === "ERC20" const toZRC20 = d.coin_type === "ZRC20" + const fromZRC20 = s.coin_type === "ZRC20" const toBitcoin = d.chain_name === "btc_testnet" const sameToken = s.ticker === d.ticker const sameChain = s.chain_name === d.chain_name @@ -153,7 +160,10 @@ const Transfer = () => { transferNativeEVM: () => sameToken && sameChain && fromGas && toGas && !fromToBitcoin, transferERC20EVM: () => - sameToken && sameChain && fromERC20 && toERC20 && !fromToBitcoin, + sameToken && + sameChain && + ((fromERC20 && toERC20) || (fromZRC20 && toZRC20)) && + !fromToBitcoin, crossChainSwap: () => !fromToZetaChain && !fromToZETAorWZETA && !sameChain && !fromBTC, // crossChainSwapBTC: () => @@ -312,6 +322,7 @@ const Transfer = () => { // Set destination amount useEffect(() => { setDestinationAmount("") + updateError("insufficientLiquidity", { enabled: false }) const fetchQuoteCrossChain = async ( s: any, d: any, @@ -535,7 +546,8 @@ const Transfer = () => { isSending || !isAddressSelectedValid || destinationAmountIsLoading || - !destinationAmount + !destinationAmount || + balancesLoading useEffect(() => { if (isSending) { @@ -1035,7 +1047,7 @@ const Transfer = () => { onChange={(e) => setSourceAmount(e.target.value)} placeholder="0" value={sourceAmount} - disabled={isSending} + disabled={isSending || balancesLoading} type="number" step="any" /> @@ -1044,8 +1056,9 @@ const Transfer = () => {