{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}

module Cardano.CLI.EraBased.Run.Governance.Committee
  ( runGovernanceCommitteeCmds
  , GovernanceCommitteeError (..)
  )
where

import           Cardano.Api
import           Cardano.Api.Shelley

import           Cardano.CLI.EraBased.Commands.Governance.Committee
import qualified Cardano.CLI.EraBased.Commands.Governance.Committee as Cmd
import           Cardano.CLI.Read (readVerificationKeySource)
import qualified Cardano.CLI.Run.Key as Key
import           Cardano.CLI.Types.Errors.GovernanceCommitteeError
import           Cardano.CLI.Types.Key.VerificationKey

import           Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BS
import           Data.Function

runGovernanceCommitteeCmds
  :: ()
  => GovernanceCommitteeCmds era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCmds :: forall era.
GovernanceCommitteeCmds era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCmds = \case
  GovernanceCommitteeKeyGenColdCmd GovernanceCommitteeKeyGenColdCmdArgs era
cmd ->
    GovernanceCommitteeKeyGenColdCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenCold GovernanceCommitteeKeyGenColdCmdArgs era
cmd
  GovernanceCommitteeKeyGenHotCmd GovernanceCommitteeKeyGenHotCmdArgs era
cmd ->
    GovernanceCommitteeKeyGenHotCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenHot GovernanceCommitteeKeyGenHotCmdArgs era
cmd
  GovernanceCommitteeKeyHashCmd GovernanceCommitteeKeyHashCmdArgs era
cmd ->
    GovernanceCommitteeKeyHashCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeKeyHashCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyHash GovernanceCommitteeKeyHashCmdArgs era
cmd
  GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
cmd ->
    GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCreateHotKeyAuthorizationCertificate GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
cmd
  GovernanceCommitteeCreateColdKeyResignationCertificateCmd GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
cmd ->
    GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeColdKeyResignationCertificate GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
cmd

runGovernanceCommitteeKeyGenCold
  :: ()
  => Cmd.GovernanceCommitteeKeyGenColdCmdArgs era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenCold :: forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenCold
  Cmd.GovernanceCommitteeKeyGenColdCmdArgs
    { vkeyOutFile :: forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> File (VerificationKey ()) 'Out
Cmd.vkeyOutFile = File (VerificationKey ()) 'Out
vkeyPath
    , skeyOutFile :: forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> File (SigningKey ()) 'Out
Cmd.skeyOutFile = File (SigningKey ()) 'Out
skeyPath
    } = do
    SigningKey CommitteeColdKey
skey <- AsType CommitteeColdKey
-> ExceptT
     GovernanceCommitteeError IO (SigningKey CommitteeColdKey)
forall (m :: * -> *) keyrole.
(MonadIO m, Key keyrole) =>
AsType keyrole -> m (SigningKey keyrole)
generateSigningKey AsType CommitteeColdKey
AsCommitteeColdKey

    let vkey :: VerificationKey CommitteeColdKey
vkey = SigningKey CommitteeColdKey -> VerificationKey CommitteeColdKey
forall keyrole.
(Key keyrole, HasTypeProxy keyrole) =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey SigningKey CommitteeColdKey
skey

    File (SigningKey ()) 'Out
-> ByteString
-> ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File (SigningKey ()) 'Out
skeyPath (Maybe TextEnvelopeDescr
-> SigningKey CommitteeColdKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.ccColdSkeyDesc) SigningKey CommitteeColdKey
skey)
      ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
