use alloy_primitives::{Address, B256, U256};
pub use alloy_primitives::Log;
#[derive(Debug, Clone)]
pub struct TxProcessingOutputOwned {
pub status: bool,
pub output: Vec<u8>,
pub contract_address: Option<Address>,
pub gas_used: u64,
pub gas_refunded: u64,
pub computational_native_used: u64,
pub native_used: u64,
pub pubdata_used: u64,
}
#[derive(Debug, Clone)]
pub struct StorageWrite {
pub key: B256,
pub value: B256,
pub account: Address,
pub account_key: B256,
}
#[derive(Debug, Clone)]
pub struct AccountDiff {
pub address: Address,
pub nonce: u64,
pub balance: U256,
pub bytecode_hash: B256,
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct TxOutput {
pub execution_result: ExecutionResult,
pub gas_used: u64,
pub gas_refunded: u64,
pub computational_native_used: u64,
pub native_used: u64,
pub pubdata_used: u64,
pub contract_address: Option<Address>,
pub logs: Vec<Log>,
pub l2_to_l1_logs: Vec<L2ToL1LogWithPreimage>,
pub storage_writes: Vec<StorageWrite>,
}
impl TxOutput {
pub fn is_success(&self) -> bool {
matches!(self.execution_result, ExecutionResult::Success(_))
}
pub fn as_returned_bytes(&self) -> &[u8] {
match &self.execution_result {
ExecutionResult::Success(o) => match o {
ExecutionOutput::Call(vec) => vec,
ExecutionOutput::Create(vec, _) => vec,
},
ExecutionResult::Revert(vec) => vec,
}
}
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum ExecutionOutput {
Call(Vec<u8>),
Create(Vec<u8>, Address),
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum ExecutionResult {
Success(ExecutionOutput),
Revert(Vec<u8>),
}
#[derive(Default, Debug, Clone)]
pub struct L2ToL1Log {
pub l2_shard_id: u8,
pub is_service: bool,
pub tx_number_in_block: u16,
pub sender: Address,
pub key: B256,
pub value: B256,
}
#[derive(Debug, Clone)]
pub struct L2ToL1LogWithPreimage {
pub log: L2ToL1Log,
pub preimage: Option<Vec<u8>>,
}