import * as React from 'react'; import { useState } from 'react'; import useSendTransaction from '../../src/hooks/useSendTransaction'; import { useBalance, useConfig } from 'wagmi'; import { mainnet } from 'viem/chains'; import useTomoUserInfo from '../../src/hooks/useTomoUserInfo'; import { parseUnits, zeroAddress } from 'viem'; import { useLoading } from './useLoading'; const SendEVMTransaction = () => { const [inputCount, setInputCount] = useState(); const [toAddress, setToAddress] = useState(); const config = useConfig(); const { evmAddress } = useTomoUserInfo(); const { sendEVMTransaction } = useSendTransaction(); const [sendEVMBiometryLoading, sendEVMLoadingBiometryFn] = useLoading(); const [sendEVMPasswordLoading, sendEVMLoadingPasswordFn] = useLoading(); // const balance = useBalance({ // chainId: sepolia.id, // }); const handleSendEVMBiometry = () => { sendEVMLoadingBiometryFn(async () => { const res = await sendEVMTransaction({ chainId: mainnet.id, fromAddress: evmAddress, toAddress: toAddress, value: parseUnits(inputCount || '0', 18), // rpc: sepolia.rpcUrls.default.http[0], config, tokenValue: parseUnits(inputCount || '0', 18), token: { chainId: mainnet.id, image: 'https://etherscan.io/images/main/empty-token.png', name: 'Ether', symbol: 'ETH', decimals: mainnet.nativeCurrency.decimals, address: zeroAddress, }, }); }); }; const handleSendEVMPassword = () => { const password = prompt('Please enter your password'); if (!password) return; sendEVMLoadingPasswordFn(async () => { const res = await sendEVMTransaction({ chainId: mainnet.id, fromAddress: evmAddress, toAddress: toAddress, value: parseUnits(inputCount || '0', 18), // rpc: sepolia.rpcUrls.default.http[0], config, tokenValue: parseUnits(inputCount || '0', 18), token: { chainId: mainnet.id, image: 'https://etherscan.io/images/main/empty-token.png', name: 'Ether', symbol: 'ETH', decimals: mainnet.nativeCurrency.decimals, address: zeroAddress, }, mfaType: 'password', password: password, }); }); }; return (

SendEVMTransaction

fromAddress: {evmAddress}

{/*

balance: {balance.data?.formatted}

*/}

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

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

); }; export default SendEVMTransaction;