diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 03ae0dd2fd..6fa19c4dc6 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -722,7 +722,7 @@ pRemoveCommitteeColdVerificationKeyHash = where deserialiseFromHex :: String -> Either String (Hash CommitteeColdKey) deserialiseFromHex = - first (\e -> docToString $ "Invalid Consitutional Committee cold key hash: " <> prettyError e) + first (\e -> docToString $ "Invalid Constitutional Committee cold key hash: " <> prettyError e) . deserialiseFromRawBytesHex (AsHash AsCommitteeColdKey) . BSC.pack @@ -897,17 +897,11 @@ pCommitteeHotKeyHash prefix = . deserialiseFromRawBytesHex (AsHash AsCommitteeHotKey) . BSC.pack -pCommitteeHotKeyOrFile :: Parser (VerificationKeyOrFile CommitteeHotKey) -pCommitteeHotKeyOrFile = - asum - [ VerificationKeyValue <$> pCommitteeHotKey - , VerificationKeyFilePath <$> pCommitteeHotKeyFile - ] - pCommitteeHotKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeHotKey) pCommitteeHotKeyOrHashOrFile = asum - [ VerificationKeyOrFile <$> pCommitteeHotKeyOrFile + [ VerificationKeyOrFile . VerificationKeyValue <$> pCommitteeHotKey + , VerificationKeyOrFile . VerificationKeyFilePath <$> pCommitteeHotKeyFile , VerificationKeyHash <$> pCommitteeHotKeyHash Nothing ] @@ -919,6 +913,16 @@ pCommitteeHotVerificationKeyOrHashOrVerificationFile = VerificationKeyHash <$> pCommitteeHotKeyHash (Just "cc") ] +pCommitteeHotVerificationKeyOrHashOrVerificationFileOrScriptHash :: Parser (VerificationKeyOrHashOrFileOrScriptHash CommitteeHotKey) +pCommitteeHotVerificationKeyOrHashOrVerificationFileOrScriptHash = + asum + [ VkhfshKeyHashFile <$> pCommitteeHotVerificationKeyOrHashOrVerificationFile + , VkhfshScriptHash <$> + pScriptHash + "cc-hot-script-hash" + "Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"." + ] + catCommands :: [Parser a] -> Maybe (Parser a) catCommands = \case [] -> Nothing @@ -3197,6 +3201,17 @@ pDRepVerificationKeyOrHashOrFile = , VerificationKeyHash <$> pDRepVerificationKeyHash ] +pDRepVerificationKeyOrHashOrFileOrScriptHash :: Parser (VerificationKeyOrHashOrFileOrScriptHash DRepKey) +pDRepVerificationKeyOrHashOrFileOrScriptHash = + asum + [ VkhfshKeyHashFile . VerificationKeyOrFile <$> pDRepVerificationKeyOrFile + , VkhfshKeyHashFile . VerificationKeyHash <$> pDRepVerificationKeyHash + , VkhfshScriptHash <$> + pScriptHash + "drep-script-hash" + "Cold Native or Plutus script file hash (hex-encoded). Obtain it with \"cardano-cli conway governance hash script ...\"." + ] + pAllOrOnlyDRepVerificationKeyOrHashOrFile :: Parser (AllOrOnly (VerificationKeyOrHashOrFile DRepKey)) pAllOrOnlyDRepVerificationKeyOrHashOrFile = pAll <|> pOnly diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs index f473e1c4f1..b68c25c8fd 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Vote.hs @@ -51,9 +51,9 @@ pGovernanceVoteCreateCmdArgs cOnwards = pAnyVotingStakeVerificationKeyOrHashOrFile :: Parser AnyVotingStakeVerificationKeyOrHashOrFile pAnyVotingStakeVerificationKeyOrHashOrFile = - asum [ AnyDRepVerificationKeyOrHashOrFile <$> pDRepVerificationKeyOrHashOrFile + asum [ AnyDRepVerificationKeyOrHashOrFileOrScriptHash <$> pDRepVerificationKeyOrHashOrFileOrScriptHash , AnyStakePoolVerificationKeyOrHashOrFile <$> pStakePoolVerificationKeyOrHashOrFile Nothing - , AnyCommitteeHotVerificationKeyOrHashOrFile <$> pCommitteeHotVerificationKeyOrHashOrVerificationFile + , AnyCommitteeHotVerificationKeyOrHashOrFileOrScriptHash <$> pCommitteeHotVerificationKeyOrHashOrVerificationFileOrScriptHash ] pGovernanceVoteViewCmd :: () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs index de02e69a83..7650c6e7ea 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs @@ -61,17 +61,17 @@ runGovernanceVoteCreateCmd shelleyBasedEraConstraints sbe $ do voter <- firstExceptT GovernanceVoteCmdReadVerificationKeyError $ case votingStakeCredentialSource of - AnyDRepVerificationKeyOrHashOrFile stake -> do - DRepKeyHash h <- readVerificationKeyOrHashOrTextEnvFile AsDRepKey stake - pure $ L.DRepVoter $ L.KeyHashObj h + AnyDRepVerificationKeyOrHashOrFileOrScriptHash stake -> do + drepCred <- readVerificationKeyOrHashOrFileOrScriptHash AsDRepKey unDRepKeyHash stake + pure $ L.DRepVoter drepCred AnyStakePoolVerificationKeyOrHashOrFile stake -> do StakePoolKeyHash h <- readVerificationKeyOrHashOrTextEnvFile AsStakePoolKey stake pure $ L.StakePoolVoter h - AnyCommitteeHotVerificationKeyOrHashOrFile stake -> do - CommitteeHotKeyHash h <- readVerificationKeyOrHashOrTextEnvFile AsCommitteeHotKey stake - pure $ L.CommitteeVoter $ L.KeyHashObj h + AnyCommitteeHotVerificationKeyOrHashOrFileOrScriptHash stake -> do + hotCred <- readVerificationKeyOrHashOrFileOrScriptHash AsCommitteeHotKey unCommitteeHotKeyHash stake + pure $ L.CommitteeVoter hotCred let govActIdentifier = createGovernanceActionId govActionTxId govActionIndex votingProcedures = singletonVotingProcedures eon voter govActIdentifier (unVotingProcedure voteProcedure) diff --git a/cardano-cli/src/Cardano/CLI/Types/Governance.hs b/cardano-cli/src/Cardano/CLI/Types/Governance.hs index 63a6a6289a..0b42791a37 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Governance.hs @@ -7,7 +7,7 @@ import Cardano.Api import Cardano.Api.Shelley import Cardano.CLI.Types.Key (DRepHashSource, VerificationKeyOrFile, - VerificationKeyOrHashOrFile) + VerificationKeyOrHashOrFile, VerificationKeyOrHashOrFileOrScriptHash) import Data.Word @@ -29,18 +29,11 @@ data VType = VCC -- committee | VSP -- spo deriving Show -data AnyVotingStakeVerificationKeyOrHashOrFile where - AnyDRepVerificationKeyOrHashOrFile - :: VerificationKeyOrHashOrFile DRepKey - -> AnyVotingStakeVerificationKeyOrHashOrFile - - AnyStakePoolVerificationKeyOrHashOrFile - :: VerificationKeyOrHashOrFile StakePoolKey - -> AnyVotingStakeVerificationKeyOrHashOrFile - - AnyCommitteeHotVerificationKeyOrHashOrFile - :: VerificationKeyOrHashOrFile CommitteeHotKey - -> AnyVotingStakeVerificationKeyOrHashOrFile +-- | Possible credentials for creating a vote +data AnyVotingStakeVerificationKeyOrHashOrFile = + AnyDRepVerificationKeyOrHashOrFileOrScriptHash (VerificationKeyOrHashOrFileOrScriptHash DRepKey) + | AnyStakePoolVerificationKeyOrHashOrFile (VerificationKeyOrHashOrFile StakePoolKey) + | AnyCommitteeHotVerificationKeyOrHashOrFileOrScriptHash (VerificationKeyOrHashOrFileOrScriptHash CommitteeHotKey) data VoteDelegationTarget = VoteDelegationTargetOfDRep DRepHashSource 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 7a08884047..e00ab79a59 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -6504,12 +6504,14 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain) ( --drep-verification-key STRING | --drep-verification-key-file FILE | --drep-key-hash HASH + | --drep-script-hash HASH | --stake-pool-verification-key STRING | --cold-verification-key-file FILE | --stake-pool-id STAKE_POOL_ID | --cc-hot-verification-key STRING | --cc-hot-verification-key-file FILE | --cc-hot-key-hash STRING + | --cc-hot-script-hash HASH ) [--anchor-url TEXT --anchor-data-hash HASH] diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli index 509027cb2a..3a618d9dfd 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_vote_create.cli @@ -4,12 +4,14 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain) ( --drep-verification-key STRING | --drep-verification-key-file FILE | --drep-key-hash HASH + | --drep-script-hash HASH | --stake-pool-verification-key STRING | --cold-verification-key-file FILE | --stake-pool-id STAKE_POOL_ID | --cc-hot-verification-key STRING | --cc-hot-verification-key-file FILE | --cc-hot-key-hash STRING + | --cc-hot-script-hash HASH ) [--anchor-url TEXT --anchor-data-hash HASH] @@ -28,6 +30,9 @@ Available options: Filepath of the DRep verification key. --drep-key-hash HASH DRep verification key hash (either Bech32-encoded or hex-encoded). + --drep-script-hash HASH Cold Native or Plutus script file hash (hex-encoded). + Obtain it with "cardano-cli conway governance hash + script ...". --stake-pool-verification-key STRING Stake pool verification key (Bech32 or hex-encoded). --cold-verification-key-file FILE @@ -40,6 +45,10 @@ Available options: --cc-hot-verification-key-file FILE Filepath of the Consitutional Committee hot key. --cc-hot-key-hash STRING Constitutional Committee key hash (hex-encoded). + --cc-hot-script-hash HASH + Cold Native or Plutus script file hash (hex-encoded). + Obtain it with "cardano-cli conway governance hash + script ...". --anchor-url TEXT Vote anchor URL --anchor-data-hash HASH Hash of the vote anchor data (obtain it with "cardano-cli conway governance hash anchor-data