Revert "Support for AccountLoaderDynamic"

This reverts commit 1153380487.
This commit is contained in:
Christian Kamm 2022-12-29 11:46:20 +01:00
parent 309c2c2f4c
commit b3707b1faa
4 changed files with 0 additions and 44 deletions

View File

@ -216,7 +216,6 @@ pub fn generate_constraint_has_one(f: &Field, c: &ConstraintHasOne) -> proc_macr
let field = match &f.ty { let field = match &f.ty {
Ty::Loader(_) => quote! {#ident.load()?}, Ty::Loader(_) => quote! {#ident.load()?},
Ty::AccountLoader(_) => quote! {#ident.load()?}, Ty::AccountLoader(_) => quote! {#ident.load()?},
Ty::AccountLoaderDynamic(_) => quote! {#ident.load_fixed()?},
_ => quote! {#ident}, _ => quote! {#ident},
}; };
let error = generate_custom_error( let error = generate_custom_error(

View File

@ -358,21 +358,6 @@ impl Field {
} }
} }
} }
Ty::AccountLoaderDynamic(_) => {
if checked {
quote! {
#container_ty::try_from(
&#field,
).map_err(|e| e.with_account_name(#field_str))?
}
} else {
quote! {
#container_ty::try_from_unchecked(
&#field,
).map_err(|e| e.with_account_name(#field_str))?
}
}
}
_ => { _ => {
if checked { if checked {
quote! { quote! {
@ -404,9 +389,6 @@ impl Field {
Ty::AccountLoader(_) => quote! { Ty::AccountLoader(_) => quote! {
anchor_lang::accounts::account_loader::AccountLoader anchor_lang::accounts::account_loader::AccountLoader
}, },
Ty::AccountLoaderDynamic(_) => quote! {
crate::state::AccountLoaderDynamic
},
Ty::Loader(_) => quote! { Ty::Loader(_) => quote! {
anchor_lang::accounts::loader::Loader anchor_lang::accounts::loader::Loader
}, },
@ -461,12 +443,6 @@ impl Field {
#ident #ident
} }
} }
Ty::AccountLoaderDynamic(ty) => {
let ident = &ty.account_type_path;
quote! {
#ident
}
}
Ty::Loader(ty) => { Ty::Loader(ty) => {
let ident = &ty.account_type_path; let ident = &ty.account_type_path;
quote! { quote! {
@ -533,7 +509,6 @@ pub enum Ty {
ProgramAccount(ProgramAccountTy), ProgramAccount(ProgramAccountTy),
Loader(LoaderTy), Loader(LoaderTy),
AccountLoader(AccountLoaderTy), AccountLoader(AccountLoaderTy),
AccountLoaderDynamic(AccountLoaderDynamicTy),
CpiAccount(CpiAccountTy), CpiAccount(CpiAccountTy),
Sysvar(SysvarTy), Sysvar(SysvarTy),
Account(AccountTy), Account(AccountTy),
@ -585,12 +560,6 @@ pub struct AccountLoaderTy {
pub account_type_path: TypePath, pub account_type_path: TypePath,
} }
#[derive(Debug, PartialEq)]
pub struct AccountLoaderDynamicTy {
// The struct type of the account.
pub account_type_path: TypePath,
}
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct LoaderTy { pub struct LoaderTy {
// The struct type of the account. // The struct type of the account.

View File

@ -886,9 +886,7 @@ impl<'ty> ConstraintGroupBuilder<'ty> {
&& !matches!(self.f_ty, Some(Ty::Account(_))) && !matches!(self.f_ty, Some(Ty::Account(_)))
&& !matches!(self.f_ty, Some(Ty::Loader(_))) && !matches!(self.f_ty, Some(Ty::Loader(_)))
&& !matches!(self.f_ty, Some(Ty::AccountLoader(_))) && !matches!(self.f_ty, Some(Ty::AccountLoader(_)))
&& !matches!(self.f_ty, Some(Ty::AccountLoaderDynamic(_)))
{ {
println!("{:?}", self.f_ty);
return Err(ParseError::new( return Err(ParseError::new(
c.span(), c.span(),
"close must be on an Account, ProgramAccount, or Loader", "close must be on an Account, ProgramAccount, or Loader",

View File

@ -239,7 +239,6 @@ fn is_field_primitive(f: &syn::Field) -> ParseResult<bool> {
| "CpiState" | "CpiState"
| "Loader" | "Loader"
| "AccountLoader" | "AccountLoader"
| "AccountLoaderDynamic"
| "Account" | "Account"
| "Program" | "Program"
| "Signer" | "Signer"
@ -264,9 +263,6 @@ fn parse_ty(f: &syn::Field) -> ParseResult<Ty> {
"UncheckedAccount" => Ty::UncheckedAccount, "UncheckedAccount" => Ty::UncheckedAccount,
"Loader" => Ty::Loader(parse_program_account_zero_copy(&path)?), "Loader" => Ty::Loader(parse_program_account_zero_copy(&path)?),
"AccountLoader" => Ty::AccountLoader(parse_program_account_loader(&path)?), "AccountLoader" => Ty::AccountLoader(parse_program_account_loader(&path)?),
"AccountLoaderDynamic" => {
Ty::AccountLoaderDynamic(parse_program_mango_account_loader(&path)?)
}
"Account" => Ty::Account(parse_account_ty(&path)?), "Account" => Ty::Account(parse_account_ty(&path)?),
"Program" => Ty::Program(parse_program_ty(&path)?), "Program" => Ty::Program(parse_program_ty(&path)?),
"Signer" => Ty::Signer, "Signer" => Ty::Signer,
@ -341,12 +337,6 @@ fn parse_program_account_loader(path: &syn::Path) -> ParseResult<AccountLoaderTy
account_type_path: account_ident, account_type_path: account_ident,
}) })
} }
fn parse_program_mango_account_loader(path: &syn::Path) -> ParseResult<AccountLoaderDynamicTy> {
let account_ident = parse_account(path)?;
Ok(AccountLoaderDynamicTy {
account_type_path: account_ident,
})
}
fn parse_account_ty(path: &syn::Path) -> ParseResult<AccountTy> { fn parse_account_ty(path: &syn::Path) -> ParseResult<AccountTy> {
let account_type_path = parse_account(path)?; let account_type_path = parse_account(path)?;