From 9db1a88f3d9da8f85f4f6e0601d1b06862f29e58 Mon Sep 17 00:00:00 2001 From: DaughterOfMars Date: Thu, 15 Feb 2024 14:49:07 -0500 Subject: [PATCH] Add strum impls to failure enums (#2004) * Add strum impls to failure enums * missed tag --- sdk/src/types/api/core.rs | 14 +++++++++++++- sdk/src/types/block/semantic/error.rs | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sdk/src/types/api/core.rs b/sdk/src/types/api/core.rs index a6538b4e63..7186ae9edc 100644 --- a/sdk/src/types/api/core.rs +++ b/sdk/src/types/api/core.rs @@ -370,8 +370,20 @@ pub enum TransactionState { } /// Describes the reason of a block failure. -#[derive(Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr)] +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + serde_repr::Serialize_repr, + serde_repr::Deserialize_repr, + strum::FromRepr, + strum::EnumString, + strum::AsRefStr, +)] #[serde(rename_all = "camelCase")] +#[strum(serialize_all = "camelCase")] #[non_exhaustive] #[repr(u8)] pub enum BlockFailureReason { diff --git a/sdk/src/types/block/semantic/error.rs b/sdk/src/types/block/semantic/error.rs index fbe660eb0e..921ed2dc90 100644 --- a/sdk/src/types/block/semantic/error.rs +++ b/sdk/src/types/block/semantic/error.rs @@ -7,8 +7,11 @@ use crate::types::block::Error; /// Describes the reason of a transaction failure. #[repr(u8)] -#[derive(Debug, Copy, Clone, Eq, PartialEq, packable::Packable, strum::FromRepr)] +#[derive( + Debug, Copy, Clone, Eq, PartialEq, packable::Packable, strum::FromRepr, strum::EnumString, strum::AsRefStr, +)] #[cfg_attr(feature = "serde", derive(serde_repr::Serialize_repr, serde_repr::Deserialize_repr))] +#[strum(serialize_all = "camelCase")] #[packable(unpack_error = Error)] #[packable(tag_type = u8, with_error = Error::InvalidTransactionFailureReason)] #[non_exhaustive]