use sov_rollup_interface::da::{BlobReaderTrait, DaSpec};
use sov_state::{AccessoryWorkingSet, WorkingSet};
use crate::transaction::Transaction;
use crate::{Context, Spec};
pub trait TxHooks {
type Context: Context;
fn pre_dispatch_tx_hook(
&self,
tx: &Transaction<Self::Context>,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<<Self::Context as Spec>::Address>;
fn post_dispatch_tx_hook(
&self,
tx: &Transaction<Self::Context>,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<()>;
}
pub trait ApplyBlobHooks<B: BlobReaderTrait> {
type Context: Context;
type BlobResult;
fn begin_blob_hook(
&self,
blob: &mut B,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<()>;
fn end_blob_hook(
&self,
result: Self::BlobResult,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
) -> anyhow::Result<()>;
}
pub trait SlotHooks<Da: DaSpec> {
type Context: Context;
fn begin_slot_hook(
&self,
slot_header: &Da::BlockHeader,
validity_condition: &Da::ValidityCondition,
working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>,
);
fn end_slot_hook(&self, working_set: &mut WorkingSet<<Self::Context as Spec>::Storage>);
fn finalize_slot_hook(
&self,
root_hash: [u8; 32],
accesorry_working_set: &mut AccessoryWorkingSet<<Self::Context as Spec>::Storage>,
);
}