Skip to content

Commit

Permalink
Use more meaningful (phantom) types for files around governance comma…
Browse files Browse the repository at this point in the history
…nds.
  • Loading branch information
KtorZ committed Apr 25, 2023
1 parent 5ba4ef7 commit 0929d04
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ data GovernanceCmd
(Maybe Word) -- Answer index
| GovernanceVerifyPoll
FilePath -- Poll file
FilePath -- Tx file
TxFile -- Tx file
deriving Show

renderGovernanceCmd :: GovernanceCmd -> Text
Expand Down
11 changes: 10 additions & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ pGovernanceCmd =
pGovernanceVerifyPoll =
GovernanceVerifyPoll
<$> pPollFile
<*> pTxFileIn
<*> pPollTxFile


pPollQuestion :: Parser Text
Expand Down Expand Up @@ -1160,6 +1160,15 @@ pPollFile =
<> Opt.completer (Opt.bashCompleter "file")
)

pPollTxFile :: Parser TxFile
pPollTxFile =
fmap TxFile $ Opt.strOption $ mconcat
[ Opt.long "signed-tx-file"
, Opt.metavar "FILE"
, Opt.help "Filepath to a signed transaction carrying a valid poll answer."
, Opt.completer (Opt.bashCompleter "file")
]

pPollNonce :: Parser Word
pPollNonce =
Opt.option auto
Expand Down
7 changes: 5 additions & 2 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ runGovernanceCreatePoll govPollQuestion govPollAnswers govPollNonce (OutputFile

runGovernanceAnswerPoll
:: FilePath
-- ^ Poll file
-> Maybe Word
-- ^ Answer index
-> ExceptT ShelleyGovernanceCmdError IO ()
Expand Down Expand Up @@ -318,9 +319,11 @@ runGovernanceAnswerPoll pollFile maybeChoice = do

runGovernanceVerifyPoll
:: FilePath
-> FilePath
-- ^ Poll file
-> TxFile
-- ^ Signed transaction (answer) file
-> ExceptT ShelleyGovernanceCmdError IO ()
runGovernanceVerifyPoll pollFile txFile = do
runGovernanceVerifyPoll pollFile (TxFile txFile) = do
poll <- firstExceptT ShelleyGovernanceCmdTextEnvReadError . newExceptT $
readFileTextEnvelope AsGovernancePoll pollFile

Expand Down

0 comments on commit 0929d04

Please sign in to comment.