6767#[ cfg( feature = "async" ) ]
6868pub use nonblocking:: ThreadSafeSigner ;
6969pub use {
70- anchor_lang ,
70+ anchor_lang_v2 ,
7171 cluster:: Cluster ,
7272 solana_commitment_config:: CommitmentConfig ,
7373 solana_instruction:: Instruction ,
@@ -81,10 +81,8 @@ pub use {
8181 solana_transaction:: Transaction ,
8282} ;
8383use {
84- anchor_lang:: {
85- solana_program:: { program_error:: ProgramError , pubkey:: Pubkey } ,
86- AccountDeserialize , Discriminator , InstructionData , ToAccountMetas ,
87- } ,
84+ anchor_lang_v2:: { AccountDeserialize , Discriminator , InstructionData , ToAccountMetas } ,
85+ solana_program:: { program_error:: ProgramError , pubkey:: Pubkey } ,
8886 futures:: { Future , StreamExt } ,
8987 regex:: Regex ,
9088 solana_account_decoder:: { UiAccount , UiAccountEncoding } ,
@@ -295,7 +293,7 @@ impl<C: Deref<Target = impl Signer> + Clone> Program<C> {
295293 } )
296294 }
297295
298- async fn on_internal < T : anchor_lang :: Event + anchor_lang :: AnchorDeserialize > (
296+ async fn on_internal < T : anchor_lang_v2 :: Event + anchor_lang_v2 :: AnchorDeserialize > (
299297 & self ,
300298 mut f : impl FnMut ( & EventContext , T ) + Send + ' static ,
301299 ) -> Result <
@@ -370,14 +368,11 @@ impl<T> Iterator for ProgramAccountsIterator<T> {
370368 }
371369}
372370
373- pub fn handle_program_log < T : anchor_lang :: Event + anchor_lang :: AnchorDeserialize > (
371+ pub fn handle_program_log < T : anchor_lang_v2 :: Event + anchor_lang_v2 :: AnchorDeserialize > (
374372 self_program_str : & str ,
375373 l : & str ,
376374) -> Result < ( Option < T > , Option < String > , bool ) , ClientError > {
377- use {
378- anchor_lang:: __private:: base64,
379- base64:: { engine:: general_purpose:: STANDARD , Engine } ,
380- } ;
375+ use base64:: { engine:: general_purpose:: STANDARD , Engine } ;
381376
382377 // Log emitted from the current program.
383378 if let Some ( log) = l
@@ -477,8 +472,6 @@ pub enum ClientError {
477472 #[ error( "Account not found" ) ]
478473 AccountNotFound ,
479474 #[ error( "{0}" ) ]
480- AnchorError ( #[ from] anchor_lang:: error:: Error ) ,
481- #[ error( "{0}" ) ]
482475 ProgramError ( #[ from] ProgramError ) ,
483476 #[ error( "{0}" ) ]
484477 SolanaClientError ( #[ from] Box < SolanaClientError > ) ,
@@ -673,7 +666,7 @@ impl<C: Deref<Target = impl Signer> + Clone, S: AsSigner> RequestBuilder<'_, C,
673666 }
674667}
675668
676- fn parse_logs_response < T : anchor_lang :: Event + anchor_lang :: AnchorDeserialize > (
669+ fn parse_logs_response < T : anchor_lang_v2 :: Event + anchor_lang_v2 :: AnchorDeserialize > (
677670 logs : RpcResponse < RpcLogsResponse > ,
678671 program_id_str : & str ,
679672) -> Result < Vec < T > , ClientError > {
@@ -733,18 +726,29 @@ fn parse_logs_response<T: anchor_lang::Event + anchor_lang::AnchorDeserialize>(
733726
734727#[ cfg( test) ]
735728mod tests {
736- // Creating a mock struct that implements `anchor_lang::events`
737- // for type inference in `test_logs`
729+ // Mock event: minimal manual impl avoiding the `#[event]` macro, which
730+ // depends on the `wincode` derive (anchor-lang-v2 transitively pulls it
731+ // in but the re-exported derive's generated code references the bare
732+ // `wincode` path, not visible from this crate). The test only needs
733+ // `Event + AnchorDeserialize + Discriminator` for type inference inside
734+ // `parse_logs_response::<MockEvent>`.
738735 use {
739- anchor_lang :: prelude :: * ,
736+ anchor_lang_v2 :: { AnchorDeserialize , AnchorSerialize , Discriminator , Event } ,
740737 futures:: { SinkExt , StreamExt } ,
741738 solana_rpc_client_api:: response:: RpcResponseContext ,
742739 std:: sync:: atomic:: { AtomicU64 , Ordering } ,
743740 tokio_tungstenite:: tungstenite:: Message ,
744741 } ;
745- #[ derive( Debug , Clone , Copy ) ]
746- #[ event]
742+ #[ derive( Debug , Clone , Copy , AnchorSerialize , AnchorDeserialize ) ]
747743 pub struct MockEvent { }
744+ impl Discriminator for MockEvent {
745+ const DISCRIMINATOR : & ' static [ u8 ] = & [ 0 ; 8 ] ;
746+ }
747+ impl Event for MockEvent {
748+ fn data ( & self ) -> Vec < u8 > {
749+ Vec :: new ( )
750+ }
751+ }
748752
749753 use super :: * ;
750754 #[ test]
@@ -775,7 +779,7 @@ mod tests {
775779 }
776780
777781 #[ test]
778- fn test_parse_logs_response ( ) -> Result < ( ) > {
782+ fn test_parse_logs_response ( ) -> anyhow :: Result < ( ) > {
779783 // Mock logs received within an `RpcResponse`. These are based on a Jupiter transaction.
780784 let logs = vec ! [
781785 "Program VeryCoolProgram invoke [1]" , // Outer instruction #1 starts
@@ -892,7 +896,7 @@ mod tests {
892896 }
893897
894898 #[ test]
895- fn test_parse_logs_response_fake_pop ( ) -> Result < ( ) > {
899+ fn test_parse_logs_response_fake_pop ( ) -> anyhow :: Result < ( ) > {
896900 let logs = [
897901 "Program fake111111111111111111111111111111111111112 invoke [1]" ,
898902 "Program log: i logged success" ,
0 commit comments