mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 19:25:55 +00:00
Filter one or multiple events by type from an EventSubscription (#461)
* Split events.rs into multiple files and start work on FilterEvents * First pass filtering event(s) * Tweak event examples to show filter_events * cargo clippy + fmt * consistify and tidy * cargo fmt * Tweak a couple of comments * Expose phase and block_hash of filtered events, too * cargo fmt * expose FilteredEventDetails * Add docs * cargo clippy * remove FilterEvents knowledge of EventSubscription so it's easier to unit test * unit test filter_events * tweak an integration test to use filter_events * cargo fmt * cargo clippy * Tweak a comment Co-authored-by: David <dvdplm@gmail.com> Co-authored-by: David <dvdplm@gmail.com>
This commit is contained in:
@@ -63,11 +63,11 @@ async fn tx_basic_transfer() -> Result<(), subxt::Error<DispatchError>> {
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
let event = events
|
||||
.find_first_event::<balances::events::Transfer>()
|
||||
.find_first::<balances::events::Transfer>()
|
||||
.expect("Failed to decode balances::events::Transfer")
|
||||
.expect("Failed to find balances::events::Transfer");
|
||||
let _extrinsic_success = events
|
||||
.find_first_event::<system::events::ExtrinsicSuccess>()
|
||||
.find_first::<system::events::ExtrinsicSuccess>()
|
||||
.expect("Failed to decode ExtrinisicSuccess")
|
||||
.expect("Failed to find ExtrinisicSuccess");
|
||||
|
||||
@@ -125,7 +125,7 @@ async fn storage_balance_lock() -> Result<(), subxt::Error<DispatchError>> {
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
.find_first_event::<system::events::ExtrinsicSuccess>()?
|
||||
.find_first::<system::events::ExtrinsicSuccess>()?
|
||||
.expect("No ExtrinsicSuccess Event found");
|
||||
|
||||
let locks = cxt
|
||||
@@ -205,7 +205,7 @@ async fn transfer_implicit_subscription() {
|
||||
.wait_for_finalized_success()
|
||||
.await
|
||||
.unwrap()
|
||||
.find_first_event::<balances::events::Transfer>()
|
||||
.find_first::<balances::events::Transfer>()
|
||||
.expect("Can decode events")
|
||||
.expect("Can find balance transfer event");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user