Emit ContractReverted error when revert flag is set (#10481)

* Emit `ContractReverted` error when revert flag is set

* `is_success()` -> `did_revert()`
This commit is contained in:
Alexander Theißen
2021-12-15 08:35:05 +01:00
committed by GitHub
parent 7ee25416c2
commit 1939567a79
5 changed files with 136 additions and 19 deletions
+9 -3
View File
@@ -131,9 +131,9 @@ pub struct ExecReturnValue {
}
impl ExecReturnValue {
/// We understand the absense of a revert flag as success.
pub fn is_success(&self) -> bool {
!self.flags.contains(ReturnFlags::REVERT)
/// The contract did revert all storage changes.
pub fn did_revert(&self) -> bool {
self.flags.contains(ReturnFlags::REVERT)
}
}
@@ -170,6 +170,12 @@ pub enum Code<Hash> {
Existing(Hash),
}
impl<T: Into<Vec<u8>>, Hash> From<T> for Code<Hash> {
fn from(from: T) -> Self {
Code::Upload(Bytes(from.into()))
}
}
/// The amount of balance that was either charged or refunded in order to pay for storage.
#[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]