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