Skip to content

Commit

Permalink
fix: IDL generation in programs using light-sdk (#1233)
Browse files Browse the repository at this point in the history
Even when using `idl-build` feature, Anchor still parses the code
of the program and expects the `#[program]` attribute applied on
the main module.

Before this change, annotating the program module only with
`#[light_program]` was preventing the IDL generation. Fix that by
requiring both attributes:

    ```rust
    #[light_program]
    #[program]
    ```

And not injecting the `#[program]` inside `#[light_program]`.
  • Loading branch information
vadorovsky authored Sep 19, 2024
1 parent 2bd693c commit 81f4456
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
1 change: 1 addition & 0 deletions examples/name-service/programs/name-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use light_sdk::{
declare_id!("7yucc7fL3JGbyMwg4neUaenNSdySS39hbAk89Ao3t1Hz");

#[light_program]
#[program]
pub mod name_service {
use super::*;

Expand Down
1 change: 0 additions & 1 deletion macros/light-sdk-macros/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ pub(crate) fn program(mut input: ItemMod) -> Result<TokenStream> {
Ok(quote! {
#instruction_params

#[program]
#input
})
}

0 comments on commit 81f4456

Please sign in to comment.