coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

`declare_program!` should derive `AnchorSerialize` and `AnchorDeserialize` on types #2968

Closed cryptopapi997 closed 1 month ago

cryptopapi997 commented 1 month ago

Currently, sharing types across programs is quite annoying to do because we need to typically wrap our external type in a new type and implement AnchorSerialize and AnchorSerialize by hand. This could be easily fixed by just having declare_program! derive this trait automatically in its generated code for the types found in the idl. I'm unsure if this doesn't bring other problems with it though which is why I'm opening this as an issue first instead of a PR (although I don't expect this to, as declare_program! already does this, and more, for accounts.