1- import { useMemo } from 'react' ;
1+ import { useMemo , useState } from 'react' ;
22import { AleoWalletProvider } from '@provablehq/aleo-wallet-adaptor-react' ;
33import { WalletConnectButton } from '@provablehq/aleo-wallet-adaptor-react-ui' ;
44import { PuzzleWalletAdapter } from '@provablehq/aleo-wallet-adaptor-puzzle' ;
@@ -29,53 +29,51 @@ const WalletInfo = () => {
2929} ;
3030
3131// Example transaction component
32- // const ExecuteTransaction = () => {
33- // const { executeTransaction, connected } = useWallet();
34- // const [txId, setTxId] = useState<string | null>(null);
35- // const [loading, setLoading] = useState(false);
32+ const ExecuteTransaction = ( ) => {
33+ const { executeTransaction, connected } = useWallet ( ) ;
34+ const [ txId , setTxId ] = useState < string | null > ( null ) ;
35+ const [ loading , setLoading ] = useState ( false ) ;
3636
37- // const handleExecute = async () => {
38- // if (!connected) return;
37+ const handleExecute = async ( ) => {
38+ if ( ! connected ) return ;
3939
40- // try {
41- // setLoading(true);
40+ try {
41+ setLoading ( true ) ;
4242
43- // // This is just an example - you would need a real program and function to call
44- // const tx = await executeTransaction({
45- // program: 'hello_world.aleo',
46- // function: 'main',
47- // inputs: [],
48- // });
43+ // This is just an example - you would need a real program and function to call
44+ const tx = await executeTransaction ( {
45+ program : 'hello_world.aleo' ,
46+ function : 'main' ,
47+ inputs : [ '1u32' , '1u32' ] ,
48+ fee : 100000 ,
49+ } ) ;
4950
50- // setTxId(tx.id);
51- // } catch (error) {
52- // console.error('Transaction failed', error);
53- // } finally {
54- // setLoading(false);
55- // }
56- // };
51+ setTxId ( tx . id ) ;
52+ } catch ( error ) {
53+ console . error ( 'Transaction failed' , error ) ;
54+ } finally {
55+ setLoading ( false ) ;
56+ }
57+ } ;
5758
58- // if (!connected) {
59- // return null;
60- // }
59+ if ( ! connected ) {
60+ return null ;
61+ }
6162
62- // return (
63- // <div className="transaction">
64- // <button
65- // onClick={handleExecute}
66- // disabled={loading}
67- // >
68- // {loading ? 'Executing...' : 'Execute Transaction'}
69- // </button>
63+ return (
64+ < div className = "transaction" >
65+ < button onClick = { handleExecute } disabled = { loading } >
66+ { loading ? 'Executing...' : 'Execute Transaction' }
67+ </ button >
7068
71- // {txId && (
72- // <div className="tx-result">
73- // <p>Transaction ID: {txId}</p>
74- // </div>
75- // )}
76- // </div>
77- // );
78- // };
69+ { txId && (
70+ < div className = "tx-result" >
71+ < p > Transaction ID: { txId } </ p >
72+ </ div >
73+ ) }
74+ </ div >
75+ ) ;
76+ } ;
7977
8078export function App ( ) {
8179 // memoize to avoid re‑instantiating adapters on each render
@@ -97,13 +95,14 @@ export function App() {
9795 ) ;
9896
9997 return (
100- < AleoWalletProvider wallets = { wallets } autoConnect network = { Network . MAINNET } >
98+ < AleoWalletProvider wallets = { wallets } autoConnect network = { Network . TESTNET3 } >
10199 < header >
102100 < div className = "app" >
103101 < h1 > Aleo Wallet Example</ h1 >
104102 < WalletConnectButton />
105103
106104 < WalletInfo />
105+ < ExecuteTransaction />
107106 </ div >
108107 </ header >
109108 < main > { /* your DApp's components */ } </ main >
0 commit comments