Skip to content

Commit

Permalink
Merge pull request #497 from input-output-hk/smelc/refactor-in-create…
Browse files Browse the repository at this point in the history
…-staked

create-staked: simplify some code
  • Loading branch information
smelc authored Dec 4, 2023
2 parents 163d80d + 56a049a commit 3b06b42
Showing 1 changed file with 23 additions and 39 deletions.
62 changes: 23 additions & 39 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,9 @@ runGenesisKeyGenGenesisCmd
} = do
skey <- liftIO $ generateSigningKey AsGenesisKey
let vkey = getVerificationKey skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile signingKeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile verificationKeyPath
$ textEnvelopeToJSON (Just Key.genesisVkeyDesc) vkey
firstExceptT GenesisCmdGenesisFileError . newExceptT $ do
void $ writeLazyByteStringFile signingKeyPath $ textEnvelopeToJSON (Just skeyDesc) skey
writeLazyByteStringFile verificationKeyPath $ textEnvelopeToJSON (Just Key.genesisVkeyDesc) vkey
where
skeyDesc :: TextEnvelopeDescr
skeyDesc = "Genesis Signing Key"
Expand All @@ -191,21 +186,16 @@ runGenesisKeyGenDelegateCmd
} = do
skey <- liftIO $ generateSigningKey AsGenesisDelegateKey
let vkey = getVerificationKey skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile signingKeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile verificationKeyPath
$ textEnvelopeToJSON (Just Key.genesisVkeyDelegateDesc) vkey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile opCertCounterPath
$ textEnvelopeToJSON (Just certCtrDesc)
$ OperationalCertificateIssueCounter
initialCounter
(castVerificationKey vkey) -- Cast to a 'StakePoolKey'
firstExceptT GenesisCmdGenesisFileError . newExceptT $ do
void $ writeLazyByteStringFile signingKeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
void $ writeLazyByteStringFile verificationKeyPath
$ textEnvelopeToJSON (Just Key.genesisVkeyDelegateDesc) vkey
writeLazyByteStringFile opCertCounterPath
$ textEnvelopeToJSON (Just certCtrDesc)
$ OperationalCertificateIssueCounter
initialCounter
(castVerificationKey vkey) -- Cast to a 'StakePoolKey'
where
skeyDesc, certCtrDesc :: TextEnvelopeDescr
skeyDesc = "Genesis delegate operator key"
Expand All @@ -223,14 +213,11 @@ runGenesisKeyGenDelegateVRF ::
runGenesisKeyGenDelegateVRF vkeyPath skeyPath = do
skey <- liftIO $ generateSigningKey AsVrfKey
let vkey = getVerificationKey skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile skeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile vkeyPath
$ textEnvelopeToJSON (Just vkeyDesc) vkey
firstExceptT GenesisCmdGenesisFileError . newExceptT $ do
void $ writeLazyByteStringFile skeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
writeLazyByteStringFile vkeyPath
$ textEnvelopeToJSON (Just vkeyDesc) vkey
where
skeyDesc, vkeyDesc :: TextEnvelopeDescr
skeyDesc = "VRF Signing Key"
Expand All @@ -247,14 +234,11 @@ runGenesisKeyGenUTxOCmd
} = do
skey <- liftIO $ generateSigningKey AsGenesisUTxOKey
let vkey = getVerificationKey skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile signingKeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
firstExceptT GenesisCmdGenesisFileError
. newExceptT
$ writeLazyByteStringFile verificationKeyPath
$ textEnvelopeToJSON (Just vkeyDesc) vkey
firstExceptT GenesisCmdGenesisFileError . newExceptT $ do
void $ writeLazyByteStringFile signingKeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
writeLazyByteStringFile verificationKeyPath
$ textEnvelopeToJSON (Just vkeyDesc) vkey
where
skeyDesc, vkeyDesc :: TextEnvelopeDescr
skeyDesc = "Genesis Initial UTxO Signing Key"
Expand Down

0 comments on commit 3b06b42

Please sign in to comment.