From eba5b500903ff9c8ea22a08f7ca9afafae994612 Mon Sep 17 00:00:00 2001 From: refcell Date: Sun, 28 Apr 2024 16:40:32 -0700 Subject: [PATCH] fix(derive): Ethereum Data Source (#159) * fix(derive): ethereum data source * fix(derive): non-optional ethereum da fields --- crates/derive/src/sources/ethereum.rs | 39 ++++++++++++--------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/crates/derive/src/sources/ethereum.rs b/crates/derive/src/sources/ethereum.rs index 8055d568d..64df7c2ba 100644 --- a/crates/derive/src/sources/ethereum.rs +++ b/crates/derive/src/sources/ethereum.rs @@ -8,7 +8,7 @@ use crate::{ }; use alloc::{boxed::Box, fmt::Debug}; use alloy_primitives::{Address, Bytes}; -use anyhow::{anyhow, Result}; +use anyhow::Result; use async_trait::async_trait; /// A factory for creating an Ethereum data source provider. @@ -58,28 +58,23 @@ where block_ref: &BlockInfo, batcher_address: Address, ) -> Result { - if let Some(ecotone) = self.ecotone_timestamp { - let source = (block_ref.timestamp >= ecotone) - .then(|| { - EthereumDataSourceVariant::Blob(BlobSource::new( - self.chain_provider.clone(), - self.blob_provider.clone(), - batcher_address, - *block_ref, - self.signer, - )) - }) - .unwrap_or_else(|| { - EthereumDataSourceVariant::Calldata(CalldataSource::new( - self.chain_provider.clone(), - batcher_address, - *block_ref, - self.signer, - )) - }); - Ok(source) + let ecotone_enabled = + self.ecotone_timestamp.map(|e| block_ref.timestamp >= e).unwrap_or(false); + if ecotone_enabled { + Ok(EthereumDataSourceVariant::Blob(BlobSource::new( + self.chain_provider.clone(), + self.blob_provider.clone(), + batcher_address, + *block_ref, + self.signer, + ))) } else { - Err(anyhow!("No data source available")) + Ok(EthereumDataSourceVariant::Calldata(CalldataSource::new( + self.chain_provider.clone(), + batcher_address, + *block_ref, + self.signer, + ))) } } }