From 1092e8b26ecf08bdfef7416ca8b49b90dac60992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Narzis?= <78718413+lean-apple@users.noreply.github.com> Date: Mon, 13 Feb 2023 11:53:22 +0000 Subject: [PATCH] add find last function (#821) --- subxt/src/events/events_type.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subxt/src/events/events_type.rs b/subxt/src/events/events_type.rs index 7efc7d93d4..aa07e4214a 100644 --- a/subxt/src/events/events_type.rs +++ b/subxt/src/events/events_type.rs @@ -187,6 +187,12 @@ impl Events { self.find::().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(&self) -> Result, Error> { + self.find::().last().transpose() + } + /// Find an event that decodes to the type provided. Returns true if it was found. pub fn has(&self) -> Result { Ok(self.find::().next().transpose()?.is_some())