File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -743,7 +743,7 @@ instance Error AnchorDataFromCertificateError where
743743 prettyError (InvalidPoolMetadataHashError url hash) =
744744 " Invalid pool metadata hash for URL " <> fromString (show url) <> " : " <> fromString (show hash)
745745
746- -- | Get anchor data hash from a certificate. A return value of `Nothing`
746+ -- | Get anchor data url and hash from a certificate. A return value of `Nothing`
747747-- means that the certificate does not contain anchor data.
748748getAnchorDataFromCertificate
749749 :: Certificate era
Original file line number Diff line number Diff line change @@ -230,3 +230,19 @@ createAnchor url anchorData =
230230 { anchorUrl = url
231231 , anchorDataHash = hashAnchorData $ Ledger. AnchorData anchorData
232232 }
233+
234+ -- | Get anchor data url and hash from a governance action. A return value of `Nothing`
235+ -- means that the governance action does not contain anchor data.
236+ getAnchorDataFromGovernanceAction
237+ :: EraCrypto (ShelleyLedgerEra era ) ~ StandardCrypto
238+ => Gov. GovAction (ShelleyLedgerEra era )
239+ -> Maybe (Ledger. Anchor StandardCrypto )
240+ getAnchorDataFromGovernanceAction govAction =
241+ case govAction of
242+ Gov. ParameterChange {} -> Nothing
243+ Gov. HardForkInitiation _ _ -> Nothing
244+ Gov. TreasuryWithdrawals _ _ -> Nothing
245+ Gov. NoConfidence _ -> Nothing
246+ Gov. UpdateCommittee {} -> Nothing
247+ Gov. NewConstitution _ constitution -> Just $ Ledger. constitutionAnchor constitution
248+ Gov. InfoAction -> Nothing
Original file line number Diff line number Diff line change @@ -999,6 +999,9 @@ module Cardano.Api
999999 , DRepMetadataReference
10001000 , hashDRepMetadata
10011001
1002+ -- ** Governance actions
1003+ , getAnchorDataFromGovernanceAction
1004+
10021005 -- ** Governance related certificates
10031006 , AnchorDataHash (.. )
10041007 , AnchorUrl (.. )
You can’t perform that action at this time.
0 commit comments