Skip to content

Commit

Permalink
add find last function (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
lean-apple authored Feb 13, 2023
1 parent b623749 commit 1092e8b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions subxt/src/events/events_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ impl<T: Config> Events<T> {
self.find::<Ev>().next().transpose()
}

/// Iterate through the events using metadata to dynamically decode and skip
/// them, and return the last event found which decodes to the provided `Ev` type.
pub fn find_last<Ev: StaticEvent>(&self) -> Result<Option<Ev>, Error> {
self.find::<Ev>().last().transpose()
}

/// Find an event that decodes to the type provided. Returns true if it was found.
pub fn has<Ev: StaticEvent>(&self) -> Result<bool, Error> {
Ok(self.find::<Ev>().next().transpose()?.is_some())
Expand Down

0 comments on commit 1092e8b

Please sign in to comment.