@@ -30,6 +30,7 @@ import {
30
30
DENOM_DISPLAY ,
31
31
DECIMAL ,
32
32
} from './utils/constants' ;
33
+ import { SigningStargateClient } from '@cosmjs/stargate' ;
33
34
34
35
function App ( ) {
35
36
const [ address , setAddress ] = useState ( '' ) ;
@@ -43,6 +44,9 @@ function App() {
43
44
reset,
44
45
} = useForm < TransferFormData > ( {
45
46
resolver : zodResolver ( transferFormSchema ) ,
47
+ defaultValues : {
48
+ amount : "0.000001" ,
49
+ } ,
46
50
} ) ;
47
51
48
52
const { data : balance , refetch : refetchBalance } = useQuery ( {
@@ -59,16 +63,16 @@ function App() {
59
63
const data = await response . json ( ) ;
60
64
// Log the response to see what we're getting
61
65
console . log ( 'Balance response:' , data ) ;
62
-
66
+
63
67
if ( ! data . balances ) {
64
68
return 0 ;
65
69
}
66
-
70
+
67
71
const atomBalance = data . balances . find ( ( b : any ) => b . denom === DENOM ) ;
68
72
if ( ! atomBalance ) {
69
73
return 0 ;
70
74
}
71
-
75
+
72
76
return Number ( atomBalance . amount ) / Math . pow ( 10 , DECIMAL ) ;
73
77
} catch ( error ) {
74
78
console . error ( 'Error fetching balance:' , error ) ;
@@ -101,8 +105,13 @@ function App() {
101
105
} ,
102
106
} ;
103
107
104
- const signer = await window . keplr . getOfflineSigner ( CHAIN_ID ) ;
105
- const response = await signer . signAndBroadcast ( msg ) ;
108
+ const offlineSigner = window . keplr . getOfflineSigner ( CHAIN_ID ) ;
109
+ const client = await SigningStargateClient . connectWithSigner ( RPC_ENDPOINT , offlineSigner ) ;
110
+ const fee = {
111
+ amount : [ { denom : DENOM , amount : "5000" } ] , // adjust fee amount as needed
112
+ gas : "200000" // adjust gas limit as needed
113
+ } ;
114
+ const response = await client . signAndBroadcast ( address , [ msg ] , fee ) ;
106
115
return response . transactionHash ;
107
116
} ,
108
117
onSuccess : ( txHash ) => {
@@ -197,7 +206,7 @@ function App() {
197
206
< CardBody >
198
207
< VStack spacing = { 4 } align = "stretch" >
199
208
< Heading size = "md" > Cosmos Wallet</ Heading >
200
-
209
+
201
210
{ ! address ? (
202
211
< Button onClick = { connectWallet } > Connect Keplr</ Button >
203
212
) : (
@@ -214,7 +223,7 @@ function App() {
214
223
onClick = { handleRefreshBalance }
215
224
/>
216
225
</ HStack >
217
-
226
+
218
227
< form onSubmit = { handleSubmit ( onSubmit ) } >
219
228
< VStack spacing = { 4 } >
220
229
< FormControl isInvalid = { ! ! errors . recipient } >
0 commit comments