diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Committee.hs index 5f48a3a4f0..04e657568e 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Committee.hs @@ -53,7 +53,7 @@ data GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era = GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs { eon :: !(ConwayEraOnwards era) , vkeyColdKeySource :: !(VerificationKeySource CommitteeColdKey) - , vkeyHotKeySource :: !(VerificationKeyOrHashOrFileOrScript CommitteeHotKey) + , vkeyHotKeySource :: !(VerificationKeySource CommitteeHotKey) , outFile :: !(File () Out) } deriving Show diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index eb0ddb57f9..859462a986 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -850,10 +850,31 @@ pCommitteeHotKey = , Opt.help "Constitutional Committee hot key (hex-encoded)." ] -pCommitteeHotVerificationKey :: Parser (VerificationKey CommitteeHotKey) -pCommitteeHotVerificationKey = +pCommitteeHotVerificationKeyOrFile :: Parser (VerificationKeyOrFile CommitteeHotKey) +pCommitteeHotVerificationKeyOrFile = + asum + [ VerificationKeyValue <$> pCommitteeHotVerificationKey "hot-verification-key" + , VerificationKeyFilePath <$> pCommitteeHotVerificationKeyFile "hot-verification-key-file" + ] + +pCommitteeHotVerificationKeyHash :: Parser (Hash CommitteeHotKey) +pCommitteeHotVerificationKeyHash = + Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat + [ Opt.long "hot-verification-key-hash" + , Opt.metavar "STRING" + , Opt.help "Constitutional Committee key hash (hex-encoded)." + ] + where + deserialiseFromHex :: String -> Either String (Hash CommitteeHotKey) + deserialiseFromHex = + first (\e -> docToString $ "Invalid Consitutional Committee hot key hash: " <> prettyError e) + . deserialiseFromRawBytesHex (AsHash AsCommitteeHotKey) + . BSC.pack + +pCommitteeHotVerificationKey :: String -> Parser (VerificationKey CommitteeHotKey) +pCommitteeHotVerificationKey longFlag = Opt.option (Opt.eitherReader deserialiseHotCCKeyFromHex) $ mconcat - [ Opt.long "cc-hot-verification-key" + [ Opt.long longFlag , Opt.metavar "STRING" , Opt.help "Constitutional Committee hot key (hex-encoded)." ] @@ -873,10 +894,10 @@ pCommitteeHotKeyFile = , Opt.completer (Opt.bashCompleter "file") ] -pCommitteeHotVerificationKeyFile :: Parser (VerificationKeyFile In) -pCommitteeHotVerificationKeyFile = +pCommitteeHotVerificationKeyFile :: String -> Parser (VerificationKeyFile In) +pCommitteeHotVerificationKeyFile longFlag = fmap File $ Opt.strOption $ mconcat - [ Opt.long "cc-hot-verification-key-file" + [ Opt.long longFlag , Opt.metavar "FILE" , Opt.help "Filepath of the Consitutional Committee hot key." , Opt.completer (Opt.bashCompleter "file") @@ -908,8 +929,8 @@ pCommitteeHotKeyOrHashOrFile = pCommitteeHotVerificationKeyOrHashOrVerificationFile :: Parser (VerificationKeyOrHashOrFile CommitteeHotKey) pCommitteeHotVerificationKeyOrHashOrVerificationFile = asum - [ VerificationKeyOrFile . VerificationKeyValue <$> pCommitteeHotVerificationKey, - VerificationKeyOrFile . VerificationKeyFilePath <$> pCommitteeHotVerificationKeyFile, + [ VerificationKeyOrFile . VerificationKeyValue <$> pCommitteeHotVerificationKey "cc-hot-verification-key", + VerificationKeyOrFile . VerificationKeyFilePath <$> pCommitteeHotVerificationKeyFile "cc-hot-verification-key-file", VerificationKeyHash <$> pCommitteeHotKeyHash (Just "cc") ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs index 56c352f975..4e05a49587 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Committee.hs @@ -106,18 +106,13 @@ pGovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd era = do ( fmap GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd $ GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs w <$> pColdCredential - <*> pHotVerificationKeyOrHashOrFileOrScript + <*> pHotCredential <*> pOutputFile ) $ Opt.progDesc $ mconcat [ "Create hot key authorization certificate for a Constitutional Committee Member" ] - where - pHotVerificationKeyOrHashOrFileOrScript = asum - [ VkhfsKeyHashFile <$> pCommitteeHotKeyOrHashOrFile - , VkhfsScript <$> pScriptFor "hot-script-file" Nothing "Hot Native or Plutus script file" - ] pGovernanceCommitteeCreateColdKeyResignationCertificateCmd :: () => CardanoEra era @@ -149,6 +144,18 @@ pColdCredential = , VksScript <$> pScriptFor "cold-script-file" Nothing "Cold Native or Plutus script file" ] +pHotCredential :: Parser (VerificationKeySource CommitteeHotKey) +pHotCredential = + asum + [ VksKeyHashFile . VerificationKeyOrFile <$> pCommitteeHotVerificationKeyOrFile + , VksKeyHashFile . VerificationKeyHash <$> pCommitteeHotVerificationKeyHash + , VksScriptHash <$> + pScriptHash + "hot-script-hash" + "Committee hot Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli hash script ...\"." + , VksScript <$> pScriptFor "hot-script-file" Nothing "Hot Native or Plutus script file" + ] + pAnchor :: Parser (Maybe (L.Anchor L.StandardCrypto)) pAnchor = Opt.optional $ diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs index 99c633eaa7..1076bd9f2b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs @@ -14,8 +14,7 @@ import Cardano.Api.Shelley 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, - readVerificationKeySource) +import Cardano.CLI.Read (readVerificationKeySource) import Cardano.CLI.Types.Errors.GovernanceCommitteeError import Cardano.CLI.Types.Key.VerificationKey @@ -141,7 +140,7 @@ runGovernanceCommitteeCreateHotKeyAuthorizationCertificate let mapError' = modifyError $ either GovernanceCommitteeCmdScriptReadError GovernanceCommitteeCmdKeyReadError hotCred <- mapError' $ - readVerificationKeyOrHashOrFileOrScript AsCommitteeHotKey unCommitteeHotKeyHash vkeyHotKeySource + readVerificationKeySource AsCommitteeHotKey unCommitteeHotKeyHash vkeyHotKeySource coldCred <- mapError' $ readVerificationKeySource AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs index 7de4f401af..b2c804effd 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/Committee.hs @@ -73,7 +73,7 @@ hprop_golden_governance_CommitteeCreateHotKeyAuthorizationCertificate = H.noteShowM_ $ execCardanoCLI [ "conway", "governance", "committee", "create-hot-key-authorization-certificate" , "--cold-verification-key-file", ccColdVKey - , "--hot-key-file", ccHotVKey + , "--hot-verification-key-file", ccHotVKey , "--out-file", certFile ] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli index 3c088a6921..d0e084e3d2 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6930,9 +6930,10 @@ Usage: cardano-cli conway governance committee create-hot-key-authorization-cert | --cold-script-hash HASH | --cold-script-file FILE ) - ( --hot-key STRING - | --hot-key-file FILE - | --hot-key-hash STRING + ( --hot-verification-key STRING + | --hot-verification-key-file FILE + | --hot-verification-key-hash STRING + | --hot-script-hash HASH | --hot-script-file FILE ) --out-file FILE diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_committee_create-hot-key-authorization-certificate.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_committee_create-hot-key-authorization-certificate.cli index aa7b5610a9..94908152dd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_committee_create-hot-key-authorization-certificate.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_committee_create-hot-key-authorization-certificate.cli @@ -5,9 +5,10 @@ Usage: cardano-cli conway governance committee create-hot-key-authorization-cert | --cold-script-hash HASH | --cold-script-file FILE ) - ( --hot-key STRING - | --hot-key-file FILE - | --hot-key-hash STRING + ( --hot-verification-key STRING + | --hot-verification-key-file FILE + | --hot-verification-key-hash STRING + | --hot-script-hash HASH | --hot-script-file FILE ) --out-file FILE @@ -25,9 +26,15 @@ Available options: (hex-encoded). Obtain it with "cardano-cli 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. - --hot-key-hash STRING Constitutional Committee key hash (hex-encoded). + --hot-verification-key STRING + Constitutional Committee hot key (hex-encoded). + --hot-verification-key-file FILE + Filepath of the Consitutional Committee hot key. + --hot-verification-key-hash STRING + Constitutional Committee key hash (hex-encoded). + --hot-script-hash HASH Committee hot Native or Plutus script file hash + (hex-encoded). Obtain it with "cardano-cli hash + script ...". --hot-script-file FILE Hot Native or Plutus script file --out-file FILE The output file. -h,--help Show this help text