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