Skip to content

Commit

Permalink
fix(cardano-chain-follower): update cip509
Browse files Browse the repository at this point in the history
Signed-off-by: bkioshn <[email protected]>
  • Loading branch information
bkioshn committed Dec 26, 2024
1 parent 944a112 commit fa0bcd5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions rust/cardano-chain-follower/src/metadata/cip509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ use std::sync::Arc;
use cardano_blockchain_types::{MetadatumLabel, TransactionAuxData};
use minicbor::{Decode, Decoder};
use pallas::ledger::traverse::MultiEraTx;
use rbac_registration::cardano::cip509::{Cip509 as RbacRegCip509, Cip509Validation, LABEL};
use rbac_registration::cardano::cip509::{Cip509 as RbacRegCip509, Cip509Validation};

use super::{
DecodedMetadata, DecodedMetadataItem, DecodedMetadataValues, ValidationReport,
};
use super::{DecodedMetadata, DecodedMetadataItem, DecodedMetadataValues, ValidationReport};

/// CIP509 metadatum.
#[derive(Debug, PartialEq, Clone, Default)]
Expand Down Expand Up @@ -42,7 +40,7 @@ impl Cip509 {
let cip509 = match RbacRegCip509::decode(&mut decoder, &mut ()) {
Ok(metadata) => metadata,
Err(e) => {
Cip509::default().validation_failure(
Cip509::default().decoding_failed(
&format!("Failed to decode CIP509 metadata: {e}"),
&mut validation_report,
decoded_metadata,
Expand All @@ -56,22 +54,22 @@ impl Cip509 {

// Create a Cip509 struct and insert it into decoded_metadata
decoded_metadata.0.insert(
LABEL,
MetadatumLabel::CIP509_RBAC,
Arc::new(DecodedMetadataItem {
value: DecodedMetadataValues::Cip509(Arc::new(Cip509 { cip509, validation })),
report: validation_report.clone(),
}),
);
}

/// Handle validation failure.
fn validation_failure(
/// Decoding of the CIP509 metadata failed, and can not continue.
fn decoding_failed(
&self, reason: &str, validation_report: &mut ValidationReport,
decoded_metadata: &DecodedMetadata,
) {
validation_report.push(reason.into());
decoded_metadata.0.insert(
LABEL,
MetadatumLabel::CIP509_RBAC,
Arc::new(DecodedMetadataItem {
value: DecodedMetadataValues::Cip509(Arc::new(self.clone()).clone()),
report: validation_report.clone(),
Expand Down

0 comments on commit fa0bcd5

Please sign in to comment.