use crate::{Gas, InstructionResult, InterpreterResult};
use core::ops::Range;
use primitives::{Bytes, Log};
use std::vec::Vec;
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CallOutcome {
pub result: InterpreterResult,
pub memory_offset: Range<usize>,
pub was_precompile_called: bool,
pub precompile_call_logs: Vec<Log>,
pub charged_new_account_state_gas: bool,
}
impl CallOutcome {
pub const fn new(result: InterpreterResult, memory_offset: Range<usize>) -> Self {
Self {
result,
memory_offset,
was_precompile_called: false,
precompile_call_logs: Vec::new(),
charged_new_account_state_gas: false,
}
}
pub fn new_oog(gas_limit: u64, memory_offset: Range<usize>, reservoir: u64) -> Self {
Self::new(
InterpreterResult::new_oog(gas_limit, reservoir),
memory_offset,
)
}
pub const fn instruction_result(&self) -> &InstructionResult {
&self.result.result
}
pub const fn gas(&self) -> Gas {
self.result.gas
}
pub const fn output(&self) -> &Bytes {
&self.result.output
}
pub const fn memory_start(&self) -> usize {
self.memory_offset.start
}
pub fn memory_length(&self) -> usize {
self.memory_offset.len()
}
}