Skip to content

Commit d55cb33

Browse files
committed
Incorporate cip-129
1 parent e270070 commit d55cb33

File tree

10 files changed

+56
-11
lines changed

10 files changed

+56
-11
lines changed

cabal.project

+6
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ if impl (ghc >= 9.12)
7777
-- https://github.com/fizruk/http-api-data/pull/146
7878
, http-api-data:base
7979

80+
81+
source-repository-package
82+
type: git
83+
location: https://github.com/IntersectMBO/cardano-api.git
84+
tag: cc7535791ee480e7644acc3283c58e4a2f44e85d
85+
subdir: cardano-api

cardano-cli/src/Cardano/CLI/EraBased/Common/Option.hs

+1
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,7 @@ pKesVerificationKey =
19781978
Left err@(Bech32DataPartToBytesError _) -> Left (docToString $ prettyError err)
19791979
Left err@(Bech32DeserialiseFromBytesError _) -> Left (docToString $ prettyError err)
19801980
Left err@(Bech32WrongPrefix _ _) -> Left (docToString $ prettyError err)
1981+
Left err@(Bech32UnexpectedHeader _ _) -> Left (docToString $ prettyError err)
19811982
-- The input was not valid Bech32. Attempt to deserialise it as hex.
19821983
Left (Bech32DecodingError _) ->
19831984
first

cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Command.hs

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Cardano.CLI.EraBased.Governance.DRep.Command
1111
, GovernanceDRepRetirementCertificateCmdArgs (..)
1212
, GovernanceDRepUpdateCertificateCmdArgs (..)
1313
, GovernanceDRepMetadataHashCmdArgs (..)
14+
, GovIdOutputFormat (..)
1415
, DRepMetadataSource (..)
1516
)
1617
where
@@ -43,7 +44,7 @@ data GovernanceDRepIdCmdArgs era
4344
= GovernanceDRepIdCmdArgs
4445
{ eon :: !(ConwayEraOnwards era)
4546
, vkeySource :: !(VerificationKeyOrHashOrFile DRepKey)
46-
, idOutputFormat :: !IdOutputFormat
47+
, idOutputFormat :: !GovIdOutputFormat
4748
, mOutFile :: !(Maybe (File () Out))
4849
}
4950

@@ -112,3 +113,8 @@ renderGovernanceDRepCmds = \case
112113
"governance drep update-certificate"
113114
GovernanceDRepMetadataHashCmd{} ->
114115
"governance drep metadata-hash"
116+
117+
data GovIdOutputFormat
118+
= IdOutputFormat IdOutputFormat
119+
| CIP129OutputFormat
120+
deriving (Eq, Show)

cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Option.hs

+8-4
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,16 @@ pGovernanceDRepKeyIdCmd era = do
7676
)
7777
$ Opt.progDesc "Generate a drep id."
7878

79-
pDRepIdOutputFormat :: Parser IdOutputFormat
79+
pDRepIdOutputFormat :: Parser GovIdOutputFormat
8080
pDRepIdOutputFormat =
81-
asum [make IdOutputFormatHex "hex", make IdOutputFormatBech32 "bech32"]
82-
<|> pure default_
81+
asum
82+
[ make (IdOutputFormat IdOutputFormatHex) "hex"
83+
, make (IdOutputFormat IdOutputFormatBech32) "bech32"
84+
, make CIP129OutputFormat "cip129"
85+
, pure default_
86+
]
8387
where
84-
default_ = IdOutputFormatBech32
88+
default_ = IdOutputFormat IdOutputFormatBech32
8589
make format flag_ =
8690
Opt.flag' format $
8791
mconcat

cardano-cli/src/Cardano/CLI/EraBased/Governance/DRep/Run.hs

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ where
1717

1818
import Cardano.Api
1919
import Cardano.Api.Ledger qualified as L
20+
import Cardano.Api.Shelley
2021

2122
import Cardano.CLI.EraBased.Governance.DRep.Command qualified as Cmd
2223
import Cardano.CLI.EraIndependent.Hash.Command qualified as Cmd
@@ -93,8 +94,12 @@ runGovernanceDRepIdCmd
9394

9495
content <-
9596
pure $ case idOutputFormat of
96-
IdOutputFormatHex -> serialiseToRawBytesHex drepVerKeyHash
97-
IdOutputFormatBech32 -> Text.encodeUtf8 $ serialiseToBech32 drepVerKeyHash
97+
Cmd.IdOutputFormat IdOutputFormatHex -> serialiseToRawBytesHex drepVerKeyHash
98+
Cmd.IdOutputFormat IdOutputFormatBech32 -> Text.encodeUtf8 $ serialiseToBech32 drepVerKeyHash
99+
Cmd.CIP129OutputFormat ->
100+
let DRepKeyHash kh = drepVerKeyHash
101+
keyCredential = L.KeyHashObj kh
102+
in Text.encodeUtf8 $ serialiseToBech32CIP129 keyCredential
98103

99104
lift (writeByteStringOutput mOutFile content)
100105
& onLeft (left . WriteFileError)

cardano-cli/src/Cardano/CLI/EraIndependent/Key/Run.hs

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import Cardano.Api
3636
import Cardano.Api.Byron qualified as ByronApi
3737
import Cardano.Api.Crypto.Ed25519Bip32 (xPrvFromBytes)
3838
import Cardano.Api.Ledger qualified as L
39+
import Cardano.Api.Shelley
3940

