diff --git a/notification-server/src/processor.rs b/notification-server/src/processor.rs index ad29fabc..dcb0bbd2 100644 --- a/notification-server/src/processor.rs +++ b/notification-server/src/processor.rs @@ -11,9 +11,9 @@ use concordium_rust_sdk::base::contracts_common::AccountAddress; use concordium_rust_sdk::types::Address::Account; use futures::{Stream, StreamExt}; -fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Option> { +fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Vec { match &effects { - AccountTransactionEffects::ContractUpdateIssued { effects } => Some( + AccountTransactionEffects::ContractUpdateIssued { effects } => effects .iter() .flat_map(|effect| match effect { @@ -33,8 +33,7 @@ fn get_cis2_events_addresses(effects: &AccountTransactionEffects) -> Option vec![], }) .collect(), - ), - _ => None, + _ => vec![] } } @@ -53,26 +52,18 @@ pub async fn process( ) -> Vec { transactions .filter_map(|result| async move { result.ok() }) - .filter_map(|t| async move { - match t.details { + .map(|t| futures::stream::iter(match t.details { AccountTransaction(ref account_transaction) => { if is_notification_emitting_transaction_effect(&account_transaction.effects) { - Some( - t.affected_addresses() - .into_iter() - .map(|addr| addr) - .collect::>(), - ) + t.affected_addresses() } else { get_cis2_events_addresses(&account_transaction.effects) } } - _ => None, + _ => vec![], } - }) - .collect::>>() - .await - .into_iter() + )) .flatten() - .collect() + .collect::>() + .await }