diff --git a/src/components/Mint.tsx b/src/components/Mint.tsx index ebdeb3c..20d01da 100644 --- a/src/components/Mint.tsx +++ b/src/components/Mint.tsx @@ -11,6 +11,7 @@ export default function () { const [loading, setLoading] = useState(false) const [error, setError] = useState('') const [success, setSuccess] = useState(false) + const [actionSuccess, setActionSuccess] = useState(false) const { isConnected } = useAccount() const signer = useEthersSigner() @@ -36,6 +37,44 @@ export default function () { } } + async function eatSpam() { + setLoading(true) + setActionSuccess(false) + try { + if (!signer) { + throw new Error('No signer') + } + const contract = Spam__factory.connect(env.VITE_CONTRACT, signer) + const tx = await contract.eatSpam() + await tx.wait() + setActionSuccess(true) + } catch (error) { + console.error(error) + setError(error instanceof Error ? error.message : `${error}`) + } finally { + setLoading(false) + } + } + + async function prayToSpamGod() { + setLoading(true) + setActionSuccess(false) + try { + if (!signer) { + throw new Error('No signer') + } + const contract = Spam__factory.connect(env.VITE_CONTRACT, signer) + const tx = await contract.prayToSpamGod() + await tx.wait() + setActionSuccess(true) + } catch (error) { + console.error(error) + setError(error instanceof Error ? error.message : `${error}`) + } finally { + setLoading(false) + } + } + return ( <> )} + + {success && ( )} + {actionSuccess && ( + + )} {error && (