Skip to content

Commit

Permalink
Merge pull request #1009 from IntersectMBO/smelc/drep-id-extension-to…
Browse files Browse the repository at this point in the history
…-key-hashes

drep id: support key hash
  • Loading branch information
smelc authored Jan 8, 2025
2 parents 56c5420 + 9f7eb2d commit 5c76870
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data GovernanceDRepKeyGenCmdArgs era
data GovernanceDRepIdCmdArgs era
= GovernanceDRepIdCmdArgs
{ eon :: !(ConwayEraOnwards era)
, vkeySource :: !(VerificationKeyOrFile DRepKey)
, vkeySource :: !(VerificationKeyOrHashOrFile DRepKey)
, idOutputFormat :: !IdOutputFormat
, mOutFile :: !(Maybe (File () Out))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pGovernanceDRepKeyIdCmd era = do
$ Opt.info
( fmap GovernanceDRepIdCmd $
GovernanceDRepIdCmdArgs w
<$> pDRepVerificationKeyOrFile
<$> pDRepVerificationKeyOrHashOrFile
<*> pDRepIdOutputFormat
<*> optional pOutputFile
)
Expand Down
8 changes: 4 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ runGovernanceDRepIdCmd
, idOutputFormat
, mOutFile
} = do
drepVerKey <-
drepVerKeyHash <-
modifyError ReadFileError $
readVerificationKeyOrTextEnvFile AsDRepKey vkeySource
readVerificationKeyOrHashOrTextEnvFile AsDRepKey vkeySource

content <-
pure $ case idOutputFormat of
IdOutputFormatHex -> serialiseToRawBytesHex $ verificationKeyHash drepVerKey
IdOutputFormatBech32 -> Text.encodeUtf8 $ serialiseToBech32 $ verificationKeyHash drepVerKey
IdOutputFormatHex -> serialiseToRawBytesHex drepVerKeyHash
IdOutputFormatBech32 -> Text.encodeUtf8 $ serialiseToBech32 drepVerKeyHash

lift (writeByteStringOutput mOutFile content)
& onLeft (left . WriteFileError)
Expand Down
18 changes: 18 additions & 0 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,24 @@ hprop_golden_governance_drep_id_hex =

H.diffFileVsGoldenFile idFile idGold

-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden governance drep id hash/"'@
hprop_golden_governance_drep_id_hash :: Property
hprop_golden_governance_drep_id_hash = propertyOnce $ do
idGold <- H.note "test/cardano-cli-golden/files/golden/governance/drep/drep.id.hash"

output <-
execCardanoCLI
[ "conway"
, "governance"
, "drep"
, "id"
, "--drep-key-hash"
, "c1a342f0dfb82b93ca2e6b406bacb04802f7d56a99d8f95a80a8b6c5"
]

H.diffVsGoldenFile output idGold

hprop_golden_governance_drep_extended_key_signing :: Property
hprop_golden_governance_drep_extended_key_signing =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
drep1cx359uxlhq4e8j3wddqxht9sfqp004t2n8v0jk5q4zmv27sh0h5
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 @@ -7087,6 +7087,7 @@ Usage: cardano-cli conway governance drep key-gen --verification-key-file FILEPA
Usage: cardano-cli conway governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand Down Expand Up @@ -9107,6 +9108,7 @@ Usage: cardano-cli latest governance drep key-gen --verification-key-file FILEPA
Usage: cardano-cli latest governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand Down Expand Up @@ -11729,6 +11731,7 @@ Usage: cardano-cli compatible conway governance drep key-gen --verification-key-
Usage: cardano-cli compatible conway governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Usage: cardano-cli compatible conway governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand All @@ -12,6 +13,8 @@ Available options:
DRep verification key (Bech32 or hex-encoded).
--drep-verification-key-file FILEPATH
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--out-file FILEPATH The output file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Usage: cardano-cli conway governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand All @@ -12,6 +13,8 @@ Available options:
DRep verification key (Bech32 or hex-encoded).
--drep-verification-key-file FILEPATH
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--out-file FILEPATH The output file.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Usage: cardano-cli latest governance drep id
( --drep-verification-key STRING
| --drep-verification-key-file FILEPATH
| --drep-key-hash HASH
)
[--output-format STRING]
[--out-file FILEPATH]
Expand All @@ -12,6 +13,8 @@ Available options:
DRep verification key (Bech32 or hex-encoded).
--drep-verification-key-file FILEPATH
Filepath of the DRep verification key.
--drep-key-hash HASH DRep verification key hash (either Bech32-encoded or
hex-encoded).
--output-format STRING Optional drep id output format. Accepted output
formats are "hex" and "bech32" (default is "bech32").
--out-file FILEPATH The output file.
Expand Down

0 comments on commit 5c76870

Please sign in to comment.