Skip to content

Commit

Permalink
Add function to access anchor data from GovAction and fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Oct 31, 2024
1 parent 3bf693a commit 694008a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 694008a

Please sign in to comment.