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

feat: Handle tuple structs in IDL #1190

Closed

Conversation

abhimanyusinghgaur
Copy link

@abhimanyusinghgaur abhimanyusinghgaur commented Dec 23, 2021

This PR adds support for handling tuple structs in IDL. It names the tuple struct fields as f0, f1, f2, etc. The integer after f is the index of the value in the tuple.

Given a tuple struct in Rust like this:

#[account]
pub struct TupleStruct(u64, String, B, [i32; 5]);

The generated IDL looks like this:

    {
      "name": "TupleStruct",
      "type": {
        "kind": "struct",
        "fields": [
          {
            "name": "f0",
            "type": "u64"
          },
          {
            "name": "f1",
            "type": "string"
          },
          {
            "name": "f2",
            "type": {
              "defined": "B"
            }
          },
          {
            "name": "f3",
            "type": {
              "array": [
                "i32",
                5
              ]
            }
          }
        ]
      }
    }

Related to #232, #971.

@paul-schaaf
Copy link
Contributor

is there anything in the way of merging this @armaniferrante ?

provided that we add changelog etc (do we have tests that test idl generation? I saw tests that check that rust types can be generated from strings but not that they result in the correct strings)?

@armaniferrante
Copy link
Member

armaniferrante commented Jan 10, 2022

do we have tests that test idl generation?

Yes, but they are all implicit in e2e tests, which makes for significantly faster development. We should add a test here before merging.

@paul-schaaf
Copy link
Contributor

@armaniferrante I suppose we can only test e2e if we add the ts code required to parse tuple structs in this PR as well then?

@darkmode-ff
Copy link

is this PR still active?

@abhimanyusinghgaur
Copy link
Author

is this PR still active?

I won't be able to contribute further ATM. If anyone else is interested, they can take it up.

@acheroncrypto acheroncrypto mentioned this pull request Feb 25, 2024
@acheroncrypto acheroncrypto added the idl related to the IDL, either program or client side label Mar 10, 2024
@acheroncrypto
Copy link
Collaborator

Superseded by #2824.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idl related to the IDL, either program or client side
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants