diff --git a/cardano-api/internal/Cardano/Api/Certificate.hs b/cardano-api/internal/Cardano/Api/Certificate.hs index 94ef89fab7..dc1c7ee494 100644 --- a/cardano-api/internal/Cardano/Api/Certificate.hs +++ b/cardano-api/internal/Cardano/Api/Certificate.hs @@ -743,7 +743,7 @@ instance Error AnchorDataFromCertificateError where prettyError (InvalidPoolMetadataHashError url hash) = "Invalid pool metadata hash for URL " <> fromString (show url) <> ": " <> fromString (show hash) --- | Get anchor data hash from a certificate. A return value of `Nothing` +-- | Get anchor data url and hash from a certificate. A return value of `Nothing` -- means that the certificate does not contain anchor data. getAnchorDataFromCertificate :: Certificate era diff --git a/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs b/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs index 6f4b202ae0..fb4ff3b934 100644 --- a/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs +++ b/cardano-api/internal/Cardano/Api/Governance/Actions/ProposalProcedure.hs @@ -230,3 +230,19 @@ createAnchor url anchorData = { anchorUrl = url , anchorDataHash = hashAnchorData $ Ledger.AnchorData anchorData } + +-- | Get anchor data url and hash from a governance action. A return value of `Nothing` +-- means that the governance action does not contain anchor data. +getAnchorDataFromGovernanceAction + :: EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto + => Gov.GovAction (ShelleyLedgerEra era) + -> Maybe (Ledger.Anchor StandardCrypto) +getAnchorDataFromGovernanceAction govAction = + case govAction of + Gov.ParameterChange{} -> Nothing + Gov.HardForkInitiation _ _ -> Nothing + Gov.TreasuryWithdrawals _ _ -> Nothing + Gov.NoConfidence _ -> Nothing + Gov.UpdateCommittee{} -> Nothing + Gov.NewConstitution _ constitution -> Just $ Ledger.constitutionAnchor constitution + Gov.InfoAction -> Nothing