Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plug *-poll legacy commands back #349

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Poll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.CLI.EraBased.Run.Governance.Poll
( runGovernancePollCmds
( runGovernancePollCmds,
runGovernanceCreatePoll,
runGovernanceAnswerPoll,
runGovernanceVerifyPoll
) where

import Cardano.Api
Expand Down
16 changes: 16 additions & 0 deletions cardano-cli/src/Cardano/CLI/Legacy/Commands/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ data LegacyGovernanceCmds
[VerificationKeyFile In]
ProtocolParametersUpdate
(Maybe FilePath)
| GovernanceCreatePoll
Text -- ^ Prompt
[Text] -- ^ Choices
(Maybe Word) -- ^ Nonce
(File GovernancePoll Out)
| GovernanceAnswerPoll
(File GovernancePoll In) -- ^ Poll file
(Maybe Word) -- ^ Answer index
(Maybe (File () Out)) -- ^ Tx file
| GovernanceVerifyPoll
(File GovernancePoll In) -- ^ Poll file
(File (Tx ()) In) -- ^ Tx file
(Maybe (File () Out)) -- ^ Tx file
deriving Show

renderLegacyGovernanceCmds :: LegacyGovernanceCmds -> Text
Expand All @@ -44,4 +57,7 @@ renderLegacyGovernanceCmds = \case
GovernanceMIRTransfer _ _ _ TransferToTreasury -> "governance create-mir-certificate transfer-to-treasury"
GovernanceMIRTransfer _ _ _ TransferToReserves -> "governance create-mir-certificate transfer-to-reserves"
GovernanceUpdateProposal {} -> "governance create-update-proposal"
GovernanceCreatePoll{} -> "governance create-poll"
GovernanceAnswerPoll{} -> "governance answer-poll"
GovernanceVerifyPoll{} -> "governance verify-poll"

31 changes: 31 additions & 0 deletions cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,15 @@ pGovernanceCmds envCli =
, subParser "create-update-proposal"
$ Opt.info pUpdateProposal
$ Opt.progDesc "Create an update proposal"
, subParser "create-poll"
$ Opt.info pGovernanceCreatePoll
$ Opt.progDesc "Create an SPO poll"
, subParser "answer-poll"
$ Opt.info pGovernanceAnswerPoll
$ Opt.progDesc "Answer an SPO poll"
, subParser "verify-poll"
$ Opt.info pGovernanceVerifyPoll
$ Opt.progDesc "Verify an answer to a given SPO poll"
]
where
mirCertParsers :: Parser LegacyGovernanceCmds
Expand Down Expand Up @@ -1090,6 +1099,28 @@ pGovernanceCmds envCli =
<*> pProtocolParametersUpdate
<*> optional pCostModels

pGovernanceCreatePoll :: Parser LegacyGovernanceCmds
pGovernanceCreatePoll =
GovernanceCreatePoll
<$> pPollQuestion
<*> some pPollAnswer
<*> optional pPollNonce
<*> pOutputFile

pGovernanceAnswerPoll :: Parser LegacyGovernanceCmds
pGovernanceAnswerPoll =
GovernanceAnswerPoll
<$> pPollFile
<*> optional pPollAnswerIndex
<*> optional pOutputFile

pGovernanceVerifyPoll :: Parser LegacyGovernanceCmds
pGovernanceVerifyPoll =
GovernanceVerifyPoll
<$> pPollFile
<*> pPollTxFile
<*> optional pOutputFile

pGenesisCmds :: EnvCli -> Parser LegacyGenesisCmds
pGenesisCmds envCli =
asum
Expand Down
8 changes: 8 additions & 0 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Data.Aeson (eitherDecode)
import qualified Data.ByteString.Lazy as LB
import Data.Function ((&))
import qualified Data.Text as Text
import Cardano.CLI.EraBased.Run.Governance.Poll

