import React, { useState, Dispatch, SetStateAction } from "react"; import { TezosToolkit } from "@taquito/taquito"; const Transfers = ({ Tezos, setUserBalance, userAddress }: { Tezos: TezosToolkit; setUserBalance: Dispatch>; userAddress: string; }): JSX.Element => { const [recipient, setRecipient] = useState(""); const [amount, setAmount] = useState(""); const [loading, setLoading] = useState(false); const sendTransfer = async (): Promise => { if (recipient && amount) { setLoading(true); try { const op = await Tezos.wallet .transfer({ to: recipient, amount: parseInt(amount) }) .send(); await op.confirmation(); setRecipient(""); setAmount(""); const balance = await Tezos.tz.getBalance(userAddress); setUserBalance(balance.toNumber()); } catch (error) { console.log(error); } finally { setLoading(false); } } }; return (
setRecipient(e.target.value)} /> setAmount(e.target.value)} />
); }; export default Transfers;