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

feature: event bytes to enum of events (rust) #2885

Closed
ckamm opened this issue Apr 3, 2024 · 2 comments · Fixed by #2897
Closed

feature: event bytes to enum of events (rust) #2885

ckamm opened this issue Apr 3, 2024 · 2 comments · Fixed by #2897
Labels
enhancement New feature or request lang

Comments

@ckamm
Copy link
Contributor

ckamm commented Apr 3, 2024

It would be helpful if anchor generated a function like:

fn event_from_bytes(bytes: &[u8]) -> Result<Event>;

enum Event {
    Event1(Event1),
    // one for each struct tagged #[event]
}

That finds the matching discriminator and then parses the event.

@acheroncrypto acheroncrypto added enhancement New feature or request lang labels Apr 3, 2024
@acheroncrypto
Copy link
Collaborator

It's a bit difficult to get all events in the current codegen, but this can easily be implemented with the new declare-program! macro. Would that be sufficient, or do you need the function to be generated with the program codegen?

@Lou-Kamades
Copy link

the new macro is probably sufficient imo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lang
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants