coral-xyz / anchor

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

FR: Add `#[idl_skip]` or `#[idl_as]` macro #3025

Open mina86 opened 2 weeks ago

mina86 commented 2 weeks ago

We are using a lot of types coming from third-party crates which do not implement IdlBuild. This prevents us from update to 0.30. We pretty much don’t care about IDL so adding wrapper for all of the types is a waste of time and makes the code much less readable. As such, I’d like to have an #[idl_skip] or #[idl_as] macro which would allow instructing Anchor to use default or given IdlBuild implementation for given field or argument. E.g.:

#[anchor_lang::program]
pub mod some_program {
    pub fn some_method(
        ctx: Context<SomeMethod>,
        #[idl_skip] arg: some_crate::Arg,
    ) -> Result<()> {
        ...
    }
}
acheroncrypto commented 2 weeks ago

We pretty much don’t care about IDL

Why not skip the IDL generation with --no-idl then?

I’d like to have an #[idl_skip] or #[idl_as] macro which would allow instructing Anchor to use default or given IdlBuild implementation for given field or argument.

#[idl_skip] would make the IDL incorrect and unusable, so what's the point? I'm positive on #[idl_as] though.

mina86 commented 2 weeks ago

D’oh, you’re absolutely right. --no-idl should solve my problem.

For idl_skip, I was imagining it would be identical to using default IdlBuild implementation which returns None for create_type.