Skip to content

Commit

Permalink
Remove Legacy prefix from era-based genesis commands
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 8, 2023
1 parent a98fc4d commit c0f3c8d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 52 deletions.
76 changes: 36 additions & 40 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
{- HLINT ignore "Use let" -}

module Cardano.CLI.EraBased.Run.Genesis
( runLegacyGenesisAddrCmd
, runLegacyGenesisCreateCardanoCmd
, runLegacyGenesisCreateCmd
, runLegacyGenesisCreateStakedCmd
, runLegacyGenesisHashFileCmd
, runLegacyGenesisKeyGenDelegateCmd
, runLegacyGenesisKeyGenGenesisCmd
, runLegacyGenesisKeyGenUTxOCmd
, runLegacyGenesisKeyHashCmd
, runLegacyGenesisTxInCmd
, runLegacyGenesisVerKeyCmd
( runGenesisAddrCmd
, runGenesisCreateCardanoCmd
, runGenesisCreateCmd
, runGenesisCreateStakedCmd
, runGenesisHashFileCmd
, runGenesisKeyGenDelegateCmd
, runGenesisKeyGenGenesisCmd
, runGenesisKeyGenUTxOCmd
, runGenesisKeyHashCmd
, runGenesisTxInCmd
, runGenesisVerKeyCmd

, readAndDecodeShelleyGenesis

Expand Down Expand Up @@ -136,15 +136,11 @@ import Text.Read (readMaybe)

import Crypto.Random as Crypto

--
-- Genesis command implementations
--

runLegacyGenesisKeyGenGenesisCmd ::
runGenesisKeyGenGenesisCmd ::
VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenGenesisCmd vkeyPath skeyPath = do
runGenesisKeyGenGenesisCmd vkeyPath skeyPath = do
skey <- liftIO $ generateSigningKey AsGenesisKey
let vkey = getVerificationKey skey
firstExceptT ShelleyGenesisCmdGenesisFileError
Expand All @@ -161,12 +157,12 @@ runLegacyGenesisKeyGenGenesisCmd vkeyPath skeyPath = do
vkeyDesc = "Genesis Verification Key"


runLegacyGenesisKeyGenDelegateCmd ::
runGenesisKeyGenDelegateCmd ::
VerificationKeyFile Out
-> SigningKeyFile Out
-> OpCertCounterFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenDelegateCmd vkeyPath skeyPath ocertCtrPath = do
runGenesisKeyGenDelegateCmd vkeyPath skeyPath ocertCtrPath = do
skey <- liftIO $ generateSigningKey AsGenesisDelegateKey
let vkey = getVerificationKey skey
firstExceptT ShelleyGenesisCmdGenesisFileError
Expand Down Expand Up @@ -216,11 +212,11 @@ runGenesisKeyGenDelegateVRF vkeyPath skeyPath = do
vkeyDesc = "VRF Verification Key"


runLegacyGenesisKeyGenUTxOCmd ::
runGenesisKeyGenUTxOCmd ::
VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenUTxOCmd vkeyPath skeyPath = do
runGenesisKeyGenUTxOCmd vkeyPath skeyPath = do
skey <- liftIO $ generateSigningKey AsGenesisUTxOKey
let vkey = getVerificationKey skey
firstExceptT ShelleyGenesisCmdGenesisFileError
Expand All @@ -237,8 +233,8 @@ runLegacyGenesisKeyGenUTxOCmd vkeyPath skeyPath = do
vkeyDesc = "Genesis Initial UTxO Verification Key"


runLegacyGenesisKeyHashCmd :: VerificationKeyFile In -> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyHashCmd vkeyPath = do
runGenesisKeyHashCmd :: VerificationKeyFile In -> ExceptT ShelleyGenesisCmdError IO ()
runGenesisKeyHashCmd vkeyPath = do
vkey <- firstExceptT ShelleyGenesisCmdTextEnvReadFileError . newExceptT $
readFileTextEnvelopeAnyOf
[ FromSomeType (AsVerificationKey AsGenesisKey)
Expand All @@ -261,11 +257,11 @@ runLegacyGenesisKeyHashCmd vkeyPath = do
. verificationKeyHash


runLegacyGenesisVerKeyCmd ::
runGenesisVerKeyCmd ::
VerificationKeyFile Out
-> SigningKeyFile In
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisVerKeyCmd vkeyPath skeyPath = do
runGenesisVerKeyCmd vkeyPath skeyPath = do
skey <- firstExceptT ShelleyGenesisCmdTextEnvReadFileError . newExceptT $
readFileTextEnvelopeAnyOf
[ FromSomeType (AsSigningKey AsGenesisKey)
Expand Down Expand Up @@ -295,24 +291,24 @@ data SomeGenesisKey f
| AGenesisUTxOKey (f GenesisUTxOKey)


runLegacyGenesisTxInCmd ::
runGenesisTxInCmd ::
VerificationKeyFile In
-> NetworkId
-> Maybe (File () Out)
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisTxInCmd vkeyPath network mOutFile = do
runGenesisTxInCmd vkeyPath network mOutFile = do
vkey <- firstExceptT ShelleyGenesisCmdTextEnvReadFileError . newExceptT $
readFileTextEnvelope (AsVerificationKey AsGenesisUTxOKey) vkeyPath
let txin = genesisUTxOPseudoTxIn network (verificationKeyHash vkey)
liftIO $ writeOutput mOutFile (renderTxIn txin)


runLegacyGenesisAddrCmd ::
runGenesisAddrCmd ::
VerificationKeyFile In
-> NetworkId
-> Maybe (File () Out)
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisAddrCmd vkeyPath network mOutFile = do
runGenesisAddrCmd vkeyPath network mOutFile = do
vkey <- firstExceptT ShelleyGenesisCmdTextEnvReadFileError . newExceptT $
readFileTextEnvelope (AsVerificationKey AsGenesisUTxOKey) vkeyPath
let vkh = verificationKeyHash (castVerificationKey vkey)
Expand All @@ -329,7 +325,7 @@ writeOutput Nothing = Text.putStrLn
-- Create Genesis command implementation
--

runLegacyGenesisCreateCmd
runGenesisCreateCmd
:: KeyOutputFormat
-> GenesisDir
-> Word -- ^ num genesis & delegate keys to make
Expand All @@ -338,7 +334,7 @@ runLegacyGenesisCreateCmd
-> Maybe Lovelace
-> NetworkId
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateCmd
runGenesisCreateCmd
fmt (GenesisDir rootdir)
genNumGenesisKeys genNumUTxOKeys
mStart mAmount network = do
Expand Down Expand Up @@ -447,7 +443,7 @@ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys = do
-- Create Genesis Cardano command implementation
--

runLegacyGenesisCreateCardanoCmd :: GenesisDir
runGenesisCreateCardanoCmd :: GenesisDir
-> Word -- ^ num genesis & delegate keys to make
-> Word -- ^ num utxo keys to make
-> Maybe SystemStart
Expand All @@ -462,7 +458,7 @@ runLegacyGenesisCreateCardanoCmd :: GenesisDir
-> FilePath -- ^ Conway Genesis
-> Maybe FilePath
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateCardanoCmd (GenesisDir rootdir)
runGenesisCreateCardanoCmd (GenesisDir rootdir)
genNumGenesisKeys genNumUTxOKeys
mStart mAmount mSecurity slotLength mSlotCoeff
network byronGenesisT shelleyGenesisT alonzoGenesisT conwayGenesisT mNodeCfg = do
Expand Down Expand Up @@ -609,7 +605,7 @@ runLegacyGenesisCreateCardanoCmd (GenesisDir rootdir)
dlgCertMap :: Genesis.GenesisData -> Map Byron.KeyHash Dlg.Certificate
dlgCertMap byronGenesis = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation byronGenesis

runLegacyGenesisCreateStakedCmd
runGenesisCreateStakedCmd
:: KeyOutputFormat -- ^ key output format
-> GenesisDir
-> Word -- ^ num genesis & delegate keys to make
Expand All @@ -625,7 +621,7 @@ runLegacyGenesisCreateStakedCmd
-> Word -- ^ num stuffed UTxO entries
-> Maybe FilePath -- ^ Specified stake pool relays
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateStakedCmd
runGenesisCreateStakedCmd
fmt (GenesisDir rootdir)
genNumGenesisKeys genNumUTxOKeys genNumPools genNumStDelegs
mStart mNonDlgAmount stDlgAmount network
Expand Down Expand Up @@ -759,7 +755,7 @@ runLegacyGenesisCreateStakedCmd
createDelegateKeys :: KeyOutputFormat -> FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createDelegateKeys fmt dir index = do
liftIO $ createDirectoryIfMissing False dir
runLegacyGenesisKeyGenDelegateCmd
runGenesisKeyGenDelegateCmd
(File @(VerificationKey ()) $ dir </> "delegate" ++ strIndex ++ ".vkey")
(onlyOut coldSK)
(onlyOut opCertCtr)
Expand Down Expand Up @@ -787,7 +783,7 @@ createGenesisKeys :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createGenesisKeys dir index = do
liftIO $ createDirectoryIfMissing False dir
let strIndex = show index
runLegacyGenesisKeyGenGenesisCmd
runGenesisKeyGenGenesisCmd
(File @(VerificationKey ()) $ dir </> "genesis" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "genesis" ++ strIndex ++ ".skey")

Expand All @@ -796,7 +792,7 @@ createUtxoKeys :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createUtxoKeys dir index = do
liftIO $ createDirectoryIfMissing False dir
let strIndex = show index
runLegacyGenesisKeyGenUTxOCmd
runGenesisKeyGenUTxOCmd
(File @(VerificationKey ()) $ dir </> "utxo" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "utxo" ++ strIndex ++ ".skey")

Expand Down Expand Up @@ -1272,8 +1268,8 @@ readInitialFundAddresses utxodir nw = do


-- | Hash a genesis file
runLegacyGenesisHashFileCmd :: GenesisFile -> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisHashFileCmd (GenesisFile fpath) = do
runGenesisHashFileCmd :: GenesisFile -> ExceptT ShelleyGenesisCmdError IO ()
runGenesisHashFileCmd (GenesisFile fpath) = do
content <- handleIOExceptT (ShelleyGenesisCmdGenesisFileError . FileIOError fpath) $
BS.readFile fpath
let gh :: Crypto.Hash Crypto.Blake2b_256 ByteString
Expand Down
24 changes: 12 additions & 12 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Cardano.CLI.Legacy.Run.Genesis
import Cardano.Api

import Cardano.Chain.Common (BlockCount)
import qualified Cardano.CLI.EraBased.Run.Genesis as EraBased
import Cardano.CLI.EraBased.Run.Genesis
import Cardano.CLI.Legacy.Commands.Genesis
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.ShelleyGenesisCmdError
Expand Down Expand Up @@ -47,43 +47,43 @@ runLegacyGenesisKeyGenGenesisCmd :: ()
=> VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenGenesisCmd = EraBased.runLegacyGenesisKeyGenGenesisCmd
runLegacyGenesisKeyGenGenesisCmd = runGenesisKeyGenGenesisCmd

runLegacyGenesisKeyGenDelegateCmd :: ()
=> VerificationKeyFile Out
-> SigningKeyFile Out
-> OpCertCounterFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenDelegateCmd = EraBased.runLegacyGenesisKeyGenDelegateCmd
runLegacyGenesisKeyGenDelegateCmd = runGenesisKeyGenDelegateCmd

runLegacyGenesisKeyGenUTxOCmd :: ()
=> VerificationKeyFile Out
-> SigningKeyFile Out
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyGenUTxOCmd = EraBased.runLegacyGenesisKeyGenUTxOCmd
runLegacyGenesisKeyGenUTxOCmd = runGenesisKeyGenUTxOCmd

runLegacyGenesisKeyHashCmd :: VerificationKeyFile In -> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisKeyHashCmd = EraBased.runLegacyGenesisKeyHashCmd
runLegacyGenesisKeyHashCmd = runGenesisKeyHashCmd

runLegacyGenesisVerKeyCmd ::
VerificationKeyFile Out
-> SigningKeyFile In
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisVerKeyCmd = EraBased.runLegacyGenesisVerKeyCmd
runLegacyGenesisVerKeyCmd = runGenesisVerKeyCmd

runLegacyGenesisTxInCmd :: ()
=> VerificationKeyFile In
-> NetworkId
-> Maybe (File () Out)
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisTxInCmd = EraBased.runLegacyGenesisTxInCmd
runLegacyGenesisTxInCmd = runGenesisTxInCmd

runLegacyGenesisAddrCmd :: ()
=> VerificationKeyFile In
-> NetworkId
-> Maybe (File () Out)
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisAddrCmd = EraBased.runLegacyGenesisAddrCmd
runLegacyGenesisAddrCmd = runGenesisAddrCmd

runLegacyGenesisCreateCmd :: ()
=> KeyOutputFormat
Expand All @@ -94,7 +94,7 @@ runLegacyGenesisCreateCmd :: ()
-> Maybe Lovelace
-> NetworkId
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateCmd = EraBased.runLegacyGenesisCreateCmd
runLegacyGenesisCreateCmd = runGenesisCreateCmd

runLegacyGenesisCreateCardanoCmd :: ()
=> GenesisDir
Expand All @@ -112,7 +112,7 @@ runLegacyGenesisCreateCardanoCmd :: ()
-> FilePath -- ^ Conway Genesis
-> Maybe FilePath
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateCardanoCmd = EraBased.runLegacyGenesisCreateCardanoCmd
runLegacyGenesisCreateCardanoCmd = runGenesisCreateCardanoCmd

runLegacyGenesisCreateStakedCmd :: ()
=> KeyOutputFormat -- ^ key output format
Expand All @@ -130,10 +130,10 @@ runLegacyGenesisCreateStakedCmd :: ()
-> Word -- ^ num stuffed UTxO entries
-> Maybe FilePath -- ^ Specified stake pool relays
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisCreateStakedCmd = EraBased.runLegacyGenesisCreateStakedCmd
runLegacyGenesisCreateStakedCmd = runGenesisCreateStakedCmd

-- | Hash a genesis file
runLegacyGenesisHashFileCmd :: ()
=> GenesisFile
-> ExceptT ShelleyGenesisCmdError IO ()
runLegacyGenesisHashFileCmd = EraBased.runLegacyGenesisHashFileCmd
runLegacyGenesisHashFileCmd = runGenesisHashFileCmd

0 comments on commit c0f3c8d

Please sign in to comment.