diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index b31ab1113..5024a933d 100644 --- a/cardano-api/internal/Cardano/Api/Certificate.hs +++ b/cardano-api/internal/Cardano/Api/Certificate.hs @@ -73,6 +73,7 @@ module Cardano.Api.Certificate -- * Internal functions , filterUnRegCreds , filterUnRegDRepCreds + , isDRepRegOrUpdateCert ) where @@ -793,3 +794,16 @@ getAnchorDataFromCertificate c = , Ledger.anchorDataHash = Ledger.unsafeMakeSafeHash hash } ) + +-- | Returns `True` if the certificate is a DRep registration or update certificate, +-- otherwise `False`. This is to see if the certificate needs to be compliant with +-- CIP-0119. +isDRepRegOrUpdateCert :: Certificate era -> Bool +isDRepRegOrUpdateCert = \case + ShelleyRelatedCertificate _ _ -> False + ConwayCertificate ceo ccert -> + conwayEraOnwardsConstraints ceo $ + case ccert of + Ledger.RegDRepTxCert{} -> True + Ledger.UpdateDRepTxCert{} -> True + _ -> False diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 6cd53753c..f499ecc49 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -517,6 +517,7 @@ module Cardano.Api -- ** Anchor data , AnchorDataFromCertificateError (..) , getAnchorDataFromCertificate + , isDRepRegOrUpdateCert -- * Rewards , DelegationsAndRewards (..)