@@ -305,10 +305,15 @@ impl SolanaBridgeClient {
305305 let ( authority, _) = Pubkey :: find_program_address ( & [ b"authority" ] , program_id) ;
306306 let ( sol_vault, _) = Pubkey :: find_program_address ( & [ b"sol_vault" ] , program_id) ;
307307
308+ let token_program_id = self . get_mint_owner ( token) . await ?;
309+ if token_program_id != spl_token:: ID && token_program_id != spl_token_2022:: ID {
310+ return Err ( SolanaBridgeClientError :: InvalidArgument ( format ! ( "Not a Solana token: {token}" ) ) ) ;
311+ }
312+
308313 let ( from_token_account, _) = Pubkey :: find_program_address (
309314 & [
310315 keypair. pubkey ( ) . as_ref ( ) ,
311- spl_token :: ID . as_ref ( ) ,
316+ token_program_id . as_ref ( ) ,
312317 token. as_ref ( ) ,
313318 ] ,
314319 & spl_associated_token_account:: ID ,
@@ -358,7 +363,7 @@ impl SolanaBridgeClient {
358363 AccountMeta :: new_readonly( sysvar:: rent:: ID , false ) ,
359364 AccountMeta :: new_readonly( * wormhole_core, false ) ,
360365 AccountMeta :: new_readonly( system_program:: ID , false ) ,
361- AccountMeta :: new_readonly( spl_token :: ID , false ) ,
366+ AccountMeta :: new_readonly( token_program_id , false ) ,
362367 ] ,
363368 ) ;
364369
@@ -441,10 +446,16 @@ impl SolanaBridgeClient {
441446 ) ;
442447 let recipient = data. payload . recipient ;
443448 let ( authority, _) = Pubkey :: find_program_address ( & [ b"authority" ] , program_id) ;
449+
450+ let token_program_id = self . get_mint_owner ( solana_token) . await ?;
451+ if token_program_id != spl_token:: ID && token_program_id != spl_token_2022:: ID {
452+ return Err ( SolanaBridgeClientError :: InvalidArgument ( format ! ( "Not a Solana token: {solana_token}" ) ) ) ;
453+ }
454+
444455 let ( token_account, _) = Pubkey :: find_program_address (
445456 & [
446457 recipient. as_ref ( ) ,
447- spl_token :: ID . as_ref ( ) ,
458+ token_program_id . as_ref ( ) ,
448459 solana_token. as_ref ( ) ,
449460 ] ,
450461 & spl_associated_token_account:: ID ,
@@ -499,7 +510,7 @@ impl SolanaBridgeClient {
499510 AccountMeta :: new_readonly( system_program:: ID , false ) ,
500511 AccountMeta :: new_readonly( spl_associated_token_account:: ID , false ) ,
501512 AccountMeta :: new_readonly( system_program:: ID , false ) ,
502- AccountMeta :: new_readonly( spl_token :: ID , false ) ,
513+ AccountMeta :: new_readonly( token_program_id , false ) ,
503514 ] ,
504515 ) ;
505516
@@ -609,11 +620,11 @@ impl SolanaBridgeClient {
609620 & self ,
610621 token : Pubkey ,
611622 ) -> Result < COption < Pubkey > , SolanaBridgeClientError > {
623+ const MINT_BASIC_DATA_SIZE : usize = 82 ;
624+
612625 let client = self . client ( ) ?;
613626
614627 let mint_account = client. get_account ( & token) . await ?;
615-
616- const MINT_BASIC_DATA_SIZE : usize = 82 ;
617628 let mint_data = Mint :: unpack ( & mint_account. data [ ..MINT_BASIC_DATA_SIZE ] )
618629 . map_err ( |e| SolanaBridgeClientError :: InvalidAccountData ( e. to_string ( ) ) ) ?;
619630
0 commit comments