Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unnamed structs in IDL #607

Closed
fanatid opened this issue Aug 14, 2021 · 4 comments
Closed

Support unnamed structs in IDL #607

fanatid opened this issue Aug 14, 2021 · 4 comments

Comments

@fanatid
Copy link
Contributor

fanatid commented Aug 14, 2021

In continue of #605.

How ⚓ should support unnamed structs (syn::Feilds::Unnamed)? I see two ways:

  1. Add arrays support to IDL.
  2. Add a new derive macro (AnchorType for example) which will add fields names to such structs:
#[derive(AnchorType)]
struct Z(#[field(name = x)] u64, #[field(name = y)] u64);

Additional derive macro looks better for me because it adds verbosity to JS and makes things more clear.

@armaniferrante
Copy link
Member

Arrays are currently supported in the IDL. Is there anything in the current implementation lacking for your use case? For example, generic lengths can't be used at the moment.

@fanatid
Copy link
Contributor Author

fanatid commented Aug 14, 2021

I did not know that arrays are supported. Looks like I need to check IDL again 😄

@archseer
Copy link
Contributor

It would be great if transparent newtype structs were at least supported, for example:

#[derive(
    Clone, Copy, Default, PartialOrd, Ord, PartialEq, Eq, AnchorSerialize, AnchorDeserialize,
)]
#[repr(transparent)]
pub struct Address(pub [u8; 20]);

This compiles fine and generates an IDL with Address references, but the Address type itself is missing. anchor test will then run and report "success! 0 test cases" when it fails to parse the IDL 😄

@acheroncrypto acheroncrypto mentioned this issue Feb 25, 2024
@acheroncrypto
Copy link
Collaborator

Added in #2824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants