{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Cardano.CLI.EraBased.Run.Governance.DRep
( runGovernanceDRepCmds
, runGovernanceDRepKeyGenCmd
)
where
import Cardano.Api
import qualified Cardano.Api.Ledger as L
import qualified Cardano.CLI.Commands.Hash as Cmd
import qualified Cardano.CLI.EraBased.Commands.Governance.DRep as Cmd
import Cardano.CLI.Run.Hash (allSchemes, carryHashChecks, getByteStringFromURL)
import qualified Cardano.CLI.Run.Key as Key
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.CmdError
import Cardano.CLI.Types.Errors.GovernanceCmdError
import Cardano.CLI.Types.Errors.HashCmdError (FetchURLError)
import Cardano.CLI.Types.Errors.RegistrationError
import Cardano.CLI.Types.Key
import Control.Monad (void)
import Data.ByteString (ByteString)
import Data.Function
import qualified Data.Text.Encoding as Text
runGovernanceDRepCmds
:: ()
=> Cmd.GovernanceDRepCmds era
-> ExceptT CmdError IO ()
runGovernanceDRepCmds :: forall era. GovernanceDRepCmds era -> ExceptT CmdError IO ()
runGovernanceDRepCmds = \case
Cmd.GovernanceDRepKeyGenCmd GovernanceDRepKeyGenCmdArgs era
args ->
ExceptT CmdError IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT CmdError IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ExceptT CmdError IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT CmdError IO ())
-> ExceptT
CmdError IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT CmdError IO ()
forall a b. (a -> b) -> a -> b
$
GovernanceDRepKeyGenCmdArgs era
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
forall era.
GovernanceDRepKeyGenCmdArgs era
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
runGovernanceDRepKeyGenCmd GovernanceDRepKeyGenCmdArgs era
args
ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
-> (ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
CmdError IO (VerificationKey DRepKey, SigningKey DRepKey))
-> ExceptT
CmdError IO (VerificationKey DRepKey, SigningKey DRepKey)
forall a b. a -> (a -> b) -> b
& (FileError () -> CmdError)
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
CmdError IO (VerificationKey DRepKey, SigningKey DRepKey)
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT (GovernanceCmdError -> CmdError
CmdGovernanceCmdError (GovernanceCmdError -> CmdError)
-> (FileError () -> GovernanceCmdError) -> FileError () -> CmdError
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileError () -> GovernanceCmdError
GovernanceCmdWriteFileError)
Cmd.GovernanceDRepIdCmd GovernanceDRepIdCmdArgs era
args ->
GovernanceDRepIdCmdArgs era -> ExceptT GovernanceCmdError IO ()
forall era.
GovernanceDRepIdCmdArgs era -> ExceptT GovernanceCmdError IO ()
runGovernanceDRepIdCmd GovernanceDRepIdCmdArgs era
args
ExceptT GovernanceCmdError IO ()
-> (ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceCmdError -> CmdError)
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCmdError -> CmdError
CmdGovernanceCmdError
Cmd.GovernanceDRepRegistrationCertificateCmd GovernanceDRepRegistrationCertificateCmdArgs era
args ->
GovernanceDRepRegistrationCertificateCmdArgs era
-> ExceptT RegistrationError IO ()
forall era.
GovernanceDRepRegistrationCertificateCmdArgs era
-> ExceptT RegistrationError IO ()
runGovernanceDRepRegistrationCertificateCmd GovernanceDRepRegistrationCertificateCmdArgs era
args
ExceptT RegistrationError IO ()
-> (ExceptT RegistrationError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (RegistrationError -> CmdError)
-> ExceptT RegistrationError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT RegistrationError -> CmdError
CmdRegistrationError
Cmd.GovernanceDRepRetirementCertificateCmd GovernanceDRepRetirementCertificateCmdArgs era
args ->
GovernanceDRepRetirementCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
forall era.
GovernanceDRepRetirementCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepRetirementCertificateCmd GovernanceDRepRetirementCertificateCmdArgs era
args
ExceptT GovernanceCmdError IO ()
-> (ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceCmdError -> CmdError)
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCmdError -> CmdError
CmdGovernanceCmdError
Cmd.GovernanceDRepUpdateCertificateCmd GovernanceDRepUpdateCertificateCmdArgs era
args ->
GovernanceDRepUpdateCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
forall era.
GovernanceDRepUpdateCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepUpdateCertificateCmd GovernanceDRepUpdateCertificateCmdArgs era
args
ExceptT GovernanceCmdError IO ()
-> (ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceCmdError -> CmdError)
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCmdError -> CmdError
CmdGovernanceCmdError
Cmd.GovernanceDRepMetadataHashCmd GovernanceDRepMetadataHashCmdArgs era
args ->
GovernanceDRepMetadataHashCmdArgs era
-> ExceptT GovernanceCmdError IO ()
forall era.
GovernanceDRepMetadataHashCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepMetadataHashCmd GovernanceDRepMetadataHashCmdArgs era
args
ExceptT GovernanceCmdError IO ()
-> (ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceCmdError -> CmdError)
-> ExceptT GovernanceCmdError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCmdError -> CmdError
CmdGovernanceCmdError
runGovernanceDRepKeyGenCmd
:: ()
=> Cmd.GovernanceDRepKeyGenCmdArgs era
-> ExceptT (FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
runGovernanceDRepKeyGenCmd :: forall era.
GovernanceDRepKeyGenCmdArgs era
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
runGovernanceDRepKeyGenCmd
Cmd.GovernanceDRepKeyGenCmdArgs
{ File (VerificationKey ()) 'Out
vkeyFile :: File (VerificationKey ()) 'Out
vkeyFile :: forall era.
GovernanceDRepKeyGenCmdArgs era -> File (VerificationKey ()) 'Out
vkeyFile
, File (SigningKey ()) 'Out
skeyFile :: File (SigningKey ()) 'Out
skeyFile :: forall era.
GovernanceDRepKeyGenCmdArgs era -> File (SigningKey ()) 'Out
skeyFile
} = do
(VerificationKey DRepKey
vkey, SigningKey DRepKey
skey) <- IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
forall a. IO a -> ExceptT (FileError ()) IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey))
-> IO (VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
forall a b. (a -> b) -> a -> b
$ AsType DRepKey -> IO (VerificationKey DRepKey, SigningKey DRepKey)
forall (m :: * -> *) keyrole.
(MonadIO m, Key keyrole, HasTypeProxy keyrole) =>
AsType keyrole -> m (VerificationKey keyrole, SigningKey keyrole)
generateKeyPair AsType DRepKey
AsDRepKey
IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ()) -> ExceptT (FileError ()) 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
skeyFile (Maybe TextEnvelopeDescr -> SigningKey DRepKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.drepSkeyDesc) SigningKey DRepKey
skey)
IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ()) -> ExceptT (FileError ()) 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
vkeyFile (Maybe TextEnvelopeDescr -> VerificationKey DRepKey -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
Key.drepVkeyDesc) VerificationKey DRepKey
vkey)
(VerificationKey DRepKey, SigningKey DRepKey)
-> ExceptT
(FileError ()) IO (VerificationKey DRepKey, SigningKey DRepKey)
forall a. a -> ExceptT (FileError ()) IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (VerificationKey DRepKey
vkey, SigningKey DRepKey
skey)
runGovernanceDRepIdCmd
:: ()
=> Cmd.GovernanceDRepIdCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepIdCmd :: forall era.
GovernanceDRepIdCmdArgs era -> ExceptT GovernanceCmdError IO ()
runGovernanceDRepIdCmd
Cmd.GovernanceDRepIdCmdArgs
{ VerificationKeyOrFile DRepKey
vkeySource :: VerificationKeyOrFile DRepKey
vkeySource :: forall era.
GovernanceDRepIdCmdArgs era -> VerificationKeyOrFile DRepKey
vkeySource
, IdOutputFormat
idOutputFormat :: IdOutputFormat
idOutputFormat :: forall era. GovernanceDRepIdCmdArgs era -> IdOutputFormat
idOutputFormat
, Maybe (File () 'Out)
mOutFile :: Maybe (File () 'Out)
mOutFile :: forall era. GovernanceDRepIdCmdArgs era -> Maybe (File () 'Out)
mOutFile
} = do
VerificationKey DRepKey
drepVerKey <-
(FileError InputDecodeError -> GovernanceCmdError)
-> ExceptT
(FileError InputDecodeError) IO (VerificationKey DRepKey)
-> ExceptT GovernanceCmdError IO (VerificationKey DRepKey)
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError FileError InputDecodeError -> GovernanceCmdError
ReadFileError (ExceptT (FileError InputDecodeError) IO (VerificationKey DRepKey)
-> ExceptT GovernanceCmdError IO (VerificationKey DRepKey))
-> ExceptT
(FileError InputDecodeError) IO (VerificationKey DRepKey)
-> ExceptT GovernanceCmdError IO (VerificationKey DRepKey)
forall a b. (a -> b) -> a -> b
$
AsType DRepKey
-> VerificationKeyOrFile DRepKey
-> ExceptT
(FileError InputDecodeError) IO (VerificationKey DRepKey)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) keyrole.
(MonadIOTransError (FileError InputDecodeError) t m,
HasTextEnvelope (VerificationKey keyrole)) =>
AsType keyrole
-> VerificationKeyOrFile keyrole -> t m (VerificationKey keyrole)
readVerificationKeyOrTextEnvFile AsType DRepKey
AsDRepKey VerificationKeyOrFile DRepKey
vkeySource
ByteString
content <-
ByteString -> ExceptT GovernanceCmdError IO ByteString
forall a. a -> ExceptT GovernanceCmdError IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> ExceptT GovernanceCmdError IO ByteString)
-> ByteString -> ExceptT GovernanceCmdError IO ByteString
forall a b. (a -> b) -> a -> b
$ case IdOutputFormat
idOutputFormat of
IdOutputFormat
IdOutputFormatHex -> Hash DRepKey -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex (Hash DRepKey -> ByteString) -> Hash DRepKey -> ByteString
forall a b. (a -> b) -> a -> b
$ VerificationKey DRepKey -> Hash DRepKey
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash VerificationKey DRepKey
drepVerKey
IdOutputFormat
IdOutputFormatBech32 -> Text -> ByteString
Text.encodeUtf8 (Text -> ByteString) -> Text -> ByteString
forall a b. (a -> b) -> a -> b
$ Hash DRepKey -> Text
forall a. SerialiseAsBech32 a => a -> Text
serialiseToBech32 (Hash DRepKey -> Text) -> Hash DRepKey -> Text
forall a b. (a -> b) -> a -> b
$ VerificationKey DRepKey -> Hash DRepKey
forall keyrole.
Key keyrole =>
VerificationKey keyrole -> Hash keyrole
verificationKeyHash VerificationKey DRepKey
drepVerKey
IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError IO (Either (FileError ()) ())
forall (m :: * -> *) a.
Monad m =>
m a -> ExceptT GovernanceCmdError m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Maybe (File () 'Out) -> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
Maybe (File content 'Out)
-> ByteString -> m (Either (FileError e) ())
writeByteStringOutput Maybe (File () 'Out)
mOutFile ByteString
content)
ExceptT GovernanceCmdError IO (Either (FileError ()) ())
-> (ExceptT GovernanceCmdError IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError IO ()
forall e x (m :: * -> *) a.
Monad m =>
(e -> ExceptT x m a) -> ExceptT x m (Either e a) -> ExceptT x m a
onLeft (GovernanceCmdError -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) x a. Monad m => x -> ExceptT x m a
left (GovernanceCmdError -> ExceptT GovernanceCmdError IO ())
-> (FileError () -> GovernanceCmdError)
-> FileError ()
-> ExceptT GovernanceCmdError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileError () -> GovernanceCmdError
WriteFileError)
runGovernanceDRepRegistrationCertificateCmd
:: ()
=> Cmd.GovernanceDRepRegistrationCertificateCmdArgs era
-> ExceptT RegistrationError IO ()
runGovernanceDRepRegistrationCertificateCmd :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era
-> ExceptT RegistrationError IO ()
runGovernanceDRepRegistrationCertificateCmd
Cmd.GovernanceDRepRegistrationCertificateCmdArgs
{ eon :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era
-> ConwayEraOnwards era
eon = ConwayEraOnwards era
w
, DRepHashSource
drepHashSource :: DRepHashSource
drepHashSource :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era -> DRepHashSource
drepHashSource
, Lovelace
deposit :: Lovelace
deposit :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era -> Lovelace
deposit
, Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor :: Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor
, File () 'Out
outFile :: File () 'Out
outFile :: forall era.
GovernanceDRepRegistrationCertificateCmdArgs era -> File () 'Out
outFile
} =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
ExceptT RegistrationError IO ())
-> ExceptT RegistrationError IO ()
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
ExceptT RegistrationError IO ())
-> ExceptT RegistrationError IO ())
-> (ConwayEraOnwardsConstraints era =>
ExceptT RegistrationError IO ())
-> ExceptT RegistrationError IO ()
forall a b. (a -> b) -> a -> b
$ do
Credential 'DRepRole StandardCrypto
drepCred <- (FileError InputDecodeError -> RegistrationError)
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
RegistrationError IO (Credential 'DRepRole StandardCrypto)
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError FileError InputDecodeError -> RegistrationError
RegistrationReadError (ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
RegistrationError IO (Credential 'DRepRole StandardCrypto))
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
RegistrationError IO (Credential 'DRepRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$ DRepHashSource
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *).
MonadIOTransError (FileError InputDecodeError) t m =>
DRepHashSource -> t m (Credential 'DRepRole StandardCrypto)
readDRepCredential DRepHashSource
drepHashSource
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT RegistrationError IO ())
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
-> ExceptT RegistrationError IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
((HashCheckError -> RegistrationError)
-> ExceptT HashCheckError IO () -> ExceptT RegistrationError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
withExceptT HashCheckError -> RegistrationError
RegistrationDRepHashCheckError (ExceptT HashCheckError IO () -> ExceptT RegistrationError IO ())
-> (PotentiallyCheckedAnchor
DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ())
-> PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT RegistrationError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ()
forall anchorType.
PotentiallyCheckedAnchor anchorType (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ()
carryHashChecks)
Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor
let req :: DRepRegistrationRequirements era
req = ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Lovelace
-> DRepRegistrationRequirements era
forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Lovelace
-> DRepRegistrationRequirements era
DRepRegistrationRequirements ConwayEraOnwards era
w Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
Credential 'DRepRole StandardCrypto
drepCred Lovelace
deposit
registrationCert :: Certificate era
registrationCert =
DRepRegistrationRequirements era
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> Certificate era
forall era.
DRepRegistrationRequirements era
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> Certificate era
makeDrepRegistrationCertificate
DRepRegistrationRequirements era
req
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> Anchor StandardCrypto
forall anchorType anchor.
PotentiallyCheckedAnchor anchorType anchor -> anchor
pcaAnchor (PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> Anchor StandardCrypto)
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
-> Maybe (Anchor StandardCrypto)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor)
description :: Maybe TextEnvelopeDescr
description = forall a. a -> Maybe a
Just @TextEnvelopeDescr TextEnvelopeDescr
"DRep Key Registration Certificate"
(FileError () -> RegistrationError)
-> ExceptT (FileError ()) IO () -> ExceptT RegistrationError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> RegistrationError
RegistrationWriteFileError
(ExceptT (FileError ()) IO () -> ExceptT RegistrationError IO ())
-> (ByteString -> ExceptT (FileError ()) IO ())
-> ByteString
-> ExceptT RegistrationError 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 (FileError ()) IO ())
-> (ByteString -> IO (Either (FileError ()) ()))
-> ByteString
-> ExceptT (FileError ()) IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. File () 'Out -> ByteString -> IO (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
File content 'Out -> ByteString -> m (Either (FileError e) ())
writeLazyByteStringFile File () 'Out
outFile
(ByteString -> ExceptT RegistrationError IO ())
-> ByteString -> ExceptT RegistrationError IO ()
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => ByteString) -> ByteString
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w
((ConwayEraOnwardsConstraints era => ByteString) -> ByteString)
-> (ConwayEraOnwardsConstraints era => ByteString) -> ByteString
forall a b. (a -> b) -> a -> b
$ Maybe TextEnvelopeDescr -> Certificate era -> ByteString
forall a.
HasTextEnvelope a =>
Maybe TextEnvelopeDescr -> a -> ByteString
textEnvelopeToJSON Maybe TextEnvelopeDescr
description Certificate era
registrationCert
runGovernanceDRepRetirementCertificateCmd
:: ()
=> Cmd.GovernanceDRepRetirementCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepRetirementCertificateCmd :: forall era.
GovernanceDRepRetirementCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepRetirementCertificateCmd
Cmd.GovernanceDRepRetirementCertificateCmdArgs
{ eon :: forall era.
GovernanceDRepRetirementCertificateCmdArgs era
-> ConwayEraOnwards era
eon = ConwayEraOnwards era
w
, DRepHashSource
drepHashSource :: DRepHashSource
drepHashSource :: forall era.
GovernanceDRepRetirementCertificateCmdArgs era -> DRepHashSource
drepHashSource
, Lovelace
deposit :: Lovelace
deposit :: forall era.
GovernanceDRepRetirementCertificateCmdArgs era -> Lovelace
deposit
, File () 'Out
outFile :: File () 'Out
outFile :: forall era.
GovernanceDRepRetirementCertificateCmdArgs era -> File () 'Out
outFile
} =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ())
-> (ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$ do
Credential 'DRepRole StandardCrypto
drepCredential <- (FileError InputDecodeError -> GovernanceCmdError)
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto)
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError FileError InputDecodeError -> GovernanceCmdError
GovernanceCmdKeyReadError (ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto))
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$ DRepHashSource
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *).
MonadIOTransError (FileError InputDecodeError) t m =>
DRepHashSource -> t m (Credential 'DRepRole StandardCrypto)
readDRepCredential DRepHashSource
drepHashSource
DRepUnregistrationRequirements era -> Certificate era
forall era. DRepUnregistrationRequirements era -> Certificate era
makeDrepUnregistrationCertificate (ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Lovelace
-> DRepUnregistrationRequirements era
forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> Lovelace
-> DRepUnregistrationRequirements era
DRepUnregistrationRequirements ConwayEraOnwards era
w Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
Credential 'DRepRole StandardCrypto
drepCredential Lovelace
deposit)
Certificate era
-> (Certificate era -> IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. a -> (a -> b) -> b
& File () 'Out
-> Maybe TextEnvelopeDescr
-> Certificate era
-> IO (Either (FileError ()) ())
forall a content.
HasTextEnvelope a =>
File content 'Out
-> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
writeFileTextEnvelope File () 'Out
outFile (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
genKeyDelegCertDesc)
IO (Either (FileError ()) ())
-> (IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall a b. a -> (a -> b) -> b
& (FileError () -> GovernanceCmdError)
-> ExceptT (FileError ()) IO () -> ExceptT GovernanceCmdError IO ()
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError FileError () -> GovernanceCmdError
GovernanceCmdTextEnvWriteError (ExceptT (FileError ()) IO () -> ExceptT GovernanceCmdError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError 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
"DRep Retirement Certificate"
runGovernanceDRepUpdateCertificateCmd
:: ()
=> Cmd.GovernanceDRepUpdateCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepUpdateCertificateCmd :: forall era.
GovernanceDRepUpdateCertificateCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepUpdateCertificateCmd
Cmd.GovernanceDRepUpdateCertificateCmdArgs
{ eon :: forall era.
GovernanceDRepUpdateCertificateCmdArgs era -> ConwayEraOnwards era
eon = ConwayEraOnwards era
w
, DRepHashSource
drepHashSource :: DRepHashSource
drepHashSource :: forall era.
GovernanceDRepUpdateCertificateCmdArgs era -> DRepHashSource
drepHashSource
, Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor :: Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor :: forall era.
GovernanceDRepUpdateCertificateCmdArgs era
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor
, File () 'Out
outFile :: File () 'Out
outFile :: forall era.
GovernanceDRepUpdateCertificateCmdArgs era -> File () 'Out
outFile
} =
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ())
-> (ConwayEraOnwardsConstraints era =>
ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$ do
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT GovernanceCmdError IO ())
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
-> ExceptT GovernanceCmdError IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
((HashCheckError -> GovernanceCmdError)
-> ExceptT HashCheckError IO () -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
withExceptT HashCheckError -> GovernanceCmdError
GovernanceDRepHashCheckError (ExceptT HashCheckError IO () -> ExceptT GovernanceCmdError IO ())
-> (PotentiallyCheckedAnchor
DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ())
-> PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT GovernanceCmdError IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ()
forall anchorType.
PotentiallyCheckedAnchor anchorType (Anchor StandardCrypto)
-> ExceptT HashCheckError IO ()
carryHashChecks)
Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor
Credential 'DRepRole StandardCrypto
drepCredential <- (FileError InputDecodeError -> GovernanceCmdError)
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto)
forall e' (t :: (* -> *) -> * -> *) (m :: * -> *) e a.
MonadTransError e' t m =>
(e -> e') -> ExceptT e m a -> t m a
modifyError FileError InputDecodeError -> GovernanceCmdError
GovernanceCmdKeyReadError (ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto))
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
-> ExceptT
GovernanceCmdError IO (Credential 'DRepRole StandardCrypto)
forall a b. (a -> b) -> a -> b
$ DRepHashSource
-> ExceptT
(FileError InputDecodeError)
IO
(Credential 'DRepRole StandardCrypto)
forall (t :: (* -> *) -> * -> *) (m :: * -> *).
MonadIOTransError (FileError InputDecodeError) t m =>
DRepHashSource -> t m (Credential 'DRepRole StandardCrypto)
readDRepCredential DRepHashSource
drepHashSource
let updateCertificate :: Certificate era
updateCertificate =
DRepUpdateRequirements era
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> Certificate era
forall era.
DRepUpdateRequirements era
-> Maybe (Anchor (EraCrypto (ShelleyLedgerEra era)))
-> Certificate era
makeDrepUpdateCertificate
(ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> DRepUpdateRequirements era
forall era.
ConwayEraOnwards era
-> Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
-> DRepUpdateRequirements era
DRepUpdateRequirements ConwayEraOnwards era
w Credential 'DRepRole (EraCrypto (ShelleyLedgerEra era))
Credential 'DRepRole StandardCrypto
drepCredential)
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> Anchor StandardCrypto
forall anchorType anchor.
PotentiallyCheckedAnchor anchorType anchor -> anchor
pcaAnchor (PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto)
-> Anchor StandardCrypto)
-> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
-> Maybe (Anchor StandardCrypto)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe
(PotentiallyCheckedAnchor DRepMetadataUrl (Anchor StandardCrypto))
mAnchor)
(FileError () -> GovernanceCmdError)
-> ExceptT (FileError ()) IO () -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCmdError
GovernanceCmdTextEnvWriteError (ExceptT (FileError ()) IO () -> ExceptT GovernanceCmdError IO ())
-> (IO (Either (FileError ()) ()) -> ExceptT (FileError ()) IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError 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 GovernanceCmdError IO ())
-> IO (Either (FileError ()) ())
-> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$
File () 'Out
-> Maybe TextEnvelopeDescr
-> Certificate era
-> IO (Either (FileError ()) ())
forall a content.
HasTextEnvelope a =>
File content 'Out
-> Maybe TextEnvelopeDescr -> a -> IO (Either (FileError ()) ())
writeFileTextEnvelope File () 'Out
outFile (TextEnvelopeDescr -> Maybe TextEnvelopeDescr
forall a. a -> Maybe a
Just TextEnvelopeDescr
"DRep Update Certificate") Certificate era
updateCertificate
runGovernanceDRepMetadataHashCmd
:: ()
=> Cmd.GovernanceDRepMetadataHashCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepMetadataHashCmd :: forall era.
GovernanceDRepMetadataHashCmdArgs era
-> ExceptT GovernanceCmdError IO ()
runGovernanceDRepMetadataHashCmd
Cmd.GovernanceDRepMetadataHashCmdArgs
{ DRepMetadataSource
drepMetadataSource :: DRepMetadataSource
drepMetadataSource :: forall era.
GovernanceDRepMetadataHashCmdArgs era -> DRepMetadataSource
drepMetadataSource
, HashGoal (Hash DRepMetadata)
hashGoal :: HashGoal (Hash DRepMetadata)
hashGoal :: forall era.
GovernanceDRepMetadataHashCmdArgs era
-> HashGoal (Hash DRepMetadata)
hashGoal
} = do
ByteString
metadataBytes <- case DRepMetadataSource
drepMetadataSource of
Cmd.DrepMetadataFileIn DRepMetadataFile 'In
metadataFile ->
(FileError InputDecodeError -> GovernanceCmdError)
-> ExceptT (FileError InputDecodeError) IO ByteString
-> ExceptT GovernanceCmdError IO ByteString
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError InputDecodeError -> GovernanceCmdError
ReadFileError (ExceptT (FileError InputDecodeError) IO ByteString
-> ExceptT GovernanceCmdError IO ByteString)
-> (IO (Either (FileError InputDecodeError) ByteString)
-> ExceptT (FileError InputDecodeError) IO ByteString)
-> IO (Either (FileError InputDecodeError) ByteString)
-> ExceptT GovernanceCmdError IO ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Either (FileError InputDecodeError) ByteString)
-> ExceptT (FileError InputDecodeError) IO ByteString
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO (Either (FileError InputDecodeError) ByteString)
-> ExceptT GovernanceCmdError IO ByteString)
-> IO (Either (FileError InputDecodeError) ByteString)
-> ExceptT GovernanceCmdError IO ByteString
forall a b. (a -> b) -> a -> b
$ DRepMetadataFile 'In
-> IO (Either (FileError InputDecodeError) ByteString)
forall (m :: * -> *) content e.
MonadIO m =>
File content 'In -> m (Either (FileError e) ByteString)
readByteStringFile DRepMetadataFile 'In
metadataFile
Cmd.DrepMetadataURL Url
urlText ->
ExceptT FetchURLError IO ByteString
-> ExceptT GovernanceCmdError IO ByteString
fetchURLToGovernanceCmdError (ExceptT FetchURLError IO ByteString
-> ExceptT GovernanceCmdError IO ByteString)
-> ExceptT FetchURLError IO ByteString
-> ExceptT GovernanceCmdError IO ByteString
forall a b. (a -> b) -> a -> b
$ SupportedSchemes -> Text -> ExceptT FetchURLError IO ByteString
getByteStringFromURL SupportedSchemes
allSchemes (Text -> ExceptT FetchURLError IO ByteString)
-> Text -> ExceptT FetchURLError IO ByteString
forall a b. (a -> b) -> a -> b
$ Url -> Text
L.urlToText Url
urlText
let (DRepMetadata
_metadata, Hash DRepMetadata
metadataHash) = ByteString -> (DRepMetadata, Hash DRepMetadata)
hashDRepMetadata ByteString
metadataBytes
case HashGoal (Hash DRepMetadata)
hashGoal of
Cmd.CheckHash Hash DRepMetadata
expectedHash
| Hash DRepMetadata
metadataHash Hash DRepMetadata -> Hash DRepMetadata -> Bool
forall a. Eq a => a -> a -> Bool
/= Hash DRepMetadata
expectedHash ->
GovernanceCmdError -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) x a. Monad m => x -> ExceptT x m a
left (GovernanceCmdError -> ExceptT GovernanceCmdError IO ())
-> GovernanceCmdError -> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$ Hash DRepMetadata -> Hash DRepMetadata -> GovernanceCmdError
GovernanceCmdHashMismatchError Hash DRepMetadata
expectedHash Hash DRepMetadata
metadataHash
| Bool
otherwise -> IO () -> ExceptT GovernanceCmdError IO ()
forall a. IO a -> ExceptT GovernanceCmdError IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ExceptT GovernanceCmdError IO ())
-> IO () -> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$ String -> IO ()
putStrLn String
"Hashes match!"
Cmd.HashToFile File () 'Out
outFile -> Maybe (File () 'Out)
-> Hash DRepMetadata -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) content.
MonadIO m =>
Maybe (File content 'Out)
-> Hash DRepMetadata -> ExceptT GovernanceCmdError m ()
writeOutput (File () 'Out -> Maybe (File () 'Out)
forall a. a -> Maybe a
Just File () 'Out
outFile) Hash DRepMetadata
metadataHash
HashGoal (Hash DRepMetadata)
Cmd.HashToStdout -> Maybe (File Any 'Out)
-> Hash DRepMetadata -> ExceptT GovernanceCmdError IO ()
forall (m :: * -> *) content.
MonadIO m =>
Maybe (File content 'Out)
-> Hash DRepMetadata -> ExceptT GovernanceCmdError m ()
writeOutput Maybe (File Any 'Out)
forall a. Maybe a
Nothing Hash DRepMetadata
metadataHash
where
writeOutput
:: MonadIO m
=> Maybe (File content Out)
-> Hash DRepMetadata
-> ExceptT GovernanceCmdError m ()
writeOutput :: forall (m :: * -> *) content.
MonadIO m =>
Maybe (File content 'Out)
-> Hash DRepMetadata -> ExceptT GovernanceCmdError m ()
writeOutput Maybe (File content 'Out)
mOutFile =
(FileError () -> GovernanceCmdError)
-> ExceptT (FileError ()) m () -> ExceptT GovernanceCmdError m ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> GovernanceCmdError
WriteFileError
(ExceptT (FileError ()) m () -> ExceptT GovernanceCmdError m ())
-> (Hash DRepMetadata -> ExceptT (FileError ()) m ())
-> Hash DRepMetadata
-> ExceptT GovernanceCmdError m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (Either (FileError ()) ()) -> ExceptT (FileError ()) m ()
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT
(m (Either (FileError ()) ()) -> ExceptT (FileError ()) m ())
-> (Hash DRepMetadata -> m (Either (FileError ()) ()))
-> Hash DRepMetadata
-> ExceptT (FileError ()) m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (File content 'Out)
-> ByteString -> m (Either (FileError ()) ())
forall (m :: * -> *) content e.
MonadIO m =>
Maybe (File content 'Out)
-> ByteString -> m (Either (FileError e) ())
writeByteStringOutput Maybe (File content 'Out)
mOutFile
(ByteString -> m (Either (FileError ()) ()))
-> (Hash DRepMetadata -> ByteString)
-> Hash DRepMetadata
-> m (Either (FileError ()) ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash DRepMetadata -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex
fetchURLToGovernanceCmdError
:: ExceptT FetchURLError IO ByteString -> ExceptT GovernanceCmdError IO ByteString
fetchURLToGovernanceCmdError :: ExceptT FetchURLError IO ByteString
-> ExceptT GovernanceCmdError IO ByteString
fetchURLToGovernanceCmdError = (FetchURLError -> GovernanceCmdError)
-> ExceptT FetchURLError IO ByteString
-> ExceptT GovernanceCmdError IO ByteString
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
withExceptT FetchURLError -> GovernanceCmdError
GovernanceCmdFetchURLError