File tree 1 file changed +18
-2
lines changed
1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -72,11 +72,27 @@ pub struct TransactionHash(pub LedgerBytes);
72
72
73
73
impl IsPlutusData for TransactionHash {
74
74
fn to_plutus_data ( & self ) -> PlutusData {
75
- self . 0 . to_plutus_data ( )
75
+ PlutusData :: Constr ( BigInt :: from ( 0 ) , vec ! [ self . 0 . to_plutus_data( ) ] )
76
76
}
77
77
78
78
fn from_plutus_data ( data : & PlutusData ) -> Result < Self , PlutusDataError > {
79
- IsPlutusData :: from_plutus_data ( data) . map ( Self )
79
+ match data {
80
+ PlutusData :: Constr ( flag, fields) => match u32:: try_from ( flag) {
81
+ Ok ( 0 ) => {
82
+ verify_constr_fields ( & fields, 1 ) ?;
83
+ Ok ( TransactionHash ( IsPlutusData :: from_plutus_data ( & fields[ 0 ] ) ?) )
84
+ }
85
+ _ => Err ( PlutusDataError :: UnexpectedPlutusInvariant {
86
+ wanted : "Constr field to be 0" . to_owned ( ) ,
87
+ got : flag. to_string ( ) ,
88
+ } ) ,
89
+ } ,
90
+
91
+ _ => Err ( PlutusDataError :: UnexpectedPlutusType {
92
+ wanted : PlutusType :: Constr ,
93
+ got : PlutusType :: from ( data) ,
94
+ } ) ,
95
+ }
80
96
}
81
97
}
82
98
You can’t perform that action at this time.
0 commit comments