-> (ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
    -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall e x (m :: * -> *) a.
Monad m =>
(e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a
onLeft (GovernanceCommitteeError -> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x a. Monad m => x -> ExceptT x m a
left (GovernanceCommitteeError
 -> ExceptT GovernanceCommitteeError IO ())
-> (FileError () -> GovernanceCommitteeError)
-> FileError ()
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdWriteFileError)

    File (VerificationKey ()) 'Out
-> ByteString
-> ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File (VerificationKey ()) 'Out
vkeyPath (Maybe TextEnvelopeDescr
-> VerificationKey CommitteeColdKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.ccColdVkeyDesc) VerificationKey CommitteeColdKey
vkey)
      ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
-> (ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
    -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall e x (m :: * -> *) a.
Monad m =>
(e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a
onLeft (GovernanceCommitteeError -> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x a. Monad m => x -> ExceptT x m a
left (GovernanceCommitteeError
 -> ExceptT GovernanceCommitteeError IO ())
-> (FileError () -> GovernanceCommitteeError)
-> FileError ()
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdWriteFileError)

runGovernanceCommitteeKeyGenHot
  :: ()
  => Cmd.GovernanceCommitteeKeyGenHotCmdArgs era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenHot :: forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyGenHot
  Cmd.GovernanceCommitteeKeyGenHotCmdArgs
    { eon :: forall era.
GovernanceCommitteeKeyGenHotCmdArgs era -> ConwayEraOnwards era
Cmd.eon = ConwayEraOnwards era
_eon
    , vkeyOutFile :: forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> File (VerificationKey ()) 'Out
Cmd.vkeyOutFile = File (VerificationKey ()) 'Out
vkeyPath
    , skeyOutFile :: forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> File (SigningKey ()) 'Out
Cmd.skeyOutFile = File (SigningKey ()) 'Out
skeyPath
    } = do
    SigningKey CommitteeHotKey
skey <- AsType CommitteeHotKey
-> ExceptT GovernanceCommitteeError IO (SigningKey CommitteeHotKey)
forall (m :: * -> *) keyrole.
(MonadIO m, Key keyrole) =>
AsType keyrole -> m (SigningKey keyrole)
generateSigningKey AsType CommitteeHotKey
AsCommitteeHotKey

    let vkey :: VerificationKey CommitteeHotKey
vkey = SigningKey CommitteeHotKey -> VerificationKey CommitteeHotKey
forall keyrole.
(Key keyrole, HasTypeProxy keyrole) =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey SigningKey CommitteeHotKey
skey

    (FileError () -> GovernanceCommitteeError)
-> ExceptT (FileError ()) IO ()
-> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdWriteFileError
      (ExceptT (FileError ()) IO ()
 -> ExceptT GovernanceCommitteeError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT
      (IO (Either (FileError ()) ())
 -> ExceptT GovernanceCommitteeError IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. (a -> b) -> a -> b
$ File (SigningKey ()) 'Out
-> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File (SigningKey ()) 'Out
skeyPath
      (ByteString -> IO (Either (FileError ()) ()))
-> ByteString -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> b
$ Maybe TextEnvelopeDescr -> SigningKey CommitteeHotKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.ccHotSkeyDesc) SigningKey CommitteeHotKey
skey

    (FileError () -> GovernanceCommitteeError)
-> ExceptT (FileError ()) IO ()
-> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdWriteFileError
      (ExceptT (FileError ()) IO ()
 -> ExceptT GovernanceCommitteeError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT
      (IO (Either (FileError ()) ())
 -> ExceptT GovernanceCommitteeError IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. (a -> b) -> a -> b
$ File (VerificationKey ()) 'Out
-> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File (VerificationKey ()) 'Out
vkeyPath
      (ByteString -> IO (Either (FileError ()) ()))
-> ByteString -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> b
$ Maybe TextEnvelopeDescr
-> VerificationKey CommitteeHotKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.ccHotVkeyDesc) VerificationKey CommitteeHotKey
vkey

data SomeCommitteeKey
  = ACommitteeHotKey (VerificationKey CommitteeHotKey)
  | ACommitteeHotExtendedKey (VerificationKey CommitteeHotExtendedKey)
  | ACommitteeColdKey (VerificationKey CommitteeColdKey)
  | ACommitteeColdExtendedKey (VerificationKey CommitteeColdExtendedKey)

runGovernanceCommitteeKeyHash
  :: ()
  => Cmd.GovernanceCommitteeKeyHashCmdArgs era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyHash :: forall era.
GovernanceCommitteeKeyHashCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeKeyHash
  Cmd.GovernanceCommitteeKeyHashCmdArgs
    { AnyVerificationKeySource
vkeySource :: AnyVerificationKeySource
vkeySource :: forall era.
GovernanceCommitteeKeyHashCmdArgs era -> AnyVerificationKeySource
Cmd.vkeySource
    } = do
    SomeCommitteeKey
vkey <-
      case AnyVerificationKeySource
vkeySource of
        AnyVerificationKeySourceOfText AnyVerificationKeyText
vkText -> do
          let asTypes :: [FromSomeType SerialiseAsBech32 SomeCommitteeKey]
asTypes =
                [ AsType (VerificationKey CommitteeHotKey)
-> (VerificationKey CommitteeHotKey -> SomeCommitteeKey)
-> FromSomeType SerialiseAsBech32 SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeHotKey -> AsType (VerificationKey CommitteeHotKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeHotKey
AsCommitteeHotKey) VerificationKey CommitteeHotKey -> SomeCommitteeKey
ACommitteeHotKey
                , AsType (VerificationKey CommitteeHotExtendedKey)
-> (VerificationKey CommitteeHotExtendedKey -> SomeCommitteeKey)
-> FromSomeType SerialiseAsBech32 SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeHotExtendedKey
-> AsType (VerificationKey CommitteeHotExtendedKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeHotExtendedKey
AsCommitteeHotExtendedKey) VerificationKey CommitteeHotExtendedKey -> SomeCommitteeKey
ACommitteeHotExtendedKey
                , AsType (VerificationKey CommitteeColdKey)
-> (VerificationKey CommitteeColdKey -> SomeCommitteeKey)
-> FromSomeType SerialiseAsBech32 SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeColdKey
-> AsType (VerificationKey CommitteeColdKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeColdKey
AsCommitteeColdKey) VerificationKey CommitteeColdKey -> SomeCommitteeKey
ACommitteeColdKey
                , AsType (VerificationKey CommitteeColdExtendedKey)
-> (VerificationKey CommitteeColdExtendedKey -> SomeCommitteeKey)
-> FromSomeType SerialiseAsBech32 SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeColdExtendedKey
-> AsType (VerificationKey CommitteeColdExtendedKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeColdExtendedKey
AsCommitteeColdExtendedKey) VerificationKey CommitteeColdExtendedKey -> SomeCommitteeKey
ACommitteeColdExtendedKey
                ]
          Either Bech32DecodeError SomeCommitteeKey
-> ExceptT
     GovernanceCommitteeError
     IO
     (Either Bech32DecodeError SomeCommitteeKey)
forall a. a -> ExceptT GovernanceCommitteeError IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([FromSomeType SerialiseAsBech32 SomeCommitteeKey]
-> Text -> Either Bech32DecodeError SomeCommitteeKey
forall b.
[FromSomeType SerialiseAsBech32 b]
-> Text -> Either Bech32DecodeError b
deserialiseAnyOfFromBech32 [FromSomeType SerialiseAsBech32 SomeCommitteeKey]
asTypes (AnyVerificationKeyText -> Text
unAnyVerificationKeyText AnyVerificationKeyText
vkText))
            ExceptT
  GovernanceCommitteeError
  IO
  (Either Bech32DecodeError SomeCommitteeKey)
-> (ExceptT
      GovernanceCommitteeError
      IO
      (Either Bech32DecodeError SomeCommitteeKey)
    -> ExceptT GovernanceCommitteeError IO SomeCommitteeKey)
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall a b. a -> (a -> b) -> b
& (Bech32DecodeError
 -> ExceptT GovernanceCommitteeError IO SomeCommitteeKey)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Either Bech32DecodeError SomeCommitteeKey)
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall e x (m :: * -> *) a.
Monad m =>
(e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a
onLeft (GovernanceCommitteeError
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall (m :: * -> *) x a. Monad m => x -> ExceptT x m a
left (GovernanceCommitteeError
 -> ExceptT GovernanceCommitteeError IO SomeCommitteeKey)
-> (Bech32DecodeError -> GovernanceCommitteeError)
-> Bech32DecodeError
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. InputDecodeError -> GovernanceCommitteeError
GovernanceCommitteeCmdKeyDecodeError (InputDecodeError -> GovernanceCommitteeError)
-> (Bech32DecodeError -> InputDecodeError)
-> Bech32DecodeError
-> GovernanceCommitteeError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bech32DecodeError -> InputDecodeError
InputBech32DecodeError)
        AnyVerificationKeySourceOfFile File (VerificationKey ()) 'In
vkeyPath -> do
          let asTypes :: [FromSomeType HasTextEnvelope SomeCommitteeKey]
asTypes =
                [ AsType (VerificationKey CommitteeHotKey)
-> (VerificationKey CommitteeHotKey -> SomeCommitteeKey)
-> FromSomeType HasTextEnvelope SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeHotKey -> AsType (VerificationKey CommitteeHotKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeHotKey
AsCommitteeHotKey) VerificationKey CommitteeHotKey -> SomeCommitteeKey
ACommitteeHotKey
                , AsType (VerificationKey CommitteeHotExtendedKey)
-> (VerificationKey CommitteeHotExtendedKey -> SomeCommitteeKey)
-> FromSomeType HasTextEnvelope SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeHotExtendedKey
-> AsType (VerificationKey CommitteeHotExtendedKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeHotExtendedKey
AsCommitteeHotExtendedKey) VerificationKey CommitteeHotExtendedKey -> SomeCommitteeKey
ACommitteeHotExtendedKey
                , AsType (VerificationKey CommitteeColdKey)
-> (VerificationKey CommitteeColdKey -> SomeCommitteeKey)
-> FromSomeType HasTextEnvelope SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeColdKey
-> AsType (VerificationKey CommitteeColdKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeColdKey
AsCommitteeColdKey) VerificationKey CommitteeColdKey -> SomeCommitteeKey
ACommitteeColdKey
                , AsType (VerificationKey CommitteeColdExtendedKey)
-> (VerificationKey CommitteeColdExtendedKey -> SomeCommitteeKey)
-> FromSomeType HasTextEnvelope SomeCommitteeKey
forall (c :: * -> Constraint) a b.
c a =>
AsType a -> (a -> b) -> FromSomeType c b
FromSomeType (AsType CommitteeColdExtendedKey
-> AsType (VerificationKey CommitteeColdExtendedKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType CommitteeColdExtendedKey
AsCommitteeColdExtendedKey) VerificationKey CommitteeColdExtendedKey -> SomeCommitteeKey
ACommitteeColdExtendedKey
                ]
          [FromSomeType HasTextEnvelope SomeCommitteeKey]
-> File (VerificationKey ()) 'In
-> IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
forall b content.
[FromSomeType HasTextEnvelope b]
-> File content 'In -> IO (Either (FileError TextEnvelopeError) b)
readFileTextEnvelopeAnyOf [FromSomeType HasTextEnvelope SomeCommitteeKey]
asTypes File (VerificationKey ()) 'In
vkeyPath
            IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
-> (IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
    -> ExceptT GovernanceCommitteeError IO SomeCommitteeKey)
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall a b. a -> (a -> b) -> b
& (FileError TextEnvelopeError -> GovernanceCommitteeError)
-> ExceptT (FileError TextEnvelopeError) IO SomeCommitteeKey
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError TextEnvelopeError -> GovernanceCommitteeError
GovernanceCommitteeCmdTextEnvReadFileError (ExceptT (FileError TextEnvelopeError) IO SomeCommitteeKey
 -> ExceptT GovernanceCommitteeError IO SomeCommitteeKey)
-> (IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
    -> ExceptT (FileError TextEnvelopeError) IO SomeCommitteeKey)
-> IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
-> ExceptT GovernanceCommitteeError IO SomeCommitteeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError TextEnvelopeError) SomeCommitteeKey)
-> ExceptT (FileError TextEnvelopeError) IO SomeCommitteeKey
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT

    IO () -> ExceptT GovernanceCommitteeError IO ()
forall a. IO a -> ExceptT GovernanceCommitteeError IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ExceptT GovernanceCommitteeError IO ())
-> IO () -> ExceptT GovernanceCommitteeError IO ()
forall a b. (a -> b) -> a -> b
$ ByteString -> IO ()
BS.putStrLn (SomeCommitteeKey -> ByteString
renderKeyHash SomeCommitteeKey
vkey)
   where
    renderKeyHash :: SomeCommitteeKey -> ByteString
    renderKeyHash :: SomeCommitteeKey -> ByteString
renderKeyHash = \case
      ACommitteeHotKey VerificationKey CommitteeHotKey
vk -> VerificationKey CommitteeHotKey -> ByteString
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> ByteString
renderVerificationKeyHash VerificationKey CommitteeHotKey
vk
      ACommitteeHotExtendedKey VerificationKey CommitteeHotExtendedKey
vk -> VerificationKey CommitteeHotExtendedKey -> ByteString
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> ByteString
renderVerificationKeyHash VerificationKey CommitteeHotExtendedKey
vk
      ACommitteeColdKey VerificationKey CommitteeColdKey
vk -> VerificationKey CommitteeColdKey -> ByteString
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> ByteString
renderVerificationKeyHash VerificationKey CommitteeColdKey
vk
      ACommitteeColdExtendedKey VerificationKey CommitteeColdExtendedKey
vk -> VerificationKey CommitteeColdExtendedKey -> ByteString
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> ByteString
renderVerificationKeyHash VerificationKey CommitteeColdExtendedKey
vk

    renderVerificationKeyHash :: Key keyrole => VerificationKey keyrole -> ByteString
    renderVerificationKeyHash :: forall keyrole.
Key keyrole =>
VerificationKey keyrole -> ByteString
renderVerificationKeyHash =
      Hash keyrole -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex
        (Hash keyrole -> ByteString)
-> (VerificationKey keyrole -> Hash keyrole)
-> VerificationKey keyrole
-> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VerificationKey keyrole -> Hash keyrole
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash

runGovernanceCommitteeCreateHotKeyAuthorizationCertificate
  :: ()
  => Cmd.GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCreateHotKeyAuthorizationCertificate :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCreateHotKeyAuthorizationCertificate
  Cmd.GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
    { eon :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> ConwayEraOnwards era
Cmd.eon = ConwayEraOnwards era
eon
    , VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> VerificationKeySource CommitteeColdKey
Cmd.vkeyColdKeySource
    , VerificationKeySource CommitteeHotKey
vkeyHotKeySource :: VerificationKeySource CommitteeHotKey
vkeyHotKeySource :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> VerificationKeySource CommitteeHotKey
Cmd.vkeyHotKeySource
    , outFile :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> File () 'Out
Cmd.outFile = File () 'Out
oFp
    } =
    ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
    ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
eon ((ConwayEraOnwardsConstraints era =>
  ExceptT GovernanceCommitteeError IO ())
 -> ExceptT GovernanceCommitteeError IO ())
-> (ConwayEraOnwardsConstraints era =>
    ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. (a -> b) -> a -> b
$ do
      let mapError' :: ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  a
-> ExceptT GovernanceCommitteeError IO a
mapError' = (Either (FileError ScriptDecodeError) (FileError InputDecodeError)
 -> GovernanceCommitteeError)
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     a
-> ExceptT GovernanceCommitteeError IO a
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError ((Either (FileError ScriptDecodeError) (FileError InputDecodeError)
  -> GovernanceCommitteeError)
 -> ExceptT
      (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
      IO
      a
 -> ExceptT GovernanceCommitteeError IO a)
-> (Either
      (FileError ScriptDecodeError) (FileError InputDecodeError)
    -> GovernanceCommitteeError)
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     a
-> ExceptT GovernanceCommitteeError IO a
forall a b. (a -> b) -> a -> b
$ (FileError ScriptDecodeError -> GovernanceCommitteeError)
-> (FileError InputDecodeError -> GovernanceCommitteeError)
-> Either
     (FileError ScriptDecodeError) (FileError InputDecodeError)
-> GovernanceCommitteeError
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either FileError ScriptDecodeError -> GovernanceCommitteeError
GovernanceCommitteeCmdScriptReadError FileError InputDecodeError -> GovernanceCommitteeError
GovernanceCommitteeCmdKeyReadError
      Credential 'HotCommitteeRole StandardCrypto
hotCred <-
        ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  (Credential 'HotCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'HotCommitteeRole StandardCrypto)
forall {a}.
ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  a
-> ExceptT GovernanceCommitteeError IO a
mapError' (ExceptT
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   IO
   (Credential 'HotCommitteeRole StandardCrypto)
 -> ExceptT
      GovernanceCommitteeError
      IO
      (Credential 'HotCommitteeRole StandardCrypto))
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'HotCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'HotCommitteeRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$
          AsType CommitteeHotKey
-> (Hash CommitteeHotKey
    -> KeyHash 'HotCommitteeRole StandardCrypto)
-> VerificationKeySource CommitteeHotKey
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'HotCommitteeRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) keyrole
       (kr :: KeyRole).
(MonadIOTransError
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   t
   m,
 Key keyrole) =>
AsType keyrole
-> (Hash keyrole -> KeyHash kr StandardCrypto)
-> VerificationKeySource keyrole
-> t m (Credential kr StandardCrypto)
readVerificationKeySource AsType CommitteeHotKey
AsCommitteeHotKey Hash CommitteeHotKey -> KeyHash 'HotCommitteeRole StandardCrypto
unCommitteeHotKeyHash VerificationKeySource CommitteeHotKey
vkeyHotKeySource
      Credential 'ColdCommitteeRole StandardCrypto
coldCred <-
        ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  (Credential 'ColdCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall {a}.
ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  a
-> ExceptT GovernanceCommitteeError IO a
mapError' (ExceptT
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   IO
   (Credential 'ColdCommitteeRole StandardCrypto)
 -> ExceptT
      GovernanceCommitteeError
      IO
      (Credential 'ColdCommitteeRole StandardCrypto))
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$
          AsType CommitteeColdKey
-> (Hash CommitteeColdKey
    -> KeyHash 'ColdCommitteeRole StandardCrypto)
-> VerificationKeySource CommitteeColdKey
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) keyrole
       (kr :: KeyRole).
(MonadIOTransError
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   t
   m,
 Key keyrole) =>
AsType keyrole
-> (Hash keyrole -> KeyHash kr StandardCrypto)
-> VerificationKeySource keyrole
-> t m (Credential kr StandardCrypto)
readVerificationKeySource AsType CommitteeColdKey
AsCommitteeColdKey Hash CommitteeColdKey -> KeyHash 'ColdCommitteeRole StandardCrypto
unCommitteeColdKeyHash VerificationKeySource CommitteeColdKey
vkeyColdKeySource

      CommitteeHotKeyAuthorizationRequirements era -> Certificate era
forall era.
CommitteeHotKeyAuthorizationRequirements era -> Certificate era
makeCommitteeHotKeyAuthorizationCertificate
        (ConwayEraOnwards era
-> Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> CommitteeHotKeyAuthorizationRequirements era
forall era.
ConwayEraOnwards era
-> Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> CommitteeHotKeyAuthorizationRequirements era
CommitteeHotKeyAuthorizationRequirements ConwayEraOnwards era
eon Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
Credential 'ColdCommitteeRole StandardCrypto
coldCred Credential 'HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
Credential 'HotCommitteeRole StandardCrypto
hotCred)
        Certificate era -> (Certificate era -> ByteString) -> ByteString
forall a b. a -> (a -> b) -> b
& Maybe TextEnvelopeDescr -> Certificate era -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
genKeyDelegCertDesc)
        ByteString
-> (ByteString -> IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. a -> (a -> b) -> b
& File () 'Out -> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File () 'Out
oFp
        IO (Either (FileError ()) ())
-> (IO (Either (FileError ()) ())
    -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> GovernanceCommitteeError)
-> ExceptT (FileError ()) IO ()
-> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdTextEnvWriteError (ExceptT (FileError ()) IO ()
 -> ExceptT GovernanceCommitteeError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT
   where
    genKeyDelegCertDesc :: TextEnvelopeDescr
    genKeyDelegCertDesc :: TextEnvelopeDescr
genKeyDelegCertDesc = TextEnvelopeDescr
"Constitutional Committee Hot Key Registration Certificate"

runGovernanceCommitteeColdKeyResignationCertificate
  :: ()
  => Cmd.GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
  -> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeColdKeyResignationCertificate :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeColdKeyResignationCertificate
  Cmd.GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
    { ConwayEraOnwards era
eon :: ConwayEraOnwards era
eon :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> ConwayEraOnwards era
Cmd.eon
    , VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> VerificationKeySource CommitteeColdKey
Cmd.vkeyColdKeySource
    , Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
anchor :: Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
anchor :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
Cmd.anchor
    , File () 'Out
outFile :: File () 'Out
outFile :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> File () 'Out
Cmd.outFile
    } =
    ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
    ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
eon ((ConwayEraOnwardsConstraints era =>
  ExceptT GovernanceCommitteeError IO ())
 -> ExceptT GovernanceCommitteeError IO ())
-> (ConwayEraOnwardsConstraints era =>
    ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. (a -> b) -> a -> b
$ do
      let modifyError' :: ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  a
-> ExceptT GovernanceCommitteeError IO a
modifyError' = (Either (FileError ScriptDecodeError) (FileError InputDecodeError)
 -> GovernanceCommitteeError)
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     a
-> ExceptT GovernanceCommitteeError IO a
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError ((Either (FileError ScriptDecodeError) (FileError InputDecodeError)
  -> GovernanceCommitteeError)
 -> ExceptT
      (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
      IO
      a
 -> ExceptT GovernanceCommitteeError IO a)
-> (Either
      (FileError ScriptDecodeError) (FileError InputDecodeError)
    -> GovernanceCommitteeError)
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     a
-> ExceptT GovernanceCommitteeError IO a
forall a b. (a -> b) -> a -> b
$ (FileError ScriptDecodeError -> GovernanceCommitteeError)
-> (FileError InputDecodeError -> GovernanceCommitteeError)
-> Either
     (FileError ScriptDecodeError) (FileError InputDecodeError)
-> GovernanceCommitteeError
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either FileError ScriptDecodeError -> GovernanceCommitteeError
GovernanceCommitteeCmdScriptReadError FileError InputDecodeError -> GovernanceCommitteeError
GovernanceCommitteeCmdKeyReadError
      Credential 'ColdCommitteeRole StandardCrypto
coldVKeyCred <-
        ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  (Credential 'ColdCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall {a}.
ExceptT
  (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
  IO
  a
-> ExceptT GovernanceCommitteeError IO a
modifyError' (ExceptT
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   IO
   (Credential 'ColdCommitteeRole StandardCrypto)
 -> ExceptT
      GovernanceCommitteeError
      IO
      (Credential 'ColdCommitteeRole StandardCrypto))
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
-> ExceptT
     GovernanceCommitteeError
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$
          AsType CommitteeColdKey
-> (Hash CommitteeColdKey
    -> KeyHash 'ColdCommitteeRole StandardCrypto)
-> VerificationKeySource CommitteeColdKey
-> ExceptT
     (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
     IO
     (Credential 'ColdCommitteeRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) keyrole
       (kr :: KeyRole).
(MonadIOTransError
   (Either (FileError ScriptDecodeError) (FileError InputDecodeError))
   t
   m,
 Key keyrole) =>
AsType keyrole
-> (Hash keyrole -> KeyHash kr StandardCrypto)
-> VerificationKeySource keyrole
-> t m (Credential kr StandardCrypto)
readVerificationKeySource AsType CommitteeColdKey
AsCommitteeColdKey Hash CommitteeColdKey -> KeyHash 'ColdCommitteeRole StandardCrypto
unCommitteeColdKeyHash VerificationKeySource CommitteeColdKey
vkeyColdKeySource

      CommitteeColdkeyResignationRequirements era -> Certificate era
forall era.
CommitteeColdkeyResignationRequirements era -> Certificate era
makeCommitteeColdkeyResignationCertificate
        (ConwayEraOnwards era
-> Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> CommitteeColdkeyResignationRequirements era
forall era.
ConwayEraOnwards era
-> Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> CommitteeColdkeyResignationRequirements era
CommitteeColdkeyResignationRequirements ConwayEraOnwards era
eon Credential 'ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
Credential 'ColdCommitteeRole StandardCrypto
coldVKeyCred Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
anchor)
        Certificate era -> (Certificate era -> ByteString) -> ByteString
forall a b. a -> (a -> b) -> b
& Maybe TextEnvelopeDescr -> Certificate era -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
genKeyDelegCertDesc)
        ByteString
-> (ByteString -> IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. a -> (a -> b) -> b
& File () 'Out -> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File () 'Out
outFile
        IO (Either (FileError ()) ())
-> (IO (Either (FileError ()) ())
    -> ExceptT GovernanceCommitteeError IO ())
-> ExceptT GovernanceCommitteeError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> GovernanceCommitteeError)
-> ExceptT (FileError ()) IO ()
-> ExceptT GovernanceCommitteeError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCommitteeError
GovernanceCommitteeCmdTextEnvWriteError (ExceptT (FileError ()) IO ()
 -> ExceptT GovernanceCommitteeError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCommitteeError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT
   where
    genKeyDelegCertDesc :: TextEnvelopeDescr
    genKeyDelegCertDesc :: TextEnvelopeDescr
genKeyDelegCertDesc = TextEnvelopeDescr
"Constitutional Committee Cold Key Resignation Certificate"