diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs index f2b7fa91e5..7f10967d4c 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs @@ -8,6 +8,7 @@ module Cardano.CLI.EraBased.Commands.Genesis , GenesisCreateCardanoCmdArgs (..) , GenesisCreateStakedCmdArgs (..) , GenesisKeyGenGenesisCmdArgs (..) + , GenesisKeyGenDelegateCmdArgs (..) , renderGenesisCmds ) where @@ -23,10 +24,7 @@ data GenesisCmds era | GenesisCreateCardano !GenesisCreateCardanoCmdArgs | GenesisCreateStaked !GenesisCreateStakedCmdArgs | GenesisKeyGenGenesis !GenesisKeyGenGenesisCmdArgs - | GenesisKeyGenDelegate - (VerificationKeyFile Out) - (SigningKeyFile Out) - (OpCertCounterFile Out) + | GenesisKeyGenDelegate !GenesisKeyGenDelegateCmdArgs | GenesisKeyGenUTxO (VerificationKeyFile Out) (SigningKeyFile Out) @@ -96,6 +94,12 @@ data GenesisKeyGenGenesisCmdArgs = GenesisKeyGenGenesisCmdArgs , signingKeyPath :: !(SigningKeyFile Out) } deriving Show +data GenesisKeyGenDelegateCmdArgs = GenesisKeyGenDelegateCmdArgs + { verificationKeyPath :: !(VerificationKeyFile Out) + , signingKeyPath :: !(SigningKeyFile Out) + , opCertCounterPath :: !(OpCertCounterFile Out) + } deriving Show + renderGenesisCmds :: GenesisCmds era -> Text renderGenesisCmds = \case GenesisCreate {} -> diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index b50f93afac..46b824fd95 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -100,7 +100,7 @@ pGenesisKeyGen = pGenesisDelegateKeyGen :: Parser (GenesisCmds era) pGenesisDelegateKeyGen = - GenesisKeyGenDelegate + fmap GenesisKeyGenDelegate $ GenesisKeyGenDelegateCmdArgs <$> pVerificationKeyFileOut <*> pSigningKeyFileOut <*> pOperatorCertIssueCounterFile diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index 5e40a262f5..e46d958028 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -145,8 +145,8 @@ runGenesisCmds :: GenesisCmds era -> ExceptT GenesisCmdError IO () runGenesisCmds = \case GenesisKeyGenGenesis args -> runGenesisKeyGenGenesisCmd args - GenesisKeyGenDelegate vk sk ctr -> - runGenesisKeyGenDelegateCmd vk sk ctr + GenesisKeyGenDelegate args -> + runGenesisKeyGenDelegateCmd args GenesisKeyGenUTxO vk sk -> runGenesisKeyGenUTxOCmd vk sk GenesisCmdKeyHash vk -> @@ -190,25 +190,28 @@ runGenesisKeyGenGenesisCmd vkeyDesc = "Genesis Verification Key" -runGenesisKeyGenDelegateCmd :: - VerificationKeyFile Out - -> SigningKeyFile Out - -> OpCertCounterFile Out +runGenesisKeyGenDelegateCmd + :: GenesisKeyGenDelegateCmdArgs -> ExceptT GenesisCmdError IO () -runGenesisKeyGenDelegateCmd vkeyPath skeyPath ocertCtrPath = do +runGenesisKeyGenDelegateCmd + Cmd.GenesisKeyGenDelegateCmdArgs + { Cmd.verificationKeyPath + , Cmd.signingKeyPath + , Cmd.opCertCounterPath + } = do skey <- liftIO $ generateSigningKey AsGenesisDelegateKey let vkey = getVerificationKey skey firstExceptT GenesisCmdGenesisFileError . newExceptT - $ writeLazyByteStringFile skeyPath + $ writeLazyByteStringFile signingKeyPath $ textEnvelopeToJSON (Just skeyDesc) skey firstExceptT GenesisCmdGenesisFileError . newExceptT - $ writeLazyByteStringFile vkeyPath + $ writeLazyByteStringFile verificationKeyPath $ textEnvelopeToJSON (Just vkeyDesc) vkey firstExceptT GenesisCmdGenesisFileError . newExceptT - $ writeLazyByteStringFile ocertCtrPath + $ writeLazyByteStringFile opCertCounterPath $ textEnvelopeToJSON (Just certCtrDesc) $ OperationalCertificateIssueCounter initialCounter @@ -791,9 +794,11 @@ createDelegateKeys :: KeyOutputFormat -> FilePath -> Word -> ExceptT GenesisCmdE createDelegateKeys fmt dir index = do liftIO $ createDirectoryIfMissing False dir runGenesisKeyGenDelegateCmd - (File @(VerificationKey ()) $ dir "delegate" ++ strIndex ++ ".vkey") - (onlyOut coldSK) - (onlyOut opCertCtr) + Cmd.GenesisKeyGenDelegateCmdArgs + { Cmd.verificationKeyPath = File @(VerificationKey ()) $ dir "delegate" ++ strIndex ++ ".vkey" + , Cmd.signingKeyPath = onlyOut coldSK + , Cmd.opCertCounterPath = onlyOut opCertCtr + } runGenesisKeyGenDelegateVRF (File @(VerificationKey ()) $ dir "delegate" ++ strIndex ++ ".vrf.vkey") (File @(SigningKey ()) $ dir "delegate" ++ strIndex ++ ".vrf.skey") diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs index 34d9181fbd..4872bbeb24 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs @@ -57,7 +57,13 @@ runLegacyGenesisKeyGenDelegateCmd :: () -> SigningKeyFile Out -> OpCertCounterFile Out -> ExceptT GenesisCmdError IO () -runLegacyGenesisKeyGenDelegateCmd = runGenesisKeyGenDelegateCmd +runLegacyGenesisKeyGenDelegateCmd vkf skf okf = + runGenesisKeyGenDelegateCmd + Cmd.GenesisKeyGenDelegateCmdArgs + { Cmd.verificationKeyPath = vkf + , Cmd.signingKeyPath = skf + , Cmd.opCertCounterPath = okf + } runLegacyGenesisKeyGenUTxOCmd :: () => VerificationKeyFile Out