runLegacyGovernanceCmds :: LegacyGovernanceCmds -> ExceptT GovernanceCmdError IO ()
runLegacyGovernanceCmds = \case
Expand All @@ -35,6 +36,13 @@ runLegacyGovernanceCmds = \case
runLegacyGovernanceGenesisKeyDelegationCertificate sbe genVk genDelegVk vrfVk out
GovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp ->
runLegacyGovernanceUpdateProposal out eNo genVKeys ppUp mCostModelFp
GovernanceCreatePoll prompt choices nonce out ->
runGovernanceCreatePoll BabbageEraOnwardsBabbage prompt choices nonce out
GovernanceAnswerPoll poll ix mOutFile ->
runGovernanceAnswerPoll BabbageEraOnwardsBabbage poll ix mOutFile
GovernanceVerifyPoll poll metadata mOutFile ->
runGovernanceVerifyPoll BabbageEraOnwardsBabbage poll metadata mOutFile


runLegacyGovernanceMIRCertificatePayStakeAddrs
:: EraInEon ShelleyToBabbageEra
Expand Down
44 changes: 44 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -8722,6 +8722,9 @@ Usage: cardano-cli legacy governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand Down Expand Up @@ -8848,6 +8851,25 @@ Usage: cardano-cli legacy governance create-update-proposal --out-file FILE

Create an update proposal

Usage: cardano-cli legacy governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE

Create an SPO poll

Usage: cardano-cli legacy governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Answer an SPO poll

Usage: cardano-cli legacy governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Verify an answer to a given SPO poll

Usage: cardano-cli legacy genesis
( key-gen-genesis
| key-gen-delegate
Expand Down Expand Up @@ -10012,6 +10034,9 @@ Usage: cardano-cli governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand Down Expand Up @@ -10138,6 +10163,25 @@ Usage: cardano-cli governance create-update-proposal --out-file FILE

Create an update proposal

Usage: cardano-cli governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE

Create an SPO poll

Usage: cardano-cli governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Answer an SPO poll

Usage: cardano-cli governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Verify an answer to a given SPO poll

Usage: cardano-cli genesis
( key-gen-genesis
| key-gen-delegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Usage: cardano-cli governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand All @@ -15,3 +18,6 @@ Available commands:
create-genesis-key-delegation-certificate
Create a genesis key delegation certificate
create-update-proposal Create an update proposal
create-poll Create an SPO poll
answer-poll Answer an SPO poll
verify-poll Verify an answer to a given SPO poll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Usage: cardano-cli governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Answer an SPO poll

Available options:
--poll-file FILE Filepath to the ongoing poll.
--answer INT The index of the chosen answer in the poll. Optional.
Asked interactively if omitted.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Usage: cardano-cli governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE

Create an SPO poll

Available options:
--question STRING The question for the poll.
--answer STRING A possible choice for the poll. The option is
repeatable.
--nonce UINT An (optional) nonce for non-replayability.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Usage: cardano-cli governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Verify an answer to a given SPO poll

Available options:
--poll-file FILE Filepath to the ongoing poll.
--tx-file FILE Filepath to the JSON TxBody or JSON Tx carrying a
valid poll answer.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Usage: cardano-cli legacy governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand All @@ -15,3 +18,6 @@ Available commands:
create-genesis-key-delegation-certificate
Create a genesis key delegation certificate
create-update-proposal Create an update proposal
create-poll Create an SPO poll
answer-poll Answer an SPO poll
verify-poll Verify an answer to a given SPO poll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Usage: cardano-cli legacy governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Answer an SPO poll

Available options:
--poll-file FILE Filepath to the ongoing poll.
--answer INT The index of the chosen answer in the poll. Optional.
Asked interactively if omitted.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Usage: cardano-cli legacy governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE

Create an SPO poll

Available options:
--question STRING The question for the poll.
--answer STRING A possible choice for the poll. The option is
repeatable.
--nonce UINT An (optional) nonce for non-replayability.
--out-file FILE The output file.
-h,--help Show this help text
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Usage: cardano-cli legacy governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Verify an answer to a given SPO poll

Available options:
--poll-file FILE Filepath to the ongoing poll.
--tx-file FILE Filepath to the JSON TxBody or JSON Tx carrying a
valid poll answer.
--out-file FILE The output file.
-h,--help Show this help text