{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Cardano.CLI.EraBased.Run.Governance
( runGovernanceCmds
, runGovernanceMIRCertificatePayStakeAddrs
, runGovernanceCreateMirCertificateTransferToTreasuryCmd
, runGovernanceCreateMirCertificateTransferToReservesCmd
)
where
import Cardano.Api
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley
import qualified Cardano.CLI.EraBased.Commands.Governance as Cmd
import Cardano.CLI.EraBased.Run.Governance.Actions
import Cardano.CLI.EraBased.Run.Governance.Committee
import Cardano.CLI.EraBased.Run.Governance.DRep
import Cardano.CLI.EraBased.Run.Governance.GenesisKeyDelegationCertificate
import Cardano.CLI.EraBased.Run.Governance.Poll
import Cardano.CLI.EraBased.Run.Governance.Vote
import Cardano.CLI.Types.Errors.CmdError
import Cardano.CLI.Types.Errors.GovernanceCmdError
import Control.Monad
import Data.Function
import GHC.Exts (IsList (..))
runGovernanceCmds
:: ()
=> Cmd.GovernanceCmds era
-> ExceptT CmdError IO ()
runGovernanceCmds :: forall era. GovernanceCmds era -> ExceptT CmdError IO ()
runGovernanceCmds = \case
Cmd.GovernanceCreateMirCertificateStakeAddressesCmd ShelleyToBabbageEra era
w MIRPot
mirpot [StakeAddress]
vKeys [Coin]
rewards File () 'Out
out ->
ShelleyToBabbageEra era
-> MIRPot
-> [StakeAddress]
-> [Coin]
-> File () 'Out
-> ExceptT GovernanceCmdError IO ()
forall era.
ShelleyToBabbageEra era
-> MIRPot
-> [StakeAddress]
-> [Coin]
-> File () 'Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceMIRCertificatePayStakeAddrs ShelleyToBabbageEra era
w MIRPot
mirpot [StakeAddress]
vKeys [Coin]
rewards File () 'Out
out
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.GovernanceCreateMirCertificateTransferToTreasuryCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp ->
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
forall era.
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToTreasuryCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp
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.GovernanceCreateMirCertificateTransferToReservesCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp ->
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
forall era.
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToReservesCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp
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.GovernanceGenesisKeyDelegationCertificate ShelleyToBabbageEra era
sta VerificationKeyOrHashOrFile GenesisKey
genVk VerificationKeyOrHashOrFile GenesisDelegateKey
genDelegVk VerificationKeyOrHashOrFile VrfKey
vrfVk File () 'Out
out ->
ShelleyToBabbageEra era
-> VerificationKeyOrHashOrFile GenesisKey
-> VerificationKeyOrHashOrFile GenesisDelegateKey
-> VerificationKeyOrHashOrFile VrfKey
-> File () 'Out
-> ExceptT GovernanceCmdError IO ()
forall era.
ShelleyToBabbageEra era
-> VerificationKeyOrHashOrFile GenesisKey
-> VerificationKeyOrHashOrFile GenesisDelegateKey
-> VerificationKeyOrHashOrFile VrfKey
-> File () 'Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceGenesisKeyDelegationCertificate ShelleyToBabbageEra era
sta VerificationKeyOrHashOrFile GenesisKey
genVk VerificationKeyOrHashOrFile GenesisDelegateKey
genDelegVk VerificationKeyOrHashOrFile VrfKey
vrfVk File () 'Out
out
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.GovernanceCommitteeCmds GovernanceCommitteeCmds era
cmds ->
GovernanceCommitteeCmds era
-> ExceptT GovernanceCommitteeError IO ()
forall era.
GovernanceCommitteeCmds era
-> ExceptT GovernanceCommitteeError IO ()
runGovernanceCommitteeCmds GovernanceCommitteeCmds era
cmds
ExceptT GovernanceCommitteeError IO ()
-> (ExceptT GovernanceCommitteeError IO ()
-> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceCommitteeError -> CmdError)
-> ExceptT GovernanceCommitteeError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceCommitteeError -> CmdError
CmdGovernanceCommitteeError
Cmd.GovernanceActionCmds GovernanceActionCmds era
cmds ->
GovernanceActionCmds era -> ExceptT GovernanceActionsError IO ()
forall era.
GovernanceActionCmds era -> ExceptT GovernanceActionsError IO ()
runGovernanceActionCmds GovernanceActionCmds era
cmds
ExceptT GovernanceActionsError IO ()
-> (ExceptT GovernanceActionsError IO () -> ExceptT CmdError IO ())
-> ExceptT CmdError IO ()
forall a b. a -> (a -> b) -> b
& (GovernanceActionsError -> CmdError)
-> ExceptT GovernanceActionsError IO () -> ExceptT CmdError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT GovernanceActionsError -> CmdError
CmdGovernanceActionError
Cmd.GovernanceDRepCmds GovernanceDRepCmds era
cmds ->
GovernanceDRepCmds era -> ExceptT CmdError IO ()
forall era. GovernanceDRepCmds era -> ExceptT CmdError IO ()
runGovernanceDRepCmds GovernanceDRepCmds era
cmds
Cmd.GovernancePollCmds GovernancePollCmds era
cmds ->
GovernancePollCmds era -> ExceptT GovernanceCmdError IO ()
forall era.
GovernancePollCmds era -> ExceptT GovernanceCmdError IO ()
runGovernancePollCmds GovernancePollCmds era
cmds
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.GovernanceVoteCmds GovernanceVoteCmds era
cmds ->
GovernanceVoteCmds era -> ExceptT CmdError IO ()
forall era. GovernanceVoteCmds era -> ExceptT CmdError IO ()
runGovernanceVoteCmds GovernanceVoteCmds era
cmds
runGovernanceMIRCertificatePayStakeAddrs
:: forall era
. ShelleyToBabbageEra era
-> L.MIRPot
-> [StakeAddress]
-> [Lovelace]
-> File () Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceMIRCertificatePayStakeAddrs :: forall era.
ShelleyToBabbageEra era
-> MIRPot
-> [StakeAddress]
-> [Coin]
-> File () 'Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceMIRCertificatePayStakeAddrs ShelleyToBabbageEra era
w MIRPot
mirPot [StakeAddress]
sAddrs [Coin]
rwdAmts File () 'Out
oFp = do
Bool
-> ExceptT GovernanceCmdError IO ()
-> ExceptT GovernanceCmdError IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([StakeAddress] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [StakeAddress]
sAddrs Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== [Coin] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Coin]
rwdAmts) (ExceptT GovernanceCmdError IO ()
-> ExceptT GovernanceCmdError IO ())
-> ExceptT GovernanceCmdError IO ()
-> ExceptT GovernanceCmdError IO ()
forall a b. (a -> b) -> a -> b
$
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
$
FilePath -> Int -> Int -> GovernanceCmdError
GovernanceCmdMIRCertificateKeyRewardMistmach
(File () 'Out -> FilePath
forall content (direction :: FileDirection).
File content direction -> FilePath
unFile File () 'Out
oFp)
([StakeAddress] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [StakeAddress]
sAddrs)
([Coin] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Coin]
rwdAmts)
let sCreds :: [StakeCredential]
sCreds = (StakeAddress -> StakeCredential)
-> [StakeAddress] -> [StakeCredential]
forall a b. (a -> b) -> [a] -> [b]
map StakeAddress -> StakeCredential
stakeAddressCredential [StakeAddress]
sAddrs
mirTarget :: MIRTarget StandardCrypto
mirTarget =
Map (Credential 'Staking StandardCrypto) DeltaCoin
-> MIRTarget StandardCrypto
forall c. Map (Credential 'Staking c) DeltaCoin -> MIRTarget c
L.StakeAddressesMIR (Map (Credential 'Staking StandardCrypto) DeltaCoin
-> MIRTarget StandardCrypto)
-> Map (Credential 'Staking StandardCrypto) DeltaCoin
-> MIRTarget StandardCrypto
forall a b. (a -> b) -> a -> b
$
[Item (Map (Credential 'Staking StandardCrypto) DeltaCoin)]
-> Map (Credential 'Staking StandardCrypto) DeltaCoin
forall l. IsList l => [Item l] -> l
fromList
[ (StakeCredential -> Credential 'Staking StandardCrypto
toShelleyStakeCredential StakeCredential
scred, Coin -> DeltaCoin
L.toDeltaCoin Coin
rwdAmt)
| (StakeCredential
scred, Coin
rwdAmt) <- [StakeCredential] -> [Coin] -> [(StakeCredential, Coin)]
forall a b. [a] -> [b] -> [(a, b)]
zip [StakeCredential]
sCreds [Coin]
rwdAmts
]
let mirCert :: Certificate era
mirCert =
MirCertificateRequirements era -> Certificate era
forall era. MirCertificateRequirements era -> Certificate era
makeMIRCertificate (MirCertificateRequirements era -> Certificate era)
-> MirCertificateRequirements era -> Certificate era
forall a b. (a -> b) -> a -> b
$
ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
forall era.
ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
MirCertificateRequirements ShelleyToBabbageEra era
w MIRPot
mirPot (MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era)
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
forall a b. (a -> b) -> a -> b
$
ShelleyToBabbageEra era
-> (ShelleyToBabbageEraConstraints era =>
MIRTarget (EraCrypto (ShelleyLedgerEra era)))
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
forall era a.
ShelleyToBabbageEra era
-> (ShelleyToBabbageEraConstraints era => a) -> a
shelleyToBabbageEraConstraints ShelleyToBabbageEra era
w MIRTarget (EraCrypto (ShelleyLedgerEra era))
MIRTarget StandardCrypto
ShelleyToBabbageEraConstraints era =>
MIRTarget (EraCrypto (ShelleyLedgerEra era))
mirTarget
sbe :: ShelleyBasedEra era
sbe = ShelleyToBabbageEra era -> ShelleyBasedEra era
forall era. ShelleyToBabbageEra era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert ShelleyToBabbageEra era
w
(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
$ ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe
((ShelleyBasedEraConstraints era => IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ()))
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
(ByteString -> IO (Either (FileError ()) ()))
-> ByteString -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
mirCertDesc) Certificate era
mirCert
where
mirCertDesc :: TextEnvelopeDescr
mirCertDesc :: TextEnvelopeDescr
mirCertDesc = TextEnvelopeDescr
"Move Instantaneous Rewards Certificate"
runGovernanceCreateMirCertificateTransferToTreasuryCmd
:: forall era
. ()
=> ShelleyToBabbageEra era
-> Lovelace
-> File () Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToTreasuryCmd :: forall era.
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToTreasuryCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp = do
let mirTarget :: MIRTarget (EraCrypto (ShelleyLedgerEra era))
mirTarget = Coin -> MIRTarget (EraCrypto (ShelleyLedgerEra era))
forall c. Coin -> MIRTarget c
L.SendToOppositePotMIR Coin
ll
let mirCert :: Certificate era
mirCert = MirCertificateRequirements era -> Certificate era
forall era. MirCertificateRequirements era -> Certificate era
makeMIRCertificate (MirCertificateRequirements era -> Certificate era)
-> MirCertificateRequirements era -> Certificate era
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
forall era.
ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
MirCertificateRequirements ShelleyToBabbageEra era
w MIRPot
L.ReservesMIR MIRTarget (EraCrypto (ShelleyLedgerEra era))
mirTarget
sbe :: ShelleyBasedEra era
sbe = ShelleyToBabbageEra era -> ShelleyBasedEra era
forall era. ShelleyToBabbageEra era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert ShelleyToBabbageEra era
w
(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
$ ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe
((ShelleyBasedEraConstraints era => IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ()))
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
(ByteString -> IO (Either (FileError ()) ()))
-> ByteString -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
mirCertDesc) Certificate era
mirCert
where
mirCertDesc :: TextEnvelopeDescr
mirCertDesc :: TextEnvelopeDescr
mirCertDesc = TextEnvelopeDescr
"MIR Certificate Send To Treasury"
runGovernanceCreateMirCertificateTransferToReservesCmd
:: forall era
. ()
=> ShelleyToBabbageEra era
-> Lovelace
-> File () Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToReservesCmd :: forall era.
ShelleyToBabbageEra era
-> Coin -> File () 'Out -> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToReservesCmd ShelleyToBabbageEra era
w Coin
ll File () 'Out
oFp = do
let mirTarget :: MIRTarget (EraCrypto (ShelleyLedgerEra era))
mirTarget = Coin -> MIRTarget (EraCrypto (ShelleyLedgerEra era))
forall c. Coin -> MIRTarget c
L.SendToOppositePotMIR Coin
ll
let mirCert :: Certificate era
mirCert = MirCertificateRequirements era -> Certificate era
forall era. MirCertificateRequirements era -> Certificate era
makeMIRCertificate (MirCertificateRequirements era -> Certificate era)
-> MirCertificateRequirements era -> Certificate era
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
forall era.
ShelleyToBabbageEra era
-> MIRPot
-> MIRTarget (EraCrypto (ShelleyLedgerEra era))
-> MirCertificateRequirements era
MirCertificateRequirements ShelleyToBabbageEra era
w MIRPot
L.TreasuryMIR MIRTarget (EraCrypto (ShelleyLedgerEra era))
mirTarget
sbe :: ShelleyBasedEra era
sbe = ShelleyToBabbageEra era -> ShelleyBasedEra era
forall era. ShelleyToBabbageEra era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert ShelleyToBabbageEra era
w
(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
$ ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe
((ShelleyBasedEraConstraints era => IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ()))
-> (ShelleyBasedEraConstraints era =>
IO (Either (FileError ()) ()))
-> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
(ByteString -> IO (Either (FileError ()) ()))
-> ByteString -> IO (Either (FileError ()) ())
forall a b. (a -> b) -> a -> 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
mirCertDesc) Certificate era
mirCert
where
mirCertDesc :: TextEnvelopeDescr
mirCertDesc :: TextEnvelopeDescr
mirCertDesc = TextEnvelopeDescr
"MIR Certificate Send To Reserves"