use fuel_types::Word;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(fuel_types::canonical::Deserialize, fuel_types::canonical::Serialize)]
#[repr(u64)]
pub enum ScriptExecutionResult {
Success,
Revert,
Panic,
GenericFailure(u64),
}
impl From<ScriptExecutionResult> for Word {
fn from(result: ScriptExecutionResult) -> Self {
match result {
ScriptExecutionResult::Success => 0x00,
ScriptExecutionResult::Revert => 0x01,
ScriptExecutionResult::Panic => 0x02,
ScriptExecutionResult::GenericFailure(value) => value,
}
}
}
impl From<Word> for ScriptExecutionResult {
fn from(value: u64) -> Self {
match value {
0x00 => Self::Success,
0x01 => Self::Revert,
0x02 => Self::Panic,
value => Self::GenericFailure(value),
}
}
}