Skip to content

Commit

Permalink
Merge pull request #337 from input-output-hk/smelc/vote-with-cc-key
Browse files Browse the repository at this point in the history
conway governance vote create: make it possible to use cc hot keys
  • Loading branch information
Jimbo4350 authored Oct 5, 2023
2 parents e86c152 + 3244a92 commit 474d1eb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
48 changes: 37 additions & 11 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -814,17 +814,25 @@ pAnyVerificationKeySource helpText =

pCommitteeHotKey :: Parser (VerificationKey CommitteeHotKey)
pCommitteeHotKey =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
Opt.option (Opt.eitherReader deserialiseHotCCKeyFromHex) $ mconcat
[ Opt.long "hot-key"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee hot key (hex-encoded)."
]
where
deserialiseFromHex :: String -> Either String (VerificationKey CommitteeHotKey)
deserialiseFromHex =
first (\e -> "Invalid Constitutional Committee hot key: " ++ displayError e)
. deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotKey)
. BSC.pack

pCommitteeHotVerificationKey :: Parser (VerificationKey CommitteeHotKey)
pCommitteeHotVerificationKey =
Opt.option (Opt.eitherReader deserialiseHotCCKeyFromHex) $ mconcat
[ Opt.long "cc-hot-verification-key"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee hot key (hex-encoded)."
]

deserialiseHotCCKeyFromHex :: String -> Either String (VerificationKey CommitteeHotKey)
deserialiseHotCCKeyFromHex =
first (\e -> "Invalid Constitutional Committee hot key: " ++ displayError e)
. deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotKey)
. BSC.pack

pCommitteeHotKeyFile :: Parser (VerificationKeyFile In)
pCommitteeHotKeyFile =
Expand All @@ -835,10 +843,20 @@ pCommitteeHotKeyFile =
, Opt.completer (Opt.bashCompleter "file")
]

pCommitteeHotKeyHash :: Parser (Hash CommitteeHotKey)
pCommitteeHotKeyHash =
pCommitteeHotVerificationKeyFile :: Parser (VerificationKeyFile In)
pCommitteeHotVerificationKeyFile =
fmap File $ Opt.strOption $ mconcat
[ Opt.long "cc-hot-verification-key-file"
, Opt.metavar "FILE"
, Opt.help "Filepath of the Consitutional Committee hot key."
, Opt.completer (Opt.bashCompleter "file")
]

-- | The first argument is the optional prefix.
pCommitteeHotKeyHash :: Maybe String -> Parser (Hash CommitteeHotKey)
pCommitteeHotKeyHash prefix =
Opt.option (Opt.eitherReader deserialiseFromHex) $ mconcat
[ Opt.long "hot-key-hash"
[ Opt.long $ prefixFlag prefix "hot-key-hash"
, Opt.metavar "STRING"
, Opt.help "Constitutional Committee key hash (hex-encoded)."
]
Expand All @@ -860,7 +878,15 @@ pCommitteeHotKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile CommitteeHot
pCommitteeHotKeyOrHashOrFile =
asum
[ VerificationKeyOrFile <$> pCommitteeHotKeyOrFile
, VerificationKeyHash <$> pCommitteeHotKeyHash
, VerificationKeyHash <$> pCommitteeHotKeyHash Nothing
]

pCommitteeHotVerificationKeyOrHashOrVerificationFile :: Parser (VerificationKeyOrHashOrFile CommitteeHotKey)
pCommitteeHotVerificationKeyOrHashOrVerificationFile =
asum
[ VerificationKeyOrFile . VerificationKeyValue <$> pCommitteeHotVerificationKey,
VerificationKeyOrFile . VerificationKeyFilePath <$> pCommitteeHotVerificationKeyFile,
VerificationKeyHash <$> pCommitteeHotKeyHash (Just "cc")
]

catCommands :: [Parser a] -> Maybe (Parser a)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ pAnyVotingStakeVerificationKeyOrHashOrFile :: Parser AnyVotingStakeVerificationK
pAnyVotingStakeVerificationKeyOrHashOrFile =
asum [ AnyDRepVerificationKeyOrHashOrFile <$> pDRepVerificationKeyOrHashOrFile
, AnyStakePoolVerificationKeyOrHashOrFile <$> pStakePoolVerificationKeyOrHashOrFile Nothing
, AnyCommitteeHotVerificationKeyOrHashOrFile <$> pCommitteeHotVerificationKeyOrHashOrVerificationFile
]
3 changes: 3 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 @@ -6563,6 +6563,9 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain)
| --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
)
--out-file FILE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Usage: cardano-cli conway governance vote create (--yes | --no | --abstain)
| --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
)
--out-file FILE

Expand All @@ -32,5 +35,10 @@ Available options:
Stake pool ID/verification key hash (either
Bech32-encoded or hex-encoded). Zero or more
occurences of this option is allowed.
--cc-hot-verification-key STRING
Constitutional Committee hot key (hex-encoded).
--cc-hot-verification-key-file FILE
Filepath of the Consitutional Committee hot key.
--cc-hot-key-hash STRING Constitutional Committee key hash (hex-encoded).
--out-file FILE Output filepath of the vote.
-h,--help Show this help text

0 comments on commit 474d1eb

Please sign in to comment.