mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
Expand the subscribe_and_watch example (#361)
* Expand the subscribe_and_watch example * Fix comment typos Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Zeke Mostov <z.mostov@gmail.com> * Add note about error on decoding events Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
This commit is contained in:
+5
-3
@@ -414,7 +414,8 @@ impl<T: Config> TransactionEvents<T> {
|
||||
&self.events
|
||||
}
|
||||
|
||||
/// Find all of the events matching the event type provided as a generic parameter.
|
||||
/// Find all of the events matching the event type provided as a generic parameter. This
|
||||
/// will return an error if a matching event is found but cannot be properly decoded.
|
||||
pub fn find_events<E: crate::Event>(&self) -> Result<Vec<E>, Error> {
|
||||
self.events
|
||||
.iter()
|
||||
@@ -422,7 +423,8 @@ impl<T: Config> TransactionEvents<T> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Find the first event that matches the event type provided as a generic parameter.
|
||||
/// Find the first event that matches the event type provided as a generic parameter. This
|
||||
/// will return an error if a matching event is found but cannot be properly decoded.
|
||||
///
|
||||
/// Use [`TransactionEvents::find_events`], or iterate over [`TransactionEvents`] yourself
|
||||
/// if you'd like to handle multiple events of the same type.
|
||||
@@ -436,7 +438,7 @@ impl<T: Config> TransactionEvents<T> {
|
||||
}
|
||||
|
||||
/// Find an event. Returns true if it was found.
|
||||
pub fn has_event<E: crate::Event>(self) -> Result<bool, Error> {
|
||||
pub fn has_event<E: crate::Event>(&self) -> Result<bool, Error> {
|
||||
Ok(self.find_first_event::<E>()?.is_some())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user