neo_devpack_solidity/runtime/runtime_parts/runtime_impl/
execution_result.rs1use super::*;
2
3impl ExecutionResult {
4 pub fn is_success(&self) -> bool {
6 self.success && self.exception.is_none()
7 }
8
9 pub fn gas_efficiency(&self) -> f64 {
11 if self.gas_limit == 0 {
12 0.0
13 } else {
14 (self.gas_used as f64) / (self.gas_limit as f64)
15 }
16 }
17
18 pub fn gas_remaining(&self) -> u64 {
20 self.gas_limit.saturating_sub(self.gas_used)
21 }
22
23 pub fn out_of_gas(&self) -> bool {
25 matches!(
26 self.exception,
27 Some(RuntimeException {
28 exception_type: ExceptionType::OutOfGas,
29 ..
30 })
31 )
32 }
33
34 pub fn return_string(&self) -> Option<String> {
36 String::from_utf8(self.return_data.clone()).ok()
37 }
38
39 pub fn return_hex(&self) -> String {
41 hex::encode(&self.return_data)
42 }
43
44 pub fn has_state_changes(&self) -> bool {
46 !self.state_changes.is_empty()
47 }
48
49 pub fn log_count(&self) -> usize {
51 self.logs.len()
52 }
53}