Skip to content

Commit

Permalink
🐛 Fixed AccountInfo and UncheckedAccount deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikrk committed Feb 8, 2024
1 parent 8225bb9 commit 7a6e500
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/client/src/fuzzer/snapshot_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ fn deserialize_ctx_struct_anchor(
return_type,
deser_method,
),
None if matches!(&f.ty, Ty::UncheckedAccount) => {
acc_unchecked_tokens(&field_name)
}
None => acc_info_tokens(&field_name),
};
Ok((
Expand Down Expand Up @@ -403,7 +406,19 @@ fn acc_info_tokens(name: &syn::Ident) -> TokenStream {
quote! {
let #name = accounts_iter
.next()
.ok_or(FuzzingError::NotEnoughAccounts)?;
.ok_or(FuzzingError::NotEnoughAccounts)?
.ok_or(FuzzingError::AccountNotFound)?;
}
}

/// Generates the code used with Unchecked accounts
fn acc_unchecked_tokens(name: &syn::Ident) -> TokenStream {
quote! {
let #name = accounts_iter
.next()
.ok_or(FuzzingError::NotEnoughAccounts)?
.map(anchor_lang::accounts::unchecked_account::UncheckedAccount::try_from)
.ok_or(FuzzingError::AccountNotFound)?;
}
}

Expand Down

0 comments on commit 7a6e500

Please sign in to comment.