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
743
743
prettyError (InvalidPoolMetadataHashError url hash) =
744
744
" Invalid pool metadata hash for URL " <> fromString (show url) <> " : " <> fromString (show hash)
745
745
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`
747
747
-- means that the certificate does not contain anchor data.
748
748
getAnchorDataFromCertificate
749
749
:: Certificate era
Original file line number Diff line number Diff line change @@ -230,3 +230,19 @@ createAnchor url anchorData =
230
230
{ anchorUrl = url
231
231
, anchorDataHash = hashAnchorData $ Ledger. AnchorData anchorData
232
232
}
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
999
999
, DRepMetadataReference
1000
1000
, hashDRepMetadata
1001
1001
1002
+ -- ** Governance actions
1003
+ , getAnchorDataFromGovernanceAction
1004
+
1002
1005
-- ** Governance related certificates
1003
1006
, AnchorDataHash (.. )
1004
1007
, AnchorUrl (.. )
You can’t perform that action at this time.
0 commit comments