Skip to content

Commit 45eae26

Browse files
committed
Review changes
1 parent 9e84d15 commit 45eae26

File tree

3 files changed

+13
-40
lines changed

3 files changed

+13
-40
lines changed

cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE DataKinds #-}
2-
{-# LANGUAGE EmptyCase #-}
32
{-# LANGUAGE FlexibleContexts #-}
43
{-# LANGUAGE GADTs #-}
54
{-# LANGUAGE NamedFieldPuns #-}
@@ -770,40 +769,19 @@ genTxCertificates =
770769
[ pure TxCertificatesNone
771770
, pure
772771
( TxCertificates w $
773-
fromList ((,BuildTxWith Nothing) <$> map (extractCertificate w) certs)
772+
fromList ((,BuildTxWith Nothing) <$> map extractCertificate certs)
774773
)
775774
-- TODO: Generate certificates
776775
]
777776
)
778777

779778
extractCertificate
780-
:: ShelleyBasedEra era
781-
-> Api.Certificate era
779+
:: Api.Certificate era
782780
-> Exp.Certificate (ShelleyLedgerEra era)
783-
extractCertificate ShelleyBasedEraShelley (Api.ShelleyRelatedCertificate _ c) =
784-
Exp.Certificate c
785-
extractCertificate ShelleyBasedEraAllegra (Api.ShelleyRelatedCertificate _ c) =
786-
Exp.Certificate c
787-
extractCertificate ShelleyBasedEraMary (Api.ShelleyRelatedCertificate _ c) =
788-
Exp.Certificate c
789-
extractCertificate ShelleyBasedEraAlonzo (Api.ShelleyRelatedCertificate _ c) =
790-
Exp.Certificate c
791-
extractCertificate ShelleyBasedEraBabbage (Api.ShelleyRelatedCertificate _ c) =
792-
Exp.Certificate c
793-
extractCertificate ShelleyBasedEraConway (Api.ShelleyRelatedCertificate sToBab _) =
794-
case sToBab :: ShelleyToBabbageEra ConwayEra of {}
795-
extractCertificate ShelleyBasedEraShelley (ConwayCertificate cOnwards _) =
796-
case cOnwards :: ConwayEraOnwards ShelleyEra of {}
797-
extractCertificate ShelleyBasedEraAllegra (ConwayCertificate cOnwards _) =
798-
case cOnwards :: ConwayEraOnwards AllegraEra of {}
799-
extractCertificate ShelleyBasedEraMary (ConwayCertificate cOnwards _) =
800-
case cOnwards :: ConwayEraOnwards MaryEra of {}
801-
extractCertificate ShelleyBasedEraAlonzo (ConwayCertificate cOnwards _) =
802-
case cOnwards :: ConwayEraOnwards AlonzoEra of {}
803-
extractCertificate ShelleyBasedEraBabbage (ConwayCertificate cOnwards _) =
804-
case cOnwards :: ConwayEraOnwards BabbageEra of {}
805-
extractCertificate ShelleyBasedEraConway (ConwayCertificate _ c) =
806-
Exp.Certificate c
781+
extractCertificate (Api.ShelleyRelatedCertificate w c) =
782+
shelleyToBabbageEraConstraints w $ Exp.Certificate c
783+
extractCertificate (ConwayCertificate w c) =
784+
conwayEraOnwardsConstraints w $ Exp.Certificate c
807785

808786
genScriptWitnessedTxCertificates :: Typeable era => Exp.Era era -> Gen (TxCertificates BuildTx era)
809787
genScriptWitnessedTxCertificates era = do
@@ -815,7 +793,7 @@ genScriptWitnessedTxCertificates era = do
815793
let certsAndWits =
816794
zipWith
817795
(\c p -> (c, Just p))
818-
(map (extractCertificate w) certs)
796+
(map extractCertificate certs)
819797
plutusScriptWits
820798

821799
pure $ mkTxCertificates (convert era) certsAndWits

cardano-api/src/Cardano/Api/Certificate/Internal.hs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ import Cardano.Ledger.BaseTypes (strictMaybe)
103103
import Cardano.Ledger.Coin qualified as L
104104
import Cardano.Ledger.Keys qualified as Ledger
105105

106+
import Control.Monad
106107
import Control.Monad.Except (MonadError (..))
107108
import Data.ByteString (ByteString)
108109
import Data.ByteString qualified as BS
@@ -579,16 +580,10 @@ filterUnRegDRepCreds
579580
-> Exp.Certificate (ShelleyLedgerEra era)
580581
-> Maybe (Ledger.Credential Ledger.DRepRole)
581582
filterUnRegDRepCreds sbe (Exp.Certificate cert) =
582-
case sbe of
583-
ShelleyBasedEraShelley -> Nothing
584-
ShelleyBasedEraAllegra -> Nothing
585-
ShelleyBasedEraMary -> Nothing
586-
ShelleyBasedEraAlonzo -> Nothing
587-
ShelleyBasedEraBabbage -> Nothing
588-
ShelleyBasedEraConway ->
589-
conwayEraOnwardsConstraints ConwayEraOnwardsConway $
590-
fst
591-
<$> Ledger.getUnRegDRepTxCert cert
583+
join $ forEraInEonMaybe (toCardanoEra sbe) $ \w ->
584+
conwayEraOnwardsConstraints w $
585+
fst
586+
<$> Ledger.getUnRegDRepTxCert cert
592587

593588
-- ----------------------------------------------------------------------------
594589
-- Internal conversion functions

cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Certificate.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ data AnchorDataFromCertificateError
114114
instance Error AnchorDataFromCertificateError where
115115
prettyError :: AnchorDataFromCertificateError -> Doc ann
116116
prettyError (InvalidPoolMetadataHashError url hash) =
117-
"Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash)
117+
"Invalid pool metadata hash for URL " <> pretty url <> ": " <> fromString (show hash)

0 commit comments

Comments
 (0)