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

Add next_events_from_metadata and rename next_event #545

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

haerdib
Copy link
Contributor

@haerdib haerdib commented Apr 21, 2023

Updated the EventSubscription Wrapper to support decoding events from the metadata:

  • added new functionality next_events_from_metadata to derive events from metadata instead of RuntimeEvents generated by the construct_runtime macro of Substrate
  • renamed next_event to more appropriate next_events.
  • introduced a metadata field for event derivation from metadata (needed by next_events_from_metadata). Therefore, the From derivation from Subscriptionis not possible any more (needs metadata) and was removed.

closes #440

@haerdib haerdib self-assigned this Apr 21, 2023
@haerdib haerdib marked this pull request as ready for review April 26, 2023 06:06
@haerdib haerdib added F7-enhancement Enhances an already existing functionality E2-breaksapi labels Apr 26, 2023
Copy link
Contributor

@Niederb Niederb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@echevrier echevrier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is not clear what this PR wants to do. Can you clarify?
Why does this PR close #440?
Do we still need RuntimeEvent? When should we use next_events, when next_events_from_metadata?

@@ -24,9 +24,6 @@ use sp_core::H256;

/// A collection of events obtained from a block, bundled with the necessary
/// information needed to decode and iterate over them.
//
// In subxt, this was generic over a `Config` type, but it's sole usage was to derive the
// hash type. We omitted this here and use the `ac_primitives::Hash` instead.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because outdated. There's no ac_primitves::Hash Type. No need to point out what Subxt did, because Subxt is constantly evolving as well.

@haerdib
Copy link
Contributor Author

haerdib commented Apr 26, 2023

I updated the PR description, better now?

Regarding the question when to use what: is the comment

/// Wait for the next value from the internal subscription.
/// Upon encounter, it retrieves and decodes the expected `EventDetails`.
//
// On the contrary to `next_events` this function only needs up-to-date metadata
// and is therefore updateable during runtime.

not explanatory enough?

@haerdib
Copy link
Contributor Author

haerdib commented Apr 26, 2023

Do we still need RuntimeEvent

Check out #440 (comment) for more elaborate explanation.
But the short answer would be: no, we don't need it. But I think it would be a waste to not offer it.

@echevrier
Copy link
Contributor

I updated the PR description, better now?
Regarding the question when to use what: is the comment

/// Wait for the next value from the internal subscription.
/// Upon encounter, it retrieves and decodes the expected `EventDetails`.
//
// On the contrary to `next_events` this function only needs up-to-date metadata
// and is therefore updateable during runtime.

not explanatory enough?

It suggests to use every time you can next_events and the next_events_from_metadata when you really need it. Your comment #440 (comment) confirms it. I would like to have this information in the PR description as we do not have examples, which explicitly show the different use cases. This would help the user, without having to click/read the PR and related issues.

@haerdib haerdib changed the title Add next_events_from_metadata Add next_events_from_metadata and rename next_event Apr 26, 2023
@haerdib haerdib merged commit 6e2c9c2 into master Apr 27, 2023
@haerdib haerdib deleted the bh/remove-event-records branch April 27, 2023 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2-breaksapi F7-enhancement Enhances an already existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate usage of EventDetails
3 participants