Skip to content

Commit

Permalink
only add public enums to the IDL
Browse files Browse the repository at this point in the history
  • Loading branch information
henrye committed Dec 12, 2022
1 parent 4846280 commit ef753af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- lang: Prevent the payer account from being initialized as a program account ([#2284](https://github.com/coral-xyz/anchor/pull/2284)).
- ts: Fixing breaking change where null or undefined wallet throws an error ([#2303](https://github.com/coral-xyz/anchor/pull/2303)).
- ts: Fixed `.fetchNullable()` to be robust towards accounts only holding a balance ([#2301](https://github.com/coral-xyz/anchor/pull/2301)).
- lang: Only add public enums to the IDL ([#2309](https://github.com/coral-xyz/anchor/pull/2309)).

### Breaking

Expand Down
11 changes: 8 additions & 3 deletions lang/syn/src/idl/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,12 @@ fn parse_ty_defs(ctx: &CrateContext, no_docs: bool) -> Result<Vec<IdlTypeDefinit
ty: IdlTypeDefinitionTy::Struct { fields },
}))
})
.chain(ctx.enums().map(|enm| {
.chain(ctx.enums().filter_map(|enm| {
// Only take public types
match &enm.vis {
syn::Visibility::Public(_) => (),
_ => return None,
}
let name = enm.ident.to_string();
let doc = if !no_docs {
docs::parse(&enm.attrs)
Expand Down Expand Up @@ -531,11 +536,11 @@ fn parse_ty_defs(ctx: &CrateContext, no_docs: bool) -> Result<Vec<IdlTypeDefinit
IdlEnumVariant { name, fields }
})
.collect::<Vec<IdlEnumVariant>>();
Ok(IdlTypeDefinition {
Some(Ok(IdlTypeDefinition {
name,
docs: doc,
ty: IdlTypeDefinitionTy::Enum { variants },
})
}))
}))
.collect()
}
Expand Down

0 comments on commit ef753af

Please sign in to comment.