Skip to main content

revm_interpreter/interpreter/
input.rs

1use crate::{interpreter_types::InputsTr, CallInput};
2use primitives::{Address, U256};
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6/// Inputs for the interpreter that are used for execution of the call.
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8#[derive(Clone, Debug, Default, PartialEq, Eq)]
9pub struct InputsImpl {
10    /// Storage of this account address is being used.
11    pub target_address: Address,
12    /// Address of the bytecode that is being executed. This field is not used inside Interpreter but it is used
13    /// by dependent projects that would need to know the address of the bytecode.
14    pub bytecode_address: Option<Address>,
15    /// Address of the caller of the call.
16    pub caller_address: Address,
17    /// Input data for the call.
18    pub input: CallInput,
19    /// Value of the call.
20    pub call_value: U256,
21    /// Call depth of the frame this interpreter executes (0 for the first frame).
22    pub depth: usize,
23}
24
25impl InputsTr for InputsImpl {
26    fn target_address(&self) -> Address {
27        self.target_address
28    }
29
30    fn depth(&self) -> usize {
31        self.depth
32    }
33
34    fn caller_address(&self) -> Address {
35        self.caller_address
36    }
37
38    fn bytecode_address(&self) -> Option<&Address> {
39        self.bytecode_address.as_ref()
40    }
41
42    fn input(&self) -> &CallInput {
43        &self.input
44    }
45
46    fn call_value(&self) -> U256 {
47        self.call_value
48    }
49}