-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make panic receipt more transparent, make script result handle reverts
- Loading branch information
Showing
5 changed files
with
149 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use fuel_types::Word; | ||
|
||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
#[cfg_attr( | ||
feature = "serde-types-minimal", | ||
derive(serde::Serialize, serde::Deserialize) | ||
)] | ||
pub enum ScriptExecutionResult { | ||
Success, | ||
Revert, | ||
Panic, | ||
// Generic failure case since any u64 is valid here | ||
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), | ||
} | ||
} | ||
} |
Oops, something went wrong.