Closed CanardMandarin closed 1 month ago
IDL generation does not check custom impls, and using AnchorSerialize
currently means using borsh
.
It should work if you use #[zero_copy]
here.
This is not related to declare_program!
because it just defaults to using borsh
when there is no serialization
field specified in the IDL here.
Thanks!
Hello,
I recently wanted to add a custom struct inside a
zero_copy
account. However, importing the generated IDL withdeclare_program!()
macro throws an error. It seems thatdeclare_program!()
does not implement Zeroable + Pod for the custom struct.I created a small reproducible example to make testing easier:
https://github.com/CanardMandarin/anchor/blob/9fffb883ea3224c81d1fc92eca8bb792b589f054/tests/declare-program/programs/external/src/lib.rs#L56-L70
Here is the generated IDL:
https://github.com/CanardMandarin/anchor/blob/9fffb883ea3224c81d1fc92eca8bb792b589f054/tests/declare-program/idls/external.json
I am not very familiar with the new IDL generation, but I will try to look into it!