Skip to content

Commit

Permalink
Add getCommitteeCold\HotCredentialFromVerKeyHashOrFile to Read
Browse files Browse the repository at this point in the history
  • Loading branch information
teodanciu committed Oct 24, 2023
1 parent 418cb4f commit 1f3c509
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ module Cardano.CLI.Read
-- * DRep credentials
, getDRepCredentialFromVerKeyHashOrFile

-- * Committee credentials
, getCommitteeColdCredentialFromVerKeyHashOrFile
, getCommitteeHotCredentialFromVerKeyHashOrFile

, ReadSafeHashError(..)
, readHexAsSafeHash
, readSafeHash
Expand Down Expand Up @@ -803,7 +807,7 @@ readVoteHashSource = \case
VoteHashSourceHash h -> return h
VoteHashSourceText c -> return $ Ledger.hashAnchorData $ Ledger.AnchorData $ Text.encodeUtf8 c
VoteHashSourceFile fp -> do
cBs <- firstExceptT VoteErrorFile . newExceptT $ readByteStringFile fp
cBs <- firstExceptT VoteErrorFile . newExceptT $ readByteStringFile fp
_utf8EncodedText <- firstExceptT VoteErrorTextNotUnicode . hoistEither $ Text.decodeUtf8' cBs
return $ Ledger.hashAnchorData $ Ledger.AnchorData cBs

Expand Down Expand Up @@ -1020,6 +1024,28 @@ getDRepCredentialFromVerKeyHashOrFile = \case
pure . Ledger.KeyHashObj . unDRepKeyHash $ verificationKeyHash drepVerKey
VerificationKeyHash kh -> pure . Ledger.KeyHashObj $ unDRepKeyHash kh

getCommitteeColdCredentialFromVerKeyHashOrFile :: ()
=> VerificationKeyOrHashOrFile CommitteeColdKey
-> ExceptT (FileError InputDecodeError) IO (Ledger.Credential Ledger.ColdCommitteeRole Ledger.StandardCrypto)
getCommitteeColdCredentialFromVerKeyHashOrFile = \case
VerificationKeyOrFile verKeyOrFile -> do
commmitteeColdVerKey <-
ExceptT (readVerificationKeyOrFile AsCommitteeColdKey verKeyOrFile)
let CommitteeColdKeyHash kh = verificationKeyHash commmitteeColdVerKey
pure $ Ledger.KeyHashObj kh
VerificationKeyHash (CommitteeColdKeyHash kh) -> pure $ Ledger.KeyHashObj kh

getCommitteeHotCredentialFromVerKeyHashOrFile :: ()
=> VerificationKeyOrHashOrFile CommitteeHotKey
-> ExceptT (FileError InputDecodeError) IO (Ledger.Credential Ledger.HotCommitteeRole Ledger.StandardCrypto)
getCommitteeHotCredentialFromVerKeyHashOrFile = \case
VerificationKeyOrFile verKeyOrFile -> do
commmitteeHotVerKey <-
ExceptT (readVerificationKeyOrFile AsCommitteeHotKey verKeyOrFile)
let CommitteeHotKeyHash kh = verificationKeyHash commmitteeHotVerKey
pure $ Ledger.KeyHashObj kh
VerificationKeyHash (CommitteeHotKeyHash kh) -> pure $ Ledger.KeyHashObj kh

data ReadSafeHashError
= ReadSafeHashErrorNotHex ByteString String
| ReadSafeHashErrorInvalidHash Text
Expand Down

0 comments on commit 1f3c509

Please sign in to comment.