Skip to content

Commit 5f79032

Browse files
authored
chore: sprint 2 fixes (#1230)
chore: fixes
1 parent f53ac4f commit 5f79032

File tree

7 files changed

+42
-98
lines changed

7 files changed

+42
-98
lines changed

frontend/src/app/(routes)/cosmwasm/components/ContractInfo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const ContractInfo = ({ chainID }: { chainID: string }) => {
2626
<div className="pb-4 border-b-[1px] border-[#ffffff1e] font-bold text-[18px]">
2727
{selectedContractInfo.label || selectedContractAddress}
2828
</div>
29-
<div className="flex gap-10 bg-[#FFFFFF0D] p-10 rounded-2xl">
29+
<div className="flex gap-10 bg-[#FFFFFF0D] p-10 rounded-2xl flex-wrap">
3030
<ContractInfoAttribute name="Network" value={chainID} />
3131
<ContractInfoAttribute
3232
name="From Code"

frontend/src/app/(routes)/transfers/components/IBCSwap.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { fromBech32 } from '@cosmjs/encoding';
3030
import { shortenAddress } from '@/utils/util';
3131
import { setError } from '@/store/features/common/commonSlice';
3232
import RoutePreview from './RoutePreview';
33+
import { SWAP_ROUTE_ERROR } from '@/utils/constants';
3334

3435
const emptyBalance = {
3536
amount: 0,
@@ -643,17 +644,27 @@ const IBCSwap = () => {
643644
Fetching route <span className="dots-flashing"></span>{' '}
644645
</div>
645646
) : routeError ? (
646-
<div>{routeError}</div>
647+
<div className="flex justify-between">
648+
<div className='text-red-400'>{routeError}</div>
649+
{routeError === SWAP_ROUTE_ERROR ? (
650+
<div
651+
onClick={fetchSwapRoute}
652+
className="text-[14px] underline font-extralight underline-offset-[3px] cursor-pointer"
653+
>
654+
Retry
655+
</div>
656+
) : null}
657+
</div>
647658
) : (
648659
<div>
649660
{!routeLoading && swapRoute ? (
650661
<div className="flex justify-between">
651662
<div>Route found</div>
652663
<div
653-
className="underline font-light underline-offset-[3px] cursor-pointer"
664+
className="text-[14px] underline font-extralight underline-offset-[3px] cursor-pointer"
654665
onClick={() => setShowRoute((prev) => !prev)}
655666
>
656-
{showRoute ? 'Close' : 'View route'}
667+
{showRoute ? 'Close Preview' : 'View route'}
657668
</div>
658669
</div>
659670
) : (

frontend/src/app/(routes)/transfers/components/MultiTransfer.tsx

+1-12
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@ import useGetChainInfo from '../../../../custom-hooks/useGetChainInfo';
1111
import { multiTxns } from '@/store/features/bank/bankSlice';
1212
import { TxStatus } from '@/types/enums';
1313
import { setError } from '@/store/features/common/commonSlice';
14-
import { TransfersTab } from './TransfersPage';
1514
import NotSupported from '@/components/illustrations/NotSupported';
1615

17-
const MultiTransfer = ({
18-
chainID,
19-
tab,
20-
handleTabChange,
21-
}: {
22-
chainID: string;
23-
tab: TransfersTab;
24-
handleTabChange: () => void;
25-
}) => {
16+
const MultiTransfer = ({ chainID }: { chainID: string }) => {
2617
const [msgs, setMsgs] = useState<Msg[]>([]);
2718
const txPendingStatus = useAppSelector((state) => state.bank.tx.status);
2819
const isAuthzMode = useAppSelector((state) => state.authz.authzModeEnabled);
@@ -98,8 +89,6 @@ const MultiTransfer = ({
9889
<Summary
9990
chainIDs={[chainID]}
10091
borderStyle="rounded-[16px_16px_0px_0px]"
101-
tab={tab}
102-
handleTabChange={handleTabChange}
10392
/>
10493
</div>
10594
{isAuthzMode ? (

frontend/src/app/(routes)/transfers/components/SingleTransfer.tsx

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
import React from 'react';
22
import Summary from './Summary';
33
import SendPage from '../SendPage';
4-
import { TransfersTab } from './TransfersPage';
54

65
const SingleTransfer = ({
76
sortedAssets,
87
chainIDs,
9-
tab,
10-
handleTabChange,
118
}: {
129
sortedAssets: ParsedAsset[];
1310
chainIDs: string[];
14-
tab: TransfersTab;
15-
handleTabChange: () => void;
1611
}) => {
1712
return (
1813
<div className="w-full h-full space-y-6 flex flex-col flex-1">
19-
<Summary
20-
chainIDs={chainIDs}
21-
borderStyle="rounded-[16px_16px_0px_0px]"
22-
tab={tab}
23-
handleTabChange={handleTabChange}
24-
/>
14+
<Summary chainIDs={chainIDs} borderStyle="rounded-[16px_16px_0px_0px]" />
2515
<div className="px-6 pb-6 flex flex-col flex-1">
2616
<SendPage sortedAssets={sortedAssets} />
2717
</div>

frontend/src/app/(routes)/transfers/components/Summary.tsx

-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import Image from 'next/image';
22
import React from 'react';
33
import { useAppSelector } from '@/custom-hooks/StateHooks';
4-
import { TransfersTab } from './TransfersPage';
54

65
const Summary = ({
76
chainIDs,
87
borderStyle,
9-
tab,
10-
handleTabChange,
118
}: {
129
chainIDs: string[];
1310
borderStyle: string;
14-
tab: TransfersTab;
15-
handleTabChange: () => void;
1611
}) => {
1712
const nameToChainIDs = useAppSelector((state) => state.wallet.nameToChainIDs);
1813
let chainName = 'All Networks';
@@ -59,14 +54,6 @@ const Summary = ({
5954
className="object-cover h-full w-full mr-[360px]"
6055
/>
6156
</div>
62-
{chainIDs.length === 1 && (
63-
<button
64-
className="secondary-custom-btn ml-auto"
65-
onClick={handleTabChange}
66-
>
67-
{tab.to}
68-
</button>
69-
)}
7057
</div>
7158
);
7259
};

frontend/src/app/(routes)/transfers/components/TransfersPage.tsx

+23-53
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import React, { useState } from 'react';
22
import MainTopNav from '@/components/MainTopNav';
33
import TransfersHistory from './TransfersHistory';
4-
import { TRANSFERS_TAB2 } from '../../../../utils/constants';
5-
import { TRANSFERS_TAB1 } from '@/utils/constants';
64
import SingleTransfer from './SingleTransfer';
75
import MultiTransfer from './MultiTransfer';
86
import useInitBalances from '@/custom-hooks/useInitBalances';
@@ -25,36 +23,43 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
2523
AuthzSkipIBC: true,
2624
});
2725

28-
const [tab, setTab] = useState<TransfersTab>(TRANSFERS_TAB1);
2926
const isAuthzMode = useAppSelector((state) => state.authz.authzModeEnabled);
3027
const isFeegrantMode = useAppSelector(
3128
(state) => state.feegrant.feegrantModeEnabled
3229
);
3330

34-
const changeTab = (tab: TransfersTab) => {
35-
if (tab === TRANSFERS_TAB1) setTab(TRANSFERS_TAB2);
36-
else setTab(TRANSFERS_TAB1);
37-
};
38-
3931
useInitBalances({ chainIDs });
4032

41-
const handleTabChange = () => {
42-
if (chainIDs.length > 1) {
33+
const tabs = ['Send', 'Multi Send', 'Swap'];
34+
const [selectedTab, setSelectedTab] = useState('Send');
35+
36+
const handleTabchange = (tab: string) => {
37+
if (tab.toLowerCase() === 'multi send' && chainIDs.length > 1) {
4338
dispatch(
4439
setError({
4540
type: 'error',
4641
message: 'Multi transfer is not available for All networks!',
4742
})
4843
);
49-
50-
return;
44+
} else if (isAuthzMode) {
45+
dispatch(
46+
setError({
47+
type: 'error',
48+
message: 'Swap is not suppported in Authz Mode',
49+
})
50+
);
51+
} else if (isFeegrantMode) {
52+
dispatch(
53+
setError({
54+
type: 'error',
55+
message: 'Swap is not suppported in Feegrant Mode',
56+
})
57+
);
58+
} else {
59+
setSelectedTab(tab);
5160
}
52-
changeTab(tab);
5361
};
5462

55-
const tabs = ['Send', 'Multi Send', 'Swap'];
56-
const [selectedTab, setSelectedTab] = useState('Send');
57-
5863
return (
5964
<div className="w-full flex justify-between max-h-screen text-white flex-1">
6065
<AuthzExecLoader chainIDs={chainIDs} />
@@ -71,36 +76,7 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
7176
? 'send-menu-item font-semibold'
7277
: 'send-menu-item font-normal'
7378
}
74-
onClick={() => {
75-
if (
76-
tab.toLowerCase() === 'multi send' &&
77-
chainIDs.length > 1
78-
) {
79-
dispatch(
80-
setError({
81-
type: 'error',
82-
message:
83-
'Multi transfer is not available for All networks!',
84-
})
85-
);
86-
} else if (isAuthzMode) {
87-
dispatch(
88-
setError({
89-
type: 'error',
90-
message: 'Swap is not suppported in Authz Mode',
91-
})
92-
);
93-
} else if (isFeegrantMode) {
94-
dispatch(
95-
setError({
96-
type: 'error',
97-
message: 'Swap is not suppported in Feegrant Mode',
98-
})
99-
);
100-
} else {
101-
setSelectedTab(tab);
102-
}
103-
}}
79+
onClick={() => handleTabchange(tab)}
10480
>
10581
{tab}
10682
</div>
@@ -120,17 +96,11 @@ const TransfersPage = ({ chainIDs }: { chainIDs: string[] }) => {
12096
<SingleTransfer
12197
sortedAssets={isAuthzMode ? authzSortedAssets : sortedAssets}
12298
chainIDs={chainIDs}
123-
tab={tab}
124-
handleTabChange={handleTabChange}
12599
/>
126100
</div>
127101
) : selectedTab === 'Multi Send' ? (
128102
<div className="bg-[#0e0b26] rounded-2xl flex flex-col flex-1">
129-
<MultiTransfer
130-
chainID={chainIDs[0]}
131-
tab={tab}
132-
handleTabChange={handleTabChange}
133-
/>
103+
<MultiTransfer chainID={chainIDs[0]} />
134104
</div>
135105
) : (
136106
<IBCSwap />

frontend/src/custom-hooks/useContracts.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ const useContracts = () => {
106106
/* eslint-disable @typescript-eslint/no-explicit-any */
107107
} catch (error: any) {
108108
const errMsg = error.message;
109-
if (
110-
errMsg?.includes('expected one of') ||
111-
errMsg?.includes('missing field')
112-
) {
109+
if (errMsg?.includes('expected') || errMsg?.includes('missing field')) {
113110
messages = extractContractMessages(error.message);
114111
} else {
115112
messages = [];
@@ -144,7 +141,7 @@ const useContracts = () => {
144141
} catch (error: any) {
145142
const errMsg = error.message;
146143
if (
147-
errMsg?.includes('expected one of') ||
144+
errMsg?.includes('expected') ||
148145
errMsg?.includes('missing field')
149146
) {
150147
messages = extractContractMessages(error.message);

0 commit comments

Comments
 (0)