use crate::PipelineErrorKind;
use alloc::{boxed::Box, sync::Arc, vec::Vec};
use alloy_consensus::{Header, Receipt, TxEnvelope};
use alloy_primitives::B256;
use async_trait::async_trait;
use core::fmt::Display;
use kona_genesis::{RollupConfig, SystemConfig};
use kona_protocol::{BatchValidationProvider, BlockInfo};
#[async_trait]
pub trait ChainProvider {
type Error: Display + Into<PipelineErrorKind>;
async fn header_by_hash(&mut self, hash: B256) -> Result<Header, Self::Error>;
async fn block_info_by_number(&mut self, number: u64) -> Result<BlockInfo, Self::Error>;
async fn receipts_by_hash(&mut self, hash: B256) -> Result<Vec<Receipt>, Self::Error>;
async fn block_info_and_transactions_by_hash(
&mut self,
hash: B256,
) -> Result<(BlockInfo, Vec<TxEnvelope>), Self::Error>;
}
#[async_trait]
pub trait L2ChainProvider: BatchValidationProviderDerive {
type Error: Display + Into<PipelineErrorKind>;
async fn system_config_by_number(
&mut self,
number: u64,
rollup_config: Arc<RollupConfig>,
) -> Result<SystemConfig, <Self as L2ChainProvider>::Error>;
}
pub trait BatchValidationProviderDerive: BatchValidationProvider {}
impl<T> BatchValidationProviderDerive for T
where
T: BatchValidationProvider,
<T as BatchValidationProvider>::Error: Into<PipelineErrorKind>,
{
}