Skip to content

Commit

Permalink
drep verification key: extended->non extended: specify description
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Oct 31, 2023
1 parent eab272f commit 789e9fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 2 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Cardano.Api
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Shelley

import qualified Cardano.CLI.EraBased.Run.Key as Key
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.GovernanceCmdError
import qualified Cardano.Ledger.Shelley.TxBody as Shelley
Expand Down Expand Up @@ -90,10 +91,8 @@ runGovernanceDRepKeyGen _w vkeyPath skeyPath = firstExceptT GovernanceCmdWriteFi
skey <- liftIO $ generateSigningKey AsDRepKey
let vkey = getVerificationKey skey
newExceptT $ writeLazyByteStringFile skeyPath (textEnvelopeToJSON (Just skeyDesc) skey)
newExceptT $ writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just vkeyDesc) vkey)
newExceptT $ writeLazyByteStringFile vkeyPath (textEnvelopeToJSON (Just Key.drepKeyEnvelopeDescr) vkey)
where
skeyDesc :: TextEnvelopeDescr
skeyDesc = "Delegate Representative Signing Key"
vkeyDesc :: TextEnvelopeDescr
vkeyDesc = "Delegate Representative Verification Key"

20 changes: 13 additions & 7 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module Cardano.CLI.EraBased.Run.Key
, runNonExtendedKeyCmd
, runVerificationKeyCmd

, drepKeyEnvelopeDescr

-- * Exports for testing
, decodeBech32
) where
Expand Down Expand Up @@ -54,6 +56,9 @@ import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import System.Exit (exitFailure)

drepKeyEnvelopeDescr :: TextEnvelopeDescr
drepKeyEnvelopeDescr = "Delegate Representative Verification Key"

runKeyCmds :: ()
=> Cmd.KeyCmds era
-> ExceptT KeyCmdError IO ()
Expand Down Expand Up @@ -110,26 +115,27 @@ runNonExtendedKeyCmd
writeVerificationKey ssk =
case ssk of
APaymentExtendedVerificationKey vk ->
writeToDisk vkf (castVerificationKey vk :: VerificationKey PaymentKey)
writeToDisk vkf Nothing (castVerificationKey vk :: VerificationKey PaymentKey)
ADRepExtendedVerificationKey vk ->
writeToDisk vkf (castVerificationKey vk :: VerificationKey DRepKey)
writeToDisk vkf (Just drepKeyEnvelopeDescr) (castVerificationKey vk :: VerificationKey DRepKey)
AStakeExtendedVerificationKey vk ->
writeToDisk vkf (castVerificationKey vk :: VerificationKey StakeKey)
writeToDisk vkf Nothing (castVerificationKey vk :: VerificationKey StakeKey)
AGenesisExtendedVerificationKey vk ->
writeToDisk vkf (castVerificationKey vk :: VerificationKey GenesisKey)
writeToDisk vkf Nothing (castVerificationKey vk :: VerificationKey GenesisKey)
AGenesisDelegateExtendedVerificationKey vk ->
writeToDisk vkf (castVerificationKey vk :: VerificationKey GenesisDelegateKey)
writeToDisk vkf Nothing (castVerificationKey vk :: VerificationKey GenesisDelegateKey)
nonExtendedKey -> left $ KeyCmdExpectedExtendedVerificationKey nonExtendedKey


writeToDisk
:: Key keyrole
=> File content Out
-> Maybe TextEnvelopeDescr
-> VerificationKey keyrole
-> ExceptT KeyCmdError IO ()
writeToDisk vkf' vk =
writeToDisk vkf' descr vk =
firstExceptT KeyCmdWriteFileError . newExceptT
$ writeLazyByteStringFile vkf' $ textEnvelopeToJSON Nothing vk
$ writeLazyByteStringFile vkf' $ textEnvelopeToJSON descr vk


readExtendedVerificationKeyFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "DRepVerificationKey_ed25519",
"description": "",
"description": "Delegate Representative Verification Key",
"cborHex": "5820b0cd9e6e3e274f4f38f55ef274af123cf4600ac0c58294399b7e076175262553"
}

0 comments on commit 789e9fd

Please sign in to comment.