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 [inputCount2, setInputCount2] = useState(''); const [toAddress2, setToAddress2] = useState(''); const [msgHash, setMsgHash] = useState(''); const [txhash, setTxhash] = useState(''); const { tonAddress, tonPublicKey } = useTomoUserInfo(); const { sendTonTransaction } = useSendTransaction(); const { queryHash } = useTonTransactions(); const [sendTONLoading, sendTONLoadingFn] = useLoading(); const [tokenContract, setTokenContract] = useState('EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT') const [tokenDecimal, setTokenDecimal] = useState('9') const balanceJetton = useBalance({ chainId: mockTonChainId, token: tokenContract, decimal: tokenDecimal ? Number(tokenDecimal) : undefined }); const handleJettonToken = () => { sendTONLoadingFn(async () => { const memo = `` const res = await sendTonTransaction({ fromAddress: `${tonAddress}`, publicKey: `${tonPublicKey}`, value: parseUnits(inputCount2 || '0', tonDecimals), toAddress: toAddress2, memo: memo, token: { chainId: mockTonChainId, image: 'https://assets.coingecko.com/coins/images/17980/standard/ton_symbol.png', name: 'Toncoin', symbol: 'TON', decimals: 9, address: zeroAddress, }, // mfaType: 'password', // password: '1234', tokenContractAddress: tokenContract, tokenPrecision: tokenDecimal ? Number(tokenDecimal) : undefined }); }); } const handleQueryTransaction = async () => { const txhashRes = await queryHash(`${tonAddress}`, msgHash); setTxhash(txhashRes); }; return (

SendTONTransaction

fromAddress: {tonAddress}

jetton balance: {balanceJetton.data?.formatted}

jetton contract address: {tokenContract}

jetton contract decimal: {tokenDecimal}

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

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

{/* sendTONLoadingFn */}

getTransactionsByInMessageHash

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

tx hash: {txhash}

); }; export default SendTONTransaction;