mirror of https://github.com/status-im/evmc.git
rust: add failure() and success() helpers to ExecutionResult
This commit is contained in:
parent
80f99dfe6b
commit
4eeb42d074
|
@ -39,6 +39,14 @@ impl ExecutionResult {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn failure() -> Self {
|
||||||
|
ExecutionResult::new(ffi::evmc_status_code::EVMC_FAILURE, 0, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn success(_gas_left: i64, _output: Option<Vec<u8>>) -> Self {
|
||||||
|
ExecutionResult::new(ffi::evmc_status_code::EVMC_SUCCESS, _gas_left, _output)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_status_code(&self) -> ffi::evmc_status_code {
|
pub fn get_status_code(&self) -> ffi::evmc_status_code {
|
||||||
self.status_code
|
self.status_code
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,9 @@ extern "C" fn execute(
|
||||||
let is_create = execution_ctx.get_message().kind == ffi::evmc_call_kind::EVMC_CREATE;
|
let is_create = execution_ctx.get_message().kind == ffi::evmc_call_kind::EVMC_CREATE;
|
||||||
|
|
||||||
if is_create {
|
if is_create {
|
||||||
ExecutionResult::new(ffi::evmc_status_code::EVMC_FAILURE, 0, None).into()
|
ExecutionResult::failure().into()
|
||||||
} else {
|
} else {
|
||||||
ExecutionResult::new(
|
ExecutionResult::success(66, Some(vec![0xc0, 0xff, 0xee])).into()
|
||||||
ffi::evmc_status_code::EVMC_SUCCESS,
|
|
||||||
66,
|
|
||||||
Some(vec![0xc0, 0xff, 0xee]),
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue