use ex3_node_error::{Error, OtherError};
use ex3_serde::cbor;
use crate::tx_type_dto::Withdrawal;
use crate::{PayloadDecoder, Result};
impl PayloadDecoder {
/// Decode the payload to a withdrawal
pub fn decode_to_withdrawal(payload: &[u8]) -> Result<ex3_node_types::transaction::Withdrawal> {
let withdrawal = cbor::deserialize::<Withdrawal>(payload).map_err(|e| {
<OtherError as Into<Error>>::into(OtherError::new(format!(
"Failed to deserialize payload to Withdrawal: {}",
e
)))
})?;
Ok(withdrawal.into())
}
}