diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index f57d19034f..9a5815152f 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -69,15 +69,18 @@ library Cardano.CLI.Environment Cardano.CLI.EraBased.Commands Cardano.CLI.EraBased.Commands.Governance + Cardano.CLI.EraBased.Commands.Governance.Actions Cardano.CLI.EraBased.Commands.Governance.Committee Cardano.CLI.EraBased.Governance Cardano.CLI.EraBased.Legacy Cardano.CLI.EraBased.Options.Common Cardano.CLI.EraBased.Options.Governance + Cardano.CLI.EraBased.Options.Governance.Actions Cardano.CLI.EraBased.Options.Governance.Committee Cardano.CLI.EraBased.Run Cardano.CLI.EraBased.Run.Certificate Cardano.CLI.EraBased.Run.Governance + Cardano.CLI.EraBased.Run.Governance.Actions Cardano.CLI.EraBased.Run.Governance.Committee Cardano.CLI.EraBased.Vote Cardano.CLI.Helpers diff --git a/cardano-cli/src/Cardano/CLI/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/Commands/Governance.hs index 767331fc60..4515fe9a08 100644 --- a/cardano-cli/src/Cardano/CLI/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Commands/Governance.hs @@ -10,6 +10,7 @@ import Cardano.Api.Shelley import Cardano.Binary (DecoderError) import Cardano.CLI.Run.Legacy.Read (CddlError) import Cardano.CLI.Run.Legacy.StakeAddress +import Cardano.CLI.Types.Common import Cardano.CLI.Types.Governance import Cardano.CLI.Types.Key import Cardano.Prelude (intercalate, toS) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs index e4748d9519..80a2532f4b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance.hs @@ -9,6 +9,8 @@ module Cardano.CLI.EraBased.Commands.Governance import Cardano.Api +import Cardano.CLI.EraBased.Commands.Governance.Actions (GovernanceActionCmds, + renderGovernanceActionCmds) import Cardano.CLI.EraBased.Commands.Governance.Committee import Cardano.CLI.EraBased.Vote import Cardano.CLI.Types.Common @@ -42,6 +44,8 @@ data EraBasedGovernanceCmds era (File () Out) | EraBasedGovernanceCommitteeCmds (GovernanceCommitteeCmds era) + | EraBasedGovernanceActionCmds + (GovernanceActionCmds era) renderEraBasedGovernanceCmds :: EraBasedGovernanceCmds era -> Text renderEraBasedGovernanceCmds = \case @@ -63,3 +67,5 @@ renderEraBasedGovernanceCmds = \case "goverance vote" EraBasedGovernanceCommitteeCmds cmds -> renderGovernanceCommitteeCmds cmds + EraBasedGovernanceActionCmds cmds -> + renderGovernanceActionCmds cmds diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs new file mode 100644 index 0000000000..f1af10dc41 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs @@ -0,0 +1,67 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE StandaloneDeriving #-} + +module Cardano.CLI.EraBased.Commands.Governance.Actions + ( AnyStakeIdentifier(..) + , GovernanceActionCmds(..) + , EraBasedUpdateProposal(..) + , EraBasedNewConstitution(..) + , renderGovernanceActionCmds + ) where + +import Cardano.Api +import Cardano.Api.Shelley + +import Cardano.CLI.Types.Common +import Cardano.CLI.Types.Key + +import Data.Text (Text) + +data GovernanceActionCmds era + = GovernanceActionCreateConstitution + (ConwayEraOnwards era) + EraBasedNewConstitution + | GovernanceActionCreateUpdateProposal + (ConwayEraOnwards era) + EraBasedUpdateProposal + deriving Show + +data EraBasedNewConstitution + = EraBasedNewConstitution + { encDeposit :: Lovelace + , encStakeCredential :: AnyStakeIdentifier + , encConstitution :: Constitution + , encFilePath :: File () Out + } deriving Show + +renderGovernanceActionCmds :: GovernanceActionCmds era -> Text +renderGovernanceActionCmds = \case + GovernanceActionCreateConstitution {} -> + "governance action create-constitution" + + GovernanceActionCreateUpdateProposal {} -> + "governance action create-update-proposal" + +data AnyStakeIdentifier + = AnyStakeKey (VerificationKeyOrHashOrFile StakeKey) + | AnyStakePoolKey (VerificationKeyOrHashOrFile StakePoolKey) + deriving Show + + +data EraBasedUpdateProposal where + ConwayOnwardsUpdateProposal + :: ConwayEraOnwards era + -> ProtocolParametersUpdate + -> Lovelace -- ^ Deposit + -> AnyStakeIdentifier -- ^ Return address + -> Maybe (File () In) -- ^ Cost model file + -> File () Out + -> EraBasedUpdateProposal + -- TODO: Conway era - add constructor for pre-conway + -- update proposals. This will require genesis delegate keys + -- see UpdateProposal type in cardano-api. + +deriving instance Show EraBasedUpdateProposal + diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Governance.hs index cf01c3803a..e243178e6b 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Governance.hs @@ -160,23 +160,3 @@ pCreateConstitution envCli = <*> pVotingCredential <*> pConstitution <*> pFileOutDirection "out-file" "Output filepath of the governance action." - -pConstitution :: Parser Constitution -pConstitution = - asum - [ fmap ConstitutionFromText $ Opt.strOption $ mconcat - [ Opt.long "constitution" - , Opt.metavar "TEXT" - , Opt.help "Input constitution as UTF-8 encoded text." - ] - , ConstitutionFromFile - <$> pFileInDirection "constitution-file" "Input constitution as a text file." - ] - -pGovActionDeposit :: Parser Lovelace -pGovActionDeposit = - Opt.option (readerFromParsecParser parseLovelace) $ mconcat - [ Opt.long "governance-action-deposit" - , Opt.metavar "NATURAL" - , Opt.help "Deposit required to submit a governance action." - ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Legacy.hs b/cardano-cli/src/Cardano/CLI/EraBased/Legacy.hs index 5f02f71c5b..0804ac99c8 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Legacy.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Legacy.hs @@ -13,7 +13,7 @@ module Cardano.CLI.EraBased.Legacy -- * Field parser and renderers , parseTxIn - + , pProtocolParametersUpdate , pKeyRegistDeposit , pStakePoolRegistrationParserRequirements , pStakePoolVerificationKeyOrHashOrFile @@ -2639,30 +2639,10 @@ pAddress = , Opt.help "A Cardano address" ] - -pStakePoolVerificationKeyHash :: Parser (Hash StakePoolKey) -pStakePoolVerificationKeyHash = - Opt.option (pBech32KeyHash AsStakePoolKey <|> pHexHash AsStakePoolKey) $ mconcat - [ Opt.long "stake-pool-id" - , Opt.metavar "STAKE_POOL_ID" - , Opt.help $ mconcat - [ "Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). " - , "Zero or more occurences of this option is allowed." - ] - ] - pDelegationTarget :: Parser DelegationTarget pDelegationTarget = StakePoolDelegationTarget <$> pStakePoolVerificationKeyOrHashOrFile -pStakePoolVerificationKeyOrHashOrFile - :: Parser (VerificationKeyOrHashOrFile StakePoolKey) -pStakePoolVerificationKeyOrHashOrFile = - asum - [ VerificationKeyOrFile <$> pStakePoolVerificationKeyOrFile - , VerificationKeyHash <$> pStakePoolVerificationKeyHash - ] - pVrfVerificationKeyFile :: Parser (VerificationKeyFile In) pVrfVerificationKeyFile = fmap File $ Opt.strOption $ mconcat diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 8e97981e0a..2b15b82fb6 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -685,3 +685,62 @@ catCommands :: [Parser a] -> Maybe (Parser a) catCommands = \case [] -> Nothing ps -> Just $ asum ps + + + +pConstitution :: Parser Constitution +pConstitution = + asum + [ fmap ConstitutionFromText $ Opt.strOption $ mconcat + [ Opt.long "constitution" + , Opt.metavar "TEXT" + , Opt.help "Input constitution as UTF-8 encoded text." + ] + , ConstitutionFromFile + <$> pFileInDirection "constitution-file" "Input constitution as a text file." + ] + +pGovActionDeposit :: Parser Lovelace +pGovActionDeposit = + Opt.option (readerFromParsecParser parseLovelace) $ mconcat + [ Opt.long "governance-action-deposit" + , Opt.metavar "NATURAL" + , Opt.help "Deposit required to submit a governance action." + ] + + +pStakeVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile StakeKey) +pStakeVerificationKeyOrHashOrFile = asum + [ VerificationKeyOrFile <$> pStakeVerificationKeyOrFile + , VerificationKeyHash <$> pStakeVerificationKeyHash + ] + +pStakeVerificationKeyHash :: Parser (Hash StakeKey) +pStakeVerificationKeyHash = + Opt.option (pHexHash AsStakeKey) $ mconcat + [ Opt.long "stake-key-hash" + , Opt.metavar "HASH" + , Opt.help $ mconcat + [ "Stake verification key hash (hex-encoded)." + ] + ] + + +pStakePoolVerificationKeyOrHashOrFile + :: Parser (VerificationKeyOrHashOrFile StakePoolKey) +pStakePoolVerificationKeyOrHashOrFile = + asum + [ VerificationKeyOrFile <$> pStakePoolVerificationKeyOrFile + , VerificationKeyHash <$> pStakePoolVerificationKeyHash + ] + +pStakePoolVerificationKeyHash :: Parser (Hash StakePoolKey) +pStakePoolVerificationKeyHash = + Opt.option (pBech32KeyHash AsStakePoolKey <|> pHexHash AsStakePoolKey) $ mconcat + [ Opt.long "stake-pool-id" + , Opt.metavar "STAKE_POOL_ID" + , Opt.help $ mconcat + [ "Stake pool ID/verification key hash (either Bech32-encoded or hex-encoded). " + , "Zero or more occurences of this option is allowed." + ] + ] diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs index 270c5832b5..a3818f9663 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance.hs @@ -15,6 +15,7 @@ import Cardano.CLI.EraBased.Commands.Governance import Cardano.CLI.EraBased.Governance import Cardano.CLI.EraBased.Legacy import Cardano.CLI.EraBased.Options.Common +import Cardano.CLI.EraBased.Options.Governance.Actions import Cardano.CLI.EraBased.Options.Governance.Committee import Cardano.CLI.EraBased.Vote import Cardano.CLI.Types.Common @@ -37,8 +38,10 @@ pEraBasedGovernanceCmds envCli era = , pEraBasedVoteCmd envCli era , pCreateMirCertificatesCmds era , pGovernanceCommitteeCmds era <&> fmap EraBasedGovernanceCommitteeCmds + , fmap EraBasedGovernanceActionCmds <$> pGovernanceActionCmds era ] + -- Registration Certificate related pEraBasedRegistrationCertificateCmd diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs new file mode 100644 index 0000000000..0cd76f1d65 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs @@ -0,0 +1,68 @@ +module Cardano.CLI.EraBased.Options.Governance.Actions + ( pGovernanceActionCmds + ) where + +import Cardano.Api + +import Cardano.CLI.EraBased.Commands.Governance.Actions +import qualified Cardano.CLI.EraBased.Legacy as Legacy +import Cardano.CLI.EraBased.Options.Common + +import Data.Foldable +import Options.Applicative +import qualified Options.Applicative as Opt + +pGovernanceActionCmds :: () + => CardanoEra era + -> Maybe (Parser (GovernanceActionCmds era)) +pGovernanceActionCmds era = + subInfoParser "action" + ( Opt.progDesc + $ mconcat + [ "Governance action commands." + ] + ) + [ pGovernanceActionNewConstitution era + , pGovernanceActionCreateUpdateProposal era + ] + + +pGovernanceActionNewConstitution + :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) +pGovernanceActionNewConstitution = + featureInEra Nothing (\cOn -> Just $ + subParser "create-constitution" + $ Opt.info (pCmd cOn) + $ Opt.progDesc "Create a constitution.") + where + pCmd :: ConwayEraOnwards era -> Parser (GovernanceActionCmds era) + pCmd cOn = + fmap (GovernanceActionCreateConstitution cOn) $ + EraBasedNewConstitution + <$> pGovActionDeposit + <*> pAnyStakeIdentifier + <*> pConstitution + <*> pFileOutDirection "out-file" "Output filepath of the constitution." + +pAnyStakeIdentifier :: Parser AnyStakeIdentifier +pAnyStakeIdentifier = + asum [ AnyStakePoolKey <$> pStakePoolVerificationKeyOrHashOrFile + , AnyStakeKey <$> pStakeVerificationKeyOrHashOrFile + ] + +pGovernanceActionCreateUpdateProposal :: CardanoEra era -> Maybe (Parser (GovernanceActionCmds era)) +pGovernanceActionCreateUpdateProposal = + featureInEra Nothing (\cOn -> Just $ + subParser "create-update-proposal" + $ Opt.info (pCmd cOn) + $ Opt.progDesc "Create an update proposal.") + where + pCmd :: ConwayEraOnwards era -> Parser (GovernanceActionCmds era) + pCmd cOn = + fmap (GovernanceActionCreateUpdateProposal cOn) $ + ConwayOnwardsUpdateProposal cOn + <$> Legacy.pProtocolParametersUpdate + <*> pGovActionDeposit + <*> pAnyStakeIdentifier + <*> optional (pFileInDirection "cost-model" "Cost model filepath.") + <*> pFileOutDirection "out-file" "Output filepath of the update proposal." diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs index 60d97b93b3..06a82f8519 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run.hs @@ -16,6 +16,7 @@ import Cardano.CLI.EraBased.Commands import Cardano.CLI.EraBased.Options.Governance import Cardano.CLI.EraBased.Run.Certificate import Cardano.CLI.EraBased.Run.Governance +import Cardano.CLI.EraBased.Run.Governance.Actions import Cardano.CLI.EraBased.Run.Governance.Committee import Cardano.CLI.EraBased.Vote @@ -73,6 +74,10 @@ runEraBasedGovernanceCmds = \case firstExceptT (const ()) -- TODO: Conway era - fix error handling $ runGovernanceCommitteeCmds cmds + EraBasedGovernanceActionCmds cmds -> + firstExceptT (const ()) -- TODO: Conway era - fix error handling + $ runGovernanceActionCmds cmds + runEraBasedGovernancePreConwayCmd :: ShelleyToBabbageEra era -> ExceptT () IO () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs new file mode 100644 index 0000000000..1d1142b807 --- /dev/null +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs @@ -0,0 +1,116 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE LambdaCase #-} + +module Cardano.CLI.EraBased.Run.Governance.Actions + ( runGovernanceActionCmds + ) where + +import Cardano.Api +import Cardano.Api.Ledger (HasKeyRole (coerceKeyRole)) +import Cardano.Api.Shelley + +import Cardano.CLI.EraBased.Commands.Governance.Actions +import Cardano.CLI.Types.Common +import Cardano.CLI.Types.Key + +import Control.Monad +import Control.Monad.Except (ExceptT) +import Control.Monad.IO.Class (liftIO) +import Control.Monad.Trans.Except.Extra +import Data.Aeson +import qualified Data.ByteString as BS +import qualified Data.Text.Encoding as Text +import Data.Text.Encoding.Error + + +data GovernanceActionsError + = GovernanceActionsCmdWriteFileError (FileError ()) + | GovernanceActionsCmdReadFileError (FileError InputDecodeError) + | GovernanceActionsCmdNonUtf8EncodedConstitution UnicodeException + -- Update proposal related + | GovernanceActionsCmdCostModelDecodeErr !(File () In) !String + | GovernanceActionsCmdEmptyCostModel !(File () In) + | GovernanceActionsCmdEmptyUpdateProposalError + + +runGovernanceActionCmds :: () + => GovernanceActionCmds era + -> ExceptT GovernanceActionsError IO () +runGovernanceActionCmds = \case + GovernanceActionCreateConstitution cOn newConstitution -> + runGovernanceActionCreateConstitution cOn newConstitution + + GovernanceActionCreateUpdateProposal cOn createUpdateProp -> + runGovernanceActionCreateUpdateProposal cOn createUpdateProp + +runGovernanceActionCreateConstitution :: () + => ConwayEraOnwards era + -> EraBasedNewConstitution + -> ExceptT GovernanceActionsError IO () +runGovernanceActionCreateConstitution cOn (EraBasedNewConstitution deposit anyStake constit outFp) = do + + stakeKeyHash <- readStakeKeyHash anyStake + + case constit of + ConstitutionFromFile fp -> do + cBs <- liftIO $ BS.readFile $ unFile fp + _utf8EncodedText <- firstExceptT GovernanceActionsCmdNonUtf8EncodedConstitution . hoistEither $ Text.decodeUtf8' cBs + let govAct = ProposeNewConstitution cBs + sbe = conwayEraOnwardsToShelleyBasedEra cOn + proposal = createProposalProcedure sbe deposit stakeKeyHash govAct + + firstExceptT GovernanceActionsCmdWriteFileError . newExceptT + $ conwayEraOnwardsConstraints cOn + $ writeFileTextEnvelope outFp Nothing proposal + + ConstitutionFromText c -> do + let constitBs = Text.encodeUtf8 c + sbe = conwayEraOnwardsToShelleyBasedEra cOn + govAct = ProposeNewConstitution constitBs + proposal = createProposalProcedure sbe deposit stakeKeyHash govAct + + firstExceptT GovernanceActionsCmdWriteFileError . newExceptT + $ conwayEraOnwardsConstraints cOn + $ writeFileTextEnvelope outFp Nothing proposal + + +readStakeKeyHash :: AnyStakeIdentifier -> ExceptT GovernanceActionsError IO (Hash StakeKey) +readStakeKeyHash anyStake = + case anyStake of + AnyStakeKey stake -> + firstExceptT GovernanceActionsCmdReadFileError + . newExceptT $ readVerificationKeyOrHashOrFile AsStakeKey stake + + AnyStakePoolKey stake -> do + StakePoolKeyHash t <- firstExceptT GovernanceActionsCmdReadFileError + . newExceptT $ readVerificationKeyOrHashOrFile AsStakePoolKey stake + return $ StakeKeyHash $ coerceKeyRole t + +runGovernanceActionCreateUpdateProposal + :: ConwayEraOnwards era + -> EraBasedUpdateProposal + -> ExceptT GovernanceActionsError IO () +runGovernanceActionCreateUpdateProposal cOn (ConwayOnwardsUpdateProposal _ update deposit anyStake mCostModelFp outFp) = do + finalUpPprams <- + case mCostModelFp of + Nothing -> return update + Just fp -> do + costModelsBs <- firstExceptT GovernanceActionsCmdReadFileError $ newExceptT $ readLazyByteStringFile fp + + cModels <- firstExceptT (GovernanceActionsCmdCostModelDecodeErr fp) $ hoistEither $ eitherDecode costModelsBs + + let costModels = fromAlonzoCostModels cModels + + when (null costModels) $ left (GovernanceActionsCmdEmptyCostModel fp) + + return $ update {protocolUpdateCostModels = costModels} + + when (finalUpPprams == mempty) $ left GovernanceActionsCmdEmptyUpdateProposalError + + sKeyHash <- readStakeKeyHash anyStake + let sbe = conwayEraOnwardsToShelleyBasedEra cOn + proposal = createProposalProcedure sbe deposit sKeyHash (UpdatePParams finalUpPprams) + + firstExceptT GovernanceActionsCmdWriteFileError . newExceptT + $ conwayEraOnwardsConstraints cOn + $ writeFileTextEnvelope outFp Nothing proposal diff --git a/cardano-cli/src/Cardano/CLI/Types/Common.hs b/cardano-cli/src/Cardano/CLI/Types/Common.hs index 72bc6f8cf6..52b9949482 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Common.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Common.hs @@ -1,10 +1,16 @@ +{-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} module Cardano.CLI.Types.Common - ( OpCertCounter + ( Constitution(..) + , OpCertCounter , TransferDirection(..) ) where +import Cardano.Api + +import Data.Text (Text) + -- | Determines the direction in which the MIR certificate will transfer ADA. data TransferDirection = TransferToReserves @@ -12,3 +18,7 @@ data TransferDirection = deriving Show data OpCertCounter + +data Constitution + = ConstitutionFromFile (File () In) + | ConstitutionFromText Text deriving Show diff --git a/cardano-cli/src/Cardano/CLI/Types/Governance.hs b/cardano-cli/src/Cardano/CLI/Types/Governance.hs index 780a15d06d..3a316e8169 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Governance.hs @@ -6,10 +6,9 @@ module Cardano.CLI.Types.Governance where import Cardano.Api import Cardano.Api.Shelley +import Cardano.CLI.Types.Common import Cardano.CLI.Types.Key -import Data.Text (Text) - type VoteFile = File ConwayVote @@ -34,10 +33,6 @@ data NewConstitution , ncFilePath :: NewConstitutionFile Out } deriving Show -data Constitution - = ConstitutionFromFile (File () In) - | ConstitutionFromText Text deriving Show - -- Vote type -- TODO: Conway era - remove me data VType = VCC -- committee | VDR -- drep diff --git a/cardano-cli/src/Cardano/CLI/Types/Key.hs b/cardano-cli/src/Cardano/CLI/Types/Key.hs index 743c0abf69..fca183684f 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Key.hs @@ -236,6 +236,7 @@ data StakeTarget era where -> StakeTarget era deriving instance Show (StakeTarget era) + newtype DelegationTarget = StakePoolDelegationTarget (VerificationKeyOrHashOrFile StakePoolKey) deriving Show 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 8e000afef1..ecfd1f5e8a 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help.cli @@ -518,6 +518,7 @@ Usage: cardano-cli conway governance | delegation-certificate | vote | committee + | action ) Era-based governance commands @@ -629,6 +630,71 @@ Usage: cardano-cli conway governance committee key-hash --verification-key-file Print the identifier (hash) of a public key +Usage: cardano-cli conway governance action + ( create-constitution + | create-update-proposal + ) + + Governance action commands. + +Usage: cardano-cli conway governance action create-constitution --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + ( --constitution TEXT + | --constitution-file FILE + ) + --out-file FILE + + Create a constitution. + +Usage: cardano-cli conway governance action create-update-proposal + [--protocol-major-version NATURAL + --protocol-minor-version NATURAL] + [--decentralization-parameter RATIONAL] + [ --extra-entropy HEX + | --reset-extra-entropy + ] + [--max-block-header-size NATURAL] + [--max-block-body-size NATURAL] + [--max-tx-size NATURAL] + [--min-fee-constant LOVELACE] + [--min-fee-linear LOVELACE] + [--min-utxo-value NATURAL] + [--key-reg-deposit-amt NATURAL] + [--pool-reg-deposit NATURAL] + [--min-pool-cost NATURAL] + [--pool-retirement-epoch-boundary EPOCH_BOUNDARY] + [--number-of-pools NATURAL] + [--pool-influence RATIONAL] + [--monetary-expansion RATIONAL] + [--treasury-expansion RATIONAL] + [--utxo-cost-per-word LOVELACE] + [--price-execution-steps RATIONAL + --price-execution-memory RATIONAL] + [--max-tx-execution-units (INT, INT)] + [--max-block-execution-units (INT, INT)] + [--max-value-size INT] + [--collateral-percent INT] + [--max-collateral-inputs INT] + [--utxo-cost-per-byte LOVELACE] + --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + [--cost-model FILE] + --out-file FILE + + Create an update proposal. + Usage: cardano-cli latest governance Latest era commands (Babbage) @@ -737,6 +803,7 @@ Usage: cardano-cli experimental governance | delegation-certificate | vote | committee + | action ) Era-based governance commands @@ -848,6 +915,71 @@ Usage: cardano-cli experimental governance committee key-hash --verification-key Print the identifier (hash) of a public key +Usage: cardano-cli experimental governance action + ( create-constitution + | create-update-proposal + ) + + Governance action commands. + +Usage: cardano-cli experimental governance action create-constitution --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + ( --constitution TEXT + | --constitution-file FILE + ) + --out-file FILE + + Create a constitution. + +Usage: cardano-cli experimental governance action create-update-proposal + [--protocol-major-version NATURAL + --protocol-minor-version NATURAL] + [--decentralization-parameter RATIONAL] + [ --extra-entropy HEX + | --reset-extra-entropy + ] + [--max-block-header-size NATURAL] + [--max-block-body-size NATURAL] + [--max-tx-size NATURAL] + [--min-fee-constant LOVELACE] + [--min-fee-linear LOVELACE] + [--min-utxo-value NATURAL] + [--key-reg-deposit-amt NATURAL] + [--pool-reg-deposit NATURAL] + [--min-pool-cost NATURAL] + [--pool-retirement-epoch-boundary EPOCH_BOUNDARY] + [--number-of-pools NATURAL] + [--pool-influence RATIONAL] + [--monetary-expansion RATIONAL] + [--treasury-expansion RATIONAL] + [--utxo-cost-per-word LOVELACE] + [--price-execution-steps RATIONAL + --price-execution-memory RATIONAL] + [--max-tx-execution-units (INT, INT)] + [--max-block-execution-units (INT, INT)] + [--max-value-size INT] + [--collateral-percent INT] + [--max-collateral-inputs INT] + [--utxo-cost-per-byte LOVELACE] + --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + [--cost-model FILE] + --out-file FILE + + Create an update proposal. + Usage: cardano-cli legacy Legacy commands Legacy commands diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli index 2d5771322b..1ea2cc1b2f 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance.cli @@ -3,6 +3,7 @@ Usage: cardano-cli conway governance | delegation-certificate | vote | committee + | action ) Era-based governance commands @@ -15,3 +16,4 @@ Available commands: delegation-certificate Delegation certificate creation. vote Vote creation. committee Committee member commands. + action Governance action commands. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action.cli new file mode 100644 index 0000000000..a4c6b99164 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action.cli @@ -0,0 +1,13 @@ +Usage: cardano-cli conway governance action + ( create-constitution + | create-update-proposal + ) + + Governance action commands. + +Available options: + -h,--help Show this help text + +Available commands: + create-constitution Create a constitution. + create-update-proposal Create an update proposal. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli new file mode 100644 index 0000000000..59cb9d6816 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-constitution.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli conway governance action create-constitution --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + ( --constitution TEXT + | --constitution-file FILE + ) + --out-file FILE + + Create a constitution. + +Available options: + --governance-action-deposit NATURAL + Deposit required to submit a governance action. + --stake-pool-verification-key STRING + Stake pool verification key (Bech32 or hex-encoded). + --cold-verification-key-file FILE + Filepath of the stake pool verification key. + --stake-pool-id STAKE_POOL_ID + Stake pool ID/verification key hash (either + Bech32-encoded or hex-encoded). Zero or more + occurences of this option is allowed. + --stake-verification-key STRING + Stake verification key (Bech32 or hex-encoded). + --stake-verification-key-file FILE + Filepath of the staking verification key. + --stake-key-hash HASH Stake verification key hash (hex-encoded). + --constitution TEXT Input constitution as UTF-8 encoded text. + --constitution-file FILE Input constitution as a text file. + --out-file FILE Output filepath of the constitution. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-update-proposal.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-update-proposal.cli new file mode 100644 index 0000000000..ddf51a420e --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_action_create-update-proposal.cli @@ -0,0 +1,130 @@ +Usage: cardano-cli conway governance action create-update-proposal + [--protocol-major-version NATURAL + --protocol-minor-version NATURAL] + [--decentralization-parameter RATIONAL] + [ --extra-entropy HEX + | --reset-extra-entropy + ] + [--max-block-header-size NATURAL] + [--max-block-body-size NATURAL] + [--max-tx-size NATURAL] + [--min-fee-constant LOVELACE] + [--min-fee-linear LOVELACE] + [--min-utxo-value NATURAL] + [--key-reg-deposit-amt NATURAL] + [--pool-reg-deposit NATURAL] + [--min-pool-cost NATURAL] + [--pool-retirement-epoch-boundary EPOCH_BOUNDARY] + [--number-of-pools NATURAL] + [--pool-influence RATIONAL] + [--monetary-expansion RATIONAL] + [--treasury-expansion RATIONAL] + [--utxo-cost-per-word LOVELACE] + [--price-execution-steps RATIONAL + --price-execution-memory RATIONAL] + [--max-tx-execution-units (INT, INT)] + [--max-block-execution-units (INT, INT)] + [--max-value-size INT] + [--collateral-percent INT] + [--max-collateral-inputs INT] + [--utxo-cost-per-byte LOVELACE] + --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + [--cost-model FILE] + --out-file FILE + + Create an update proposal. + +Available options: + --protocol-major-version NATURAL + Major protocol version. An increase indicates a hard + fork. + --protocol-minor-version NATURAL + Minor protocol version. An increase indicates a soft + fork (old software canvalidate but not produce new + blocks). + --decentralization-parameter RATIONAL + Decentralization parameter. + --extra-entropy HEX Praos extra entropy seed, as a hex byte string. + --reset-extra-entropy Reset the Praos extra entropy to none. + --max-block-header-size NATURAL + Maximum block header size. + --max-block-body-size NATURAL + Maximal block body size. + --max-tx-size NATURAL Maximum transaction size. + --min-fee-constant LOVELACE + The constant factor for the minimum fee calculation. + --min-fee-linear LOVELACE + The linear factor per byte for the minimum fee + calculation. + --min-utxo-value NATURAL The minimum allowed UTxO value (Shelley to Mary + eras). + --key-reg-deposit-amt NATURAL + Key registration deposit amount. + --pool-reg-deposit NATURAL + The amount of a pool registration deposit. + --min-pool-cost NATURAL The minimum allowed cost parameter for stake pools. + --pool-retirement-epoch-boundary EPOCH_BOUNDARY + Epoch bound on pool retirement. + --number-of-pools NATURAL + Desired number of pools. + --pool-influence RATIONAL + Pool influence. + --monetary-expansion RATIONAL + Monetary expansion. + --treasury-expansion RATIONAL + Treasury expansion. + --utxo-cost-per-word LOVELACE + Cost in lovelace per unit of UTxO storage (from + Alonzo era). + --price-execution-steps RATIONAL + Step price of execution units for script languages + that use them (from Alonzo era). (Examples: '1.1', + '11/10') + --price-execution-memory RATIONAL + Memory price of execution units for script languages + that use them (from Alonzo era). (Examples: '1.1', + '11/10') + --max-tx-execution-units (INT, INT) + Max total script execution resources units allowed + per tx (from Alonzo era). They are denominated as + follows (steps, memory). + --max-block-execution-units (INT, INT) + Max total script execution resources units allowed + per block (from Alonzo era). They are denominated as + follows (steps, memory). + --max-value-size INT Max size of a multi-asset value in a tx output (from + Alonzo era). + --collateral-percent INT The percentage of the script contribution to the + txfee that must be provided as collateral inputs when + including Plutus scripts (from Alonzo era). + --max-collateral-inputs INT + The maximum number of collateral inputs allowed in a + transaction (from Alonzo era). + --utxo-cost-per-byte LOVELACE + Cost in lovelace per unit of UTxO storage (from + Babbage era). + --governance-action-deposit NATURAL + Deposit required to submit a governance action. + --stake-pool-verification-key STRING + Stake pool verification key (Bech32 or hex-encoded). + --cold-verification-key-file FILE + Filepath of the stake pool verification key. + --stake-pool-id STAKE_POOL_ID + Stake pool ID/verification key hash (either + Bech32-encoded or hex-encoded). Zero or more + occurences of this option is allowed. + --stake-verification-key STRING + Stake verification key (Bech32 or hex-encoded). + --stake-verification-key-file FILE + Filepath of the staking verification key. + --stake-key-hash HASH Stake verification key hash (hex-encoded). + --cost-model FILE Cost model filepath. + --out-file FILE Output filepath of the update proposal. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli index acb7e1e66c..db6f3d7503 100644 --- a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance.cli @@ -3,6 +3,7 @@ Usage: cardano-cli experimental governance | delegation-certificate | vote | committee + | action ) Era-based governance commands @@ -15,3 +16,4 @@ Available commands: delegation-certificate Delegation certificate creation. vote Vote creation. committee Committee member commands. + action Governance action commands. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action.cli new file mode 100644 index 0000000000..770e1a9de8 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action.cli @@ -0,0 +1,13 @@ +Usage: cardano-cli experimental governance action + ( create-constitution + | create-update-proposal + ) + + Governance action commands. + +Available options: + -h,--help Show this help text + +Available commands: + create-constitution Create a constitution. + create-update-proposal Create an update proposal. diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-constitution.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-constitution.cli new file mode 100644 index 0000000000..bab6b1e7a6 --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-constitution.cli @@ -0,0 +1,35 @@ +Usage: cardano-cli experimental governance action create-constitution --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + ( --constitution TEXT + | --constitution-file FILE + ) + --out-file FILE + + Create a constitution. + +Available options: + --governance-action-deposit NATURAL + Deposit required to submit a governance action. + --stake-pool-verification-key STRING + Stake pool verification key (Bech32 or hex-encoded). + --cold-verification-key-file FILE + Filepath of the stake pool verification key. + --stake-pool-id STAKE_POOL_ID + Stake pool ID/verification key hash (either + Bech32-encoded or hex-encoded). Zero or more + occurences of this option is allowed. + --stake-verification-key STRING + Stake verification key (Bech32 or hex-encoded). + --stake-verification-key-file FILE + Filepath of the staking verification key. + --stake-key-hash HASH Stake verification key hash (hex-encoded). + --constitution TEXT Input constitution as UTF-8 encoded text. + --constitution-file FILE Input constitution as a text file. + --out-file FILE Output filepath of the constitution. + -h,--help Show this help text diff --git a/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-update-proposal.cli b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-update-proposal.cli new file mode 100644 index 0000000000..450cbcf6cd --- /dev/null +++ b/cardano-cli/test/cardano-cli-golden/files/golden/help/experimental_governance_action_create-update-proposal.cli @@ -0,0 +1,130 @@ +Usage: cardano-cli experimental governance action create-update-proposal + [--protocol-major-version NATURAL + --protocol-minor-version NATURAL] + [--decentralization-parameter RATIONAL] + [ --extra-entropy HEX + | --reset-extra-entropy + ] + [--max-block-header-size NATURAL] + [--max-block-body-size NATURAL] + [--max-tx-size NATURAL] + [--min-fee-constant LOVELACE] + [--min-fee-linear LOVELACE] + [--min-utxo-value NATURAL] + [--key-reg-deposit-amt NATURAL] + [--pool-reg-deposit NATURAL] + [--min-pool-cost NATURAL] + [--pool-retirement-epoch-boundary EPOCH_BOUNDARY] + [--number-of-pools NATURAL] + [--pool-influence RATIONAL] + [--monetary-expansion RATIONAL] + [--treasury-expansion RATIONAL] + [--utxo-cost-per-word LOVELACE] + [--price-execution-steps RATIONAL + --price-execution-memory RATIONAL] + [--max-tx-execution-units (INT, INT)] + [--max-block-execution-units (INT, INT)] + [--max-value-size INT] + [--collateral-percent INT] + [--max-collateral-inputs INT] + [--utxo-cost-per-byte LOVELACE] + --governance-action-deposit NATURAL + ( --stake-pool-verification-key STRING + | --cold-verification-key-file FILE + | --stake-pool-id STAKE_POOL_ID + | --stake-verification-key STRING + | --stake-verification-key-file FILE + | --stake-key-hash HASH + ) + [--cost-model FILE] + --out-file FILE + + Create an update proposal. + +Available options: + --protocol-major-version NATURAL + Major protocol version. An increase indicates a hard + fork. + --protocol-minor-version NATURAL + Minor protocol version. An increase indicates a soft + fork (old software canvalidate but not produce new + blocks). + --decentralization-parameter RATIONAL + Decentralization parameter. + --extra-entropy HEX Praos extra entropy seed, as a hex byte string. + --reset-extra-entropy Reset the Praos extra entropy to none. + --max-block-header-size NATURAL + Maximum block header size. + --max-block-body-size NATURAL + Maximal block body size. + --max-tx-size NATURAL Maximum transaction size. + --min-fee-constant LOVELACE + The constant factor for the minimum fee calculation. + --min-fee-linear LOVELACE + The linear factor per byte for the minimum fee + calculation. + --min-utxo-value NATURAL The minimum allowed UTxO value (Shelley to Mary + eras). + --key-reg-deposit-amt NATURAL + Key registration deposit amount. + --pool-reg-deposit NATURAL + The amount of a pool registration deposit. + --min-pool-cost NATURAL The minimum allowed cost parameter for stake pools. + --pool-retirement-epoch-boundary EPOCH_BOUNDARY + Epoch bound on pool retirement. + --number-of-pools NATURAL + Desired number of pools. + --pool-influence RATIONAL + Pool influence. + --monetary-expansion RATIONAL + Monetary expansion. + --treasury-expansion RATIONAL + Treasury expansion. + --utxo-cost-per-word LOVELACE + Cost in lovelace per unit of UTxO storage (from + Alonzo era). + --price-execution-steps RATIONAL + Step price of execution units for script languages + that use them (from Alonzo era). (Examples: '1.1', + '11/10') + --price-execution-memory RATIONAL + Memory price of execution units for script languages + that use them (from Alonzo era). (Examples: '1.1', + '11/10') + --max-tx-execution-units (INT, INT) + Max total script execution resources units allowed + per tx (from Alonzo era). They are denominated as + follows (steps, memory). + --max-block-execution-units (INT, INT) + Max total script execution resources units allowed + per block (from Alonzo era). They are denominated as + follows (steps, memory). + --max-value-size INT Max size of a multi-asset value in a tx output (from + Alonzo era). + --collateral-percent INT The percentage of the script contribution to the + txfee that must be provided as collateral inputs when + including Plutus scripts (from Alonzo era). + --max-collateral-inputs INT + The maximum number of collateral inputs allowed in a + transaction (from Alonzo era). + --utxo-cost-per-byte LOVELACE + Cost in lovelace per unit of UTxO storage (from + Babbage era). + --governance-action-deposit NATURAL + Deposit required to submit a governance action. + --stake-pool-verification-key STRING + Stake pool verification key (Bech32 or hex-encoded). + --cold-verification-key-file FILE + Filepath of the stake pool verification key. + --stake-pool-id STAKE_POOL_ID + Stake pool ID/verification key hash (either + Bech32-encoded or hex-encoded). Zero or more + occurences of this option is allowed. + --stake-verification-key STRING + Stake verification key (Bech32 or hex-encoded). + --stake-verification-key-file FILE + Filepath of the staking verification key. + --stake-key-hash HASH Stake verification key hash (hex-encoded). + --cost-model FILE Cost model filepath. + --out-file FILE Output filepath of the update proposal. + -h,--help Show this help text