Răsfoiți Sursa

lang: export accounts module, re-export its types in the prelude (#1208)

Paul 3 ani în urmă
părinte
comite
a830644203

+ 2 - 0
CHANGELOG.md

@@ -35,6 +35,8 @@ incremented for features.
 * client: Client::new and Client::new_with_options now accept `Rc<dyn Signer>` instead of `Keypair` ([#975](https://github.com/project-serum/anchor/pull/975)).
 * lang, ts: Change error enum name and message for 'wrong program ownership' account validation ([#1154](https://github.com/project-serum/anchor/pull/1154)).
 * lang: Change from `#[repr(packed)]` to `#[repr(C)]` for zero copy accounts ([#1106](https://github.com/project-serum/anchor/pull/1106)).
+* lang: Account types can now be found either in the `prelude` module or the `accounts` module but not longer directly under the root.
+Deprecated account types are no longer imported by the prelude ([#1208](https://github.com/project-serum/anchor/pull/1208)).
 
 ## [0.19.0] - 2021-12-08
 

+ 1 - 1
lang/attribute/access-control/src/lib.rs

@@ -26,7 +26,7 @@ use syn::parse_macro_input;
 /// #[derive(Accounts)]
 /// pub struct Create {
 ///   #[account(init)]
-///   my_account: ProgramAccount<'info, MyAccount>,
+///   my_account: Account<'info, MyAccount>,
 /// }
 ///
 /// impl Create {

+ 1 - 1
lang/attribute/interface/src/lib.rs

@@ -198,7 +198,7 @@ pub fn interface(
                 format!("{:?}", sighash_arr).parse().unwrap();
             quote! {
                 pub fn #method_name<'a,'b, 'c, 'info, T: anchor_lang::Accounts<'info> + anchor_lang::ToAccountMetas + anchor_lang::ToAccountInfos<'info>>(
-                    ctx: anchor_lang::CpiContext<'a, 'b, 'c, 'info, T>,
+                    ctx: anchor_lang::context::CpiContext<'a, 'b, 'c, 'info, T>,
                     #(#args),*
                 ) -> anchor_lang::solana_program::entrypoint::ProgramResult {
                     #args_struct

+ 3 - 1
lang/src/accounts/account.rs

@@ -26,7 +26,7 @@ use std::ops::{Deref, DerefMut};
 /// - `Account.info.owner == T::owner()`
 /// - `!(Account.info.owner == SystemProgram && Account.info.lamports() == 0)`
 ///
-/// Example
+/// # Example
 /// ```ignore
 /// use anchor_lang::prelude::*;
 /// use other_program::Auth;
@@ -69,6 +69,8 @@ use std::ops::{Deref, DerefMut};
 /// ...
 /// ```
 ///
+/// # Using Account with non-anchor programs
+///
 /// Account can also be used with non-anchor programs. The data types from
 /// those programs are not annotated with `#[account]` so you have to
 /// - create a wrapper type around the structs you want to wrap with Account

+ 1 - 1
lang/src/accounts/cpi_state.rs

@@ -1,6 +1,6 @@
 use crate::error::ErrorCode;
 #[allow(deprecated)]
-use crate::{accounts::state::ProgramState, CpiStateContext};
+use crate::{accounts::state::ProgramState, context::CpiStateContext};
 use crate::{
     AccountDeserialize, AccountSerialize, Accounts, AccountsExit, Key, ToAccountInfo,
     ToAccountInfos, ToAccountMetas,

+ 1 - 1
lang/src/accounts/loader.rs

@@ -17,7 +17,7 @@ use std::ops::DerefMut;
 
 /// Account loader facilitating on demand zero copy deserialization.
 /// Note that using accounts in this way is distinctly different from using,
-/// for example, the [`ProgramAccount`](./struct.ProgramAccount.html). Namely,
+/// for example, the [`Account`](./struct.Account.html). Namely,
 /// one must call `load`, `load_mut`, or `load_init`, before reading or writing
 /// to the account. For more details on zero-copy-deserialization, see the
 /// [`account`](./attr.account.html) attribute.

+ 1 - 1
lang/src/accounts/loader_account.rs

@@ -17,7 +17,7 @@ use std::ops::DerefMut;
 
 /// Account AccountLoader facilitating on demand zero copy deserialization.
 /// Note that using accounts in this way is distinctly different from using,
-/// for example, the [`ProgramAccount`](./struct.ProgramAccount.html). Namely,
+/// for example, the [`Account`](./struct.Account.html). Namely,
 /// one must call `load`, `load_mut`, or `load_init`, before reading or writing
 /// to the account. For more details on zero-copy-deserialization, see the
 /// [`account`](./attr.account.html) attribute.

+ 2 - 0
lang/src/accounts/mod.rs

@@ -1,3 +1,5 @@
+//! Account types that can be used in the account validation struct.
+
 pub mod account;
 pub mod account_info;
 pub mod boxed;

+ 2 - 0
lang/src/idl.rs

@@ -17,6 +17,8 @@
 //! Note that IDL account instructions are automatically inserted into all
 //! Anchor programs. To remove them, one can use the `no-idl` feature.
 
+#[allow(deprecated)]
+use crate::accounts::program_account::ProgramAccount;
 use crate::prelude::*;
 use solana_program::pubkey::Pubkey;
 

+ 17 - 44
lang/src/lib.rs

@@ -32,44 +32,19 @@ use solana_program::pubkey::Pubkey;
 use std::io::Write;
 
 mod account_meta;
-mod accounts;
+pub mod accounts;
 mod bpf_upgradeable_state;
 mod common;
-mod context;
+pub mod context;
 mod ctor;
 mod error;
 #[doc(hidden)]
 pub mod idl;
 mod system_program;
 
-pub use crate::accounts::account::Account;
-#[doc(hidden)]
-#[allow(deprecated)]
-pub use crate::accounts::cpi_account::CpiAccount;
-#[doc(hidden)]
-#[allow(deprecated)]
-pub use crate::accounts::cpi_state::CpiState;
-#[allow(deprecated)]
-pub use crate::accounts::loader::Loader;
-pub use crate::accounts::loader_account::AccountLoader;
-pub use crate::accounts::program::Program;
-#[doc(hidden)]
-#[allow(deprecated)]
-pub use crate::accounts::program_account::ProgramAccount;
-pub use crate::accounts::signer::Signer;
-#[doc(hidden)]
-#[allow(deprecated)]
-pub use crate::accounts::state::ProgramState;
-pub use crate::accounts::system_account::SystemAccount;
-pub use crate::accounts::sysvar::Sysvar;
-pub use crate::accounts::unchecked_account::UncheckedAccount;
 pub use crate::system_program::System;
 mod vec;
 pub use crate::bpf_upgradeable_state::*;
-#[doc(hidden)]
-#[allow(deprecated)]
-pub use crate::context::CpiStateContext;
-pub use crate::context::{Context, CpiContext};
 pub use anchor_attribute_access_control::access_control;
 pub use anchor_attribute_account::{account, declare_id, zero_copy};
 pub use anchor_attribute_constant::constant;
@@ -244,18 +219,15 @@ impl Key for Pubkey {
 /// All programs should include it via `anchor_lang::prelude::*;`.
 pub mod prelude {
     pub use super::{
-        access_control, account, constant, declare_id, emit, error, event, interface, program,
+        access_control, account, accounts::account::Account,
+        accounts::loader_account::AccountLoader, accounts::program::Program,
+        accounts::signer::Signer, accounts::system_account::SystemAccount,
+        accounts::sysvar::Sysvar, accounts::unchecked_account::UncheckedAccount, constant,
+        context::Context, context::CpiContext, declare_id, emit, error, event, interface, program,
         require, solana_program::bpf_loader_upgradeable::UpgradeableLoaderState, state, zero_copy,
-        Account, AccountDeserialize, AccountLoader, AccountSerialize, Accounts, AccountsExit,
-        AnchorDeserialize, AnchorSerialize, Context, CpiContext, Id, Key, Owner, Program,
-        ProgramData, Signer, System, SystemAccount, Sysvar, ToAccountInfo, ToAccountInfos,
-        ToAccountMetas, UncheckedAccount,
-    };
-
-    #[allow(deprecated)]
-    pub use super::{
-        accounts::cpi_account::CpiAccount, accounts::cpi_state::CpiState, accounts::loader::Loader,
-        accounts::program_account::ProgramAccount, accounts::state::ProgramState, CpiStateContext,
+        AccountDeserialize, AccountSerialize, Accounts, AccountsExit, AnchorDeserialize,
+        AnchorSerialize, Id, Key, Owner, ProgramData, System, ToAccountInfo, ToAccountInfos,
+        ToAccountMetas,
     };
 
     pub use borsh;
@@ -279,12 +251,18 @@ pub mod prelude {
     pub use thiserror;
 }
 
-// Internal module used by macros and unstable apis.
+/// Internal module used by macros and unstable apis.
 pub mod __private {
     // Modules with useful information for users
     // don't use #[doc(hidden)] on these
     pub use crate::error::ErrorCode;
 
+    /// The discriminator anchor uses to mark an account as closed.
+    pub const CLOSED_ACCOUNT_DISCRIMINATOR: [u8; 8] = [255, 255, 255, 255, 255, 255, 255, 255];
+
+    /// The starting point for user defined error codes.
+    pub const ERROR_CODE_OFFSET: u32 = 6000;
+
     #[doc(hidden)]
     pub use crate::ctor::Ctor;
     #[doc(hidden)]
@@ -307,9 +285,6 @@ pub mod __private {
         pub use crate::accounts::state::*;
     }
 
-    /// The starting point for user defined error codes.
-    pub const ERROR_CODE_OFFSET: u32 = 6000;
-
     // Calculates the size of an account, which may be larger than the deserialized
     // data in it. This trait is currently only used for `#[state]` accounts.
     #[doc(hidden)]
@@ -336,8 +311,6 @@ pub mod __private {
 
     #[doc(hidden)]
     pub use crate::accounts::state::PROGRAM_STATE_SEED;
-    #[doc(hidden)]
-    pub const CLOSED_ACCOUNT_DISCRIMINATOR: [u8; 8] = [255, 255, 255, 255, 255, 255, 255, 255];
 }
 
 /// Ensures a condition is true, otherwise returns the given error.

+ 4 - 4
lang/syn/src/codegen/accounts/constraints.rs

@@ -447,7 +447,7 @@ pub fn generate_init(
                             authority: #owner.to_account_info(),
                             rent: rent.to_account_info(),
                         };
-                        let cpi_ctx = CpiContext::new(cpi_program, accounts);
+                        let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, accounts);
                         anchor_spl::token::initialize_account(cpi_ctx)?;
                     }
 
@@ -480,7 +480,7 @@ pub fn generate_init(
                             token_program: token_program.to_account_info(),
                             rent: rent.to_account_info(),
                         };
-                        let cpi_ctx = CpiContext::new(cpi_program, cpi_accounts);
+                        let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, cpi_accounts);
                         anchor_spl::associated_token::create(cpi_ctx)?;
                     }
                     let pa: #ty_decl = #from_account_info;
@@ -530,7 +530,7 @@ pub fn generate_init(
                             mint: #field.to_account_info(),
                             rent: rent.to_account_info(),
                         };
-                        let cpi_ctx = CpiContext::new(cpi_program, accounts);
+                        let cpi_ctx = anchor_lang::context::CpiContext::new(cpi_program, accounts);
                         anchor_spl::token::initialize_mint(cpi_ctx, #decimals, &#owner.key(), #freeze_authority)?;
                     }
                     let pa: #ty_decl = #from_account_info;
@@ -735,7 +735,7 @@ pub fn generate_constraint_state(f: &Field, c: &ConstraintState) -> proc_macro2:
     quote! {
         // Checks the given state account is the canonical state account for
         // the target program.
-        if #ident.key() != anchor_lang::CpiState::<#account_ty>::address(&#program_target.key()) {
+        if #ident.key() != anchor_lang::accounts::cpi_state::CpiState::<#account_ty>::address(&#program_target.key()) {
             return Err(anchor_lang::__private::ErrorCode::ConstraintState.into());
         }
         if #ident.to_account_info().owner != &#program_target.key() {

+ 2 - 2
lang/syn/src/codegen/program/cpi.rs

@@ -29,7 +29,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
 
                             quote! {
                                 pub fn #method_name<'a, 'b, 'c, 'info>(
-                                    ctx: CpiStateContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
+                                    ctx: anchor_lang::context::CpiStateContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
                                     #(#args),*
                                 ) -> ProgramResult {
                                     let ix = {
@@ -72,7 +72,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                     format!("{:?}", sighash_arr).parse().unwrap();
                 quote! {
                     pub fn #method_name<'a, 'b, 'c, 'info>(
-                        ctx: CpiContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
+                        ctx: anchor_lang::context::CpiContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
                         #(#args),*
                     ) -> ProgramResult {
                         let ix = {

+ 12 - 12
lang/syn/src/codegen/program/handlers.rs

@@ -246,7 +246,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                             )?;
 
                             // Zero copy deserialize.
-                            let loader: anchor_lang::Loader<#mod_name::#name> = anchor_lang::Loader::try_from_unchecked(program_id, &ctor_accounts.to)?;
+                            let loader: anchor_lang::accounts::loader::Loader<#mod_name::#name> = anchor_lang::accounts::loader::Loader::try_from_unchecked(program_id, &ctor_accounts.to)?;
 
                             // Invoke the ctor in a new lexical scope so that
                             // the zero-copy RefMut gets dropped. Required
@@ -254,7 +254,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                             {
                                 let mut instance = loader.load_init()?;
                                 instance.new(
-                                    anchor_lang::Context::new(
+                                    anchor_lang::context::Context::new(
                                         program_id,
                                         &mut ctor_user_def_accounts,
                                         remaining_accounts,
@@ -291,7 +291,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
 
                             // Invoke the ctor.
                             let instance = #mod_name::#name::new(
-                                anchor_lang::Context::new(
+                                anchor_lang::context::Context::new(
                                     program_id,
                                     &mut ctor_user_def_accounts,
                                     remaining_accounts,
@@ -302,7 +302,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                             // Create the solana account for the ctor data.
                             let from = ctor_accounts.from.key;
                             let (base, nonce) = Pubkey::find_program_address(&[], ctor_accounts.program.key);
-                            let seed = anchor_lang::ProgramState::<#name>::seed();
+                            let seed = anchor_lang::accounts::state::ProgramState::<#name>::seed();
                             let owner = ctor_accounts.program.key;
                             let to = Pubkey::create_with_seed(&base, seed, owner).unwrap();
                             let space = anchor_lang::__private::AccountSize::size(&instance)?;
@@ -392,7 +392,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                     if remaining_accounts.is_empty() {
                                         return Err(anchor_lang::__private::ErrorCode::AccountNotEnoughKeys.into());
                                     }
-                                    let loader: anchor_lang::Loader<#mod_name::#name> = anchor_lang::Loader::try_accounts(program_id, &mut remaining_accounts, &[])?;
+                                    let loader: anchor_lang::accounts::loader::Loader<#mod_name::#name> = anchor_lang::accounts::loader::Loader::try_accounts(program_id, &mut remaining_accounts, &[])?;
 
                                     // Deserialize accounts.
                                     let mut accounts = #anchor_ident::try_accounts(
@@ -400,7 +400,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                         &mut remaining_accounts,
                                         ix_data,
                                     )?;
-                                    let ctx = Context::new(program_id, &mut accounts, remaining_accounts);
+                                    let ctx = anchor_lang::context::Context::new(program_id, &mut accounts, remaining_accounts);
 
                                     // Execute user defined function.
                                     {
@@ -438,7 +438,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                     if remaining_accounts.is_empty() {
                                         return Err(anchor_lang::__private::ErrorCode::AccountNotEnoughKeys.into());
                                     }
-                                    let mut state: anchor_lang::ProgramState<#state_ty> = anchor_lang::ProgramState::try_accounts(program_id, &mut remaining_accounts, &[])?;
+                                    let mut state: anchor_lang::accounts::state::ProgramState<#state_ty> = anchor_lang::accounts::state::ProgramState::try_accounts(program_id, &mut remaining_accounts, &[])?;
 
                                     // Deserialize accounts.
                                     let mut accounts = #anchor_ident::try_accounts(
@@ -446,7 +446,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                         &mut remaining_accounts,
                                         ix_data,
                                     )?;
-                                    let ctx = Context::new(program_id, &mut accounts, remaining_accounts);
+                                    let ctx = anchor_lang::context::Context::new(program_id, &mut accounts, remaining_accounts);
 
                                     // Execute user defined function.
                                     state.#ix_method_name(
@@ -551,7 +551,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                             if remaining_accounts.is_empty() {
                                                 return Err(anchor_lang::__private::ErrorCode::AccountNotEnoughKeys.into());
                                             }
-                                            let mut state: anchor_lang::ProgramState<#state_ty> = anchor_lang::ProgramState::try_accounts(program_id, &mut remaining_accounts, &[])?;
+                                            let mut state: anchor_lang::accounts::state::ProgramState<#state_ty> = anchor_lang::accounts::state::ProgramState::try_accounts(program_id, &mut remaining_accounts, &[])?;
 
                                             // Deserialize accounts.
                                             let mut accounts = #anchor_ident::try_accounts(
@@ -559,7 +559,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
                                                 &mut remaining_accounts,
                                                 ix_data,
                                             )?;
-                                            let ctx = Context::new(program_id, &mut accounts, remaining_accounts);
+                                            let ctx = anchor_lang::context::Context::new(program_id, &mut accounts, remaining_accounts);
 
                                             // Execute user defined function.
                                             state.#ix_method_name(
@@ -603,7 +603,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
 
                                             // Execute user defined function.
                                             #state_name::#ix_method_name(
-                                                Context::new(program_id, &mut accounts, remaining_accounts),
+                                                anchor_lang::context::Context::new(program_id, &mut accounts, remaining_accounts),
                                                 #(#ix_arg_names),*
                                             )?;
 
@@ -654,7 +654,7 @@ pub fn generate(program: &Program) -> proc_macro2::TokenStream {
 
                     // Invoke user defined handler.
                     #program_name::#ix_method_name(
-                        Context::new(program_id, &mut accounts, remaining_accounts),
+                        anchor_lang::context::Context::new(program_id, &mut accounts, remaining_accounts),
                         #(#ix_arg_names),*
                     )?;
 

+ 9 - 9
lang/syn/src/lib.rs

@@ -279,24 +279,24 @@ impl Field {
     pub fn container_ty(&self) -> proc_macro2::TokenStream {
         match &self.ty {
             Ty::ProgramAccount(_) => quote! {
-                anchor_lang::ProgramAccount
+                anchor_lang::accounts::program_account::ProgramAccount
             },
             Ty::Account(_) => quote! {
-                anchor_lang::Account
+                anchor_lang::accounts::account::Account
             },
             Ty::AccountLoader(_) => quote! {
-                anchor_lang::AccountLoader
+                anchor_lang::accounts::loader_account::AccountLoader
             },
             Ty::Loader(_) => quote! {
-                anchor_lang::Loader
+                anchor_lang::accounts::loader::Loader
             },
             Ty::CpiAccount(_) => quote! {
-                anchor_lang::CpiAccount
+                anchor_lang::accounts::cpi_account::CpiAccount
             },
-            Ty::Sysvar(_) => quote! { anchor_lang::Sysvar },
-            Ty::CpiState(_) => quote! { anchor_lang::CpiState },
-            Ty::ProgramState(_) => quote! { anchor_lang::ProgramState },
-            Ty::Program(_) => quote! { anchor_lang::Program },
+            Ty::Sysvar(_) => quote! { anchor_lang::accounts::sysvar::Sysvar },
+            Ty::CpiState(_) => quote! { anchor_lang::accounts::cpi_state::CpiState },
+            Ty::ProgramState(_) => quote! { anchor_lang::accounts::state::ProgramState },
+            Ty::Program(_) => quote! { anchor_lang::accounts::program::Program },
             Ty::AccountInfo => quote! {},
             Ty::UncheckedAccount => quote! {},
             Ty::Signer => quote! {},

+ 1 - 1
spl/src/associated_token.rs

@@ -1,7 +1,7 @@
 use anchor_lang::solana_program::account_info::AccountInfo;
 use anchor_lang::solana_program::entrypoint::ProgramResult;
 use anchor_lang::solana_program::pubkey::Pubkey;
-use anchor_lang::{Accounts, CpiContext};
+use anchor_lang::{context::CpiContext, Accounts};
 
 pub use spl_associated_token_account::{get_associated_token_address, ID};
 

+ 1 - 1
spl/src/dex.rs

@@ -2,7 +2,7 @@ use anchor_lang::solana_program::account_info::AccountInfo;
 use anchor_lang::solana_program::entrypoint::ProgramResult;
 use anchor_lang::solana_program::program_error::ProgramError;
 use anchor_lang::solana_program::pubkey::Pubkey;
-use anchor_lang::{Accounts, CpiContext, ToAccountInfos};
+use anchor_lang::{context::CpiContext, Accounts, ToAccountInfos};
 use serum_dex::instruction::SelfTradeBehavior;
 use serum_dex::matching::{OrderType, Side};
 use std::io::Write;

+ 1 - 1
spl/src/shmem.rs

@@ -2,7 +2,7 @@
 //! [program](https://github.com/solana-labs/solana-program-library/tree/master/shared-memory).
 
 use anchor_lang::ToAccountInfo;
-use anchor_lang::{Accounts, CpiContext};
+use anchor_lang::{context::CpiContext, Accounts};
 use solana_program::account_info::AccountInfo;
 use solana_program::declare_id;
 use solana_program::entrypoint::ProgramResult;

+ 1 - 1
spl/src/token.rs

@@ -4,7 +4,7 @@ use anchor_lang::solana_program::entrypoint::ProgramResult;
 use anchor_lang::solana_program::program_error::ProgramError;
 use anchor_lang::solana_program::program_pack::Pack;
 use anchor_lang::solana_program::pubkey::Pubkey;
-use anchor_lang::{Accounts, CpiContext};
+use anchor_lang::{context::CpiContext, Accounts};
 use std::ops::Deref;
 
 pub use spl_token::ID;

+ 1 - 1
tests/cfo/deps/stake

@@ -1 +1 @@
-Subproject commit 2f3e7e7975e8072ebf588cfddf9f8d25c1295cd5
+Subproject commit bc73b510285050f5a21da13c5bc3b8b4c959948f

+ 1 - 0
tests/chat/programs/chat/src/lib.rs

@@ -1,6 +1,7 @@
 //! A simple chat program using a ring buffer to store messages.
 
 use anchor_lang::prelude::*;
+use anchor_lang::accounts::loader::Loader;
 
 declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
 

+ 1 - 0
tests/lockup/programs/lockup/src/lib.rs

@@ -1,6 +1,7 @@
 //! A relatively advanced example of a lockup program. If you're new to Anchor,
 //! it's suggested to start with the other examples.
 
+use anchor_lang::accounts::state::ProgramState;
 use anchor_lang::prelude::*;
 use anchor_lang::solana_program;
 use anchor_lang::solana_program::instruction::Instruction;

+ 1 - 0
tests/lockup/programs/registry/src/lib.rs

@@ -1,6 +1,7 @@
 //! A relatively advanced example of a staking program. If you're new to Anchor,
 //! it's suggested to start with the other examples.
 
+use anchor_lang::accounts::state::ProgramState;
 use anchor_lang::prelude::*;
 use anchor_lang::solana_program::account_info::next_account_info;
 use anchor_lang::solana_program::program_option::COption;

+ 2 - 0
tests/misc/programs/misc/src/context.rs

@@ -1,5 +1,7 @@
 use crate::account::*;
 use anchor_lang::prelude::*;
+use anchor_lang::accounts::loader::Loader;
+use anchor_lang::accounts::cpi_state::CpiState;
 use anchor_spl::associated_token::AssociatedToken;
 use anchor_spl::token::{Mint, Token, TokenAccount};
 use misc2::misc2::MyState as Misc2State;

+ 1 - 0
tests/multisig/programs/multisig/src/lib.rs

@@ -18,6 +18,7 @@
 //! signed.
 
 use anchor_lang::prelude::*;
+use anchor_lang::accounts::program_account::ProgramAccount;
 use anchor_lang::solana_program;
 use anchor_lang::solana_program::instruction::Instruction;
 use std::convert::Into;