Skip to content

Commit

Permalink
Review remarks: rename VerificationKeyOrHashOrFileOrScriptOrScriptHas…
Browse files Browse the repository at this point in the history
…h to VerificationKeySource
  • Loading branch information
carbolymer committed Apr 8, 2024
1 parent 78a200e commit 14176e0
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ data GovernanceCommitteeKeyHashCmdArgs era =
data GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era =
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, vkeyColdKeySource :: !(VerificationKeyOrHashOrFileOrScriptOrScriptHash CommitteeColdKey)
, vkeyColdKeySource :: !(VerificationKeySource CommitteeColdKey)
, vkeyHotKeySource :: !(VerificationKeyOrHashOrFileOrScript CommitteeHotKey)
, outFile :: !(File () Out)
} deriving Show

data GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era =
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, vkeyColdKeySource :: !(VerificationKeyOrHashOrFileOrScriptOrScriptHash CommitteeColdKey)
, vkeyColdKeySource :: !(VerificationKeySource CommitteeColdKey)
, anchor :: !(Maybe (L.Anchor (L.EraCrypto (ShelleyLedgerEra era))))
, outFile :: !(File () Out)
} deriving Show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,16 @@ pGovernanceCommitteeCreateColdKeyResignationCertificateCmd era = do
(GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs w <$>
pColdCredential <*> pAnchor <*> pOutputFile)

pColdCredential :: Parser (VerificationKeyOrHashOrFileOrScriptOrScriptHash CommitteeColdKey)
pColdCredential :: Parser (VerificationKeySource CommitteeColdKey)
pColdCredential =
asum
[ VkhfsshKeyHashFile . VerificationKeyOrFile <$> pCommitteeColdVerificationKeyOrFile
, VkhfsshKeyHashFile . VerificationKeyHash <$> pCommitteeColdVerificationKeyHash
, VkhfsshScriptHash <$>
[ VksKeyHashFile . VerificationKeyOrFile <$> pCommitteeColdVerificationKeyOrFile
, VksKeyHashFile . VerificationKeyHash <$> pCommitteeColdVerificationKeyHash
, VksScriptHash <$>
pScriptHash
"cold-script-hash"
"Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
, VkhfsshScript <$> pScriptFor "cold-script-file" Nothing "Cold Native or Plutus script file"
"Committee cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"."
, VksScript <$> pScriptFor "cold-script-file" Nothing "Cold Native or Plutus script file"
]

pAnchor :: Parser (Maybe (L.Anchor L.StandardCrypto))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Cardano.CLI.EraBased.Commands.Governance.Committee
import qualified Cardano.CLI.EraBased.Commands.Governance.Committee as Cmd
import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Read (readVerificationKeyOrHashOrFileOrScript,
readVerificationKeyOrHashOrFileOrScriptOrScriptHash)
readVerificationKeySource)
import Cardano.CLI.Types.Errors.GovernanceCommitteeError
import Cardano.CLI.Types.Key.VerificationKey

Expand Down Expand Up @@ -136,7 +136,7 @@ runGovernanceCommitteeCreateHotKeyAuthorizationCertificate
readVerificationKeyOrHashOrFileOrScript AsCommitteeHotKey unCommitteeHotKeyHash vkeyHotKeySource
coldCred <-
mapError' $
readVerificationKeyOrHashOrFileOrScriptOrScriptHash AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource
readVerificationKeySource AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource

makeCommitteeHotKeyAuthorizationCertificate (CommitteeHotKeyAuthorizationRequirements eon coldCred hotCred)
& textEnvelopeToJSON (Just genKeyDelegCertDesc)
Expand All @@ -160,7 +160,7 @@ runGovernanceCommitteeColdKeyResignationCertificate
conwayEraOnwardsConstraints eon $ do
let modifyError' = modifyError $ either GovernanceCommitteeCmdScriptReadError GovernanceCommitteeCmdKeyReadError
coldVKeyCred <- modifyError' $
readVerificationKeyOrHashOrFileOrScriptOrScriptHash AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource
readVerificationKeySource AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource

makeCommitteeColdkeyResignationCertificate (CommitteeColdkeyResignationRequirements eon coldVKeyCred anchor)
& textEnvelopeToJSON (Just genKeyDelegCertDesc)
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module Cardano.CLI.Read
, readVoteDelegationTarget

, readVerificationKeyOrHashOrFileOrScript
, readVerificationKeyOrHashOrFileOrScriptOrScriptHash
, readVerificationKeySource
) where

import Cardano.Api as Api
Expand Down Expand Up @@ -436,22 +436,22 @@ readVerificationKeyOrHashOrFileOrScript asType extractHash = \case
fmap (L.KeyHashObj . extractHash) . modifyError Right $
readVerificationKeyOrHashOrTextEnvFile asType vkOrHashOrFp

