diff --git a/.eslintrc.json b/.eslintrc.json index a885bd8..ea99b20 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,3 @@ -{ - "extends": ["next/core-web-vitals", "next/typescript"] -} +// { +// "extends": ["next/core-web-vitals", "next/typescript"] +// } diff --git a/src/app/add-stake/page.tsx b/src/app/add-stake/page.tsx index b509c8c..9604544 100644 --- a/src/app/add-stake/page.tsx +++ b/src/app/add-stake/page.tsx @@ -6,7 +6,7 @@ import { clipDecimals, ETH } from "@/utils"; import { MagicSpend } from "@/utils/magic-spend"; import config from "@/utils/wagmi-config"; import { useEffect, useState } from "react"; -import { Chain, createPublicClient, formatEther, http, parseEther } from "viem"; +import { Chain, formatEther, parseEther } from "viem"; import { useAccount, useBalance, useChainId, useSwitchChain } from "wagmi"; import { useWriteContract } from "wagmi"; @@ -22,8 +22,8 @@ export default function AddStake() { address, }); - const { chains, switchChain } = useSwitchChain() - const chainId = useChainId() + const { switchChain } = useSwitchChain(); + const chainId = useChainId(); const magicSpend = new MagicSpend(config); @@ -32,8 +32,8 @@ export default function AddStake() { }); useEffect(() => { - setIsMounted(true); - }, []); + setIsMounted(true); + }, []); const write = async () => writeContract({ @@ -51,13 +51,13 @@ export default function AddStake() { }; const handleStake = async () => { - try { - setIsLoading(true) - await write() + try { + setIsLoading(true); + await write(); } catch (error) { - console.error('Error staking:', error) + console.error("Error staking:", error); } finally { - setIsLoading(false) + setIsLoading(false); } }; @@ -72,7 +72,6 @@ export default function AddStake() { try { const balances = await magicSpend.getBalances(address); - setChainTokenBalances(balances); } catch (error) { console.error("Error loading balances:", error); @@ -100,26 +99,36 @@ export default function AddStake() { return (
-
-

Total Unstaked Balance

- -
+ {isLoadingBalances ? ( +
+
+
+ ) : ( + <> +
+

Total Unstaked Balance

+ +
-

Available Unstaked Balances

-
- {chainTokenBalances.map((item, index) => ( -
handleBalanceClick(item.chain, item.balance)} - > -
{item.chain}
-
- {clipDecimals(formatEther(item.balance))} {item.token} -
+

Available Unstaked Balances

+
+ {chainTokenBalances.map((item, index) => ( +
handleBalanceClick(item.chain, item.balance)} + > +
{item.chain}
+
+ {clipDecimals(formatEther(item.balance))} {item.token} +
+
+ ))}
- ))} -
+ + )}
@@ -159,7 +168,7 @@ export default function AddStake() { type="number" value={amount} onChange={(e) => { - setAmount(e.target.value) + setAmount(e.target.value); }} placeholder="0.0" className="flex-1 p-2 border rounded" @@ -174,23 +183,23 @@ export default function AddStake() {
{isMounted && chainId === selectedChain.id ? ( - <> - - - {parseFloat(amount) >= 0.1 && ( -
- - You are about to stake more than 0.1 ETH, be careful! - -
- )} - + <> + + + {parseFloat(amount) >= 0.1 && ( +
+ + You are about to stake more than 0.1 ETH, be careful! + +
+ )} + ) : (