metaplex-foundation / solita

Genrates an SDK API from solana contract IDL.
Apache License 2.0
140 stars 32 forks source link

[feat]: Support for non-uniform Data Enums #71

Closed ngundotra closed 2 years ago

ngundotra commented 2 years ago

Right now, Solita is unable to handle IDL types that have the following structure:

  {
      "name": "VoteThreshold",
      "type": {
        "kind": "enum",
        "variants": [
          {
            "name": "YesVotePercentage",
            "fields": [
              "u8"
            ]
          },
          {
            "name": "QuorumPercentage",
            "fields": [
              "u8"
            ]
          },
          {
            "name": "Disabled"
          }
        ]
      }
    }

Would be helpful for automatically maintaining SDKs like for SPL Governance.

ngundotra commented 2 years ago

Even Anchor doesn't have support for this: https://github.com/coral-xyz/anchor/blob/698426033052781988cd7980249726501ae08bdc/ts/src/coder/borsh/idl.ts#L126-L142

thlorenz commented 2 years ago

Could you have another go? I think https://github.com/metaplex-foundation/solita/pull/72 might have fixed this as well. This now handles mixed enums i.e. with data and scalar variants.

ngundotra commented 2 years ago

Yes this is done! Thank you Thorsten :)