codama-idl / codama

Generate clients, CLIs, documentation and more from your Solana programs
MIT License
73 stars 16 forks source link

[renderers] Support enum with custom number indexes #79

Open lorisleiva opened 3 months ago

lorisleiva commented 3 months ago

If enum variants have custom discriminator values, we should consider using them when generating the enum in JavaScript or Rust.

enum MyEnum {
  First = 1,
  Second,
  Fifth = 5,
}

The same goes for discriminated unions in JavaScript which is going to be a combination of the type discriminator and/or the codec's options.