-
Notifications
You must be signed in to change notification settings - Fork 258
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
Expand the subscribe_and_watch
example
#361
Conversation
} | ||
} | ||
// Finalized! | ||
else if let Finalized(details) = ev { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasn't aware of this syntax but I prefer matching regardless :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah, I kept flicking between a match
and if let
here, but since I only wanted to check for two states I thoughtI'd save a level of indentation with if let :)
@@ -436,7 +436,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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> Co-authored-by: Zeke Mostov <z.mostov@gmail.com>
let events = balance_transfer.fetch_events().await?; | ||
|
||
let failed_event = | ||
events.find_first_event::<polkadot::system::events::ExtrinsicFailed>()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth mentioning how find_first_event
could return error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's worth an explicit shout out in the example really, but I added this note to the docs for the relevant methods because it wasn't clear enough there :)
* 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>
And make
has_event
take&self
; it does not need or want ownership.