From c2d6579cff604486c843fbc6e224487f8432ff23 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 18 Dec 2024 20:34:12 +0100 Subject: [PATCH] Add function to check if a certificate is DRep registration or update --- cardano-api/internal/Cardano/Api/Certificate.hs | 14 ++++++++++++++ cardano-api/src/Cardano/Api.hs | 1 + 2 files changed, 15 insertions(+) diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index b31ab11135..5024a933d5 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 6cd53753c5..f499ecc49b 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 (..)