cosmos / ibc-rs

Rust implementation of the Inter-Blockchain Communication (IBC) protocol.
Apache License 2.0
181 stars 73 forks source link

implement `TryFrom<TmAbciEvent>` for event types #1220

Closed rnbguy closed 1 week ago

rnbguy commented 1 month ago

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:

https://github.com/cosmos/ibc-rs/blob/4ea4dcb863efa12f5628a05588e2207112035e4a/ibc-core/ics02-client/types/src/events.rs#L210-L221

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

rnbguy commented 1 week ago

Closed by #1253