Skip to content

Commit

Permalink
Revert "Support for AccountLoaderDynamic"
Browse files Browse the repository at this point in the history
This reverts commit 1153380.
  • Loading branch information
ckamm committed Dec 29, 2022
1 parent 309c2c2 commit b3707b1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 44 deletions.
1 change: 0 additions & 1 deletion lang/syn/src/codegen/accounts/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ pub fn generate_constraint_has_one(f: &Field, c: &ConstraintHasOne) -> proc_macr
let field = match &f.ty {
Ty::Loader(_) => quote! {#ident.load()?},
Ty::AccountLoader(_) => quote! {#ident.load()?},
Ty::AccountLoaderDynamic(_) => quote! {#ident.load_fixed()?},
_ => quote! {#ident},
};
let error = generate_custom_error(
Expand Down
31 changes: 0 additions & 31 deletions lang/syn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
quote! {
Expand Down Expand Up @@ -404,9 +389,6 @@ impl Field {
Ty::AccountLoader(_) => quote! {
anchor_lang::accounts::account_loader::AccountLoader
},
Ty::AccountLoaderDynamic(_) => quote! {
crate::state::AccountLoaderDynamic
},
Ty::Loader(_) => quote! {
anchor_lang::accounts::loader::Loader
},
Expand Down Expand Up @@ -461,12 +443,6 @@ impl Field {
#ident
}
}
Ty::AccountLoaderDynamic(ty) => {
let ident = &ty.account_type_path;
quote! {
#ident
}
}
Ty::Loader(ty) => {
let ident = &ty.account_type_path;
quote! {
Expand Down Expand Up @@ -533,7 +509,6 @@ pub enum Ty {
ProgramAccount(ProgramAccountTy),
Loader(LoaderTy),
AccountLoader(AccountLoaderTy),
AccountLoaderDynamic(AccountLoaderDynamicTy),
CpiAccount(CpiAccountTy),
Sysvar(SysvarTy),
Account(AccountTy),
Expand Down Expand Up @@ -585,12 +560,6 @@ pub struct AccountLoaderTy {
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)]
pub struct LoaderTy {
// The struct type of the account.
Expand Down
2 changes: 0 additions & 2 deletions lang/syn/src/parser/accounts/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,7 @@ impl<'ty> ConstraintGroupBuilder<'ty> {
&& !matches!(self.f_ty, Some(Ty::Account(_)))
&& !matches!(self.f_ty, Some(Ty::Loader(_)))
&& !matches!(self.f_ty, Some(Ty::AccountLoader(_)))
&& !matches!(self.f_ty, Some(Ty::AccountLoaderDynamic(_)))
{
println!("{:?}", self.f_ty);
return Err(ParseError::new(
c.span(),
"close must be on an Account, ProgramAccount, or Loader",
Expand Down
10 changes: 0 additions & 10 deletions lang/syn/src/parser/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ fn is_field_primitive(f: &syn::Field) -> ParseResult<bool> {
| "CpiState"
| "Loader"
| "AccountLoader"
| "AccountLoaderDynamic"
| "Account"
| "Program"
| "Signer"
Expand All @@ -264,9 +263,6 @@ fn parse_ty(f: &syn::Field) -> ParseResult<Ty> {
"UncheckedAccount" => Ty::UncheckedAccount,
"Loader" => Ty::Loader(parse_program_account_zero_copy(&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)?),
"Program" => Ty::Program(parse_program_ty(&path)?),
"Signer" => Ty::Signer,
Expand Down Expand Up @@ -341,12 +337,6 @@ fn parse_program_account_loader(path: &syn::Path) -> ParseResult<AccountLoaderTy
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> {
let account_type_path = parse_account(path)?;
Expand Down

0 comments on commit b3707b1

Please sign in to comment.