@@ -191,36 +191,31 @@ export default function CryptoWidgetPaymentButton({
191
191
} else {
192
192
const provider = await window . solana . connect ( ) ;
193
193
if ( provider . publicKey ) {
194
+ const pub_key = provider . publicKey ;
195
+ const connection = new Connection ( `${ rpcHost } /rpc` ) ;
196
+ const amount = Math . round ( currentAmount * LAMPORTS_PER_SOL ) ;
197
+
198
+ const transaction = new Transaction ( ) . add (
199
+ SystemProgram . transfer ( {
200
+ fromPubkey : pub_key ,
201
+ toPubkey : addresses . SOL ,
202
+ lamports : amount ,
203
+ } ) ,
204
+ ) ;
205
+ transaction . feePayer = pub_key ;
206
+ const blockhashObj = await connection . getLatestBlockhash ( "confirmed" ) ;
207
+ transaction . recentBlockhash = await blockhashObj . blockhash ;
208
+
194
209
try {
195
- const pub_key = provider . publicKey ;
196
- const connection = new Connection ( `${ rpcHost } /rpc` ) ;
197
- console . log ( connection )
198
- const amount = Math . round ( currentAmount * LAMPORTS_PER_SOL ) ;
199
-
200
- const transaction = new Transaction ( ) . add (
201
- SystemProgram . transfer ( {
202
- fromPubkey : pub_key ,
203
- toPubkey : addresses . SOL ,
204
- lamports : amount ,
205
- } ) ,
206
- ) ;
207
- transaction . feePayer = pub_key ;
208
- const blockhashObj = await connection . getLatestBlockhash ( "confirmed" ) ;
209
- transaction . recentBlockhash = await blockhashObj . blockhash ;
210
-
211
- try {
212
- const result =
213
- await window . solana . signAndSendTransaction ( transaction ) ;
214
- if ( result . signature ) {
215
- window . solana . disconnect ( ) ;
216
- setIsSuccessView ( true ) ;
217
- }
218
- } catch ( e ) {
219
- setGenericError ( ) ;
210
+ const result =
211
+ await window . solana . signAndSendTransaction ( transaction ) ;
212
+ if ( result . signature ) {
220
213
window . solana . disconnect ( ) ;
214
+ setIsSuccessView ( true ) ;
221
215
}
222
216
} catch ( e ) {
223
- console . log ( e )
217
+ setGenericError ( ) ;
218
+ window . solana . disconnect ( ) ;
224
219
}
225
220
} else {
226
221
setGenericError ( ) ;
@@ -246,7 +241,6 @@ export default function CryptoWidgetPaymentButton({
246
241
// this is the account address that will receive bat
247
242
const destinationAccountOwner = new PublicKey ( addresses . SOL ) ;
248
243
const connection = new Connection ( `${ rpcHost } /rpc` ) ;
249
- console . log ( connection )
250
244
const contract = new PublicKey ( contractAddress ) ;
251
245
// Check to see if the sender has an associated token account
252
246
const senderAccount = await connection . getParsedTokenAccountsByOwner (
@@ -319,7 +313,6 @@ export default function CryptoWidgetPaymentButton({
319
313
return ;
320
314
}
321
315
} catch ( e ) {
322
- console . log ( e )
323
316
setGenericError ( ) ;
324
317
window . solana . disconnect ( ) ;
325
318
}
0 commit comments