@@ -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 ( ) {
0 commit comments