diff --git a/crates/core/transaction/src/proposal.rs b/crates/core/transaction/src/proposal.rs index 049998953c..ee9fea0c98 100644 --- a/crates/core/transaction/src/proposal.rs +++ b/crates/core/transaction/src/proposal.rs @@ -587,12 +587,22 @@ impl From> for pb::ProposalOutcome { } Outcome::Failed { withdrawn } => { pb::proposal_outcome::Outcome::Failed(pb::proposal_outcome::Failed { - withdrawn_with_reason: withdrawn.into(), + withdrawn: match withdrawn { + Withdrawn::No => None, + Withdrawn::WithReason { reason } => { + Some(pb::proposal_outcome::Withdrawn { reason }) + } + }, }) } Outcome::Slashed { withdrawn } => { pb::proposal_outcome::Outcome::Slashed(pb::proposal_outcome::Slashed { - withdrawn_with_reason: withdrawn.into(), + withdrawn: match withdrawn { + Withdrawn::No => None, + Withdrawn::WithReason { reason } => { + Some(pb::proposal_outcome::Withdrawn { reason }) + } + }, }) } }; @@ -615,14 +625,22 @@ impl TryFrom for Outcome { Outcome::Passed } pb::proposal_outcome::Outcome::Failed(pb::proposal_outcome::Failed { - withdrawn_with_reason, + withdrawn, }) => Outcome::Failed { - withdrawn: withdrawn_with_reason.into(), + withdrawn: if let Some(pb::proposal_outcome::Withdrawn { reason }) = withdrawn { + Withdrawn::WithReason { reason } + } else { + Withdrawn::No + }, }, pb::proposal_outcome::Outcome::Slashed(pb::proposal_outcome::Slashed { - withdrawn_with_reason, + withdrawn, }) => Outcome::Slashed { - withdrawn: withdrawn_with_reason.into(), + withdrawn: if let Some(pb::proposal_outcome::Withdrawn { reason }) = withdrawn { + Withdrawn::WithReason { reason } + } else { + Withdrawn::No + }, }, }, ) @@ -645,12 +663,20 @@ impl From> for pb::ProposalOutcome { } Outcome::Failed { withdrawn } => { pb::proposal_outcome::Outcome::Failed(pb::proposal_outcome::Failed { - withdrawn_with_reason: >::from(withdrawn).map(|()| "".to_string()), + withdrawn: >::from(withdrawn).map(|()| { + pb::proposal_outcome::Withdrawn { + reason: "".to_string(), + } + }), }) } Outcome::Slashed { withdrawn } => { pb::proposal_outcome::Outcome::Slashed(pb::proposal_outcome::Slashed { - withdrawn_with_reason: >::from(withdrawn).map(|()| "".to_string()), + withdrawn: >::from(withdrawn).map(|()| { + pb::proposal_outcome::Withdrawn { + reason: "".to_string(), + } + }), }) } }; @@ -673,14 +699,14 @@ impl TryFrom for Outcome<()> { Outcome::Passed } pb::proposal_outcome::Outcome::Failed(pb::proposal_outcome::Failed { - withdrawn_with_reason, + withdrawn, }) => Outcome::Failed { - withdrawn: >::from(withdrawn_with_reason).try_into()?, + withdrawn: >::from(withdrawn.map(|w| w.reason)).try_into()?, }, pb::proposal_outcome::Outcome::Slashed(pb::proposal_outcome::Slashed { - withdrawn_with_reason, + withdrawn, }) => Outcome::Slashed { - withdrawn: >::from(withdrawn_with_reason).try_into()?, + withdrawn: >::from(withdrawn.map(|w| w.reason)).try_into()?, }, }, )