Skip to content

Commit d183401

Browse files
committed
fix(cardano-blockchain-types): impl display for cip36
Signed-off-by: bkioshn <[email protected]>
1 parent 0e9b3e8 commit d183401

File tree

1 file changed

+21
-0
lines changed
  • rust/cardano-blockchain-types/src/metadata/cip36

1 file changed

+21
-0
lines changed

rust/cardano-blockchain-types/src/metadata/cip36/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,27 @@ pub struct Cip36 {
4444
err_report: ProblemReport,
4545
}
4646

47+
impl fmt::Display for Cip36 {
48+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
49+
write!(
50+
f,
51+
"Cip36 {{ network: {network}, slot: {slot:?}, txn_idx: {txn_idx:?}, is_catalyst_strict: {is_catalyst_strict}, key_registration: {key_registration:?}, registration_witness: {registration_witness:?}, validation: {{ signature: {is_valid_signature}, payment_address_network: {is_valid_payment_address_network}, voting_keys: {is_valid_voting_keys}, purpose: {is_valid_purpose} }}, err_report: {err_report} }}",
52+
key_registration = self.key_registration,
53+
registration_witness = self.registration_witness,
54+
network = self.network,
55+
slot = self.slot,
56+
txn_idx = self.txn_idx,
57+
is_catalyst_strict = self.is_catalyst_strict,
58+
is_valid_signature = self.is_valid_signature,
59+
is_valid_payment_address_network = self.is_valid_payment_address_network,
60+
is_valid_voting_keys = self.is_valid_voting_keys,
61+
is_valid_purpose = self.is_valid_purpose,
62+
err_report = serde_json::to_string(&self.err_report)
63+
.unwrap_or_else(|_| String::from("Failed to serialize ProblemReport"))
64+
)
65+
}
66+
}
67+
4768
/// CIP-36 Catalyst registration error
4869
#[allow(dead_code, clippy::module_name_repetitions)]
4970
pub struct Cip36Error {

0 commit comments

Comments
 (0)