|
@@ -136,7 +136,7 @@ fn generate_constraint_address(f: &Field, c: &ConstraintAddress) -> proc_macro2:
|
|
|
let addr = &c.address;
|
|
|
let error = generate_custom_error(&c.error, quote! { ConstraintAddress });
|
|
|
quote! {
|
|
|
- if #field.to_account_info().key != &#addr {
|
|
|
+ if #field.key() != #addr {
|
|
|
return Err(#error);
|
|
|
}
|
|
|
}
|
|
@@ -168,7 +168,7 @@ pub fn generate_constraint_close(f: &Field, c: &ConstraintClose) -> proc_macro2:
|
|
|
let field = &f.ident;
|
|
|
let target = &c.sol_dest;
|
|
|
quote! {
|
|
|
- if #field.to_account_info().key == #target.to_account_info().key {
|
|
|
+ if #field.key() == #target.key() {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintClose.into());
|
|
|
}
|
|
|
}
|
|
@@ -194,7 +194,7 @@ pub fn generate_constraint_has_one(f: &Field, c: &ConstraintHasOne) -> proc_macr
|
|
|
};
|
|
|
let error = generate_custom_error(&c.error, quote! { ConstraintHasOne });
|
|
|
quote! {
|
|
|
- if &#field.#target != #target.to_account_info().key {
|
|
|
+ if #field.#target != #target.key() {
|
|
|
return Err(#error);
|
|
|
}
|
|
|
}
|
|
@@ -342,7 +342,7 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
|
&[#s],
|
|
|
program_id,
|
|
|
);
|
|
|
- if #name.to_account_info().key != &__program_signer {
|
|
|
+ if #name.key() != __program_signer {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
}
|
|
|
if __bump != #b {
|
|
@@ -380,7 +380,7 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
|
&#seeds[..],
|
|
|
program_id,
|
|
|
).map_err(|_| anchor_lang::__private::ErrorCode::ConstraintSeeds)?;
|
|
|
- if #name.to_account_info().key != &__program_signer {
|
|
|
+ if #name.key() != __program_signer {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
}
|
|
|
}
|
|
@@ -396,7 +396,7 @@ fn generate_constraint_associated_token(
|
|
|
let spl_token_mint_address = &c.mint;
|
|
|
quote! {
|
|
|
let __associated_token_address = anchor_spl::associated_token::get_associated_token_address(&#wallet_address.key(), &#spl_token_mint_address.key());
|
|
|
- if #name.to_account_info().key != &__associated_token_address {
|
|
|
+ if #name.key() != __associated_token_address {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintAssociated.into());
|
|
|
}
|
|
|
}
|
|
@@ -424,7 +424,7 @@ pub fn generate_init(
|
|
|
let create_account = generate_create_account(
|
|
|
field,
|
|
|
quote! {anchor_spl::token::TokenAccount::LEN},
|
|
|
- quote! {token_program.to_account_info().key},
|
|
|
+ quote! {&token_program.key()},
|
|
|
seeds_with_nonce,
|
|
|
);
|
|
|
quote! {
|
|
@@ -505,7 +505,7 @@ pub fn generate_init(
|
|
|
let create_account = generate_create_account(
|
|
|
field,
|
|
|
quote! {anchor_spl::token::Mint::LEN},
|
|
|
- quote! {token_program.to_account_info().key},
|
|
|
+ quote! {&token_program.key()},
|
|
|
seeds_with_nonce,
|
|
|
);
|
|
|
let freeze_authority = match freeze_authority {
|
|
@@ -643,14 +643,14 @@ pub fn generate_create_account(
|
|
|
// return them all back to the payer so that the account has
|
|
|
// zero lamports when the system program's create instruction
|
|
|
// is eventually called.
|
|
|
- let __current_lamports = #field.to_account_info().lamports();
|
|
|
+ let __current_lamports = #field.lamports();
|
|
|
if __current_lamports == 0 {
|
|
|
// Create the token account with right amount of lamports and space, and the correct owner.
|
|
|
let lamports = __anchor_rent.minimum_balance(#space);
|
|
|
anchor_lang::solana_program::program::invoke_signed(
|
|
|
&anchor_lang::solana_program::system_instruction::create_account(
|
|
|
- payer.to_account_info().key,
|
|
|
- #field.to_account_info().key,
|
|
|
+ &payer.key(),
|
|
|
+ &#field.key(),
|
|
|
lamports,
|
|
|
#space as u64,
|
|
|
#owner,
|
|
@@ -671,8 +671,8 @@ pub fn generate_create_account(
|
|
|
if required_lamports > 0 {
|
|
|
anchor_lang::solana_program::program::invoke(
|
|
|
&anchor_lang::solana_program::system_instruction::transfer(
|
|
|
- payer.to_account_info().key,
|
|
|
- #field.to_account_info().key,
|
|
|
+ &payer.key(),
|
|
|
+ &#field.key(),
|
|
|
required_lamports,
|
|
|
),
|
|
|
&[
|
|
@@ -685,7 +685,7 @@ pub fn generate_create_account(
|
|
|
// Allocate space.
|
|
|
anchor_lang::solana_program::program::invoke_signed(
|
|
|
&anchor_lang::solana_program::system_instruction::allocate(
|
|
|
- #field.to_account_info().key,
|
|
|
+ &#field.key(),
|
|
|
#space as u64,
|
|
|
),
|
|
|
&[
|
|
@@ -697,7 +697,7 @@ pub fn generate_create_account(
|
|
|
// Assign to the spl token program.
|
|
|
anchor_lang::solana_program::program::invoke_signed(
|
|
|
&anchor_lang::solana_program::system_instruction::assign(
|
|
|
- #field.to_account_info().key,
|
|
|
+ &#field.key(),
|
|
|
#owner,
|
|
|
),
|
|
|
&[
|
|
@@ -732,10 +732,10 @@ 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.to_account_info().key != &anchor_lang::CpiState::<#account_ty>::address(#program_target.to_account_info().key) {
|
|
|
+ if #ident.key() != anchor_lang::CpiState::<#account_ty>::address(&#program_target.key()) {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintState.into());
|
|
|
}
|
|
|
- if #ident.to_account_info().owner != #program_target.to_account_info().key {
|
|
|
+ if #ident.to_account_info().owner != &#program_target.key() {
|
|
|
return Err(anchor_lang::__private::ErrorCode::ConstraintState.into());
|
|
|
}
|
|
|
}
|