Skip to content

Commit 99b4c5e

Browse files
committed
refacto: remove entities dependency to messages
1 parent 92ecbe8 commit 99b4c5e

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

mithril-common/src/entities/cardano_transactions_set_proof.rs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::crypto_helper::{MKMapProof, ProtocolMkProof};
22
use crate::entities::TransactionHash;
3-
use crate::messages::CardanoTransactionsSetProofMessagePart;
4-
use crate::{StdError, StdResult};
3+
use crate::StdResult;
54

65
use super::BlockRange;
76

@@ -15,10 +14,10 @@ cfg_test_tools! {
1514
#[derive(Clone, Debug, PartialEq)]
1615
pub struct CardanoTransactionsSetProof {
1716
/// Hashes of the certified transactions
18-
transactions_hashes: Vec<TransactionHash>,
17+
pub transactions_hashes: Vec<TransactionHash>,
1918

2019
/// Proof of the transactions
21-
transactions_proof: ProtocolMkProof,
20+
pub transactions_proof: ProtocolMkProof,
2221
}
2322

2423
impl CardanoTransactionsSetProof {
@@ -104,28 +103,6 @@ impl CardanoTransactionsSetProof {
104103
}
105104
}
106105

107-
impl TryFrom<CardanoTransactionsSetProof> for CardanoTransactionsSetProofMessagePart {
108-
type Error = StdError;
109-
110-
fn try_from(proof: CardanoTransactionsSetProof) -> Result<Self, Self::Error> {
111-
Ok(Self {
112-
transactions_hashes: proof.transactions_hashes,
113-
proof: proof.transactions_proof.to_json_hex()?,
114-
})
115-
}
116-
}
117-
118-
impl TryFrom<CardanoTransactionsSetProofMessagePart> for CardanoTransactionsSetProof {
119-
type Error = StdError;
120-
121-
fn try_from(proof: CardanoTransactionsSetProofMessagePart) -> Result<Self, Self::Error> {
122-
Ok(Self {
123-
transactions_hashes: proof.transactions_hashes,
124-
transactions_proof: ProtocolMkProof::from_json_hex(&proof.proof)?,
125-
})
126-
}
127-
}
128-
129106
#[cfg(test)]
130107
mod tests {
131108
use super::*;

mithril-common/src/messages/message_parts/cardano_transactions_set_proof.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use crate::entities::{HexEncodedKey, TransactionHash};
1+
use crate::{
2+
crypto_helper::ProtocolMkProof,
3+
entities::{CardanoTransactionsSetProof, HexEncodedKey, TransactionHash},
4+
StdError,
5+
};
26
use serde::{Deserialize, Serialize};
37

48
#[cfg(target_family = "wasm")]
@@ -23,3 +27,25 @@ impl CardanoTransactionsSetProofMessagePart {
2327
}
2428
}
2529
}
30+
31+
impl TryFrom<CardanoTransactionsSetProof> for CardanoTransactionsSetProofMessagePart {
32+
type Error = StdError;
33+
34+
fn try_from(proof: CardanoTransactionsSetProof) -> Result<Self, Self::Error> {
35+
Ok(Self {
36+
transactions_hashes: proof.transactions_hashes,
37+
proof: proof.transactions_proof.to_json_hex()?,
38+
})
39+
}
40+
}
41+
42+
impl TryFrom<CardanoTransactionsSetProofMessagePart> for CardanoTransactionsSetProof {
43+
type Error = StdError;
44+
45+
fn try_from(proof: CardanoTransactionsSetProofMessagePart) -> Result<Self, Self::Error> {
46+
Ok(Self {
47+
transactions_hashes: proof.transactions_hashes,
48+
transactions_proof: ProtocolMkProof::from_json_hex(&proof.proof)?,
49+
})
50+
}
51+
}

0 commit comments

Comments
 (0)