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

Enums don't use the correct discriminator when not in order #56

Open
y2kappa opened this issue Nov 28, 2022 · 1 comment
Open

Enums don't use the correct discriminator when not in order #56

y2kappa opened this issue Nov 28, 2022 · 1 comment

Comments

@y2kappa
Copy link

y2kappa commented Nov 28, 2022

#[derive(Debug, TryFromPrimitive, PartialEq, Eq, Clone, Copy)]
#[repr(u16)]
pub enum GlobalConfigOption {
    EmergencyMode = 0,
    ...

    // 100
    ScopeProgramId = 100,
    ScopePriceId = 101,
}

Codegen:

export interface ScopePriceIdJSON {
  kind: "ScopePriceId"
}

export class ScopePriceId {
  static readonly discriminator = 17
  static readonly kind = "ScopePriceId"
  readonly discriminator = 17
  readonly kind = "ScopePriceId"
}

This should be 101, not 17..

@kklas
Copy link
Owner

kklas commented Dec 1, 2022

Anchor currently doesn't encode enum discriminants in the IDL so this is not possible.

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

2 participants