revm_interpreter/
interpreter_action.rs

1mod call_inputs;
2mod call_outcome;
3mod create_inputs;
4mod create_outcome;
5mod eof_create_inputs;
6
7pub use call_inputs::{CallInputs, CallScheme, CallValue};
8pub use call_outcome::CallOutcome;
9pub use create_inputs::{CreateInputs, CreateScheme};
10pub use create_outcome::CreateOutcome;
11pub use eof_create_inputs::{EOFCreateInputs, EOFCreateKind};
12
13use crate::InterpreterResult;
14use std::boxed::Box;
15
16#[derive(Clone, Debug, Default, PartialEq, Eq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18pub enum InterpreterAction {
19    /// CALL, CALLCODE, DELEGATECALL, STATICCALL
20    /// or EOF EXT instruction called.
21    Call { inputs: Box<CallInputs> },
22    /// CREATE or CREATE2 instruction called.
23    Create { inputs: Box<CreateInputs> },
24    /// EOF CREATE instruction called.
25    EOFCreate { inputs: Box<EOFCreateInputs> },
26    /// Interpreter finished execution.
27    Return { result: InterpreterResult },
28    /// No action
29    #[default]
30    None,
31}
32
33impl InterpreterAction {
34    /// Returns true if action is call.
35    pub fn is_call(&self) -> bool {
36        matches!(self, InterpreterAction::Call { .. })
37    }
38
39    /// Returns true if action is create.
40    pub fn is_create(&self) -> bool {
41        matches!(self, InterpreterAction::Create { .. })
42    }
43
44    /// Returns true if action is return.
45    pub fn is_return(&self) -> bool {
46        matches!(self, InterpreterAction::Return { .. })
47    }
48
49    /// Returns true if action is none.
50    pub fn is_none(&self) -> bool {
51        matches!(self, InterpreterAction::None)
52    }
53
54    /// Returns true if action is some.
55    pub fn is_some(&self) -> bool {
56        !self.is_none()
57    }
58
59    /// Returns result if action is return.
60    pub fn into_result_return(self) -> Option<InterpreterResult> {
61        match self {
62            InterpreterAction::Return { result } => Some(result),
63            _ => None,
64        }
65    }
66}