diff --git a/web/src/app/[cat]/InteractionClient.tsx b/web/src/app/[cat]/InteractionClient.tsx index 448656a0..f6015012 100644 --- a/web/src/app/[cat]/InteractionClient.tsx +++ b/web/src/app/[cat]/InteractionClient.tsx @@ -1,12 +1,18 @@ "use client"; import React, { useEffect, useState } from "react"; -import { Info } from "lucide-react"; +import { Info, Coins, Settings, ArrowUpRight, ArrowDownRight, Lock, Unlock } from "lucide-react"; import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card"; import { getPublicClient } from "@wagmi/core"; import { config } from "@/utils/config"; import { useSearchParams } from "next/navigation"; import { CONTRIBUTION_ACCOUNTING_TOKEN_ABI } from "@/contractsABI/ContributionAccountingTokenABI"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog"; +import { useAccount, useWriteContract, useWaitForTransactionReceipt } from "wagmi"; +import { parseEther } from "viem"; // Define supported chain IDs type SupportedChainId = 1 | 137 | 534351 | 5115 | 61 | 2001; @@ -22,9 +28,16 @@ interface TokenDetailsState { } export default function InteractionClient() { + const { address } = useAccount(); const searchParams = useSearchParams(); const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); + const [mintAmount, setMintAmount] = useState(""); + const [newMaxSupply, setNewMaxSupply] = useState(""); + const [newThresholdSupply, setNewThresholdSupply] = useState(""); + const [newMaxExpansionRate, setNewMaxExpansionRate] = useState(""); + const [transferAmount, setTransferAmount] = useState(""); + const [transferTo, setTransferTo] = useState(""); const [tokenAddress, setTokenAddress] = useState<`0x${string}`>("0x0"); const [chainId, setChainId] = useState(null); @@ -130,7 +143,38 @@ export default function InteractionClient() { } }, [tokenAddress, chainId]); - // Rest of the component remains the same... + // Contract write hooks + const { writeContract: mint, data: mintData } = useWriteContract(); + + const { writeContract: reduceMaxSupply, data: reduceMaxSupplyData } = useWriteContract(); + + const { writeContract: reduceThresholdSupply, data: reduceThresholdSupplyData } = useWriteContract(); + + const { writeContract: reduceMaxExpansionRate, data: reduceMaxExpansionRateData } = useWriteContract(); + + const { writeContract: disableTransferRestriction, data: disableTransferRestrictionData } = useWriteContract(); + + // Transaction hooks + const { isLoading: isMinting } = useWaitForTransactionReceipt({ + hash: mintData, + }); + + const { isLoading: isReducingMaxSupply } = useWaitForTransactionReceipt({ + hash: reduceMaxSupplyData, + }); + + const { isLoading: isReducingThresholdSupply } = useWaitForTransactionReceipt({ + hash: reduceThresholdSupplyData, + }); + + const { isLoading: isReducingMaxExpansionRate } = useWaitForTransactionReceipt({ + hash: reduceMaxExpansionRateData, + }); + + const { isLoading: isDisablingTransferRestriction } = useWaitForTransactionReceipt({ + hash: disableTransferRestrictionData, + }); + if (isLoading) { return (
@@ -150,73 +194,213 @@ export default function InteractionClient() { } return ( -
- - - -
- - Token Information -
-
-
- -
-
-
-
- Token Name -
-
- {tokenDetails.tokenName} +
+
+ {/* Header Section */} +
+

+ {tokenDetails.tokenSymbol} Token Management +

+
+ + {/* Token Overview Card */} + + + + + Token Overview + + + +
+
+
+ +

Max Supply

+

+ {tokenDetails.maxSupply} +

-
-
- Token Symbol -
-
- {tokenDetails.tokenSymbol} +
+
+ +

Threshold Supply

+

+ {tokenDetails.thresholdSupply} +

-
-
- Max Supply -
-
- {tokenDetails.maxSupply} +
+
+ +

Max Expansion Rate

+

+ {tokenDetails.maxExpansionRate}% +

+
+
+
+
+ +

Contract Address

+
+

+ {tokenDetails.transactionHash} +

+
+ + + + {/* Mint Tokens Card */} + + + + + Mint Tokens + + + +
+
+ + setMintAmount(e.target.value)} + className="h-12 text-lg" + />
+
-
-
-
- Threshold Supply + + + + {/* Admin Functions Card */} + + + + + Admin Functions + + + +
+
+
+ + setNewMaxSupply(e.target.value)} + className="h-12 text-lg" + /> +
-
- {tokenDetails.thresholdSupply} + +
+ + setNewThresholdSupply(e.target.value)} + className="h-12 text-lg" + /> +
-
-
- Max Expansion Rate + +
+
+ + setNewMaxExpansionRate(e.target.value)} + className="h-12 text-lg" + /> +
-
- {tokenDetails.maxExpansionRate}% + +
+ +
-
-
-
- Transaction Hash -
-
- {tokenDetails.transactionHash} -
-
- - + + +
); }