11{-# LANGUAGE ScopedTypeVariables #-}
22
3- module Cardano.CLI.EraBased.HashChecking
3+ module Cardano.CLI.EraBased.Transaction.HashCheck
44 ( checkCertificateHashes
55 , checkVotingProcedureHashes
66 , checkProposalHashes
@@ -14,10 +14,9 @@ import qualified Cardano.Api.Shelley as Shelley
1414import Cardano.CLI.Run.Hash (carryHashChecks )
1515import Cardano.CLI.Types.Common (MustCheckHash (.. ), PotentiallyCheckedAnchor (.. ))
1616import Cardano.CLI.Types.Errors.TxCmdError (TxCmdError (.. ))
17- import qualified Cardano.Ledger.Api.Governance as L
1817
1918import Control.Monad (forM_ )
20- import Control.Monad.Trans.Except.Extra ( left )
19+ import qualified Cardano.Api as L
2120
2221-- | Check the hash of the anchor data against the hash in the anchor
2322checkAnchorMetadataHash :: L. Anchor L. StandardCrypto -> ExceptT TxCmdError IO ()
@@ -33,48 +32,9 @@ checkAnchorMetadataHash anchor =
3332-- | Find references to anchor data and check the hashes are valid
3433-- and they match the linked data.
3534checkCertificateHashes :: Certificate era -> ExceptT TxCmdError IO ()
36- checkCertificateHashes c =
37- case c of
38- ShelleyRelatedCertificate _ shelleyCert ->
39- case shelleyCert of
40- L. ShelleyTxCertDelegCert shelleyDelegCert ->
41- case shelleyDelegCert of
42- L. ShelleyRegCert _ -> return ()
43- L. ShelleyUnRegCert _ -> return ()
44- L. ShelleyDelegCert _ _ -> return ()
45- L. ShelleyTxCertPool shelleyPoolCert ->
46- case shelleyPoolCert of
47- L. RegPool poolParams -> forM_ (L. ppMetadata poolParams) checkPoolMetadataHash
48- L. RetirePool _ _ -> return ()
49- L. ShelleyTxCertGenesisDeleg _ -> return ()
50- L. ShelleyTxCertMir _ -> return ()
51- ConwayCertificate ceo conwayCert ->
52- Shelley. conwayEraOnwardsConstraints ceo $
53- case conwayCert of
54- L. ConwayTxCertDeleg _ -> return ()
55- L. ConwayTxCertPool conwayPoolCert ->
56- case conwayPoolCert of
57- L. RegPool poolParams -> forM_ (L. ppMetadata poolParams) checkPoolMetadataHash
58- L. RetirePool _ _ -> return ()
59- L. ConwayTxCertGov govCert ->
60- case govCert of
61- L. ConwayRegDRep _ _ mAnchor -> forM_ mAnchor checkAnchorMetadataHash
62- L. ConwayUnRegDRep _ _ -> return ()
63- L. ConwayUpdateDRep _ mAnchor -> forM_ mAnchor checkAnchorMetadataHash
64- L. ConwayAuthCommitteeHotKey _ _ -> return ()
65- L. ConwayResignCommitteeColdKey _ mAnchor -> forM_ mAnchor checkAnchorMetadataHash
66- where
67- checkPoolMetadataHash :: L. PoolMetadata -> ExceptT TxCmdError IO ()
68- checkPoolMetadataHash (L. PoolMetadata {L. pmUrl = url, L. pmHash = hashBytes}) = do
69- let mHash = L. hashFromBytes hashBytes
70- hash <- maybe (left $ TxCmdPoolMetadataHashError url) return mHash
71- let safeHash = L. unsafeMakeSafeHash hash
72- checkAnchorMetadataHash
73- ( L. Anchor
74- { L. anchorUrl = url
75- , L. anchorDataHash = safeHash
76- }
77- )
35+ checkCertificateHashes cert = do
36+ mAnchor <- L. withExceptT TxCmdPoolMetadataHashError $ L. getAnchorDataFromCertificate cert
37+ maybe (return mempty ) checkAnchorMetadataHash mAnchor
7838
7939-- | Find references to anchor data in voting procedures and check the hashes are valid
8040-- and they match the linked data.
0 commit comments