|
@@ -177,7 +177,7 @@ pub fn generate_constraint_close(f: &Field, c: &ConstraintClose) -> proc_macro2:
|
|
let target = &c.sol_dest;
|
|
let target = &c.sol_dest;
|
|
quote! {
|
|
quote! {
|
|
if #field.key() == #target.key() {
|
|
if #field.key() == #target.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintClose.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintClose.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -240,7 +240,7 @@ pub fn generate_constraint_literal(c: &ConstraintLiteral) -> proc_macro2::TokenS
|
|
};
|
|
};
|
|
quote! {
|
|
quote! {
|
|
if !(#lit) {
|
|
if !(#lit) {
|
|
- return Err(anchor_lang::__private::ErrorCode::Deprecated.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::Deprecated.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -278,7 +278,7 @@ pub fn generate_constraint_rent_exempt(
|
|
ConstraintRentExempt::Skip => quote! {},
|
|
ConstraintRentExempt::Skip => quote! {},
|
|
ConstraintRentExempt::Enforce => quote! {
|
|
ConstraintRentExempt::Enforce => quote! {
|
|
if !__anchor_rent.is_exempt(#info.lamports(), #info.try_data_len()?) {
|
|
if !__anchor_rent.is_exempt(#info.lamports(), #info.try_data_len()?) {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintRentExempt.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintRentExempt.into());
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|
|
@@ -375,10 +375,10 @@ fn generate_constraint_init(f: &Field, c: &ConstraintInitGroup) -> proc_macro2::
|
|
let pa: #ty_decl = #from_account_info;
|
|
let pa: #ty_decl = #from_account_info;
|
|
if #if_needed {
|
|
if #if_needed {
|
|
if pa.mint != #mint.key() {
|
|
if pa.mint != #mint.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintTokenMint.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintTokenMint.into());
|
|
}
|
|
}
|
|
if pa.owner != #owner.key() {
|
|
if pa.owner != #owner.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintTokenOwner.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintTokenOwner.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pa
|
|
pa
|
|
@@ -410,14 +410,14 @@ fn generate_constraint_init(f: &Field, c: &ConstraintInitGroup) -> proc_macro2::
|
|
let pa: #ty_decl = #from_account_info;
|
|
let pa: #ty_decl = #from_account_info;
|
|
if #if_needed {
|
|
if #if_needed {
|
|
if pa.mint != #mint.key() {
|
|
if pa.mint != #mint.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintTokenMint.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintTokenMint.into());
|
|
}
|
|
}
|
|
if pa.owner != #owner.key() {
|
|
if pa.owner != #owner.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintTokenOwner.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintTokenOwner.into());
|
|
}
|
|
}
|
|
|
|
|
|
if pa.key() != anchor_spl::associated_token::get_associated_token_address(&#owner.key(), &#mint.key()) {
|
|
if pa.key() != anchor_spl::associated_token::get_associated_token_address(&#owner.key(), &#mint.key()) {
|
|
- return Err(anchor_lang::__private::ErrorCode::AccountNotAssociatedTokenAccount.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::AccountNotAssociatedTokenAccount.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pa
|
|
pa
|
|
@@ -463,16 +463,16 @@ fn generate_constraint_init(f: &Field, c: &ConstraintInitGroup) -> proc_macro2::
|
|
let pa: #ty_decl = #from_account_info;
|
|
let pa: #ty_decl = #from_account_info;
|
|
if #if_needed {
|
|
if #if_needed {
|
|
if pa.mint_authority != anchor_lang::solana_program::program_option::COption::Some(#owner.key()) {
|
|
if pa.mint_authority != anchor_lang::solana_program::program_option::COption::Some(#owner.key()) {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintMintMintAuthority.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintMintMintAuthority.into());
|
|
}
|
|
}
|
|
if pa.freeze_authority
|
|
if pa.freeze_authority
|
|
.as_ref()
|
|
.as_ref()
|
|
.map(|fa| #freeze_authority.as_ref().map(|expected_fa| fa != *expected_fa).unwrap_or(true))
|
|
.map(|fa| #freeze_authority.as_ref().map(|expected_fa| fa != *expected_fa).unwrap_or(true))
|
|
.unwrap_or(#freeze_authority.is_some()) {
|
|
.unwrap_or(#freeze_authority.is_some()) {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintMintFreezeAuthority.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintMintFreezeAuthority.into());
|
|
}
|
|
}
|
|
if pa.decimals != #decimals {
|
|
if pa.decimals != #decimals {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintMintDecimals.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintMintDecimals.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pa
|
|
pa
|
|
@@ -575,17 +575,17 @@ fn generate_constraint_init(f: &Field, c: &ConstraintInitGroup) -> proc_macro2::
|
|
// Assert the account was created correctly.
|
|
// Assert the account was created correctly.
|
|
if #if_needed {
|
|
if #if_needed {
|
|
if space != actual_field.data_len() {
|
|
if space != actual_field.data_len() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintSpace.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintSpace.into());
|
|
}
|
|
}
|
|
|
|
|
|
if actual_owner != #owner {
|
|
if actual_owner != #owner {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintOwner.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintOwner.into());
|
|
}
|
|
}
|
|
|
|
|
|
{
|
|
{
|
|
let required_lamports = __anchor_rent.minimum_balance(space);
|
|
let required_lamports = __anchor_rent.minimum_balance(space);
|
|
if pa.to_account_info().lamports() < required_lamports {
|
|
if pa.to_account_info().lamports() < required_lamports {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintRentExempt.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintRentExempt.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -627,10 +627,10 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
let b = c.bump.as_ref().unwrap();
|
|
let b = c.bump.as_ref().unwrap();
|
|
quote! {
|
|
quote! {
|
|
if #name.key() != __pda_address {
|
|
if #name.key() != __pda_address {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintSeeds.into());
|
|
}
|
|
}
|
|
if __bump != #b {
|
|
if __bump != #b {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintSeeds.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -642,7 +642,7 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
else if c.is_init {
|
|
else if c.is_init {
|
|
quote! {
|
|
quote! {
|
|
if #name.key() != __pda_address {
|
|
if #name.key() != __pda_address {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintSeeds.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -665,7 +665,7 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
let __pda_address = Pubkey::create_program_address(
|
|
let __pda_address = Pubkey::create_program_address(
|
|
&[#maybe_seeds_plus_comma &[#b][..]],
|
|
&[#maybe_seeds_plus_comma &[#b][..]],
|
|
&#deriving_program_id,
|
|
&#deriving_program_id,
|
|
- ).map_err(|_| anchor_lang::__private::ErrorCode::ConstraintSeeds)?;
|
|
|
|
|
|
+ ).map_err(|_| anchor_lang::error::ErrorCode::ConstraintSeeds)?;
|
|
},
|
|
},
|
|
};
|
|
};
|
|
quote! {
|
|
quote! {
|
|
@@ -674,7 +674,7 @@ fn generate_constraint_seeds(f: &Field, c: &ConstraintSeedsGroup) -> proc_macro2
|
|
|
|
|
|
// Check it.
|
|
// Check it.
|
|
if #name.key() != __pda_address {
|
|
if #name.key() != __pda_address {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintSeeds.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintSeeds.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -689,11 +689,11 @@ fn generate_constraint_associated_token(
|
|
let spl_token_mint_address = &c.mint;
|
|
let spl_token_mint_address = &c.mint;
|
|
quote! {
|
|
quote! {
|
|
if #name.owner != #wallet_address.key() {
|
|
if #name.owner != #wallet_address.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintTokenOwner.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintTokenOwner.into());
|
|
}
|
|
}
|
|
let __associated_token_address = anchor_spl::associated_token::get_associated_token_address(&#wallet_address.key(), &#spl_token_mint_address.key());
|
|
let __associated_token_address = anchor_spl::associated_token::get_associated_token_address(&#wallet_address.key(), &#spl_token_mint_address.key());
|
|
if #name.key() != __associated_token_address {
|
|
if #name.key() != __associated_token_address {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintAssociated.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintAssociated.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -788,7 +788,7 @@ pub fn generate_constraint_executable(
|
|
let name = &f.ident;
|
|
let name = &f.ident;
|
|
quote! {
|
|
quote! {
|
|
if !#name.to_account_info().executable {
|
|
if !#name.to_account_info().executable {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintExecutable.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintExecutable.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -804,10 +804,10 @@ pub fn generate_constraint_state(f: &Field, c: &ConstraintState) -> proc_macro2:
|
|
// Checks the given state account is the canonical state account for
|
|
// Checks the given state account is the canonical state account for
|
|
// the target program.
|
|
// the target program.
|
|
if #ident.key() != anchor_lang::accounts::cpi_state::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());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintState.into());
|
|
}
|
|
}
|
|
if #ident.as_ref().owner != &#program_target.key() {
|
|
if #ident.as_ref().owner != &#program_target.key() {
|
|
- return Err(anchor_lang::__private::ErrorCode::ConstraintState.into());
|
|
|
|
|
|
+ return Err(anchor_lang::error::ErrorCode::ConstraintState.into());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -818,6 +818,6 @@ fn generate_custom_error(
|
|
) -> proc_macro2::TokenStream {
|
|
) -> proc_macro2::TokenStream {
|
|
match custom_error {
|
|
match custom_error {
|
|
Some(error) => quote! { #error.into() },
|
|
Some(error) => quote! { #error.into() },
|
|
- None => quote! { anchor_lang::__private::ErrorCode::#error.into() },
|
|
|
|
|
|
+ None => quote! { anchor_lang::error::ErrorCode::#error.into() },
|
|
}
|
|
}
|
|
}
|
|
}
|