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

implement TryFrom<TmAbciEvent> for event types #1220

Open
rnbguy opened this issue May 10, 2024 · 0 comments
Open

implement TryFrom<TmAbciEvent> for event types #1220

rnbguy opened this issue May 10, 2024 · 0 comments

Comments

@rnbguy
Copy link
Collaborator

rnbguy commented May 10, 2024

Feature Summary

Currently, we have impl From<T> for TmAbciEvent for an event type T. But the other way around is not implemented.

Proposal

Implement impl TryFrom<TmAbciEvent> for T for all event type T. For example, the CreateClient case:

impl From<CreateClient> for abci::Event {
fn from(c: CreateClient) -> Self {
Self {
kind: CREATE_CLIENT_EVENT.to_owned(),
attributes: vec![
c.client_id.into(),
c.client_type.into(),
c.consensus_height.into(),
],
}
}
}

The following TryFrom implementation is missing:

impl TryFrom<abci::Event> for CreateClient {
    type Error = ...;

    fn try_from(value: abci::Event) -> Result<Self, Self::Error> {
        (value.kind == CREATE_CLIENT_EVENT)
            .then(|| { ... })
            .ok_or_else(|| { ... })
    }
}

We should do the same for abci::EventAttribute too. We may need to break this issue into sub-issues for each set of events for: client, connection, channel, packet, host, handler, routing.

Requested by @penso

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

1 participant