@@ -9,7 +9,7 @@ use cardano_blockchain_types::{MetadatumLabel, MultiEraBlock, TxnIndex};
99use catalyst_types:: {
1010 hashes:: { Blake2b256Hash , BLAKE_2B256_SIZE } ,
1111 problem_report:: ProblemReport ,
12- uuid:: V4 ,
12+ uuid:: UuidV4 ,
1313} ;
1414use cbork_utils:: decode_helper:: { decode_bytes, decode_helper, decode_map_len} ;
1515use minicbor:: {
@@ -55,7 +55,7 @@ pub struct Cip509 {
5555 /// A registration purpose (`UUIDv4`).
5656 ///
5757 /// The purpose is defined by the consuming dApp.
58- purpose : Option < V4 > ,
58+ purpose : Option < UuidV4 > ,
5959 /// Transaction inputs hash.
6060 txn_inputs_hash : Option < TxInputHash > ,
6161 /// An optional hash of the previous transaction.
@@ -247,7 +247,7 @@ impl Cip509 {
247247 /// # Errors
248248 ///
249249 /// - `Err(ProblemReport)`
250- pub fn consume ( self ) -> Result < ( V4 , Cip509RbacMetadata , PaymentHistory ) , ProblemReport > {
250+ pub fn consume ( self ) -> Result < ( UuidV4 , Cip509RbacMetadata , PaymentHistory ) , ProblemReport > {
251251 match (
252252 self . purpose ,
253253 self . txn_inputs_hash ,
@@ -436,7 +436,7 @@ fn payment_history(
436436/// Decodes purpose.
437437fn decode_purpose (
438438 d : & mut Decoder , context : & str , report : & ProblemReport ,
439- ) -> Result < Option < V4 > , ( ) > {
439+ ) -> Result < Option < UuidV4 > , ( ) > {
440440 let bytes = match decode_bytes ( d, "Cip509 purpose" ) {
441441 Ok ( v) => v,
442442 Err ( e) => {
@@ -455,17 +455,12 @@ fn decode_purpose(
455455 ) ;
456456 return Ok ( None ) ;
457457 } ;
458- let uuid = V4 :: from ( uuid) ;
459- if uuid. is_valid ( ) {
460- Ok ( Some ( uuid) )
461- } else {
462- report. invalid_value (
463- "purpose" ,
464- & format ! ( "{uuid:?}" ) ,
465- "Invalid UUID version, UuidV4 expected" ,
466- context,
467- ) ;
468- Ok ( None )
458+ match UuidV4 :: try_from ( uuid) {
459+ Ok ( v) => Ok ( Some ( v) ) ,
460+ Err ( e) => {
461+ report. other ( & format ! ( "Invalid purpose UUID: {e:?}" ) , context) ;
462+ Ok ( None )
463+ } ,
469464 }
470465}
471466
0 commit comments