Skip to content

Commit b52d099

Browse files
authored
Optional account fix (#100)
1 parent 85658b8 commit b52d099

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

crates/anchor-idl/src/account.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@ pub fn generate_account_fields(
1919
} else {
2020
quote! {}
2121
};
22-
let ty = if info.signer {
23-
quote! { Signer<'info> }
24-
} else {
25-
quote! { AccountInfo<'info> }
22+
let ty = {
23+
let acc_type = if info.signer {
24+
quote! { Signer<'info> }
25+
} else {
26+
quote! { AccountInfo<'info> }
27+
};
28+
29+
if info.optional {
30+
quote! { Option<#acc_type>}
31+
} else {
32+
acc_type
33+
}
2634
};
2735
quote! {
2836
#annotation

0 commit comments

Comments
 (0)