import * as React from 'react'; import { useState } from 'react'; import useSendTransaction from '../../src/hooks/useSendTransaction'; import useTomoUserInfo from '../../src/hooks/useTomoUserInfo'; import { parseUnits, zeroAddress } from 'viem'; import { useLoading } from './useLoading'; import { mockTonChainId, tonDecimals } from '../../src/config/ton'; import useBalance from '../../src/hooks/useBalance'; import useTonTransactions from '../../src/hooks/useTonTransactions'; const SendTONTransaction = () => { const [inputCount, setInputCount] = useState(''); const [toAddress, setToAddress] = useState(''); const [msgHash, setMsgHash] = useState(''); const [txhash, setTxhash] = useState(''); const { tonAddress, tonPublicKey } = useTomoUserInfo(); const { sendTonTransaction } = useSendTransaction(); const { queryHash } = useTonTransactions(); const [sendTONLoading, sendTONLoadingFn] = useLoading(); const balance = useBalance({ chainId: mockTonChainId, }); const handleSendTONToken = () => { sendTONLoadingFn(async () => { const res = await sendTonTransaction({ fromAddress: `${tonAddress}`, publicKey: `${tonPublicKey}`, value: parseUnits(inputCount || '0', tonDecimals), toAddress: toAddress, memo: `${Date.now()}`, token: { chainId: mockTonChainId, image: 'https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png', name: 'Toncoin', symbol: 'TON', decimals: 9, address: zeroAddress, }, }); }); }; const handleQueryTransaction = async () => { const txhashRes = await queryHash(`${tonAddress}`, msgHash); setTxhash(txhashRes); }; return (

SendTONTransaction

fromAddress: {tonAddress}

balance: {balance.data?.formatted}

toAddress: setToAddress(e.target.value)} />

value: setInputCount(e.target.value)} />

getTransactionsByInMessageHash

msgHash: setMsgHash(e.target.value)} />

tx hash: {txhash}

); }; export default SendTONTransaction;