Skip to content

Commit d7d53f1

Browse files
committed
Review changes
1 parent 21059d3 commit d7d53f1

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 #-}
@@ -794,40 +793,19 @@ genTxCertificates =
794793
[ pure TxCertificatesNone
795794
, pure
796795
( TxCertificates w $
797-
fromList ((,BuildTxWith Nothing) <$> map (extractCertificate w) certs)
796+
fromList ((,BuildTxWith Nothing) <$> map extractCertificate certs)
798797
)
799798
-- TODO: Generate certificates
800799
]
801800
)
802801

803802
extractCertificate
804-
:: ShelleyBasedEra era
805-
-> Api.Certificate era
803+
:: Api.Certificate era
806804
-> Exp.Certificate (ShelleyLedgerEra era)
807-
extractCertificate ShelleyBasedEraShelley (Api.ShelleyRelatedCertificate _ c) =
808-
Exp.Certificate c
809-
extractCertificate ShelleyBasedEraAllegra (Api.ShelleyRelatedCertificate _ c) =
810-
Exp.Certificate c
811-
extractCertificate ShelleyBasedEraMary (Api.ShelleyRelatedCertificate _ c) =
812-
Exp.Certificate c
813-
extractCertificate ShelleyBasedEraAlonzo (Api.ShelleyRelatedCertificate _ c) =
814-
Exp.Certificate c
815-
extractCertificate ShelleyBasedEraBabbage (Api.ShelleyRelatedCertificate _ c) =
816-
Exp.Certificate c
817-
extractCertificate ShelleyBasedEraConway (Api.ShelleyRelatedCertificate sToBab _) =
818-
case sToBab :: ShelleyToBabbageEra ConwayEra of {}
819-
extractCertificate ShelleyBasedEraShelley (ConwayCertificate cOnwards _) =
820-
case cOnwards :: ConwayEraOnwards ShelleyEra of {}
821-
extractCertificate ShelleyBasedEraAllegra (ConwayCertificate cOnwards _) =
822-
case cOnwards :: ConwayEraOnwards AllegraEra of {}
823-
extractCertificate ShelleyBasedEraMary (ConwayCertificate cOnwards _) =
824-
case cOnwards :: ConwayEraOnwards MaryEra of {}
825-
extractCertificate ShelleyBasedEraAlonzo (ConwayCertificate cOnwards _) =
826-
case cOnwards :: ConwayEraOnwards AlonzoEra of {}
827-
extractCertificate ShelleyBasedEraBabbage (ConwayCertificate cOnwards _) =
828-
case cOnwards :: ConwayEraOnwards BabbageEra of {}
829-
extractCertificate ShelleyBasedEraConway (ConwayCertificate _ c) =
830-
Exp.Certificate c
805+
extractCertificate (Api.ShelleyRelatedCertificate w c) =
806+
shelleyToBabbageEraConstraints w $ Exp.Certificate c
807+
extractCertificate (ConwayCertificate w c) =
808+
conwayEraOnwardsConstraints w $ Exp.Certificate c
831809

832810
genScriptWitnessedTxCertificates :: Typeable era => Exp.Era era -> Gen (TxCertificates BuildTx era)
833811
genScriptWitnessedTxCertificates era = do
@@ -839,7 +817,7 @@ genScriptWitnessedTxCertificates era = do
839817
let certsAndWits =
840818
zipWith
841819
(\c p -> (c, Just p))
842-
(map (extractCertificate w) certs)
820+
(map extractCertificate certs)
843821
plutusScriptWits
844822

845823
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
@@ -105,6 +105,7 @@ import Cardano.Ledger.Coin qualified as L
105105
import Cardano.Ledger.Keys qualified as Ledger
106106
import Cardano.Ledger.State qualified as Ledger
107107

108+
import Control.Monad
108109
import Control.Monad.Except (MonadError (..))
109110
import Data.ByteString (ByteString)
110111
import Data.ByteString qualified as BS
@@ -582,16 +583,10 @@ filterUnRegDRepCreds
582583
-> Exp.Certificate (ShelleyLedgerEra era)
583584
-> Maybe (Ledger.Credential Ledger.DRepRole)
584585
filterUnRegDRepCreds sbe (Exp.Certificate cert) =
585-
case sbe of
586-
ShelleyBasedEraShelley -> Nothing
587-
ShelleyBasedEraAllegra -> Nothing
588-
ShelleyBasedEraMary -> Nothing
589-
ShelleyBasedEraAlonzo -> Nothing
590-
ShelleyBasedEraBabbage -> Nothing
591-
ShelleyBasedEraConway ->
592-
conwayEraOnwardsConstraints ConwayEraOnwardsConway $
593-
fst
594-
<$> Ledger.getUnRegDRepTxCert cert
586+
join $ forEraInEonMaybe (toCardanoEra sbe) $ \w ->
587+
conwayEraOnwardsConstraints w $
588+
fst
589+
<$> Ledger.getUnRegDRepTxCert cert
595590

596591
-- ----------------------------------------------------------------------------
597592
-- 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
@@ -118,4 +118,4 @@ data AnchorDataFromCertificateError
118118
instance Error AnchorDataFromCertificateError where
119119
prettyError :: AnchorDataFromCertificateError -> Doc ann
120120
prettyError (InvalidPoolMetadataHashError url hash) =
121-
"Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash)
121+
"Invalid pool metadata hash for URL " <> pretty url <> ": " <> fromString (show hash)

0 commit comments

Comments
 (0)