Skip to content

Commit 2d9a048

Browse files
committed
fix no account form loading state
1 parent fb0b786 commit 2d9a048

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

frontend/src/features/swap/components/ft-allowance-tip/ft-allowance-tip.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@ type Props = {
1313
symbol: string | undefined;
1414
amount: string;
1515
isVaraNetwork: boolean;
16+
isLoading: boolean;
1617
};
1718

18-
function FTAllowanceTip({ allowance, decimals, symbol, amount, isVaraNetwork }: Props) {
19-
const isLoading = isUndefined(allowance) || !decimals || !symbol;
20-
if (isLoading) return <Skeleton width="14px" height="14px" borderRadius="50%" className={styles.skeleton} />;
19+
function FTAllowanceTip({ allowance, decimals, symbol, amount, isVaraNetwork, isLoading }: Props) {
20+
const isEmpty = isUndefined(allowance) || !decimals || !symbol;
21+
22+
if (isLoading || isEmpty)
23+
return (
24+
<Skeleton
25+
width="14px"
26+
height="14px"
27+
borderRadius="50%"
28+
className={styles.skeleton}
29+
disabled={!isLoading && isEmpty}
30+
/>
31+
);
2132

2233
const formattedAllowance = formatUnits(allowance, decimals);
2334
const contractName = isVaraNetwork ? 'VFT' : 'ERC20';

frontend/src/features/swap/components/swap-form/swap-form.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ function SwapForm({
131131
symbol={symbol}
132132
amount={amount}
133133
isVaraNetwork={isVaraNetwork}
134+
isLoading={bridge.isLoading || allowance.isLoading}
134135
/>
135136
</div>
136137
</footer>

frontend/src/features/swap/hooks/eth/use-eth-ft-balance.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function useEthFTBalance(address: HexString | undefined, decimals: number | unde
1515
const ethAccount = useEthAccount();
1616

1717
// TODO: logger
18-
const { data, isPending } = useReadContract({
18+
const { data, isLoading } = useReadContract({
1919
address,
2020
abi,
2121
functionName: FUNCTION_NAME.FUNGIBLE_TOKEN_BALANCE,
@@ -29,7 +29,6 @@ function useEthFTBalance(address: HexString | undefined, decimals: number | unde
2929

3030
const value = data;
3131
const formattedValue = !isUndefined(value) && !isUndefined(decimals) ? formatUnits(value, decimals) : undefined;
32-
const isLoading = ethAccount.isConnected && isPending;
3332

3433
return { value, formattedValue, decimals, isLoading };
3534
}

frontend/src/features/swap/hooks/vara/use-vara-ft-balance.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function useVaraFTBalance(address: HexString | undefined, decimals: number | und
1515
id: address,
1616
});
1717

18-
const { data, isPending } = useProgramQuery({
18+
const { data, isLoading } = useProgramQuery({
1919
program,
2020
serviceName: SERVICE_NAME.VFT,
2121
functionName: QUERY_NAME.BALANCE,
@@ -25,7 +25,6 @@ function useVaraFTBalance(address: HexString | undefined, decimals: number | und
2525

2626
const value = data;
2727
const formattedValue = !isUndefined(value) && !isUndefined(decimals) ? formatUnits(value, decimals) : undefined;
28-
const isLoading = isPending;
2928

3029
return { value, formattedValue, decimals, isLoading };
3130
}

0 commit comments

Comments
 (0)