forked from bluealloy/revm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinner_models.rs
98 lines (91 loc) · 2.71 KB
/
inner_models.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
pub use crate::primitives::CreateScheme;
use crate::primitives::{Address, Bytes, U256};
/// Inputs for a call.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CallInputs {
/// The target of the call.
pub contract: Address,
/// The transfer, if any, in this call.
pub transfer: Transfer,
/// The call data of the call.
pub input: Bytes,
/// The gas limit of the call.
pub gas_limit: u64,
/// The context of the call.
pub context: CallContext,
/// Whether this is a static call.
pub is_static: bool,
}
/// Inputs for a create call.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateInputs {
/// Caller address of the EVM.
pub caller: Address,
/// The create scheme.
pub scheme: CreateScheme,
/// The value to transfer.
pub value: U256,
/// The init code of the contract.
pub init_code: Bytes,
/// The gas limit of the call.
pub gas_limit: u64,
}
/// Call schemes.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum CallScheme {
/// `CALL`
Call,
/// `CALLCODE`
CallCode,
/// `DELEGATECALL`
DelegateCall,
/// `STATICCALL`
StaticCall,
}
/// Context of a runtime call.
#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CallContext {
/// Execution address.
pub address: Address,
/// Caller address of the EVM.
pub caller: Address,
/// The address the contract code was loaded from, if any.
pub code_address: Address,
/// Apparent value of the EVM.
pub apparent_value: U256,
/// The scheme used for the call.
pub scheme: CallScheme,
}
impl Default for CallContext {
fn default() -> Self {
CallContext {
address: Address::default(),
caller: Address::default(),
code_address: Address::default(),
apparent_value: U256::default(),
scheme: CallScheme::Call,
}
}
}
/// Transfer from source to target, with given value.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Transfer {
/// The source address.
pub source: Address,
/// The target address.
pub target: Address,
/// The transfer value.
pub value: U256,
}
/// Result of a call that resulted in a self destruct.
#[derive(Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SelfDestructResult {
pub had_value: bool,
pub target_exists: bool,
pub is_cold: bool,
pub previously_destroyed: bool,
}