Skip to content

Commit be39835

Browse files
committed
Misc changes
Review changes
1 parent 1347d5a commit be39835

File tree

15 files changed

+83
-68
lines changed

15 files changed

+83
-68
lines changed

cardano-cli/cardano-cli.cabal

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ library
137137
Cardano.CLI.EraIndependent.Address.Info.Run
138138
Cardano.CLI.EraIndependent.Address.Option
139139
Cardano.CLI.EraIndependent.Address.Run
140+
Cardano.CLI.EraIndependent.Cip.Cip129.Command
141+
Cardano.CLI.EraIndependent.Cip.Cip129.Internal.Conversion
142+
Cardano.CLI.EraIndependent.Cip.Cip129.Option
143+
Cardano.CLI.EraIndependent.Cip.Cip129.Run
144+
Cardano.CLI.EraIndependent.Cip.Command
145+
Cardano.CLI.EraIndependent.Cip.Common
146+
Cardano.CLI.EraIndependent.Cip.Option
147+
Cardano.CLI.EraIndependent.Cip.Run
140148
Cardano.CLI.EraIndependent.Debug.CheckNodeConfiguration.Command
141149
Cardano.CLI.EraIndependent.Debug.CheckNodeConfiguration.Run
142150
Cardano.CLI.EraIndependent.Debug.Command
@@ -177,6 +185,10 @@ library
177185
Cardano.CLI.Orphan
178186
Cardano.CLI.Parser
179187
Cardano.CLI.Read
188+
Cardano.CLI.Read.Committee.ColdKey
189+
Cardano.CLI.Read.Committee.HotKey
190+
Cardano.CLI.Read.DRep
191+
Cardano.CLI.Read.GovernanceActionId
180192
Cardano.CLI.Render
181193
Cardano.CLI.Run
182194
Cardano.CLI.Run.Mnemonic
@@ -280,6 +292,7 @@ library
280292
transformers-except ^>=0.1.3,
281293
unliftio-core,
282294
utf8-string,
295+
validation,
283296
vary ^>=0.1.1.2,
284297
vector,
285298
yaml,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import Cardano.CLI.Type.Key
2525

2626
import Data.Text (Text)
2727
import Vary
28-
import Vary (Vary)
2928

3029
data GovernanceDRepCmds era
3130
= GovernanceDRepKeyGenCmd !(GovernanceDRepKeyGenCmdArgs era)

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import Data.Foldable (asum)
2323
import Data.Function
2424
import Options.Applicative (Parser)
2525
import Options.Applicative qualified as Opt
26-
import Vary
2726

2827
pGovernanceDRepCmds
2928
:: ()
@@ -85,22 +84,6 @@ pGovernanceDRepKeyIdCmd era = do
8584
)
8685
$ Opt.progDesc "Generate a drep id."
8786

88-
pDRepIdOutputFormat :: Parser (Vary [FormatBech32, FormatHex])
89-
pDRepIdOutputFormat =
90-
asum [make (Vary.from FormatHex) "hex", make (Vary.from FormatBech32) "bech32"]
91-
<|> pure default_
92-
where
93-
default_ = Vary.from FormatBech32
94-
make format flag_ =
95-
Opt.flag' format $
96-
mconcat
97-
[ Opt.help $
98-
"Format drep id output as "
99-
<> flag_
100-
<> (if format == default_ then " (the default)." else ".")
101-
, Opt.long ("output-" <> flag_)
102-
]
103-
10487
-- Registration Certificate related
10588

10689
pRegistrationCertificateCmd

cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ where
4242
import Cardano.Api hiding (QueryInShelleyBasedEra (..))
4343
import Cardano.Api qualified as Api
4444
import Cardano.Api.Consensus qualified as Consensus
45-
import Cardano.Api.Ledger (StandardCrypto, strictMaybeToMaybe)
45+
import Cardano.Api.Ledger (strictMaybeToMaybe)
4646
import Cardano.Api.Ledger qualified as L
4747
import Cardano.Api.Network (LedgerPeerSnapshot, Serialised (..))
4848
import Cardano.Api.Network qualified as Consensus
@@ -1224,7 +1224,7 @@ writePoolState outputFormat mOutFile serialisedCurrentEpochState = do
12241224
<> Map.keysSet (L.psFutureStakePoolParams poolState)
12251225
<> Map.keysSet (L.psRetiring poolState)
12261226

