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