Skip to content

Commit

Permalink
only add public enums to the IDL (#2310)
Browse files Browse the repository at this point in the history
Co-authored-by: henrye <henry@notanemail>
  • Loading branch information
Henry-E and henrye authored Dec 12, 2022
1 parent 7527033 commit 03eff34
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 @@ -46,6 +46,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

1 comment on commit 03eff34

@vercel
Copy link

@vercel vercel bot commented on 03eff34 Dec 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

anchor-docs – ./

anchor-lang.com
www.anchor-lang.com
anchor-docs-git-master-200ms.vercel.app
anchor-docs-200ms.vercel.app

Please sign in to comment.