1227-
let poolStates :: Map (L.KeyHash 'L.StakePool) (Params StandardCrypto)
1227+
let poolStates :: Map (L.KeyHash 'L.StakePool) Params
12281228
poolStates =
12291229
fromList $
12301230
hks

cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Conversion.hs renamed to cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Internal/Conversion.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE DataKinds #-}
22

3-
module Cardano.CLI.EraIndependent.Cip.Cip129.Conversion
3+
module Cardano.CLI.EraIndependent.Cip.Cip129.Internal.Conversion
44
( encodeCip129DrepVerficationKeyText
55
, encodeCip129CommitteeColdVerficationKeyText
66
, encodeCip129CommitteeHotVerficationKeyText

cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Options.hs renamed to cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Option.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Cardano.CLI.EraIndependent.Cip.Cip129.Options
1+
module Cardano.CLI.EraIndependent.Cip.Cip129.Option
22
( pCip129
33
)
44
where
@@ -7,7 +7,7 @@ import Cardano.CLI.EraIndependent.Cip.Command
77
import Cardano.CLI.EraIndependent.Cip.Common
88
import Cardano.CLI.Parser
99

10-
import Control.Applicative
10+
import Data.Foldable
1111
import Options.Applicative qualified as Opt
1212

1313
-- Add sub parsers

cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Cip129/Run.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Cardano.Api hiding (Cip129)
99

1010
import Cardano.CLI.Compatible.Exception
1111
import Cardano.CLI.EraIndependent.Cip.Cip129.Command
12-
import Cardano.CLI.EraIndependent.Cip.Cip129.Conversion
12+
import Cardano.CLI.EraIndependent.Cip.Cip129.Internal.Conversion
1313
import Cardano.CLI.EraIndependent.Cip.Common
1414
import Cardano.CLI.Orphan ()
1515
import Cardano.CLI.Read

cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Options.hs renamed to cardano-cli/src/Cardano/CLI/EraIndependent/Cip/Option.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
module Cardano.CLI.EraIndependent.Cip.Options
1+
module Cardano.CLI.EraIndependent.Cip.Option
22
( parseCipCmd
33
)
44
where
55

66
import Cardano.CLI.Command (ClientCommand (CipFormatCmds))
7-
import Cardano.CLI.EraIndependent.Cip.Cip129.Options
7+
import Cardano.CLI.EraIndependent.Cip.Cip129.Option
88
import Cardano.CLI.EraIndependent.Cip.Command
99
import Cardano.CLI.Parser
1010

@@ -27,6 +27,6 @@ pCipFormat =
2727
Opt.info pCip129 $
2828
Opt.progDesc $
2929
mconcat
30-
[ "Modified binary encoding of drep keys, constitutional committee cold and hot keys, governance actions."
30+
[ "Modified binary encoding of drep keys, constitutional committee cold and hot keys, governance actions. "
3131
, "https://github.com/cardano-foundation/CIPs/tree/master/CIP-0129"
3232
]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Cardano.Api
3737
import Cardano.Api.Byron qualified as ByronApi
3838
import Cardano.Api.Crypto.Ed25519Bip32 (xPrvFromBytes)
3939
import Cardano.Api.Ledger qualified as L
40-
import Cardano.Api.Shelley (StakePoolKey)
40+
import Cardano.Api.Shelley
4141

4242
import Cardano.CLI.Byron.Key qualified as Byron
4343
import Cardano.CLI.EraIndependent.Key.Command qualified as Cmd
@@ -205,8 +205,8 @@ runNonExtendedKeyCmd
205205
vk@AGenesisUTxOVerificationKey{} -> goFail vk
206206
vk@AKesVerificationKey{} -> goFail vk
207207
vk@AVrfVerificationKey{} -> goFail vk
208-
vk@AStakeVerificationKey{} -> goFail vk
209208
vk@AStakePoolVerificationKey{} -> goFail vk
209+
vk@AStakeVerificationKey{} -> goFail vk
210210
vk@ADRepVerificationKey{} -> goFail vk
211211
vk@ACommitteeColdVerificationKey{} -> goFail vk
212212
vk@ACommitteeHotVerificationKey{} -> goFail vk
@@ -245,18 +245,18 @@ readExtendedVerificationKeyFile evkfile = do
245245
k@ADRepExtendedVerificationKey{} -> return k
246246
k@ACommitteeColdExtendedVerificationKey{} -> return k
247247
k@ACommitteeHotExtendedVerificationKey{} -> return k
248+
k@AStakePoolExtendedVerificationKey{} -> return k
248249
k@AStakeExtendedVerificationKey{} -> return k
249250
k@AGenesisExtendedVerificationKey{} -> return k
250251
k@AGenesisDelegateExtendedVerificationKey{} -> return k
251-
k@AStakePoolExtendedVerificationKey{} -> return k
252252
-- Non-extended keys are below and cause failure.
253253
k@AByronVerificationKey{} -> goFail k
254254
k@APaymentVerificationKey{} -> goFail k
255255
k@AGenesisUTxOVerificationKey{} -> goFail k
256256
k@AKesVerificationKey{} -> goFail k
257257
k@AVrfVerificationKey{} -> goFail k
258-
k@AStakeVerificationKey{} -> goFail k
259258
k@AStakePoolVerificationKey{} -> goFail k
259+
k@AStakeVerificationKey{} -> goFail k
260260
k@ADRepVerificationKey{} -> goFail k
261261
k@ACommitteeColdVerificationKey{} -> goFail k
262262
k@ACommitteeHotVerificationKey{} -> goFail k

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Cardano.CLI.EraBased.Common.Option
1616
import Cardano.CLI.EraBased.Option
1717
import Cardano.CLI.EraBased.Query.Option (pQueryCmdsTopLevel)
1818
import Cardano.CLI.EraIndependent.Address.Option
19-
import Cardano.CLI.EraIndependent.Cip.Options
19+
import Cardano.CLI.EraIndependent.Cip.Option
2020
import Cardano.CLI.EraIndependent.Debug.Option
2121
import Cardano.CLI.EraIndependent.Hash.Option
2222
import Cardano.CLI.EraIndependent.Key.Option

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Cardano.Ledger.Conway.Governance qualified as L
2525
import Cardano.Ledger.State qualified as L
2626

2727
import Data.Aeson
28+
import Text.Parsec qualified as Text
2829

2930
instance ToJSON L.DefaultVote where
3031
toJSON defaultVote =
@@ -33,6 +34,15 @@ instance ToJSON L.DefaultVote where
3334
L.DefaultAbstain -> String "DefaultAbstain"
3435
L.DefaultNoConfidence -> String "DefaultNoConfidence"
3536

37+
instance Error [Bech32DecodeError] where
38+
prettyError errs = vsep $ map prettyError errs
39+
40+
instance Error [RawBytesHexError] where
41+
prettyError errs = vsep $ map prettyError errs
42+
43+
instance Error Text.ParseError where
44+
prettyError = pretty . show
45+
3646
instance Error (VotesMergingConflict era) where
3747
prettyError = pretty . show
3848

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ module Cardano.CLI.Read
6868
, fileOrPipePath
6969
, fileOrPipeCache
7070
, readFileOrPipe
71+
, readFileOrPipeTextEnvelopeAnyOf
7172

7273
-- * Stake credentials
7374
, getStakeCredentialFromVerifier

cardano-cli/src/Cardano/CLI/Read/Committee/ColdKey.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import Data.Text (Text)
2525
import Data.Validation
2626

2727
data AnyCommitteeColdVerificationKey where
28-
AnyCommitteeColdVerificationKey :: VerificationKey CommitteeColdKey -> AnyCommitteeColdVerificationKey
28+
AnyCommitteeColdVerificationKey
29+
:: VerificationKey CommitteeColdKey -> AnyCommitteeColdVerificationKey
2930
AnyCommitteeColdExtendedVerificationKey
3031
:: VerificationKey CommitteeColdExtendedKey -> AnyCommitteeColdVerificationKey
3132

@@ -37,11 +38,11 @@ readCommitteeColdBech32VerificationKeyText committeeColdText =
3738
let vkey =
3839
liftError return $
3940
AnyCommitteeColdVerificationKey
40-
<$> deserialiseFromBech32 (AsVerificationKey AsCommitteeColdKey) committeeColdText
41+
<$> deserialiseFromBech32 committeeColdText
4142
extendedVkey =
4243
liftError return $
4344
AnyCommitteeColdExtendedVerificationKey
44-
<$> deserialiseFromBech32 (AsVerificationKey AsCommitteeColdExtendedKey) committeeColdText
45+
<$> deserialiseFromBech32 committeeColdText
4546
in vkey <> extendedVkey
4647

4748
readCommitteeColdHexVerificationKeyText
@@ -51,11 +52,11 @@ readCommitteeColdHexVerificationKeyText committeeColdText =
5152
vkey =
5253
liftError return $
5354
AnyCommitteeColdVerificationKey
54-
<$> deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeColdKey) committeeColdBs
55+
<$> deserialiseFromRawBytesHex committeeColdBs
5556
extendedVkey =
5657
liftError return $
5758
AnyCommitteeColdExtendedVerificationKey
58-
<$> deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeColdExtendedKey) committeeColdBs
59+
<$> deserialiseFromRawBytesHex committeeColdBs
5960
in vkey <> extendedVkey
6061

6162
readCommitteeColdVerificationKeyFile

cardano-cli/src/Cardano/CLI/Read/Committee/HotKey.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ readCommitteeHotBech32VerificationKeyText committeeHot =
3737
let vkey =
3838
liftError return $
3939
AnyCommitteeHotVerificationKey
40-
<$> deserialiseFromBech32 (AsVerificationKey AsCommitteeHotKey) committeeHot
40+
<$> deserialiseFromBech32 committeeHot
4141
extendedVkey =
4242
liftError return $
4343
AnyCommitteeHotExtendedVerificationKey
44-
<$> deserialiseFromBech32 (AsVerificationKey AsCommitteeHotExtendedKey) committeeHot
44+
<$> deserialiseFromBech32 committeeHot
4545
in vkey <> extendedVkey
4646

4747
readCommitteeHotHexVerificationKeyText
@@ -51,11 +51,11 @@ readCommitteeHotHexVerificationKeyText committeeHotText =
5151
vkey =
5252
liftError return $
5353
AnyCommitteeHotVerificationKey
54-
<$> deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotKey) committeeHotBs
54+
<$> deserialiseFromRawBytesHex committeeHotBs
5555
extendedVkey =
5656
liftError return $
5757
AnyCommitteeHotExtendedVerificationKey
58-
<$> deserialiseFromRawBytesHex (AsVerificationKey AsCommitteeHotExtendedKey) committeeHotBs
58+
<$> deserialiseFromRawBytesHex committeeHotBs
5959
in vkey <> extendedVkey
6060

6161
readCommitteeHotVerificationKeyFile
Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
1+
{-# LANGUAGE FlexibleInstances #-}
22
{-# LANGUAGE GADTs #-}
33
{-# LANGUAGE StandaloneDeriving #-}
4-
{-# LANGUAGE FlexibleInstances #-}
54

65
module Cardano.CLI.Read.DRep
7-
( AnyDrepVerificationKey(..)
6+
( AnyDrepVerificationKey (..)
87

98
-- * Read bech32 or hex encoded DRep verification key
109
, readDRepBech32VerificationKeyText
@@ -15,40 +14,49 @@ module Cardano.CLI.Read.DRep
1514
)
1615
where
1716

18-
import Prelude
1917
import Cardano.Api
20-
import Data.Validation
21-
import Data.Text (Text)
22-
import qualified Cardano.Prelude as Text
23-
import Cardano.CLI.Read
2418

19+
import Cardano.CLI.Read
20+
import Cardano.Prelude qualified as Text
2521

22+
import Prelude
2623

24+
import Data.Text (Text)
25+
import Data.Validation
2726

28-
data AnyDrepVerificationKey where
29-
AnyDrepVerificationKey :: VerificationKey DRepKey -> AnyDrepVerificationKey
30-
AnyDrepExtendedVerificationKey :: VerificationKey DRepExtendedKey -> AnyDrepVerificationKey
27+
data AnyDrepVerificationKey where
28+
AnyDrepVerificationKey :: VerificationKey DRepKey -> AnyDrepVerificationKey
29+
AnyDrepExtendedVerificationKey :: VerificationKey DRepExtendedKey -> AnyDrepVerificationKey
3130

3231
deriving instance Show AnyDrepVerificationKey
3332

3433
readDRepBech32VerificationKeyText :: Text -> Validation [Bech32DecodeError] AnyDrepVerificationKey
35-
readDRepBech32VerificationKeyText drep =
36-
let vkey = liftError return $ AnyDrepVerificationKey <$> deserialiseFromBech32 (AsVerificationKey AsDRepKey) drep
37-
extendedVkey = liftError return $ AnyDrepExtendedVerificationKey <$> deserialiseFromBech32 (AsVerificationKey AsDRepExtendedKey) drep
38-
in vkey <> extendedVkey
34+
readDRepBech32VerificationKeyText drep =
35+
let vkey =
36+
liftError return $
37+
AnyDrepVerificationKey <$> deserialiseFromBech32 drep
38+
extendedVkey =
39+
liftError return $
40+
AnyDrepExtendedVerificationKey <$> deserialiseFromBech32 drep
41+
in vkey <> extendedVkey
3942

4043
readDRepHexVerificationKeyText :: Text -> Validation [RawBytesHexError] AnyDrepVerificationKey
41-
readDRepHexVerificationKeyText drepText =
42-
let drepBs = Text.encodeUtf8 drepText
43-
vkey = liftError return $ AnyDrepVerificationKey <$> deserialiseFromRawBytesHex (AsVerificationKey AsDRepKey) drepBs
44-
extendedVkey = liftError return $ AnyDrepExtendedVerificationKey <$> deserialiseFromRawBytesHex (AsVerificationKey AsDRepExtendedKey) drepBs
45-
in vkey <> extendedVkey
46-
47-
48-
readDrepVerificationKeyFile
44+
readDRepHexVerificationKeyText drepText =
45+
let drepBs = Text.encodeUtf8 drepText
46+
vkey =
47+
liftError return $
48+
AnyDrepVerificationKey <$> deserialiseFromRawBytesHex drepBs
49+
extendedVkey =
50+
liftError return $
51+
AnyDrepExtendedVerificationKey
52+
<$> deserialiseFromRawBytesHex drepBs
53+
in vkey <> extendedVkey
54+
55+
readDrepVerificationKeyFile
4956
:: FileOrPipe -> IO (Either (FileError TextEnvelopeError) AnyDrepVerificationKey)
50-
readDrepVerificationKeyFile = readFileOrPipeTextEnvelopeAnyOf types
57+
readDrepVerificationKeyFile = readFileOrPipeTextEnvelopeAnyOf types
5158
where
52-
types = [ FromSomeType (AsVerificationKey AsDRepKey) AnyDrepVerificationKey
53-
, FromSomeType (AsVerificationKey AsDRepExtendedKey) AnyDrepExtendedVerificationKey
54-
]
59+
types =
60+
[ FromSomeType (AsVerificationKey AsDRepKey) AnyDrepVerificationKey
61+
, FromSomeType (AsVerificationKey AsDRepExtendedKey) AnyDrepExtendedVerificationKey
62+
]

0 commit comments

Comments
 (0)