import { useState } from "react" import { useProposeTransaction, useSafeBalances } from "../../hooks/useSafeTransaction" import { useWalletConnection } from "../../hooks/useWallet" export function TransactionComposer() { const { address, isConnected } = useWalletConnection() const { data: balances } = useSafeBalances() const { propose, isLoading, error } = useProposeTransaction() const [recipient, setRecipient] = useState("") const [amount, setAmount] = useState("") const [tokenAddress, setTokenAddress] = useState("") const [title, setTitle] = useState("") const [signerKey, setSignerKey] = useState("") const [result, setResult] = useState(null) const handleSubmit = async () => { if (!recipient || !amount || !signerKey) return const res = await propose({ recipientAddress: recipient, amount, tokenAddress: tokenAddress || undefined, title: title || undefined, signerPrivateKey: signerKey, }) if (res) { setResult(`Proposed: ${res.safeTxHash.slice(0, 16)}...`) setRecipient("") setAmount("") setTitle("") } } const inputStyle: React.CSSProperties = { width: "100%", padding: "8px 10px", border: "1px solid #334155", borderRadius: 6, background: "#1e293b", color: "#e2e8f0", fontSize: 12, fontFamily: "monospace", outline: "none", boxSizing: "border-box", } const labelStyle: React.CSSProperties = { fontSize: 11, fontWeight: 600, color: "#94a3b8", marginBottom: 4, display: "block", } return (
{/* Title */}
setTitle(e.target.value)} />
{/* Recipient */}
setRecipient(e.target.value)} />
{/* Token (optional) */}
{/* Amount */}
setAmount(e.target.value)} type="text" />
{/* Signer Key */}
setSignerKey(e.target.value)} /> Must be a Safe owner. Key is sent to treasury-service for signing.
{/* Submit */} {/* Result / Error */} {result && (
{result}
)} {error && (
{error}
)}
) }