Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drep id: support key hash #1009

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -83,14 +83,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
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
Loading