diff --git a/starknet-core/src/types/execution_result.rs b/starknet-core/src/types/execution_result.rs index 3479d554..81c6b91b 100644 --- a/starknet-core/src/types/execution_result.rs +++ b/starknet-core/src/types/execution_result.rs @@ -61,20 +61,17 @@ impl<'de> Deserialize<'de> for ExecutionResult { #[cfg_attr(feature = "no_unknown_fields", serde(deny_unknown_fields))] struct Raw { execution_status: TransactionExecutionStatus, - revert_reason: Option, + #[serde(default)] + revert_reason: String, } let raw = Raw::deserialize(deserializer)?; - match (raw.execution_status, raw.revert_reason) { - (TransactionExecutionStatus::Succeeded, None) => Ok(Self::Succeeded), - (TransactionExecutionStatus::Reverted, Some(reason)) => Ok(Self::Reverted { reason }), - (TransactionExecutionStatus::Succeeded, Some(_)) => Err(serde::de::Error::custom( - "field `revert_reason` must not exist when `execution_status` is `SUCCEEDED`", - )), - (TransactionExecutionStatus::Reverted, None) => Err(serde::de::Error::custom( - "field `revert_reason` missing when `execution_status` is `REVERTED`", - )), + match raw.execution_status { + TransactionExecutionStatus::Succeeded => Ok(Self::Succeeded), + TransactionExecutionStatus::Reverted => Ok(Self::Reverted { + reason: raw.revert_reason, + }), } } }