kona_interop/
traits.rs

1//! Traits for the `kona-interop` crate.
2
3use alloc::{boxed::Box, vec::Vec};
4use alloy_consensus::Header;
5use alloy_primitives::B256;
6use async_trait::async_trait;
7use core::{error::Error, fmt::Display};
8use op_alloy_consensus::OpReceiptEnvelope;
9
10/// Describes the interface of the interop data provider. This provider is multiplexed over several
11/// chains, with each method consuming a chain ID to determine the target chain.
12#[async_trait]
13pub trait InteropProvider {
14    /// The error type for the provider.
15    type Error: Error + Display;
16
17    /// Fetch a [Header] by its number.
18    async fn header_by_number(&self, chain_id: u64, number: u64) -> Result<Header, Self::Error>;
19
20    /// Fetch all receipts for a given block by number.
21    async fn receipts_by_number(
22        &self,
23        chain_id: u64,
24        number: u64,
25    ) -> Result<Vec<OpReceiptEnvelope>, Self::Error>;
26
27    /// Fetch all receipts for a given block by hash.
28    async fn receipts_by_hash(
29        &self,
30        chain_id: u64,
31        block_hash: B256,
32    ) -> Result<Vec<OpReceiptEnvelope>, Self::Error>;
33}