readVerificationKeyOrHashOrFileOrScriptOrScriptHash
readVerificationKeySource
:: MonadIOTransError (Either (FileError ScriptDecodeError) (FileError InputDecodeError)) t m
=> Key keyrole
=> AsType keyrole
-> (Hash keyrole -> L.KeyHash kr L.StandardCrypto)
-> VerificationKeyOrHashOrFileOrScriptOrScriptHash keyrole
-> VerificationKeySource keyrole
-> t m (L.Credential kr L.StandardCrypto)
readVerificationKeyOrHashOrFileOrScriptOrScriptHash asType extractHash = \case
VkhfsshScriptHash (ScriptHash scriptHash) ->
readVerificationKeySource asType extractHash = \case
VksScriptHash (ScriptHash scriptHash) ->
pure $ L.ScriptHashObj scriptHash
VkhfsshScript (File fp) -> do
VksScript (File fp) -> do
ScriptInAnyLang _lang script <-
modifyError Left $
readFileScriptInAnyLang fp
pure . L.ScriptHashObj . toShelleyScriptHash $ hashScript script
VkhfsshKeyHashFile vKeyOrHashOrFile ->
VksKeyHashFile vKeyOrHashOrFile ->
fmap (L.KeyHashObj . extractHash) . modifyError Right $
readVerificationKeyOrHashOrTextEnvFile asType vKeyOrHashOrFile

Expand Down
30 changes: 17 additions & 13 deletions cardano-cli/src/Cardano/CLI/Types/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Cardano.CLI.Types.Key

, VerificationKeyOrHashOrFileOrScript(..)
, VerificationKeyOrHashOrFileOrScriptHash(..)
, VerificationKeyOrHashOrFileOrScriptOrScriptHash(..)
, VerificationKeySource(..)
, readVerificationKeyOrHashOrFileOrScriptHash

, PaymentVerifier(..)
Expand Down Expand Up @@ -345,25 +345,29 @@ data VerificationKeyOrHashOrFileOrScript keyrole
= VkhfsKeyHashFile !(VerificationKeyOrHashOrFile keyrole)
| VkhfsScript !(File ScriptInAnyLang In)

deriving instance (Eq (VerificationKeyOrHashOrFile c)) => Eq (VerificationKeyOrHashOrFileOrScript c)
deriving instance (Show (VerificationKeyOrHashOrFile c)) => Show (VerificationKeyOrHashOrFileOrScript c)
deriving instance (Eq (VerificationKeyOrHashOrFile keyrole))
=> Eq (VerificationKeyOrHashOrFileOrScript keyrole)
deriving instance (Show (VerificationKeyOrHashOrFile keyrole))
=> Show (VerificationKeyOrHashOrFileOrScript keyrole)

data VerificationKeyOrHashOrFileOrScriptHash keyrole
= VkhfshKeyHashFile !(VerificationKeyOrHashOrFile keyrole)
| VkhfshScriptHash !ScriptHash

deriving instance (Eq (VerificationKeyOrHashOrFile c)) => Eq (VerificationKeyOrHashOrFileOrScriptHash c)
deriving instance (Show (VerificationKeyOrHashOrFile c)) => Show (VerificationKeyOrHashOrFileOrScriptHash c)
deriving instance (Eq (VerificationKeyOrHashOrFile keyrole))
=> Eq (VerificationKeyOrHashOrFileOrScriptHash keyrole)
deriving instance (Show (VerificationKeyOrHashOrFile keyrole))
=> Show (VerificationKeyOrHashOrFileOrScriptHash keyrole)

data VerificationKeyOrHashOrFileOrScriptOrScriptHash keyrole
= VkhfsshKeyHashFile !(VerificationKeyOrHashOrFile keyrole)
| VkhfsshScript !(File ScriptInAnyLang In)
| VkhfsshScriptHash !ScriptHash
data VerificationKeySource keyrole
= VksKeyHashFile !(VerificationKeyOrHashOrFile keyrole)
| VksScript !(File ScriptInAnyLang In)
| VksScriptHash !ScriptHash

deriving instance (Eq (VerificationKeyOrHashOrFile c)) =>
Eq (VerificationKeyOrHashOrFileOrScriptOrScriptHash c)
deriving instance (Show (VerificationKeyOrHashOrFile c)) =>
Show (VerificationKeyOrHashOrFileOrScriptOrScriptHash c)
deriving instance (Eq (VerificationKeyOrHashOrFile keyrole))
=> Eq (VerificationKeySource keyrole)
deriving instance (Show (VerificationKeyOrHashOrFile keyrole))
=> Show (VerificationKeySource keyrole)

readVerificationKeyOrHashOrFileOrScriptHash
:: MonadIOTransError (FileError InputDecodeError) t m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Available options:
Filepath of the Consitutional Committee cold key.
--cold-verification-key-hash STRING
Constitutional Committee key hash (hex-encoded).
--cold-script-hash HASH Cold Native or Plutus script file hash (hex-encoded).
Obtain it with "cardano-cli conway governance hash
script ...".
--cold-script-hash HASH Committee cold Native or Plutus script file hash
(hex-encoded). Obtain it with "cardano-cli conway
governance hash script ...".
--cold-script-file FILE Cold Native or Plutus script file
--resignation-metadata-url TEXT
Constitutional Committee cold key resignation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Available options:
Filepath of the Consitutional Committee cold key.
--cold-verification-key-hash STRING
Constitutional Committee key hash (hex-encoded).
--cold-script-hash HASH Cold Native or Plutus script file hash (hex-encoded).
Obtain it with "cardano-cli conway governance hash
script ...".
--cold-script-hash HASH Committee cold Native or Plutus script file hash
(hex-encoded). Obtain it with "cardano-cli conway
governance hash script ...".
--cold-script-file FILE Cold Native or Plutus script file
--hot-key STRING Constitutional Committee hot key (hex-encoded).
--hot-key-file FILE Filepath of the Consitutional Committee hot key.
Expand Down

0 comments on commit 14176e0

Please sign in to comment.