Skip to content

Commit 8f8ae91

Browse files
committed
wip
1 parent 07d7935 commit 8f8ae91

File tree

4 files changed

+9
-46
lines changed

4 files changed

+9
-46
lines changed

rust/cardano-blockchain-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ crate-type = ["cdylib", "rlib"]
1818
workspace = true
1919

2020
[dependencies]
21-
catalyst-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.6" }
21+
catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" }
2222
cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" }
2323

2424
ouroboros = "0.18.4"

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

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl fmt::Display for Cip36 {
5151
) -> fmt::Result {
5252
write!(
5353
f,
54-
"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} }}",
54+
"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} }}, problematic: {is_problematic} }}",
5555
key_registration = self.key_registration,
5656
registration_witness = self.registration_witness,
5757
network = self.network,
@@ -62,34 +62,7 @@ impl fmt::Display for Cip36 {
6262
is_valid_payment_address_network = self.is_valid_payment_address_network,
6363
is_valid_voting_keys = self.is_valid_voting_keys,
6464
is_valid_purpose = self.is_valid_purpose,
65-
err_report = serde_json::to_string(&self.err_report)
66-
.unwrap_or_else(|_| String::from("Failed to serialize ProblemReport"))
67-
)
68-
}
69-
}
70-
71-
/// CIP-36 Catalyst registration error
72-
#[allow(dead_code, clippy::module_name_repetitions)]
73-
#[derive(Debug)]
74-
pub struct Cip36Error {
75-
/// The decoding error that make the code not able to process.
76-
error: anyhow::Error,
77-
/// The problem report that contains the errors found during decoding and validation.
78-
report: ProblemReport,
79-
}
80-
81-
impl fmt::Display for Cip36Error {
82-
fn fmt(
83-
&self,
84-
fmt: &mut fmt::Formatter<'_>,
85-
) -> fmt::Result {
86-
let report_json = serde_json::to_string(&self.report)
87-
.unwrap_or_else(|_| String::from("Failed to serialize ProblemReport"));
88-
89-
write!(
90-
fmt,
91-
"Cip36Error {{ error: {}, report: {} }}",
92-
self.error, report_json
65+
is_problematic = self.err_report.is_problematic(),
9366
)
9467
}
9568
}
@@ -118,7 +91,7 @@ impl Cip36 {
11891
block: &MultiEraBlock,
11992
txn_idx: TxnIndex,
12093
is_catalyst_strict: bool,
121-
) -> Result<Option<Cip36>, Cip36Error> {
94+
) -> anyhow::Result<Option<Cip36>> {
12295
// Record of errors found during decoding and validation
12396
let mut err_report = ProblemReport::new("CIP36 Registration Decoding and Validation");
12497

@@ -148,25 +121,15 @@ impl Cip36 {
148121
metadata
149122
},
150123
Err(e) => {
151-
return Err(Cip36Error {
152-
error: anyhow::anyhow!(format!(
153-
"Failed to construct CIP-36 key registration, {e}"
154-
)),
155-
report: err_report,
156-
});
124+
anyhow::bail!("Failed to construct CIP-36 key registration, {e}");
157125
},
158126
};
159127

160128
let registration_witness =
161129
match Cip36RegistrationWitness::decode(&mut registration_witness, &mut err_report) {
162130
Ok(metadata) => metadata,
163131
Err(e) => {
164-
return Err(Cip36Error {
165-
error: anyhow::anyhow!(format!(
166-
"Failed to construct CIP-36 registration witness {e}"
167-
)),
168-
report: err_report,
169-
});
132+
anyhow::bail!("Failed to construct CIP-36 registration witness {e}");
170133
},
171134
};
172135

@@ -210,7 +173,7 @@ impl Cip36 {
210173
pub fn cip36_from_block(
211174
block: &MultiEraBlock,
212175
is_catalyst_strict: bool,
213-
) -> Option<HashMap<TxnIndex, Result<Cip36, Cip36Error>>> {
176+
) -> Option<HashMap<TxnIndex, anyhow::Result<Cip36>>> {
214177
let mut cip36_map = HashMap::new();
215178

216179
for (txn_idx, _tx) in block.decode().txs().iter().enumerate() {

rust/cardano-chain-follower/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mithril-client = { version = "=0.12.2", default-features = false, features = [
1717
] }
1818

1919
cardano-blockchain-types = { version = "0.0.6", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.6" }
20-
catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" }
20+
catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" }
2121

2222
thiserror = "1.0.69"
2323
tokio = { version = "1.45.0", features = [

rust/rbac-registration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ thiserror = "2.0.11"
3535
c509-certificate = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "c509-certificate-v0.0.3" }
3636
cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" }
3737
cardano-blockchain-types = { version = "0.0.7", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cardano-blockchain-types/v0.0.7" }
38-
catalyst-types = { version = "0.0.8", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.8" }
38+
catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" }

0 commit comments

Comments
 (0)