revm_interpreter/interpreter_action/
eof_create_inputs.rs1use bytecode::Eof;
2use primitives::{Address, Bytes, U256};
3
4use super::CallInput;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18pub enum EOFCreateKind {
19 Tx {
20 initdata: Bytes,
21 },
22 Opcode {
23 initcode: Eof,
24 input: CallInput,
25 created_address: Address,
26 },
27}
28
29impl EOFCreateKind {
30 pub fn created_address(&self) -> Option<&Address> {
32 match self {
33 EOFCreateKind::Opcode {
34 created_address, ..
35 } => Some(created_address),
36 EOFCreateKind::Tx { .. } => None,
37 }
38 }
39}
40
41impl Default for EOFCreateKind {
42 fn default() -> Self {
43 EOFCreateKind::Opcode {
44 initcode: Eof::default(),
45 input: CallInput::Bytes(Bytes::default()),
46 created_address: Address::default(),
47 }
48 }
49}
50
51#[derive(Debug, Default, Clone, PartialEq, Eq)]
53#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
54pub struct EOFCreateInputs {
55 pub caller: Address,
57 pub value: U256,
59 pub gas_limit: u64,
61 pub kind: EOFCreateKind,
63}
64
65impl EOFCreateInputs {
66 pub fn new(caller: Address, value: U256, gas_limit: u64, kind: EOFCreateKind) -> Self {
70 EOFCreateInputs {
72 caller,
73 value,
74 gas_limit,
75 kind,
76 }
77 }
78
79 pub fn new_opcode(
81 caller: Address,
82 created_address: Address,
83 value: U256,
84 eof_init_code: Eof,
85 gas_limit: u64,
86 input: CallInput,
87 ) -> EOFCreateInputs {
88 EOFCreateInputs::new(
89 caller,
90 value,
91 gas_limit,
92 EOFCreateKind::Opcode {
93 initcode: eof_init_code,
94 input,
95 created_address,
96 },
97 )
98 }
99}