@@ -74,18 +74,10 @@ impl HaskellDisplay for ConwayLedgerFailure {
7474 format ! ( "ConwayWdrlNotDelegatedToDRep {}" , v. to_haskell_str_p( ) )
7575 }
7676 TreasuryValueMismatch ( c1, c2) => {
77- format ! (
78- "ConwayTreasuryValueMismatch {} {}" ,
79- c1. to_haskell_str_p( ) ,
80- c2. to_haskell_str_p( )
81- )
77+ format ! ( "ConwayTreasuryValueMismatch ({})" , as_mismatch( c1, c2) , )
8278 }
8379 TxRefScriptsSizeTooBig ( s1, s2) => {
84- format ! (
85- "ConwayTxRefScriptsSizeTooBig {} {}" ,
86- s1. to_haskell_str_p( ) ,
87- s2. to_haskell_str_p( )
88- )
80+ format ! ( "ConwayTxRefScriptsSizeTooBig ({})" , as_mismatch( s2, s1) )
8981 }
9082 MempoolFailure ( e) => format ! ( "ConwayMempoolFailure {}" , e. to_haskell_str( ) ) ,
9183 U8 ( v) => format ! ( "U8 {}" , v) ,
@@ -104,22 +96,18 @@ impl HaskellDisplay for ConwayGovCertPredFailure {
10496 DRepNotRegistered ( cred) => {
10597 format ! ( "ConwayDRepNotRegistered {}" , cred. to_haskell_str_p( ) )
10698 }
107- DRepIncorrectDeposit ( expected, actual) => format ! (
108- "ConwayDRepIncorrectDeposit {} {}" ,
109- expected. to_haskell_str_p( ) ,
110- actual. to_haskell_str_p( )
111- ) ,
99+ DRepIncorrectDeposit ( c1, c2) => {
100+ format ! ( "ConwayDRepIncorrectDeposit ({})" , as_mismatch( c2, c1) )
101+ }
112102 CommitteeHasPreviouslyResigned ( cred) => {
113103 format ! (
114104 "ConwayCommitteeHasPreviouslyResigned {}" ,
115105 cred. to_haskell_str_p( )
116106 )
117107 }
118- DRepIncorrectRefund ( expected, actual) => format ! (
119- "ConwayDRepIncorrectRefund {} {}" ,
120- expected. to_haskell_str_p( ) ,
121- actual. to_haskell_str_p( )
122- ) ,
108+ DRepIncorrectRefund ( v1, v2) => {
109+ format ! ( "ConwayDRepIncorrectRefund ({})" , as_mismatch( v2, v1) )
110+ }
123111 CommitteeIsUnknown ( cred) => {
124112 format ! ( "ConwayCommitteeIsUnknown {}" , cred. to_haskell_str_p( ) )
125113 }
@@ -203,13 +191,15 @@ impl HaskellDisplay for ConwayUtxoWPredFailure {
203191 format ! ( "(ScriptWitnessNotValidatingUTXOW {})" , e. to_haskell_str_p( ) )
204192 }
205193 MissingTxBodyMetadataHash ( b) => {
206- format ! ( "(MissingTxBodyMetadataHash ({}))" , b. as_aux_data_hash ( ) )
194+ format ! ( "(MissingTxBodyMetadataHash ({}))" , b. as_tx_aux_data_hash ( ) )
207195 }
208- MissingTxMetadata ( e) => format ! ( "(MissingTxMetadata ({}))" , e. as_aux_data_hash ( ) ) ,
196+ MissingTxMetadata ( e) => format ! ( "(MissingTxMetadata ({}))" , e. as_tx_aux_data_hash ( ) ) ,
209197 ConflictingMetadataHash ( e1, e2) => format ! (
210- "(ConflictingMetadataHash ({}) ({}))" ,
211- e1. as_aux_data_hash( ) ,
212- e2. as_aux_data_hash( )
198+ "(ConflictingMetadataHash ({}))" ,
199+ as_mismatch(
200+ & e2. as_tx_aux_data_hash( ) . as_is( ) ,
201+ & e1. as_tx_aux_data_hash( ) . as_is( )
202+ )
213203 ) ,
214204 InvalidMetadata ( ) => "InvalidMetadata" . to_string ( ) ,
215205 ExtraneousScriptWitnessesUTXOW ( vec) => {
@@ -229,11 +219,9 @@ impl HaskellDisplay for ConwayUtxoWPredFailure {
229219 e1. to_haskell_str_p( ) ,
230220 e2. to_haskell_str_p( )
231221 ) ,
232- PPViewHashesDontMatch ( h1, h2) => format ! (
233- "(PPViewHashesDontMatch {} {})" ,
234- h1. to_haskell_str_p( ) ,
235- h2. to_haskell_str_p( )
236- ) ,
222+ PPViewHashesDontMatch ( h1, h2) => {
223+ format ! ( "(PPViewHashesDontMatch ({}))" , as_mismatch( h2, h1) )
224+ }
237225 UnspendableUTxONoDatumHash ( e) => {
238226 format ! ( "(UnspendableUTxONoDatumHash {})" , e. to_haskell_str_p( ) )
239227 }
@@ -273,11 +261,7 @@ impl HaskellDisplay for ConwayGovPredFailure {
273261 )
274262 }
275263 ProposalDepositIncorrect ( c1, c2) => {
276- format ! (
277- "ProposalDepositIncorrect {} {}" ,
278- c1. to_haskell_str_p( ) ,
279- c2. to_haskell_str_p( )
280- )
264+ format ! ( "ProposalDepositIncorrect ({})" , as_mismatch( c2, c1) )
281265 }
282266 DisallowedVoters ( v) => {
283267 format ! ( "DisallowedVoters {}" , v. to_haskell_str_p( ) )
@@ -296,10 +280,12 @@ impl HaskellDisplay for ConwayGovPredFailure {
296280 }
297281 ProposalCantFollow ( a, p1, p2) => {
298282 format ! (
299- "ProposalCantFollow {} ({}) ({}) " ,
283+ "ProposalCantFollow {} ({})" ,
300284 a. to_haskell_str_p( ) ,
301- p1. as_protocol_version( ) ,
302- p2. as_protocol_version( )
285+ as_mismatch(
286+ & p2. as_protocol_version( ) . as_is( ) ,
287+ & p1. as_protocol_version( ) . as_is( )
288+ )
303289 )
304290 }
305291 InvalidPolicyHash ( maybe1, maybe2) => {
@@ -348,17 +334,9 @@ impl HaskellDisplay for UtxoFailure {
348334 interval. to_haskell_str( ) ,
349335 slot. as_slot_no( )
350336 ) ,
351- MaxTxSizeUTxO ( actual, max) => format ! (
352- "(MaxTxSizeUTxO {} {})" ,
353- actual. to_haskell_str( ) ,
354- max. to_haskell_str( )
355- ) ,
337+ MaxTxSizeUTxO ( s1, s2) => format ! ( "(MaxTxSizeUTxO ({}))" , as_mismatch( s2, s1) ) ,
356338 InputSetEmptyUTxO => "InputSetEmptyUTxO" . to_string ( ) ,
357- FeeTooSmallUTxO ( required, provided) => format ! (
358- "(FeeTooSmallUTxO {} {})" ,
359- required. to_haskell_str_p( ) ,
360- provided. to_haskell_str_p( )
361- ) ,
339+ FeeTooSmallUTxO ( c1, c2) => format ! ( "(FeeTooSmallUTxO ({}))" , as_mismatch( c1, c2) ) ,
362340 ValueNotConservedUTxO ( required, provided) => format ! (
363341 "(ValueNotConservedUTxO {})" ,
364342 Mismatch ( required. to_owned( ) , provided. to_owned( ) ) . to_haskell_str_p( )
@@ -375,11 +353,7 @@ impl HaskellDisplay for UtxoFailure {
375353 required. to_haskell_str_p( )
376354 ) ,
377355 ScriptsNotPaidUTxO ( utxo) => format ! ( "(ScriptsNotPaidUTxO {})" , utxo. to_haskell_str_p( ) ) ,
378- ExUnitsTooBigUTxO ( provided, max) => format ! (
379- "(ExUnitsTooBigUTxO {} {})" ,
380- provided. to_haskell_str_p( ) ,
381- max. to_haskell_str_p( )
382- ) ,
356+ ExUnitsTooBigUTxO ( u1, u2) => format ! ( "(ExUnitsTooBigUTxO ({}))" , as_mismatch( u1, u2) ) ,
383357 WrongNetwork ( network, addrs) => format ! (
384358 "(WrongNetwork {} {})" ,
385359 network. to_haskell_str( ) ,
@@ -396,13 +370,11 @@ impl HaskellDisplay for UtxoFailure {
396370 }
397371 NoCollateralInputs => "NoCollateralInputs" . to_string ( ) ,
398372 TooManyCollateralInputs ( actual, max) => {
399- format ! ( "(TooManyCollateralInputs {} {})" , actual, max)
373+ format ! ( "(TooManyCollateralInputs ({}))" , as_mismatch( actual, max) )
374+ }
375+ WrongNetworkInTxBody ( n1, n2) => {
376+ format ! ( "(WrongNetworkInTxBody ({}))" , as_mismatch( n1, n2) )
400377 }
401- WrongNetworkInTxBody ( expected, actual) => format ! (
402- "(WrongNetworkInTxBody {} {})" ,
403- expected. to_haskell_str( ) ,
404- actual. to_haskell_str( )
405- ) ,
406378 IncorrectTotalCollateralField ( actual, provided) => format ! (
407379 "(IncorrectTotalCollateralField {} {})" ,
408380 actual. to_haskell_str_p( ) ,
@@ -641,14 +613,32 @@ where
641613 T : HaskellDisplay ,
642614{
643615 fn to_haskell_str ( & self ) -> String {
644- format ! (
645- "Mismatch {{mismatchSupplied = {}, mismatchExpected = {}}}" ,
646- self . 0 . to_haskell_str( ) ,
647- self . 1 . to_haskell_str( )
648- )
616+ as_mismatch ( & self . 1 , & self . 0 )
649617 }
650618}
651619
620+ pub fn as_mismatch < T > ( expected : & T , supplied : & T ) -> String
621+ where
622+ T : HaskellDisplay ,
623+ {
624+ format ! (
625+ "Mismatch {{mismatchSupplied = {}, mismatchExpected = {}}}" ,
626+ supplied. to_haskell_str( ) ,
627+ expected. to_haskell_str( )
628+ )
629+ }
630+
631+ pub fn as_mismatch_p < T > ( expected : & T , supplied : & T ) -> String
632+ where
633+ T : HaskellDisplay ,
634+ {
635+ format ! (
636+ "Mismatch {{mismatchSupplied = {}, mismatchExpected = {}}}" ,
637+ supplied. to_haskell_str_p( ) ,
638+ expected. to_haskell_str_p( )
639+ )
640+ }
641+
652642impl HaskellDisplay for FieldedRewardAccount {
653643 fn to_haskell_str ( & self ) -> String {
654644 format ! (
@@ -1237,6 +1227,10 @@ trait AsVKey {
12371227 fn as_vkey ( & self ) -> String ;
12381228}
12391229
1230+ trait AsVrfKeyHash {
1231+ fn as_vrf_key_hash ( & self ) -> String ;
1232+ }
1233+
12401234trait AsScriptHashObject {
12411235 fn as_script_hash_obj ( & self ) -> String ;
12421236}
@@ -1337,6 +1331,13 @@ where
13371331 }
13381332}
13391333
1334+ impl AsVrfKeyHash for [ u8 ] {
1335+ fn as_vrf_key_hash ( & self ) -> String {
1336+ let hex = hex:: encode ( self ) ;
1337+ format ! ( "VRFVerKeyHash {{unVRFVerKeyHash = \" {}\" }}" , hex)
1338+ }
1339+ }
1340+
13401341impl AsKeyHash for [ u8 ] {
13411342 fn as_key_hash ( & self ) -> String {
13421343 let hex = hex:: encode ( self ) ;
@@ -1550,11 +1551,28 @@ impl HaskellDisplay for BigInt {
15501551 fn to_haskell_str ( & self ) -> String {
15511552 use BigInt :: * ;
15521553
1554+ match self {
1555+ Int ( i) => {
1556+ let value: i128 = i. 0 . into ( ) ;
1557+ value. to_haskell_str ( )
1558+ }
1559+ BigNInt ( bb) => {
1560+ format ! ( "BigNInt {}" , bb. to_haskell_str( ) )
1561+ }
1562+ BigUInt ( bb) => {
1563+ format ! ( "BigUInt {}" , bb. to_haskell_str( ) )
1564+ }
1565+ }
1566+ }
1567+
1568+ fn to_haskell_str_p ( & self ) -> String {
1569+ use BigInt :: * ;
1570+
15531571 match self {
15541572 Int ( i) => {
15551573 let value: i128 = i. 0 . into ( ) ;
15561574 value. to_haskell_str_p ( )
1557- } ,
1575+ }
15581576 BigNInt ( bb) => {
15591577 format ! ( "BigNInt {}" , bb. to_haskell_str_p( ) )
15601578 }
@@ -2052,7 +2070,7 @@ impl HaskellDisplay for Pointer {
20522070 fn to_haskell_str ( & self ) -> String {
20532071 format ! (
20542072 "Ptr ({}) ({}) ({})" ,
2055- self . slot( ) . as_slot_no ( ) ,
2073+ self . slot( ) . as_slot_no32 ( ) ,
20562074 self . tx_idx( ) . as_tx_ix( ) ,
20572075 self . cert_idx( ) . as_cert_ix( )
20582076 )
@@ -2175,12 +2193,16 @@ impl HaskellDisplay for SlotNo {
21752193
21762194trait AsSlotNo {
21772195 fn as_slot_no ( & self ) -> String ;
2196+ fn as_slot_no32 ( & self ) -> String ;
21782197}
21792198
21802199impl AsSlotNo for u64 {
21812200 fn as_slot_no ( & self ) -> String {
21822201 format ! ( "SlotNo {}" , self )
21832202 }
2203+ fn as_slot_no32 ( & self ) -> String {
2204+ format ! ( "SlotNo32 {}" , self )
2205+ }
21842206}
21852207
21862208impl AsSlotNo for SMaybe < u64 > {
@@ -2190,6 +2212,13 @@ impl AsSlotNo for SMaybe<u64> {
21902212 _ => "SNothing" . to_string ( ) ,
21912213 }
21922214 }
2215+
2216+ fn as_slot_no32 ( & self ) -> String {
2217+ match self {
2218+ SMaybe :: Some ( v) => format ! ( "SJust (SlotNo32 {})" , v) ,
2219+ _ => "SNothing" . to_string ( ) ,
2220+ }
2221+ }
21932222}
21942223
21952224trait AsBlake2b256 {
@@ -2328,7 +2357,7 @@ impl HaskellDisplay for Certificate {
23282357 } => format ! (
23292358 "RegPool (PoolParams {{ppId = {}, ppVrf = {}, ppPledge = {}, ppCost = {}, ppMargin = {}, ppRewardAccount = {}, ppOwners = {}, ppRelays = {}, ppMetadata = {}}})" ,
23302359 operator. as_key_hash( ) ,
2331- vrf_keyhash. to_string ( ) . to_haskell_str ( ) ,
2360+ vrf_keyhash. as_vrf_key_hash ( ) ,
23322361 pledge. as_display_coin( ) ,
23332362 cost. as_display_coin( ) ,
23342363 margin. to_haskell_str( ) ,
@@ -2483,7 +2512,7 @@ where
24832512
24842513impl HaskellDisplay for DeltaCoin {
24852514 fn to_haskell_str ( & self ) -> String {
2486- format ! ( "DeltaCoin {}" , self . 0 . to_haskell_str ( ) )
2515+ format ! ( "DeltaCoin {}" , self . 0 . to_haskell_str_p ( ) )
24872516 }
24882517}
24892518
@@ -2525,16 +2554,14 @@ impl AsAddress for Bytes {
25252554 . to_haskell_str ( )
25262555 }
25272556}
2528- trait AsAuxDataHash {
2529- fn as_aux_data_hash ( & self ) -> String ;
2557+
2558+ trait AsTxAuxDataHash {
2559+ fn as_tx_aux_data_hash ( & self ) -> String ;
25302560}
25312561
2532- impl AsAuxDataHash for Bytes {
2533- fn as_aux_data_hash ( & self ) -> String {
2534- format ! (
2535- "AuxiliaryDataHash {{unsafeAuxiliaryDataHash = SafeHash \" {}\" }}" ,
2536- self
2537- )
2562+ impl AsTxAuxDataHash for Bytes {
2563+ fn as_tx_aux_data_hash ( & self ) -> String {
2564+ format ! ( "TxAuxDataHash {{unTxAuxDataHash = SafeHash \" {}\" }}" , self )
25382565 }
25392566}
25402567
0 commit comments