diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs index 787a93b3d9..bb7aed140b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs @@ -49,8 +49,8 @@ data GoveranceActionUpdateCommitteeCmdArgs era , returnAddress :: !StakeIdentifier , proposalUrl :: !ProposalUrl , proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData) - , oldCommitteeVkeySource :: ![VerificationKeyOrHashOrFile CommitteeColdKey] - , newCommitteeVkeySource :: ![(VerificationKeyOrHashOrFile CommitteeColdKey, EpochNo)] + , oldCommitteeVkeySource :: ![VerificationKeyOrHashOrFileOrScript CommitteeColdKey] + , newCommitteeVkeySource :: ![(VerificationKeyOrHashOrFileOrScript CommitteeColdKey, EpochNo)] , requiredQuorum :: !Rational , mPrevGovernanceActionId :: !(Maybe (TxId, Word32)) , outFile :: !(File () Out) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 8ac3fc00ed..80bcdafd05 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -634,11 +634,12 @@ pOperatorCertIssueCounterFile = --- -pAddCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeColdKey) +pAddCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFileOrScript CommitteeColdKey) pAddCommitteeColdVerificationKeyOrHashOrFile = asum - [ VerificationKeyOrFile <$> pAddCommitteeColdVerificationKeyOrFile - , VerificationKeyHash <$> pAddCommitteeColdVerificationKeyHash + [ VkhfsKeyHashFile . VerificationKeyOrFile <$> pAddCommitteeColdVerificationKeyOrFile + , VkhfsKeyHashFile . VerificationKeyHash <$> pAddCommitteeColdVerificationKeyHash + , VkhfsScript <$> pScriptFor "add-cc-cold-script-file" Nothing "Cold Native or Plutus script file" ] pAddCommitteeColdVerificationKeyHash :: Parser (Hash CommitteeColdKey) @@ -686,11 +687,12 @@ pAddCommitteeColdVerificationKeyFile = ] --- -pRemoveCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeColdKey) +pRemoveCommitteeColdVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFileOrScript CommitteeColdKey) pRemoveCommitteeColdVerificationKeyOrHashOrFile = asum - [ VerificationKeyOrFile <$> pRemoveCommitteeColdVerificationKeyOrFile - , VerificationKeyHash <$> pRemoveCommitteeColdVerificationKeyHash + [ VkhfsKeyHashFile . VerificationKeyOrFile <$> pRemoveCommitteeColdVerificationKeyOrFile + , VkhfsKeyHashFile . VerificationKeyHash <$> pRemoveCommitteeColdVerificationKeyHash + , VkhfsScript <$> pScriptFor "remove-cc-cold-script-file" Nothing "Cold Native or Plutus script file" ] pRemoveCommitteeColdVerificationKeyHash :: Parser (Hash CommitteeColdKey) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs index 932a2c12b6..7c3f4782d3 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -25,8 +25,7 @@ import Cardano.CLI.Types.Errors.GovernanceActionsError import Cardano.CLI.Types.Key import Control.Monad -import Data.Function -import GHC.IsList +import GHC.Exts (IsList (..)) runGovernanceActionCmds :: () => GovernanceActionCmds era @@ -216,14 +215,15 @@ runGovernanceActionUpdateCommitteeCmd { L.anchorUrl = unProposalUrl proposalUrl , L.anchorDataHash = proposalHash } + mapError' = modifyError $ either GovernanceActionsCmdScriptReadError GovernanceActionsCmdReadFileError oldCommitteeKeyHashes <- forM oldCommitteeVkeySource $ \vkeyOrHashOrTextFile -> - modifyError GovernanceActionsCmdReadFileError $ - readVerificationKeyOrHashOrTextEnvFile AsCommitteeColdKey vkeyOrHashOrTextFile + mapError' $ + readVerificationKeyOrHashOrFileOrScript AsCommitteeColdKey unCommitteeColdKeyHash vkeyOrHashOrTextFile newCommitteeKeyHashes <- forM newCommitteeVkeySource $ \(vkeyOrHashOrTextFile, expEpoch) -> do - kh <- modifyError GovernanceActionsCmdReadFileError $ - readVerificationKeyOrHashOrTextEnvFile AsCommitteeColdKey vkeyOrHashOrTextFile + kh <- mapError' $ + readVerificationKeyOrHashOrFileOrScript AsCommitteeColdKey unCommitteeColdKeyHash vkeyOrHashOrTextFile pure (kh, expEpoch) depositStakeCredential 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 06eb724321..94187fd93a 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Committee.hs @@ -146,10 +146,10 @@ runGovernanceCommitteeCreateHotKeyAuthorizationCertificate let mapError' = modifyError $ either GovernanceCommitteeCmdScriptReadError GovernanceCommitteeCmdKeyReadError hotCred <- mapError' $ - readVerificationKeyOrHashOrFileOrScript AsCommitteeHotKey (\(CommitteeHotKeyHash kh) -> kh) vkeyHotKeySource + readVerificationKeyOrHashOrFileOrScript AsCommitteeHotKey unCommitteeHotKeyHash vkeyHotKeySource coldCred <- mapError' $ - readVerificationKeyOrHashOrFileOrScript AsCommitteeColdKey (\(CommitteeColdKeyHash kh) -> kh) vkeyColdKeySource + readVerificationKeyOrHashOrFileOrScript AsCommitteeColdKey unCommitteeColdKeyHash vkeyColdKeySource makeCommitteeHotKeyAuthorizationCertificate (CommitteeHotKeyAuthorizationRequirements eon coldCred hotCred) & textEnvelopeToJSON (Just genKeyDelegCertDesc) diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs index 72dcb212f0..4892d829dd 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/GovernanceActionsError.hs @@ -14,6 +14,7 @@ data GovernanceActionsError | GovernanceActionsCmdProposalError ProposalError | GovernanceActionsCmdCostModelsError CostModelsError | GovernanceActionsCmdReadFileError (FileError InputDecodeError) + | GovernanceActionsCmdScriptReadError (FileError ScriptDecodeError) | GovernanceActionsReadStakeCredErrror StakeCredentialError | GovernanceActionsCmdReadTextEnvelopeFileError (FileError TextEnvelopeError) | GovernanceActionsCmdWriteFileError (FileError ()) @@ -30,14 +31,13 @@ instance Error GovernanceActionsError where "Cannot read constitution: " <> pshow e -- TODO Conway render this properly GovernanceActionsCmdReadFileError e -> "Cannot read file: " <> prettyError e + GovernanceActionsCmdScriptReadError e -> + "Cannot read script file: " <> prettyError e GovernanceActionsCmdReadTextEnvelopeFileError e -> "Cannot read text envelope file: " <> prettyError e GovernanceActionsCmdWriteFileError e -> "Cannot write file: " <> prettyError e GovernanceActionsValueUpdateProtocolParametersNotFound (AnyShelleyBasedEra expectedShelleyEra) -> - mconcat - [ "Protocol parameters update value for " <> pshow (toCardanoEra expectedShelleyEra) - , " was not found." - ] + "Protocol parameters update value for" <+> pretty expectedShelleyEra <+> "was not found." GovernanceActionsReadStakeCredErrror e -> prettyError e diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs index fe05cf77a6..19e4ae87dd 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/EraBased/Governance/VerifyPoll.hs @@ -31,10 +31,10 @@ hprop_golden_governanceVerifyPoll = propertyOnce $ do , "--poll-file", pollFile , "--tx-file", txFile ] - - liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case - Left e -> - H.failWith Nothing $ docToString $ prettyError e + H.evalIO (runExceptT $ readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case + Left e -> do + H.noteShow_ $ prettyError e + H.failure Right vk -> do let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] H.assert $ expected `BSC.isInfixOf` stdout 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 7548e717c9..ed4152fdbf 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6211,11 +6211,13 @@ Usage: cardano-cli conway governance action update-committee [ --remove-cc-cold-verification-key STRING | --remove-cc-cold-verification-key-file FILE | --remove-cc-cold-verification-key-hash STRING + | --remove-cc-cold-script-file FILE ] [ ( --add-cc-cold-verification-key STRING | --add-cc-cold-verification-key-file FILE | --add-cc-cold-verification-key-hash STRING + | --add-cc-cold-script-file FILE ) --epoch NATURAL] --quorum RATIONAL diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli index eae7014ec8..ca75d240af 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_update-committee.cli @@ -14,11 +14,13 @@ Usage: cardano-cli conway governance action update-committee [ --remove-cc-cold-verification-key STRING | --remove-cc-cold-verification-key-file FILE | --remove-cc-cold-verification-key-hash STRING + | --remove-cc-cold-script-file FILE ] [ ( --add-cc-cold-verification-key STRING | --add-cc-cold-verification-key-file FILE | --add-cc-cold-verification-key-hash STRING + | --add-cc-cold-script-file FILE ) --epoch NATURAL] --quorum RATIONAL @@ -52,12 +54,16 @@ Available options: Filepath of the Consitutional Committee cold key. --remove-cc-cold-verification-key-hash STRING Constitutional Committee key hash (hex-encoded). + --remove-cc-cold-script-file FILE + Cold Native or Plutus script file --add-cc-cold-verification-key STRING Constitutional Committee cold key (hex-encoded). --add-cc-cold-verification-key-file FILE Filepath of the Consitutional Committee cold key. --add-cc-cold-verification-key-hash STRING Constitutional Committee key hash (hex-encoded). + --add-cc-cold-script-file FILE + Cold Native or Plutus script file --epoch NATURAL Committee member expiry epoch --quorum RATIONAL Quorum of the committee that is necessary for a successful vote.