mithril_common/messages/message_parts/
cardano_transactions_set_proof.rs1use crate::{
2 StdError,
3 crypto_helper::ProtocolMkProof,
4 entities::{CardanoTransactionsSetProof, HexEncodedKey, TransactionHash},
5};
6use serde::{Deserialize, Serialize};
7
8#[cfg(target_family = "wasm")]
9use wasm_bindgen::prelude::*;
10
11#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
13#[cfg_attr(target_family = "wasm", wasm_bindgen(getter_with_clone))]
14pub struct CardanoTransactionsSetProofMessagePart {
15 pub transactions_hashes: Vec<TransactionHash>,
17
18 pub proof: HexEncodedKey,
20}
21
22impl TryFrom<CardanoTransactionsSetProof> for CardanoTransactionsSetProofMessagePart {
23 type Error = StdError;
24
25 fn try_from(proof: CardanoTransactionsSetProof) -> Result<Self, Self::Error> {
26 Ok(Self {
27 transactions_hashes: proof.transactions_hashes,
28 proof: proof.transactions_proof.to_json_hex()?,
29 })
30 }
31}
32
33impl TryFrom<CardanoTransactionsSetProofMessagePart> for CardanoTransactionsSetProof {
34 type Error = StdError;
35
36 fn try_from(proof: CardanoTransactionsSetProofMessagePart) -> Result<Self, Self::Error> {
37 Ok(Self {
38 transactions_hashes: proof.transactions_hashes,
39 transactions_proof: ProtocolMkProof::from_json_hex(&proof.proof)?,
40 })
41 }
42}