4041
import Cardano.CLI.Byron.Key qualified as Byron
4142
import Cardano.CLI.EraIndependent.Key.Command qualified as Cmd
@@ -178,12 +179,15 @@ runNonExtendedKeyCmd
178179
vkf
179180
(Just genesisVkeyDelegateDesc)
180181
(castVerificationKey vk :: VerificationKey GenesisDelegateKey)
182+
AStakePoolExtendedVerificationKey vk ->
183+
writeToDisk vkf (Just stakeVkeyDesc) (castVerificationKey vk :: VerificationKey StakePoolKey)
181184
-- Non-extended keys are below and cause failure.
182185
vk@AByronVerificationKey{} -> goFail vk
183186
vk@APaymentVerificationKey{} -> goFail vk
184187
vk@AGenesisUTxOVerificationKey{} -> goFail vk
185188
vk@AKesVerificationKey{} -> goFail vk
186189
vk@AVrfVerificationKey{} -> goFail vk
190+
vk@AStakePoolVerificationKey{} -> goFail vk
187191
vk@AStakeVerificationKey{} -> goFail vk
188192
vk@ADRepVerificationKey{} -> goFail vk
189193
vk@ACommitteeColdVerificationKey{} -> goFail vk
@@ -216,6 +220,7 @@ readExtendedVerificationKeyFile evkfile = do
216220
k@ADRepExtendedVerificationKey{} -> return k
217221
k@ACommitteeColdExtendedVerificationKey{} -> return k
218222
k@ACommitteeHotExtendedVerificationKey{} -> return k
223+
k@AStakePoolExtendedVerificationKey{} -> return k
219224
k@AStakeExtendedVerificationKey{} -> return k
220225
k@AGenesisExtendedVerificationKey{} -> return k
221226
k@AGenesisDelegateExtendedVerificationKey{} -> return k
@@ -225,6 +230,7 @@ readExtendedVerificationKeyFile evkfile = do
225230
k@AGenesisUTxOVerificationKey{} -> goFail k
226231
k@AKesVerificationKey{} -> goFail k
227232
k@AVrfVerificationKey{} -> goFail k
233+
k@AStakePoolVerificationKey{} -> goFail k
228234
k@AStakeVerificationKey{} -> goFail k
229235
k@ADRepVerificationKey{} -> goFail k
230236
k@ACommitteeColdVerificationKey{} -> goFail k

cardano-cli/test/cardano-cli-golden/files/golden/help.cli

+9-2
Original file line numberDiff line numberDiff line change
@@ -7347,7 +7347,10 @@ Usage: cardano-cli conway governance drep id
73477347
| --drep-verification-key-file FILEPATH
73487348
| --drep-key-hash HASH
73497349
)
7350-
[--output-hex | --output-bech32]
7350+
[ --output-hex
7351+
| --output-bech32
7352+
| --output-cip129
7353+
]
73517354
[--out-file FILEPATH]
73527355

73537356
Generate a drep id.
@@ -9448,7 +9451,10 @@ Usage: cardano-cli latest governance drep id
94489451
| --drep-verification-key-file FILEPATH
94499452
| --drep-key-hash HASH
94509453
)
9451-
[--output-hex | --output-bech32]
9454+
[ --output-hex
9455+
| --output-bech32
9456+
| --output-cip129
9457+
]
94529458
[--out-file FILEPATH]
94539459

94549460
Generate a drep id.
@@ -12628,6 +12634,7 @@ Usage: cardano-cli compatible conway governance drep id
1262812634
)
1262912635
[ --output-hex
1263012636
| --output-bech32
12637+
| --output-cip129
1263112638
]
1263212639
[--out-file FILEPATH]
1263312640

cardano-cli/test/cardano-cli-golden/files/golden/help/compatible_conway_governance_drep_id.cli

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Usage: cardano-cli compatible conway governance drep id
55
)
66
[ --output-hex
77
| --output-bech32
8+
| --output-cip129
89
]
910
[--out-file FILEPATH]
1011

@@ -19,5 +20,6 @@ Available options:
1920
hex-encoded).
2021
--output-hex Format drep id output as hex.
2122
--output-bech32 Format drep id output as bech32 (the default).
23+
--output-cip129 Format drep id output as cip129.
2224
--out-file FILEPATH The output file.
2325
-h,--help Show this help text

cardano-cli/test/cardano-cli-golden/files/golden/help/conway_governance_drep_id.cli

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ Usage: cardano-cli conway governance drep id
33
| --drep-verification-key-file FILEPATH
44
| --drep-key-hash HASH
55
)
6-
[--output-hex | --output-bech32]
6+
[ --output-hex
7+
| --output-bech32
8+
| --output-cip129
9+
]
710
[--out-file FILEPATH]
811

912
Generate a drep id.
@@ -17,5 +20,6 @@ Available options:
1720
hex-encoded).
1821
--output-hex Format drep id output as hex.
1922
--output-bech32 Format drep id output as bech32 (the default).
23+
--output-cip129 Format drep id output as cip129.
2024
--out-file FILEPATH The output file.
2125
-h,--help Show this help text

cardano-cli/test/cardano-cli-golden/files/golden/help/latest_governance_drep_id.cli

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ Usage: cardano-cli latest governance drep id
33
| --drep-verification-key-file FILEPATH
44
| --drep-key-hash HASH
55
)
6-
[--output-hex | --output-bech32]
6+
[ --output-hex
7+
| --output-bech32
8+
| --output-cip129
9+
]
710
[--out-file FILEPATH]
811

912
Generate a drep id.
@@ -17,5 +20,6 @@ Available options:
1720
hex-encoded).
1821
--output-hex Format drep id output as hex.
1922
--output-bech32 Format drep id output as bech32 (the default).
23+
--output-cip129 Format drep id output as cip129.
2024
--out-file FILEPATH The output file.
2125
-h,--help Show this help text

0 commit comments

Comments
 (0)