diff --git a/examples/sample-react-app/src/App.tsx b/examples/sample-react-app/src/App.tsx index 752817e5..fff1ca16 100644 --- a/examples/sample-react-app/src/App.tsx +++ b/examples/sample-react-app/src/App.tsx @@ -1,12 +1,13 @@ import { WalletButton, + useConnex, useWallet, useWalletModal, } from '@vechain/dapp-kit-react'; -import { useEffect, useState } from 'react'; +import { useCallback, useEffect, useState } from 'react'; function App() { - const { account } = useWallet(); + const { account, setSource, connect } = useWallet(); const { open, onConnectionStatusChange } = useWalletModal(); const [buttonText, setButtonText] = useState('Connect Custom Button'); @@ -28,13 +29,84 @@ function App() { onConnectionStatusChange(handleConnected); }, [account, onConnectionStatusChange]); + const { vendor } = useConnex(); + + const sendVetTransaction = useCallback(() => { + if (account) { + const clauses = [ + { + to: account, + value: '1000000000000000000', // 1 vet + }, + ]; + vendor.sign('tx', clauses).signer(account).request(); + } + }, [account, vendor]); + + const sendVthoTransaction = useCallback(() => { + if (account) { + const vthoClauses = [ + { + data: '0xa9059cbb000000000000000000000000d420d35c6a07e58a188d776114267b0b0a2392350000000000000000000000000000000000000000000000000de0b6b3a7640000', + to: account, + value: 0, + }, // 1 vtho + ]; + vendor.sign('tx', vthoClauses).signer(account).request(); + } + }, [account, vendor]); + + const connectWithVeworld = useCallback(() => { + setSource('veworld'); + connect(); + }, [setSource, connect]); + + const connectWithWalletConnect = useCallback(() => { + setSource('wallet-connect'); + connect(); + }, [setSource, connect]); + + const connectWithSync2 = useCallback(() => { + setSource('sync2'); + connect(); + }, [setSource, connect]); + return ( -