Skip to content

Commit

Permalink
Add function to check if a certificate is DRep registration or update
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Dec 18, 2024
1 parent e095ed8 commit c2d6579
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module Cardano.Api.Certificate
-- * Internal functions
, filterUnRegCreds
, filterUnRegDRepCreds
, isDRepRegOrUpdateCert
)
where

Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ module Cardano.Api
-- ** Anchor data
, AnchorDataFromCertificateError (..)
, getAnchorDataFromCertificate
, isDRepRegOrUpdateCert

-- * Rewards
, DelegationsAndRewards (..)
Expand Down

0 comments on commit c2d6579

Please sign in to comment.