From 5f79032361f9435b90d405d7fba7431cb5b55e8c Mon Sep 17 00:00:00 2001 From: Hemanth Sai Date: Tue, 7 May 2024 14:53:36 +0530 Subject: [PATCH] chore: sprint 2 fixes (#1230) chore: fixes --- .../cosmwasm/components/ContractInfo.tsx | 2 +- .../(routes)/transfers/components/IBCSwap.tsx | 17 ++++- .../transfers/components/MultiTransfer.tsx | 13 +--- .../transfers/components/SingleTransfer.tsx | 12 +-- .../(routes)/transfers/components/Summary.tsx | 13 ---- .../transfers/components/TransfersPage.tsx | 76 ++++++------------- frontend/src/custom-hooks/useContracts.ts | 7 +- 7 files changed, 42 insertions(+), 98 deletions(-) diff --git a/frontend/src/app/(routes)/cosmwasm/components/ContractInfo.tsx b/frontend/src/app/(routes)/cosmwasm/components/ContractInfo.tsx index a30449a51..77700a037 100644 --- a/frontend/src/app/(routes)/cosmwasm/components/ContractInfo.tsx +++ b/frontend/src/app/(routes)/cosmwasm/components/ContractInfo.tsx @@ -26,7 +26,7 @@ const ContractInfo = ({ chainID }: { chainID: string }) => {
{selectedContractInfo.label || selectedContractAddress}
-
+
{ Fetching route {' '}
) : routeError ? ( -
{routeError}
+
+
{routeError}
+ {routeError === SWAP_ROUTE_ERROR ? ( +
+ Retry +
+ ) : null} +
) : (
{!routeLoading && swapRoute ? (
Route found
setShowRoute((prev) => !prev)} > - {showRoute ? 'Close' : 'View route'} + {showRoute ? 'Close Preview' : 'View route'}
) : ( diff --git a/frontend/src/app/(routes)/transfers/components/MultiTransfer.tsx b/frontend/src/app/(routes)/transfers/components/MultiTransfer.tsx index b1f8bb38f..16db0e376 100644 --- a/frontend/src/app/(routes)/transfers/components/MultiTransfer.tsx +++ b/frontend/src/app/(routes)/transfers/components/MultiTransfer.tsx @@ -11,18 +11,9 @@ import useGetChainInfo from '../../../../custom-hooks/useGetChainInfo'; import { multiTxns } from '@/store/features/bank/bankSlice'; import { TxStatus } from '@/types/enums'; import { setError } from '@/store/features/common/commonSlice'; -import { TransfersTab } from './TransfersPage'; import NotSupported from '@/components/illustrations/NotSupported'; -const MultiTransfer = ({ - chainID, - tab, - handleTabChange, -}: { - chainID: string; - tab: TransfersTab; - handleTabChange: () => void; -}) => { +const MultiTransfer = ({ chainID }: { chainID: string }) => { const [msgs, setMsgs] = useState([]); const txPendingStatus = useAppSelector((state) => state.bank.tx.status); const isAuthzMode = useAppSelector((state) => state.authz.authzModeEnabled); @@ -98,8 +89,6 @@ const MultiTransfer = ({
{isAuthzMode ? ( diff --git a/frontend/src/app/(routes)/transfers/components/SingleTransfer.tsx b/frontend/src/app/(routes)/transfers/components/SingleTransfer.tsx index 8ea32df93..4b93447be 100644 --- a/frontend/src/app/(routes)/transfers/components/SingleTransfer.tsx +++ b/frontend/src/app/(routes)/transfers/components/SingleTransfer.tsx @@ -1,27 +1,17 @@ import React from 'react'; import Summary from './Summary'; import SendPage from '../SendPage'; -import { TransfersTab } from './TransfersPage'; const SingleTransfer = ({ sortedAssets, chainIDs, - tab, - handleTabChange, }: { sortedAssets: ParsedAsset[]; chainIDs: string[]; - tab: TransfersTab; - handleTabChange: () => void; }) => { return (
- +
diff --git a/frontend/src/app/(routes)/transfers/components/Summary.tsx b/frontend/src/app/(routes)/transfers/components/Summary.tsx index 4b81becb2..b8a6d7ad7 100644 --- a/frontend/src/app/(routes)/transfers/components/Summary.tsx +++ b/frontend/src/app/(routes)/transfers/components/Summary.tsx @@ -1,18 +1,13 @@ import Image from 'next/image'; import React from 'react'; import { useAppSelector } from '@/custom-hooks/StateHooks'; -import { TransfersTab } from './TransfersPage'; const Summary = ({ chainIDs, borderStyle, - tab, - handleTabChange, }: { chainIDs: string[]; borderStyle: string; - tab: TransfersTab; - handleTabChange: () => void; }) => { const nameToChainIDs = useAppSelector((state) => state.wallet.nameToChainIDs); let chainName = 'All Networks'; @@ -59,14 +54,6 @@ const Summary = ({ className="object-cover h-full w-full mr-[360px]" />
- {chainIDs.length === 1 && ( - - )}
); }; diff --git a/frontend/src/app/(routes)/transfers/components/TransfersPage.tsx b/frontend/src/app/(routes)/transfers/components/TransfersPage.tsx index ed81abf77..48104e397 100644 --- a/frontend/src/app/(routes)/transfers/components/TransfersPage.tsx +++ b/frontend/src/app/(routes)/transfers/components/TransfersPage.tsx @@ -1,8 +1,6 @@ import React, { useState } from 'react'; import MainTopNav from '@/components/MainTopNav'; import TransfersHistory from './TransfersHistory'; -import { TRANSFERS_TAB2 } from '../../../../utils/constants'; -import { TRANSFERS_TAB1 } from '@/utils/constants'; import SingleTransfer from './SingleTransfer'; import MultiTransfer from './MultiTransfer'; import useInitBalances from '@/custom-hooks/useInitBalances'; @@ -25,36 +23,43 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => { AuthzSkipIBC: true, }); - const [tab, setTab] = useState(TRANSFERS_TAB1); const isAuthzMode = useAppSelector((state) => state.authz.authzModeEnabled); const isFeegrantMode = useAppSelector( (state) => state.feegrant.feegrantModeEnabled ); - const changeTab = (tab: TransfersTab) => { - if (tab === TRANSFERS_TAB1) setTab(TRANSFERS_TAB2); - else setTab(TRANSFERS_TAB1); - }; - useInitBalances({ chainIDs }); - const handleTabChange = () => { - if (chainIDs.length > 1) { + const tabs = ['Send', 'Multi Send', 'Swap']; + const [selectedTab, setSelectedTab] = useState('Send'); + + const handleTabchange = (tab: string) => { + if (tab.toLowerCase() === 'multi send' && chainIDs.length > 1) { dispatch( setError({ type: 'error', message: 'Multi transfer is not available for All networks!', }) ); - - return; + } else if (isAuthzMode) { + dispatch( + setError({ + type: 'error', + message: 'Swap is not suppported in Authz Mode', + }) + ); + } else if (isFeegrantMode) { + dispatch( + setError({ + type: 'error', + message: 'Swap is not suppported in Feegrant Mode', + }) + ); + } else { + setSelectedTab(tab); } - changeTab(tab); }; - const tabs = ['Send', 'Multi Send', 'Swap']; - const [selectedTab, setSelectedTab] = useState('Send'); - return (
@@ -71,36 +76,7 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => { ? 'send-menu-item font-semibold' : 'send-menu-item font-normal' } - onClick={() => { - if ( - tab.toLowerCase() === 'multi send' && - chainIDs.length > 1 - ) { - dispatch( - setError({ - type: 'error', - message: - 'Multi transfer is not available for All networks!', - }) - ); - } else if (isAuthzMode) { - dispatch( - setError({ - type: 'error', - message: 'Swap is not suppported in Authz Mode', - }) - ); - } else if (isFeegrantMode) { - dispatch( - setError({ - type: 'error', - message: 'Swap is not suppported in Feegrant Mode', - }) - ); - } else { - setSelectedTab(tab); - } - }} + onClick={() => handleTabchange(tab)} > {tab}
@@ -120,17 +96,11 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => { ) : selectedTab === 'Multi Send' ? (
- +
) : ( diff --git a/frontend/src/custom-hooks/useContracts.ts b/frontend/src/custom-hooks/useContracts.ts index 397c38cda..eb6f36382 100644 --- a/frontend/src/custom-hooks/useContracts.ts +++ b/frontend/src/custom-hooks/useContracts.ts @@ -106,10 +106,7 @@ const useContracts = () => { /* eslint-disable @typescript-eslint/no-explicit-any */ } catch (error: any) { const errMsg = error.message; - if ( - errMsg?.includes('expected one of') || - errMsg?.includes('missing field') - ) { + if (errMsg?.includes('expected') || errMsg?.includes('missing field')) { messages = extractContractMessages(error.message); } else { messages = []; @@ -144,7 +141,7 @@ const useContracts = () => { } catch (error: any) { const errMsg = error.message; if ( - errMsg?.includes('expected one of') || + errMsg?.includes('expected') || errMsg?.includes('missing field') ) { messages = extractContractMessages(error.message);