From 0a031d8bf5dec8001eb9b6a4f44f1bed315bd873 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Thu, 1 Feb 2024 13:52:02 -0500 Subject: [PATCH] fix: prune empty transaction protocol component groups from `map_pools_created` --- substreams/ethereum-balancer/src/modules.rs | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/substreams/ethereum-balancer/src/modules.rs b/substreams/ethereum-balancer/src/modules.rs index 7471c36..0bc9aed 100644 --- a/substreams/ethereum-balancer/src/modules.rs +++ b/substreams/ethereum-balancer/src/modules.rs @@ -41,14 +41,8 @@ pub fn map_pools_created( Ok(tycho::GroupedTransactionProtocolComponents { tx_components: block .transactions() - .map(|tx| tycho::TransactionProtocolComponents { - tx: Some(tycho::Transaction { - hash: tx.hash.clone(), - from: tx.from.clone(), - to: tx.to.clone(), - index: Into::::into(tx.index), - }), - components: tx + .filter_map(|tx| { + let components = tx .logs_with_calls() .filter(|(_, call)| !call.call.state_reverted) .filter_map(|(log, call)| { @@ -58,7 +52,21 @@ pub fn map_pools_created( call.call, )?) }) - .collect::>(), + .collect::>(); + + if !components.is_empty() { + Some(tycho::TransactionProtocolComponents { + tx: Some(tycho::Transaction { + hash: tx.hash.clone(), + from: tx.from.clone(), + to: tx.to.clone(), + index: Into::::into(tx.index), + }), + components, + }) + } else { + None + } }) .collect::>(), })