Skip to content

Commit b6e3199

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

File tree

21 files changed

+299
-11
lines changed

21 files changed

+299
-11
lines changed

cabal.project

Lines changed: 6 additions & 0 deletions
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/cardano-cli.cabal

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ library
142142
Cardano.CLI.EraIndependent.Address.Info.Run
143143
Cardano.CLI.EraIndependent.Address.Option
144144
Cardano.CLI.EraIndependent.Address.Run
145+
Cardano.CLI.EraIndependent.Cip.Cip129.Command
146+
Cardano.CLI.EraIndependent.Cip.Cip129.Options
147+
Cardano.CLI.EraIndependent.Cip.Cip129.Run
148+
Cardano.CLI.EraIndependent.Cip.Command
149+
Cardano.CLI.EraIndependent.Cip.Common
150+
Cardano.CLI.EraIndependent.Cip.Options
151+
Cardano.CLI.EraIndependent.Cip.Run
145152
Cardano.CLI.EraIndependent.Debug.CheckNodeConfiguration.Command
146153
Cardano.CLI.EraIndependent.Debug.CheckNodeConfiguration.Run
147154
Cardano.CLI.EraIndependent.Debug.Command

cardano-cli/src/Cardano/CLI/Command.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Cardano.CLI.Compatible.Command
1010
import Cardano.CLI.EraBased.Command
1111
import Cardano.CLI.EraBased.Query.Command
1212
import Cardano.CLI.EraIndependent.Address.Command
13+
import Cardano.CLI.EraIndependent.Cip.Command (CipFormatCmds)
1314
import Cardano.CLI.EraIndependent.Debug.Command
1415
import Cardano.CLI.EraIndependent.Hash.Command (HashCmds)
1516
import Cardano.CLI.EraIndependent.Key.Command
@@ -37,6 +38,8 @@ data ClientCommand
3738
forall era. QueryCommands (QueryCmds era)
3839
| -- | Legacy shelley-based Commands
3940
LegacyCmds LegacyCmds
41+
| -- | Miscellaneous commands
42+
CipFormatCmds CipFormatCmds
4043
| CliPingCommand PingCmd
4144
| CliDebugCmds DebugCmds
4245
| forall a. Help ParserPrefs (ParserInfo a)

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 7 additions & 1 deletion
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+
, DRepIdOutputFormat (..)
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 :: !DRepIdOutputFormat
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 DRepIdOutputFormat
118+
= IdOutputFormat IdOutputFormat
119+
| DRepCIP129OutputFormat
120+
deriving (Eq, Show)

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

Lines changed: 8 additions & 4 deletions
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 DRepIdOutputFormat
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 DRepCIP129OutputFormat "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

Lines changed: 7 additions & 2 deletions
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.DRepCIP129OutputFormat ->
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)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Cardano.CLI.EraIndependent.Cip.Cip129.Command
2+
( Cip129(..)
3+
)
4+
where
5+
6+
import Cardano.CLI.EraIndependent.Cip.Common
7+
8+
data Cip129
9+
= Cip129DRep Input Output
10+
| Cip129CommitteeHotKey Input Output
11+
| Cip129CommitteeColdKey Input Output
12+
| Cip129GovernanceAction Input Output
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
module Cardano.CLI.EraIndependent.Cip.Cip129.Options
2+
( pCip129
3+
)
4+
where
5+
6+
import Options.Applicative qualified as Opt
7+
import Cardano.CLI.EraIndependent.Cip.Command
8+
import Control.Applicative
9+
import Cardano.CLI.EraIndependent.Cip.Common
10+
11+
pCip129 :: Opt.Parser CipFormatCmds
12+
pCip129 = Cip129 <$> asum [ pCip129Drep
13+
, pCip129CommitteeHotKey
14+
, pCip129CommitteeColdKey
15+
, pCip129GovernanceAction
16+
]
17+
18+
pCip129Drep :: Opt.Parser Cip129
19+
pCip129Drep =
20+
Cip129DRep
21+
<$> pInput
22+
<*> pOutput
23+
where
24+
pInput = asum [ pInputFile "drep-file" "Input hex/bech32/text envelope drep file"
25+
, pInputHexText "drep-hex" "HEX" "Input hex encoded drep"
26+
, pInputBech32Text "drep-bech32" "BECH32" "Input bech32 encoded drep"
27+
]
28+
29+
pCip129CommitteeHotKey :: Opt.Parser Cip129
30+
pCip129CommitteeHotKey =
31+
Cip129CommitteeHotKey
32+
<$> pInput
33+
<*> pOutput
34+
where
35+
pInput = asum [ pInputFile "committee-hot-key-file" "Input hex/bech32/text envelope committee hot key file"
36+
, pInputHexText "committee-hot-key-hex" "HEX" "Input hex encoded committee hot key"
37+
, pInputBech32Text "committee-hot-key-bech32" "BECH32" "Input bech32 encoded committee hot key"
38+
]
39+
40+
pCip129CommitteeColdKey :: Opt.Parser Cip129
41+
pCip129CommitteeColdKey =
42+
Cip129CommitteeColdKey
43+
<$> pInput
44+
<*> pOutput
45+
where
46+
pInput = asum [ pInputFile "committee-cold-key-file" "Input hex/bech32/text envelope committee cold key file"
47+
, pInputHexText "committee-cold-key-hex" "HEX" "Input hex encoded committee cold key"
48+
, pInputBech32Text "committee-cold-key-bech32" "BECH32" "Input bech32 encoded committee cold key"
49+
]
50+
51+
pCip129GovernanceAction :: Opt.Parser Cip129
52+
pCip129GovernanceAction =
53+
Cip129GovernanceAction
54+
<$> pInput
55+
<*> pOutput
56+
where
57+
pInput = asum [ pInputFile "governance-action-file" "Input hex/bech32/text envelope governance action file"
58+
, pInputHexText "governance-action-hex" "HEX" "Input hex encoded governance action"
59+
, pInputBech32Text "governance-action-bech32" "BECH32" "Input bech32 encoded governance action"
60+
]
61+
62+
63+
64+
pOutput :: Opt.Parser Output
65+
pOutput = asum [ pOutputFile "output-file" "Output file"
66+
, pOutputText "output-text" "TEXT" "Output text"
67+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Cardano.CLI.EraIndependent.Cip.Cip129.Run
2+
( runCip129
3+
)
4+
where
5+
6+
import Cardano.CLI.EraIndependent.Cip.Cip129.Command
7+
8+
runCip129 :: Cip129 -> IO ()
9+
runCip129 (Cip129DRep inp out) = undefined
10+
runCip129 (Cip129CommitteeHotKey inp out) = undefined
11+
runCip129 (Cip129CommitteeColdKey inp out) = undefined
12+
runCip129 (Cip129GovernanceAction inp out) = undefined

0 commit comments

Comments
 (0)