Browse Source

lang: Rename StateCpiContext to CpiStateContext

Armani Ferrante 4 years ago
parent
commit
3d661cdc66
4 changed files with 11 additions and 11 deletions
  1. 4 4
      lang/src/context.rs
  2. 4 4
      lang/src/cpi_state.rs
  3. 2 2
      lang/src/lib.rs
  4. 1 1
      lang/syn/src/codegen/program.rs

+ 4 - 4
lang/src/context.rs

@@ -70,12 +70,12 @@ where
 
 /// Context specifying non-argument inputs for cross-program-invocations
 /// targeted at program state instructions.
-pub struct StateCpiContext<'a, 'b, 'c, 'info, T: Accounts<'info>> {
+pub struct CpiStateContext<'a, 'b, 'c, 'info, T: Accounts<'info>> {
     state: AccountInfo<'info>,
     cpi_ctx: CpiContext<'a, 'b, 'c, 'info, T>,
 }
 
-impl<'a, 'b, 'c, 'info, T: Accounts<'info>> StateCpiContext<'a, 'b, 'c, 'info, T> {
+impl<'a, 'b, 'c, 'info, T: Accounts<'info>> CpiStateContext<'a, 'b, 'c, 'info, T> {
     pub fn new(program: AccountInfo<'info>, state: AccountInfo<'info>, accounts: T) -> Self {
         Self {
             state,
@@ -118,7 +118,7 @@ impl<'a, 'b, 'c, 'info, T: Accounts<'info>> StateCpiContext<'a, 'b, 'c, 'info, T
 }
 
 impl<'a, 'b, 'c, 'info, T: Accounts<'info>> ToAccountMetas
-    for StateCpiContext<'a, 'b, 'c, 'info, T>
+    for CpiStateContext<'a, 'b, 'c, 'info, T>
 {
     fn to_account_metas(&self, is_signer: Option<bool>) -> Vec<AccountMeta> {
         // State account is always first for state instructions.
@@ -132,7 +132,7 @@ impl<'a, 'b, 'c, 'info, T: Accounts<'info>> ToAccountMetas
 }
 
 impl<'a, 'b, 'c, 'info, T: Accounts<'info>> ToAccountInfos<'info>
-    for StateCpiContext<'a, 'b, 'c, 'info, T>
+    for CpiStateContext<'a, 'b, 'c, 'info, T>
 {
     fn to_account_infos(&self) -> Vec<AccountInfo<'info>> {
         let mut infos = self.cpi_ctx.accounts.to_account_infos();

+ 4 - 4
lang/src/cpi_state.rs

@@ -1,5 +1,5 @@
 use crate::{
-    AccountDeserialize, AccountSerialize, Accounts, AccountsExit, ProgramState, StateCpiContext,
+    AccountDeserialize, AccountSerialize, Accounts, AccountsExit, CpiStateContext, ProgramState,
     ToAccountInfo, ToAccountInfos, ToAccountMetas,
 };
 use solana_program::account_info::AccountInfo;
@@ -47,13 +47,13 @@ impl<'info, T: AccountSerialize + AccountDeserialize + Clone> CpiState<'info, T>
         Pubkey::create_with_seed(&base, seed, owner).unwrap()
     }
 
-    /// Convenience api for creating a `StateCpiContext`.
+    /// Convenience api for creating a `CpiStateContext`.
     pub fn context<'a, 'b, 'c, A: Accounts<'info>>(
         &self,
         program: AccountInfo<'info>,
         accounts: A,
-    ) -> StateCpiContext<'a, 'b, 'c, 'info, A> {
-        StateCpiContext::new(program, self.inner.info.clone(), accounts)
+    ) -> CpiStateContext<'a, 'b, 'c, 'info, A> {
+        CpiStateContext::new(program, self.inner.info.clone(), accounts)
     }
 }
 

+ 2 - 2
lang/src/lib.rs

@@ -52,7 +52,7 @@ pub mod __private {
     pub use base64;
 }
 
-pub use crate::context::{Context, CpiContext, StateCpiContext};
+pub use crate::context::{Context, CpiContext, CpiStateContext};
 pub use crate::cpi_account::CpiAccount;
 pub use crate::cpi_state::CpiState;
 pub use crate::program_account::ProgramAccount;
@@ -211,7 +211,7 @@ pub mod prelude {
     pub use super::{
         access_control, account, emit, error, event, interface, program, state, AccountDeserialize,
         AccountSerialize, Accounts, AccountsExit, AccountsInit, AnchorDeserialize, AnchorSerialize,
-        Context, CpiAccount, CpiContext, CpiState, ProgramAccount, ProgramState, StateCpiContext,
+        Context, CpiAccount, CpiContext, CpiState, CpiStateContext, ProgramAccount, ProgramState,
         Sysvar, ToAccountInfo, ToAccountInfos, ToAccountMetas,
     };
 

+ 1 - 1
lang/syn/src/codegen/program.rs

@@ -1120,7 +1120,7 @@ fn generate_cpi(program: &Program) -> proc_macro2::TokenStream {
 
                             quote! {
                                 pub fn #method_name<'a, 'b, 'c, 'info>(
-                                    ctx: StateCpiContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
+                                    ctx: CpiStateContext<'a, 'b, 'c, 'info, #accounts_ident<'info>>,
                                     #(#args),*
                                 ) -> ProgramResult {
                                     let ix = {