Skip to content
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

Merged
merged 3 commits into from Dec 10, 2021
Merged

Conversation

jsdw
Copy link
Collaborator

@jsdw jsdw commented Dec 9, 2021

And make has_event take &self; it does not need or want ownership.

}
}
// Finalized!
else if let Finalized(details) = ev {
Copy link
Member

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 :)

Copy link
Collaborator Author

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> {
Copy link
Member

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>()?;
Copy link
Contributor

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?

Copy link
Collaborator Author

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 :)

@jsdw jsdw merged commit dd9bb11 into master Dec 10, 2021
@jsdw jsdw deleted the jsdw-more-transfer-example branch December 10, 2021 11:20
0623forbidden pushed a commit to DEIPworld/substrate-subxt that referenced this pull request Feb 15, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants