cyfs_base_meta/
evm_def.rs1use std::borrow::Cow;
2use primitive_types::H256;
3use cyfs_base::ObjectId;
4
5#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum ExitReason {
8 Succeed(ExitSucceed),
10 Error(ExitError),
12 Revert(ExitRevert),
14 Fatal(ExitFatal),
17}
18
19impl ExitReason {
20 pub fn is_succeed(&self) -> bool {
22 match self {
23 Self::Succeed(_) => true,
24 _ => false,
25 }
26 }
27
28 pub fn is_error(&self) -> bool {
30 match self {
31 Self::Error(_) => true,
32 _ => false,
33 }
34 }
35
36 pub fn is_revert(&self) -> bool {
38 match self {
39 Self::Revert(_) => true,
40 _ => false,
41 }
42 }
43
44 pub fn is_fatal(&self) -> bool {
46 match self {
47 Self::Fatal(_) => true,
48 _ => false,
49 }
50 }
51}
52
53#[derive(Clone, Copy, Debug, Eq, PartialEq)]
55#[cfg_attr(feature = "with-codec", derive(codec::Encode, codec::Decode))]
56#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
57pub enum ExitSucceed {
58 Stopped,
60 Returned,
62 Suicided,
64}
65
66impl From<ExitSucceed> for ExitReason {
67 fn from(s: ExitSucceed) -> Self {
68 Self::Succeed(s)
69 }
70}
71
72#[derive(Clone, Copy, Debug, Eq, PartialEq)]
74pub enum ExitRevert {
75 Reverted,
77}
78
79impl From<ExitRevert> for ExitReason {
80 fn from(s: ExitRevert) -> Self {
81 Self::Revert(s)
82 }
83}
84
85#[derive(Clone, Debug, Eq, PartialEq)]
87#[cfg_attr(feature = "with-codec", derive(codec::Encode, codec::Decode))]
88#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
89pub enum ExitError {
90 StackUnderflow,
92 StackOverflow,
94 InvalidJump,
96 InvalidRange,
98 DesignatedInvalid,
100 CallTooDeep,
102 CreateCollision,
104 CreateContractLimit,
106
107 OutOfOffset,
110 OutOfGas,
112 OutOfFund,
114
115 PCUnderflow,
117 CreateEmpty,
119
120 Other(Cow<'static, str>),
122}
123
124impl From<ExitError> for ExitReason {
125 fn from(s: ExitError) -> Self {
126 Self::Error(s)
127 }
128}
129
130#[derive(Clone, Debug, Eq, PartialEq)]
132#[cfg_attr(feature = "with-codec", derive(codec::Encode, codec::Decode))]
133#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
134pub enum ExitFatal {
135 NotSupported,
137 UnhandledInterrupt,
139 CallErrorAsFatal(ExitError),
141
142 Other(Cow<'static, str>),
144}
145
146impl From<ExitFatal> for ExitReason {
147 fn from(s: ExitFatal) -> Self {
148 Self::Fatal(s)
149 }
150}
151
152extern crate alloc;
153
154pub type Bytes = alloc::vec::Vec<u8>;
155
156#[derive(Clone, Debug, PartialEq, Eq)]
157pub struct Log {
158 pub address: ObjectId,
159 pub topics: Vec<H256>,
160 pub data: Bytes,
161}