@@ -39,7 +39,7 @@ export default function CryptoWidgetPaymentButton({
39
39
const solanaBatAddress = cryptoConstants . solana_bat_address ;
40
40
const solanaMainUrls = cryptoConstants . solana_main_urls ;
41
41
const rpcHost = solanaMainUrls . filter ( ( url ) =>
42
- url . toLowerCase ( ) . includes ( window . location . host . toLowerCase ( ) ) ,
42
+ url . toLowerCase ( ) . includes ( window . location . origin . toLowerCase ( ) ) ,
43
43
) [ 0 ] ;
44
44
const ethUsdcAddress = cryptoConstants . eth_usdc_address ;
45
45
const solUsdcAddress = cryptoConstants . solana_usdc_address ;
@@ -191,31 +191,36 @@ 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
-
209
194
try {
210
- const result =
211
- await window . solana . signAndSendTransaction ( transaction ) ;
212
- if ( result . signature ) {
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 ( ) ;
213
220
window . solana . disconnect ( ) ;
214
- setIsSuccessView ( true ) ;
215
221
}
216
222
} catch ( e ) {
217
- setGenericError ( ) ;
218
- window . solana . disconnect ( ) ;
223
+ console . log ( e )
219
224
}
220
225
} else {
221
226
setGenericError ( ) ;
@@ -241,6 +246,7 @@ export default function CryptoWidgetPaymentButton({
241
246
// this is the account address that will receive bat
242
247
const destinationAccountOwner = new PublicKey ( addresses . SOL ) ;
243
248
const connection = new Connection ( `${ rpcHost } /rpc` ) ;
249
+ console . log ( connection )
244
250
const contract = new PublicKey ( contractAddress ) ;
245
251
// Check to see if the sender has an associated token account
246
252
const senderAccount = await connection . getParsedTokenAccountsByOwner (
@@ -313,6 +319,7 @@ export default function CryptoWidgetPaymentButton({
313
319
return ;
314
320
}
315
321
} catch ( e ) {
322
+ console . log ( e )
316
323
setGenericError ( ) ;
317
324
window . solana . disconnect ( ) ;
318
325
}
0 commit comments