{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}

module Cardano.CLI.Compatible.Transaction
  ( CompatibleTransactionCmds (..)
  , CompatibleTransactionError (..)
  , pAllCompatibleTransactionCommands
  , renderCompatibleTransactionCmd
  , runCompatibleTransactionCmd
  )
where

import           Cardano.Api
import           Cardano.Api.Compatible
import           Cardano.Api.Ledger hiding (TxIn, VotingProcedures)
import           Cardano.Api.Shelley hiding (VotingProcedures)

import           Cardano.CLI.Environment
import           Cardano.CLI.EraBased.Options.Common hiding (pRefScriptFp, pTxOutDatum)
import           Cardano.CLI.EraBased.Run.Transaction
import           Cardano.CLI.Parser
import           Cardano.CLI.Read
import           Cardano.CLI.Types.Common
import           Cardano.CLI.Types.Errors.BootstrapWitnessError
import           Cardano.CLI.Types.Errors.TxCmdError
import           Cardano.CLI.Types.Governance

import           Data.Foldable
import           Data.Function
import           Data.Text (Text)
import           Options.Applicative
import qualified Options.Applicative as Opt

pAllCompatibleTransactionCommands
  :: EnvCli -> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pAllCompatibleTransactionCommands :: forall era.
EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pAllCompatibleTransactionCommands EnvCli
envCli ShelleyBasedEra era
sbe =
  let allCommannds :: Parser (CompatibleTransactionCmds era)
allCommannds =
        [Parser (CompatibleTransactionCmds era)]
-> Parser (CompatibleTransactionCmds era)
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
          [ EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
forall era.
EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransactionCommand EnvCli
envCli ShelleyBasedEra era
sbe
          ]
   in String
-> ParserInfo (CompatibleTransactionCmds era)
-> Parser (CompatibleTransactionCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"transaction" (ParserInfo (CompatibleTransactionCmds era)
 -> Parser (CompatibleTransactionCmds era))
-> ParserInfo (CompatibleTransactionCmds era)
-> Parser (CompatibleTransactionCmds era)
forall a b. (a -> b) -> a -> b
$
        Parser (CompatibleTransactionCmds era)
-> InfoMod (CompatibleTransactionCmds era)
-> ParserInfo (CompatibleTransactionCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser (CompatibleTransactionCmds era)
allCommannds (InfoMod (CompatibleTransactionCmds era)
 -> ParserInfo (CompatibleTransactionCmds era))
-> InfoMod (CompatibleTransactionCmds era)
-> ParserInfo (CompatibleTransactionCmds era)
forall a b. (a -> b) -> a -> b
$
          String -> InfoMod (CompatibleTransactionCmds era)
forall a. String -> InfoMod a
Opt.progDesc String
"Transaction commands."

pCompatibleSignedTransactionCommand
  :: EnvCli -> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransactionCommand :: forall era.
EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransactionCommand EnvCli
envCli ShelleyBasedEra era
sbe =
  String
-> ParserInfo (CompatibleTransactionCmds era)
-> Parser (CompatibleTransactionCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"signed-transaction" (ParserInfo (CompatibleTransactionCmds era)
 -> Parser (CompatibleTransactionCmds era))
-> ParserInfo (CompatibleTransactionCmds era)
-> Parser (CompatibleTransactionCmds era)
forall a b. (a -> b) -> a -> b
$
    Parser (CompatibleTransactionCmds era)
-> InfoMod (CompatibleTransactionCmds era)
-> ParserInfo (CompatibleTransactionCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
forall era.
EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransaction EnvCli
envCli ShelleyBasedEra era
sbe) (InfoMod (CompatibleTransactionCmds era)
 -> ParserInfo (CompatibleTransactionCmds era))
-> InfoMod (CompatibleTransactionCmds era)
-> ParserInfo (CompatibleTransactionCmds era)
forall a b. (a -> b) -> a -> b
$
      String -> InfoMod (CompatibleTransactionCmds era)
forall a. String -> InfoMod a
Opt.progDesc String
"Create a simple signed transaction."

pCompatibleSignedTransaction
  :: EnvCli -> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransaction :: forall era.
EnvCli
-> ShelleyBasedEra era -> Parser (CompatibleTransactionCmds era)
pCompatibleSignedTransaction EnvCli
env ShelleyBasedEra era
sbe =
  ShelleyBasedEra era
-> [TxIn]
-> [TxOutAnyEra]
-> Maybe
     (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
-> Maybe
     (Featured
        ConwayEraOnwards
        era
        [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
-> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> [WitnessSigningData]
-> Maybe NetworkId
-> Coin
-> File () 'Out
-> CompatibleTransactionCmds era
forall era.
ShelleyBasedEra era
-> [TxIn]
-> [TxOutAnyEra]
-> Maybe
     (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
-> Maybe
     (Featured
        ConwayEraOnwards
        era
        [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
-> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> [WitnessSigningData]
-> Maybe NetworkId
-> Coin
-> File () 'Out
-> CompatibleTransactionCmds era
CreateCompatibleSignedTransaction ShelleyBasedEra era
sbe
    ([TxIn]
 -> [TxOutAnyEra]
 -> Maybe
      (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
 -> Maybe
      (Featured
         ConwayEraOnwards
         era
         [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
 -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
 -> [WitnessSigningData]
 -> Maybe NetworkId
 -> Coin
 -> File () 'Out
 -> CompatibleTransactionCmds era)
-> Parser [TxIn]
-> Parser
     ([TxOutAnyEra]
      -> Maybe
           (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
      -> Maybe
           (Featured
              ConwayEraOnwards
              era
              [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
      -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
      -> [WitnessSigningData]
      -> Maybe NetworkId
      -> Coin
      -> File () 'Out
      -> CompatibleTransactionCmds era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser TxIn -> Parser [TxIn]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser TxIn
pTxInOnly
    Parser
  ([TxOutAnyEra]
   -> Maybe
        (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
   -> Maybe
        (Featured
           ConwayEraOnwards
           era
           [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
   -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
   -> [WitnessSigningData]
   -> Maybe NetworkId
   -> Coin
   -> File () 'Out
   -> CompatibleTransactionCmds era)
-> Parser [TxOutAnyEra]
-> Parser
     (Maybe
        (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
      -> Maybe
           (Featured
              ConwayEraOnwards
              era
              [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
      -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
      -> [WitnessSigningData]
      -> Maybe NetworkId
      -> Coin
      -> File () 'Out
      -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxOutAnyEra -> Parser [TxOutAnyEra]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ShelleyBasedEra era -> Parser TxOutAnyEra
forall era. ShelleyBasedEra era -> Parser TxOutAnyEra
pTxOutEraAware ShelleyBasedEra era
sbe)
    Parser
  (Maybe
     (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
   -> Maybe
        (Featured
           ConwayEraOnwards
           era
           [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
   -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
   -> [WitnessSigningData]
   -> Maybe NetworkId
   -> Coin
   -> File () 'Out
   -> CompatibleTransactionCmds era)
-> Parser
     (Maybe
        (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)))
-> Parser
     (Maybe
        (Featured
           ConwayEraOnwards
           era
           [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
      -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
      -> [WitnessSigningData]
      -> Maybe NetworkId
      -> Coin
      -> File () 'Out
      -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era
-> Parser (Maybe UpdateProposalFile)
-> Parser
     (Maybe
        (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)))
forall (eon :: * -> *) (f :: * -> *) era a.
(Eon eon, ToCardanoEra f) =>
f era -> Parser a -> Parser (Maybe (Featured eon era a))
pFeatured (ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe) (Parser UpdateProposalFile -> Parser (Maybe UpdateProposalFile)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser UpdateProposalFile
pUpdateProposalFile)
    Parser
  (Maybe
     (Featured
        ConwayEraOnwards
        era
        [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
   -> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
   -> [WitnessSigningData]
   -> Maybe NetworkId
   -> Coin
   -> File () 'Out
   -> CompatibleTransactionCmds era)
-> Parser
     (Maybe
        (Featured
           ConwayEraOnwards
           era
           [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]))
-> Parser
     ([(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
      -> [WitnessSigningData]
      -> Maybe NetworkId
      -> Coin
      -> File () 'Out
      -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era
-> Parser
     [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> Parser
     (Maybe
        (Featured
           ConwayEraOnwards
           era
           [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]))
forall (eon :: * -> *) (f :: * -> *) era a.
(Eon eon, ToCardanoEra f) =>
f era -> Parser a -> Parser (Maybe (Featured eon era a))
pFeatured (ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe) (Parser (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
-> Parser
     [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser
     (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
forall era.
ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser
     (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
pProposalFile ShelleyBasedEra era
sbe BalanceTxExecUnits
ManualBalance))
    Parser
  ([(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
   -> [WitnessSigningData]
   -> Maybe NetworkId
   -> Coin
   -> File () 'Out
   -> CompatibleTransactionCmds era)
-> Parser [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> Parser
     ([WitnessSigningData]
      -> Maybe NetworkId
      -> Coin
      -> File () 'Out
      -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
forall era.
ShelleyBasedEra era
-> BalanceTxExecUnits
-> Parser [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
pVoteFiles ShelleyBasedEra era
sbe BalanceTxExecUnits
ManualBalance
    Parser
  ([WitnessSigningData]
   -> Maybe NetworkId
   -> Coin
   -> File () 'Out
   -> CompatibleTransactionCmds era)
-> Parser [WitnessSigningData]
-> Parser
     (Maybe NetworkId
      -> Coin -> File () 'Out -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser WitnessSigningData -> Parser [WitnessSigningData]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser WitnessSigningData
pWitnessSigningData
    Parser
  (Maybe NetworkId
   -> Coin -> File () 'Out -> CompatibleTransactionCmds era)
-> Parser (Maybe NetworkId)
-> Parser (Coin -> File () 'Out -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId -> Parser (Maybe NetworkId)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (EnvCli -> Parser NetworkId
pNetworkId EnvCli
env)
    Parser (Coin -> File () 'Out -> CompatibleTransactionCmds era)
-> Parser Coin
-> Parser (File () 'Out -> CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Coin
pTxFee
    Parser (File () 'Out -> CompatibleTransactionCmds era)
-> Parser (File () 'Out) -> Parser (CompatibleTransactionCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (File () 'Out)
forall content. Parser (File content 'Out)
pOutputFile

pTxInOnly :: Parser TxIn
pTxInOnly :: Parser TxIn
pTxInOnly =
  ReadM TxIn -> Mod OptionFields TxIn -> Parser TxIn
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (Parser TxIn -> ReadM TxIn
forall a. Parser a -> ReadM a
readerFromParsecParser Parser TxIn
parseTxIn)
    ( String -> Mod OptionFields TxIn
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-in"
        Mod OptionFields TxIn
-> Mod OptionFields TxIn -> Mod OptionFields TxIn
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields TxIn
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"TX-IN"
        Mod OptionFields TxIn
-> Mod OptionFields TxIn -> Mod OptionFields TxIn
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields TxIn
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"TxId#TxIx"
    )

-- This parser renders the appropriate parsers depending on what
-- functionality is available per era.
pTxOutEraAware :: ShelleyBasedEra era -> Parser TxOutAnyEra
pTxOutEraAware :: forall era. ShelleyBasedEra era -> Parser TxOutAnyEra
pTxOutEraAware ShelleyBasedEra era
sbe =
  ReadM (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Parser
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (Parser (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> ReadM (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall a. Parser a -> ReadM a
readerFromParsecParser Parser (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
parseTxOutAnyEra)
    ( String
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-out"
        Mod
  OptionFields
  (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall a. Semigroup a => a -> a -> a
<> String
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"ADDRESS VALUE"
        -- TODO alonzo: Update the help text to describe the new syntax as well.
        Mod
  OptionFields
  (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall a. Semigroup a => a -> a -> a
<> String
-> Mod
     OptionFields
     (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
forall (f :: * -> *) a. String -> Mod f a
Opt.help
          String
"The transaction output as ADDRESS VALUE where ADDRESS is \
          \the Bech32-encoded address followed by the value in \
          \the multi-asset syntax (including simply Lovelace)."
    )
    Parser (TxOutDatumAnyEra -> ReferenceScriptAnyEra -> TxOutAnyEra)
-> Parser TxOutDatumAnyEra
-> Parser (ReferenceScriptAnyEra -> TxOutAnyEra)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ShelleyBasedEra era -> Parser TxOutDatumAnyEra
forall era. ShelleyBasedEra era -> Parser TxOutDatumAnyEra
pTxOutDatum ShelleyBasedEra era
sbe
    Parser (ReferenceScriptAnyEra -> TxOutAnyEra)
-> Parser ReferenceScriptAnyEra -> Parser TxOutAnyEra
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ShelleyBasedEra era -> Parser ReferenceScriptAnyEra
forall era. ShelleyBasedEra era -> Parser ReferenceScriptAnyEra
pRefScriptFp ShelleyBasedEra era
sbe

pTxOutDatum :: ShelleyBasedEra era -> Parser TxOutDatumAnyEra
pTxOutDatum :: forall era. ShelleyBasedEra era -> Parser TxOutDatumAnyEra
pTxOutDatum =
  (ShelleyToMaryEraConstraints era =>
 ShelleyToMaryEra era -> Parser TxOutDatumAnyEra)
-> (AlonzoEraOnwardsConstraints era =>
    AlonzoEraOnwards era -> Parser TxOutDatumAnyEra)
-> ShelleyBasedEra era
-> Parser TxOutDatumAnyEra
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
    (Parser TxOutDatumAnyEra
-> ShelleyToMaryEra era -> Parser TxOutDatumAnyEra
forall a b. a -> b -> a
const (Parser TxOutDatumAnyEra
 -> ShelleyToMaryEra era -> Parser TxOutDatumAnyEra)
-> Parser TxOutDatumAnyEra
-> ShelleyToMaryEra era
-> Parser TxOutDatumAnyEra
forall a b. (a -> b) -> a -> b
$ TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatumAnyEra
TxOutDatumByNone)
    ( \case
        AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo ->
          Parser TxOutDatumAnyEra
pAlonzoDatumFunctionality Parser TxOutDatumAnyEra
-> Parser TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatumAnyEra
TxOutDatumByNone
        AlonzoEraOnwards era
AlonzoEraOnwardsBabbage ->
          Parser TxOutDatumAnyEra
pBabbageDatumFunctionality Parser TxOutDatumAnyEra
-> Parser TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatumAnyEra
TxOutDatumByNone
        AlonzoEraOnwards era
AlonzoEraOnwardsConway -> Parser TxOutDatumAnyEra
pConwayDatumFunctionality Parser TxOutDatumAnyEra
-> Parser TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TxOutDatumAnyEra -> Parser TxOutDatumAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxOutDatumAnyEra
TxOutDatumByNone
    )
 where
  pAlonzoDatumFunctionality :: Parser TxOutDatumAnyEra
pAlonzoDatumFunctionality =
    [Parser TxOutDatumAnyEra] -> Parser TxOutDatumAnyEra
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
      [ Parser TxOutDatumAnyEra
pTxOutDatumByHashOnly
      , Parser TxOutDatumAnyEra
pTxOutDatumByHashOf
      , Parser TxOutDatumAnyEra
pTxOutDatumByValue
      ]
  pBabbageDatumFunctionality :: Parser TxOutDatumAnyEra
pBabbageDatumFunctionality =
    [Parser TxOutDatumAnyEra] -> Parser TxOutDatumAnyEra
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
      [ Parser TxOutDatumAnyEra
pAlonzoDatumFunctionality
      , Parser TxOutDatumAnyEra
pTxOutInlineDatumByValue
      ]

  pConwayDatumFunctionality :: Parser TxOutDatumAnyEra
pConwayDatumFunctionality = Parser TxOutDatumAnyEra
pBabbageDatumFunctionality

  pTxOutDatumByHashOnly :: Parser TxOutDatumAnyEra
pTxOutDatumByHashOnly =
    (Hash ScriptData -> TxOutDatumAnyEra)
-> Parser (Hash ScriptData) -> Parser TxOutDatumAnyEra
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Hash ScriptData -> TxOutDatumAnyEra
TxOutDatumByHashOnly (Parser (Hash ScriptData) -> Parser TxOutDatumAnyEra)
-> Parser (Hash ScriptData) -> Parser TxOutDatumAnyEra
forall a b. (a -> b) -> a -> b
$
      ReadM (Hash ScriptData)
-> Mod OptionFields (Hash ScriptData) -> Parser (Hash ScriptData)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser (Hash ScriptData) -> ReadM (Hash ScriptData)
forall a. Parser a -> ReadM a
readerFromParsecParser (Parser (Hash ScriptData) -> ReadM (Hash ScriptData))
-> Parser (Hash ScriptData) -> ReadM (Hash ScriptData)
forall a b. (a -> b) -> a -> b
$ AsType (Hash ScriptData) -> Parser (Hash ScriptData)
forall a.
SerialiseAsRawBytes (Hash a) =>
AsType (Hash a) -> Parser (Hash a)
parseHash (AsType ScriptData -> AsType (Hash ScriptData)
forall a. AsType a -> AsType (Hash a)
AsHash AsType ScriptData
AsScriptData)) (Mod OptionFields (Hash ScriptData) -> Parser (Hash ScriptData))
-> Mod OptionFields (Hash ScriptData) -> Parser (Hash ScriptData)
forall a b. (a -> b) -> a -> b
$
        [Mod OptionFields (Hash ScriptData)]
-> Mod OptionFields (Hash ScriptData)
forall a. Monoid a => [a] -> a
mconcat
          [ String -> Mod OptionFields (Hash ScriptData)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-out-datum-hash"
          , String -> Mod OptionFields (Hash ScriptData)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"HASH"
          , String -> Mod OptionFields (Hash ScriptData)
forall (f :: * -> *) a. String -> Mod f a
Opt.help (String -> Mod OptionFields (Hash ScriptData))
-> String -> Mod OptionFields (Hash ScriptData)
forall a b. (a -> b) -> a -> b
$
              [String] -> String
forall a. Monoid a => [a] -> a
mconcat
                [ String
"The script datum hash for this tx output, as "
                , String
"the raw datum hash (in hex)."
                ]
          ]

  pTxOutDatumByHashOf :: Parser TxOutDatumAnyEra
pTxOutDatumByHashOf =
    ScriptDataOrFile -> TxOutDatumAnyEra
TxOutDatumByHashOf
      (ScriptDataOrFile -> TxOutDatumAnyEra)
-> Parser ScriptDataOrFile -> Parser TxOutDatumAnyEra
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> String -> Parser ScriptDataOrFile
pScriptDataOrFile
        String
"tx-out-datum-hash"
        String
"The script datum hash for this tx output, by hashing the script datum given here."
        String
"The script datum hash for this tx output, by hashing the script datum in the file."

  pTxOutDatumByValue :: Parser TxOutDatumAnyEra
pTxOutDatumByValue =
    ScriptDataOrFile -> TxOutDatumAnyEra
TxOutDatumByValue
      (ScriptDataOrFile -> TxOutDatumAnyEra)
-> Parser ScriptDataOrFile -> Parser TxOutDatumAnyEra
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> String -> Parser ScriptDataOrFile
pScriptDataOrFile
        String
"tx-out-datum-embed"
        String
"The script datum to embed in the tx for this output, given here."
        String
"The script datum to embed in the tx for this output, in the given file."

  pTxOutInlineDatumByValue :: Parser TxOutDatumAnyEra
pTxOutInlineDatumByValue =
    ScriptDataOrFile -> TxOutDatumAnyEra
TxOutInlineDatumByValue
      (ScriptDataOrFile -> TxOutDatumAnyEra)
-> Parser ScriptDataOrFile -> Parser TxOutDatumAnyEra
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> String -> Parser ScriptDataOrFile
pScriptDataOrFile
        String
"tx-out-inline-datum"
        String
"The script datum to embed in the tx output as an inline datum, given here."
        String
"The script datum to embed in the tx output as an inline datum, in the given file."

pRefScriptFp :: ShelleyBasedEra era -> Parser ReferenceScriptAnyEra
pRefScriptFp :: forall era. ShelleyBasedEra era -> Parser ReferenceScriptAnyEra
pRefScriptFp =
  (ShelleyToBabbageEraConstraints era =>
 ShelleyToBabbageEra era -> Parser ReferenceScriptAnyEra)
-> (ConwayEraOnwardsConstraints era =>
    ConwayEraOnwards era -> Parser ReferenceScriptAnyEra)
-> ShelleyBasedEra era
-> Parser ReferenceScriptAnyEra
forall era a.
(ShelleyToBabbageEraConstraints era =>
 ShelleyToBabbageEra era -> a)
-> (ConwayEraOnwardsConstraints era => ConwayEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToBabbageOrConwayEraOnwards
    (Parser ReferenceScriptAnyEra
-> ShelleyToBabbageEra era -> Parser ReferenceScriptAnyEra
forall a b. a -> b -> a
const (Parser ReferenceScriptAnyEra
 -> ShelleyToBabbageEra era -> Parser ReferenceScriptAnyEra)
-> Parser ReferenceScriptAnyEra
-> ShelleyToBabbageEra era
-> Parser ReferenceScriptAnyEra
forall a b. (a -> b) -> a -> b
$ ReferenceScriptAnyEra -> Parser ReferenceScriptAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReferenceScriptAnyEra
ReferenceScriptAnyEraNone)
    ( Parser ReferenceScriptAnyEra
-> ConwayEraOnwards era -> Parser ReferenceScriptAnyEra
forall a b. a -> b -> a
const (Parser ReferenceScriptAnyEra
 -> ConwayEraOnwards era -> Parser ReferenceScriptAnyEra)
-> Parser ReferenceScriptAnyEra
-> ConwayEraOnwards era
-> Parser ReferenceScriptAnyEra
forall a b. (a -> b) -> a -> b
$
        String -> ReferenceScriptAnyEra
ReferenceScriptAnyEra
          (String -> ReferenceScriptAnyEra)
-> Parser String -> Parser ReferenceScriptAnyEra
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> Parser String
parseFilePath String
"tx-out-reference-script-file" String
"Reference script input file."
            Parser ReferenceScriptAnyEra
-> Parser ReferenceScriptAnyEra -> Parser ReferenceScriptAnyEra
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ReferenceScriptAnyEra -> Parser ReferenceScriptAnyEra
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReferenceScriptAnyEra
ReferenceScriptAnyEraNone
    )

-- TODO: After QA confirmms that the new compatibility commands meet their needs
-- we can remove all remaining legacy commands. We can also remove/move the exising
-- byron era commands under the new compatiblilty commands.
data CompatibleTransactionCmds era
  = CreateCompatibleSignedTransaction
      (ShelleyBasedEra era)
      [TxIn]
      [TxOutAnyEra]
      !(Maybe (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)))
      !(Maybe (Featured ConwayEraOnwards era [(ProposalFile In, Maybe (ScriptWitnessFiles WitCtxStake))]))
      ![(VoteFile In, Maybe (ScriptWitnessFiles WitCtxStake))]
      [WitnessSigningData]
      -- ^ Signing keys
      (Maybe NetworkId)
      !Coin
      -- ^ Tx fee
      !(File () Out)

renderCompatibleTransactionCmd :: CompatibleTransactionCmds era -> Text
renderCompatibleTransactionCmd :: forall era. CompatibleTransactionCmds era -> Text
renderCompatibleTransactionCmd CompatibleTransactionCmds era
_ = Text
""

data CompatibleTransactionError
  = CompatibleTxOutError !TxCmdError
  | CompatibleWitnessError !ReadWitnessSigningDataError
  | CompatiblePParamsConversionError !ProtocolParametersConversionError
  | CompatibleBootstrapWitnessError !BootstrapWitnessError
  | forall err. Error err => CompatibleFileError (FileError err)
  | CompatibleTxBodyError !TxBodyError
  | CompatibleProposalError !ProposalError
  | CompatibleVoteError !VoteError
  | forall era. CompatibleVoteMergeError !(VotesMergingConflict era)

instance Error CompatibleTransactionError where
  prettyError :: forall ann. CompatibleTransactionError -> Doc ann
prettyError = \case
    CompatibleTxOutError TxCmdError
e -> TxCmdError -> Doc ann
forall ann. TxCmdError -> Doc ann
renderTxCmdError TxCmdError
e
    CompatibleWitnessError ReadWitnessSigningDataError
e -> ReadWitnessSigningDataError -> Doc ann
forall ann. ReadWitnessSigningDataError -> Doc ann
renderReadWitnessSigningDataError ReadWitnessSigningDataError
e
    CompatiblePParamsConversionError ProtocolParametersConversionError
e -> ProtocolParametersConversionError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. ProtocolParametersConversionError -> Doc ann
prettyError ProtocolParametersConversionError
e
    CompatibleBootstrapWitnessError BootstrapWitnessError
e -> BootstrapWitnessError -> Doc ann
forall ann. BootstrapWitnessError -> Doc ann
renderBootstrapWitnessError BootstrapWitnessError
e
    CompatibleFileError FileError err
e -> FileError err -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. FileError err -> Doc ann
prettyError FileError err
e
    CompatibleTxBodyError TxBodyError
e -> TxBodyError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. TxBodyError -> Doc ann
prettyError TxBodyError
e
    CompatibleProposalError ProposalError
e -> ProposalError -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow ProposalError
e
    CompatibleVoteError VoteError
e -> VoteError -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow VoteError
e
    CompatibleVoteMergeError VotesMergingConflict era
e -> VotesMergingConflict era -> Doc ann
forall a ann. Show a => a -> Doc ann
pshow VotesMergingConflict era
e

runCompatibleTransactionCmd
  :: CompatibleTransactionCmds era -> ExceptT CompatibleTransactionError IO ()
runCompatibleTransactionCmd :: forall era.
CompatibleTransactionCmds era
-> ExceptT CompatibleTransactionError IO ()
runCompatibleTransactionCmd
  ( CreateCompatibleSignedTransaction
      ShelleyBasedEra era
sbe
      [TxIn]
ins
      [TxOutAnyEra]
outs
      Maybe (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
mUpdateProposal
      Maybe
  (Featured
     ConwayEraOnwards
     era
     [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
mProposalProcedure
      [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
mVotes
      [WitnessSigningData]
witnesses
      Maybe NetworkId
mNetworkId
      Coin
fee
      File () 'Out
outputFp
    ) = do
    [SomeSigningWitness]
sks <- (ReadWitnessSigningDataError -> CompatibleTransactionError)
-> ExceptT ReadWitnessSigningDataError IO [SomeSigningWitness]
-> ExceptT CompatibleTransactionError IO [SomeSigningWitness]
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT ReadWitnessSigningDataError -> CompatibleTransactionError
CompatibleWitnessError (ExceptT ReadWitnessSigningDataError IO [SomeSigningWitness]
 -> ExceptT CompatibleTransactionError IO [SomeSigningWitness])
-> ExceptT ReadWitnessSigningDataError IO [SomeSigningWitness]
-> ExceptT CompatibleTransactionError IO [SomeSigningWitness]
forall a b. (a -> b) -> a -> b
$ (WitnessSigningData
 -> ExceptT ReadWitnessSigningDataError IO SomeSigningWitness)
-> [WitnessSigningData]
-> ExceptT ReadWitnessSigningDataError IO [SomeSigningWitness]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (IO (Either ReadWitnessSigningDataError SomeSigningWitness)
-> ExceptT ReadWitnessSigningDataError IO SomeSigningWitness
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO (Either ReadWitnessSigningDataError SomeSigningWitness)
 -> ExceptT ReadWitnessSigningDataError IO SomeSigningWitness)
-> (WitnessSigningData
    -> IO (Either ReadWitnessSigningDataError SomeSigningWitness))
-> WitnessSigningData
-> ExceptT ReadWitnessSigningDataError IO SomeSigningWitness
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WitnessSigningData
-> IO (Either ReadWitnessSigningDataError SomeSigningWitness)
readWitnessSigningData) [WitnessSigningData]
witnesses

    [TxOut CtxTx era]
allOuts <- (TxCmdError -> CompatibleTransactionError)
-> ExceptT TxCmdError IO [TxOut CtxTx era]
-> ExceptT CompatibleTransactionError IO [TxOut CtxTx era]
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT TxCmdError -> CompatibleTransactionError
CompatibleTxOutError (ExceptT TxCmdError IO [TxOut CtxTx era]
 -> ExceptT CompatibleTransactionError IO [TxOut CtxTx era])
-> ExceptT TxCmdError IO [TxOut CtxTx era]
-> ExceptT CompatibleTransactionError IO [TxOut CtxTx era]
forall a b. (a -> b) -> a -> b
$ (TxOutAnyEra -> ExceptT TxCmdError IO (TxOut CtxTx era))
-> [TxOutAnyEra] -> ExceptT TxCmdError IO [TxOut CtxTx era]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (ShelleyBasedEra era
-> TxOutAnyEra -> ExceptT TxCmdError IO (TxOut CtxTx era)
forall era.
ShelleyBasedEra era
-> TxOutAnyEra -> ExceptT TxCmdError IO (TxOut CtxTx era)
toTxOutInAnyEra ShelleyBasedEra era
sbe) [TxOutAnyEra]
outs

    TxBody era
apiTxBody <-
      (TxBodyError -> CompatibleTransactionError)
-> ExceptT TxBodyError IO (TxBody era)
-> ExceptT CompatibleTransactionError IO (TxBody era)
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT TxBodyError -> CompatibleTransactionError
CompatibleTxBodyError (ExceptT TxBodyError IO (TxBody era)
 -> ExceptT CompatibleTransactionError IO (TxBody era))
-> ExceptT TxBodyError IO (TxBody era)
-> ExceptT CompatibleTransactionError IO (TxBody era)
forall a b. (a -> b) -> a -> b
$
        Either TxBodyError (TxBody era)
-> ExceptT TxBodyError IO (TxBody era)
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either TxBodyError (TxBody era)
 -> ExceptT TxBodyError IO (TxBody era))
-> Either TxBodyError (TxBody era)
-> ExceptT TxBodyError IO (TxBody era)
forall a b. (a -> b) -> a -> b
$
          ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
createTransactionBody ShelleyBasedEra era
sbe (TxBodyContent BuildTx era -> Either TxBodyError (TxBody era))
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
            ShelleyBasedEra era -> TxBodyContent BuildTx era
forall era. ShelleyBasedEra era -> TxBodyContent BuildTx era
defaultTxBodyContent ShelleyBasedEra era
sbe
              TxBodyContent BuildTx era
-> (TxBodyContent BuildTx era -> TxBodyContent BuildTx era)
-> TxBodyContent BuildTx era
forall a b. a -> (a -> b) -> b
& TxIns BuildTx era
-> TxBodyContent BuildTx era -> TxBodyContent BuildTx era
forall build era.
TxIns build era
-> TxBodyContent build era -> TxBodyContent build era
setTxIns ((TxIn -> (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)))
-> [TxIn] -> TxIns BuildTx era
forall a b. (a -> b) -> [a] -> [b]
map (,Witness WitCtxTxIn era
-> BuildTxWith BuildTx (Witness WitCtxTxIn era)
forall a. a -> BuildTxWith BuildTx a
BuildTxWith (KeyWitnessInCtx WitCtxTxIn -> Witness WitCtxTxIn era
forall witctx era. KeyWitnessInCtx witctx -> Witness witctx era
KeyWitness KeyWitnessInCtx WitCtxTxIn
KeyWitnessForSpending)) [TxIn]
ins)
              TxBodyContent BuildTx era
-> (TxBodyContent BuildTx era -> TxBodyContent BuildTx era)
-> TxBodyContent BuildTx era
forall a b. a -> (a -> b) -> b
& [TxOut CtxTx era]
-> TxBodyContent BuildTx era -> TxBodyContent BuildTx era
forall era build.
[TxOut CtxTx era]
-> TxBodyContent build era -> TxBodyContent build era
setTxOuts [TxOut CtxTx era]
allOuts
              TxBodyContent BuildTx era
-> (TxBodyContent BuildTx era -> TxBodyContent BuildTx era)
-> TxBodyContent BuildTx era
forall a b. a -> (a -> b) -> b
& TxFee era -> TxBodyContent BuildTx era -> TxBodyContent BuildTx era
forall era build.
TxFee era -> TxBodyContent build era -> TxBodyContent build era
setTxFee (ShelleyBasedEra era -> Coin -> TxFee era
forall era. ShelleyBasedEra era -> Coin -> TxFee era
TxFeeExplicit ShelleyBasedEra era
sbe Coin
fee)

    let ([ShelleyBootstrapWitnessSigningKeyData]
sksByron, [ShelleyWitnessSigningKey]
sksShelley) = [ByronOrShelleyWitness]
-> ([ShelleyBootstrapWitnessSigningKeyData],
    [ShelleyWitnessSigningKey])
partitionSomeWitnesses ([ByronOrShelleyWitness]
 -> ([ShelleyBootstrapWitnessSigningKeyData],
     [ShelleyWitnessSigningKey]))
-> [ByronOrShelleyWitness]
-> ([ShelleyBootstrapWitnessSigningKeyData],
    [ShelleyWitnessSigningKey])
forall a b. (a -> b) -> a -> b
$ (SomeSigningWitness -> ByronOrShelleyWitness)
-> [SomeSigningWitness] -> [ByronOrShelleyWitness]
forall a b. (a -> b) -> [a] -> [b]
map SomeSigningWitness -> ByronOrShelleyWitness
categoriseSomeSigningWitness [SomeSigningWitness]
sks

    [KeyWitness era]
byronWitnesses <-
      (BootstrapWitnessError -> CompatibleTransactionError)
-> ExceptT BootstrapWitnessError IO [KeyWitness era]
-> ExceptT CompatibleTransactionError IO [KeyWitness era]
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT BootstrapWitnessError -> CompatibleTransactionError
CompatibleBootstrapWitnessError (ExceptT BootstrapWitnessError IO [KeyWitness era]
 -> ExceptT CompatibleTransactionError IO [KeyWitness era])
-> ExceptT BootstrapWitnessError IO [KeyWitness era]
-> ExceptT CompatibleTransactionError IO [KeyWitness era]
forall a b. (a -> b) -> a -> b
$
        Either BootstrapWitnessError [KeyWitness era]
-> ExceptT BootstrapWitnessError IO [KeyWitness era]
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (ShelleyBasedEra era
-> Maybe NetworkId
-> TxBody era
-> [ShelleyBootstrapWitnessSigningKeyData]
-> Either BootstrapWitnessError [KeyWitness era]
forall era.
ShelleyBasedEra era
-> Maybe NetworkId
-> TxBody era
-> [ShelleyBootstrapWitnessSigningKeyData]
-> Either BootstrapWitnessError [KeyWitness era]
mkShelleyBootstrapWitnesses ShelleyBasedEra era
sbe Maybe NetworkId
mNetworkId TxBody era
apiTxBody [ShelleyBootstrapWitnessSigningKeyData]
sksByron)

    let newShelleyKeyWits :: [KeyWitness era]
newShelleyKeyWits = (ShelleyWitnessSigningKey -> KeyWitness era)
-> [ShelleyWitnessSigningKey] -> [KeyWitness era]
forall a b. (a -> b) -> [a] -> [b]
map (ShelleyBasedEra era
-> TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
forall era.
ShelleyBasedEra era
-> TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
makeShelleyKeyWitness ShelleyBasedEra era
sbe TxBody era
apiTxBody) [ShelleyWitnessSigningKey]
sksShelley
        allKeyWits :: [KeyWitness era]
allKeyWits = [KeyWitness era]
newShelleyKeyWits [KeyWitness era] -> [KeyWitness era] -> [KeyWitness era]
forall a. [a] -> [a] -> [a]
++ [KeyWitness era]
byronWitnesses

    (AnyProtocolUpdate era
protocolUpdates, AnyVote era
votes) <-
      (ShelleyToBabbageEraConstraints era =>
 ShelleyToBabbageEra era
 -> ExceptT
      CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era))
-> (ConwayEraOnwardsConstraints era =>
    ConwayEraOnwards era
    -> ExceptT
         CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era))
-> ShelleyBasedEra era
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
forall era a.
(ShelleyToBabbageEraConstraints era =>
 ShelleyToBabbageEra era -> a)
-> (ConwayEraOnwardsConstraints era => ConwayEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToBabbageOrConwayEraOnwards
        ( ExceptT
  CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
-> ShelleyToBabbageEra era
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
forall a b. a -> b -> a
const (ExceptT
   CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
 -> ShelleyToBabbageEra era
 -> ExceptT
      CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era))
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
-> ShelleyToBabbageEra era
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
forall a b. (a -> b) -> a -> b
$ do
            AnyProtocolUpdate era
prop <- ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
-> (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)
    -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> Maybe
     (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> AnyProtocolUpdate era
forall era. ShelleyBasedEra era -> AnyProtocolUpdate era
NoPParamsUpdate ShelleyBasedEra era
sbe) Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall era.
Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readUpdateProposalFile Maybe (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile))
mUpdateProposal
            (AnyProtocolUpdate era, AnyVote era)
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
prop, AnyVote era
forall era. AnyVote era
NoVotes)
        )
        ( \ConwayEraOnwards era
w -> do
            AnyProtocolUpdate era
prop <- ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
-> (Featured
      ConwayEraOnwards
      era
      [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
    -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> Maybe
     (Featured
        ConwayEraOnwards
        era
        [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> AnyProtocolUpdate era
forall era. ShelleyBasedEra era -> AnyProtocolUpdate era
NoPParamsUpdate ShelleyBasedEra era
sbe) Featured
  ConwayEraOnwards
  era
  [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall era.
Featured
  ConwayEraOnwards
  era
  [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readProposalProcedureFile Maybe
  (Featured
     ConwayEraOnwards
     era
     [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))])
mProposalProcedure
            [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
votesAndWits <- (VoteError -> CompatibleTransactionError)
-> ExceptT
     VoteError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> ExceptT
     CompatibleTransactionError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT VoteError -> CompatibleTransactionError
CompatibleVoteError (ExceptT
   VoteError
   IO
   [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
 -> ExceptT
      CompatibleTransactionError
      IO
      [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
-> ExceptT
     VoteError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> ExceptT
     CompatibleTransactionError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
forall a b. (a -> b) -> a -> b
$ IO
  (Either
     VoteError
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
-> ExceptT
     VoteError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO
   (Either
      VoteError
      [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
 -> ExceptT
      VoteError
      IO
      [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
-> IO
     (Either
        VoteError
        [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
-> ExceptT
     VoteError
     IO
     [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era
-> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> IO
     (Either
        VoteError
        [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
forall era.
ConwayEraOnwards era
-> [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> IO
     (Either
        VoteError
        [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))])
readVotingProceduresFiles ConwayEraOnwards era
w [(VoteFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
mVotes
            TxVotingProcedures BuildTx era
votingProcedures <-
              (VotesMergingConflict era -> CompatibleTransactionError)
-> ExceptT
     (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era)
-> ExceptT
     CompatibleTransactionError IO (TxVotingProcedures BuildTx era)
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT VotesMergingConflict era -> CompatibleTransactionError
forall era. VotesMergingConflict era -> CompatibleTransactionError
CompatibleVoteMergeError (ExceptT
   (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era)
 -> ExceptT
      CompatibleTransactionError IO (TxVotingProcedures BuildTx era))
-> ExceptT
     (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era)
-> ExceptT
     CompatibleTransactionError IO (TxVotingProcedures BuildTx era)
forall a b. (a -> b) -> a -> b
$ Either (VotesMergingConflict era) (TxVotingProcedures BuildTx era)
-> ExceptT
     (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era)
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either (VotesMergingConflict era) (TxVotingProcedures BuildTx era)
 -> ExceptT
      (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era))
-> Either
     (VotesMergingConflict era) (TxVotingProcedures BuildTx era)
-> ExceptT
     (VotesMergingConflict era) IO (TxVotingProcedures BuildTx era)
forall a b. (a -> b) -> a -> b
$ [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Either
     (VotesMergingConflict era) (TxVotingProcedures BuildTx era)
forall build era.
Applicative (BuildTxWith build) =>
[(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Either (VotesMergingConflict era) (TxVotingProcedures build era)
mkTxVotingProcedures [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
votesAndWits
            (AnyProtocolUpdate era, AnyVote era)
-> ExceptT
     CompatibleTransactionError IO (AnyProtocolUpdate era, AnyVote era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
prop, ConwayEraOnwards era
-> TxVotingProcedures BuildTx era -> AnyVote era
forall era.
ConwayEraOnwards era
-> TxVotingProcedures BuildTx era -> AnyVote era
VotingProcedures ConwayEraOnwards era
w TxVotingProcedures BuildTx era
votingProcedures)
        )
        ShelleyBasedEra era
sbe

    Tx era
signedTx <-
      (ProtocolParametersConversionError -> CompatibleTransactionError)
-> ExceptT ProtocolParametersConversionError IO (Tx era)
-> ExceptT CompatibleTransactionError IO (Tx era)
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT ProtocolParametersConversionError -> CompatibleTransactionError
CompatiblePParamsConversionError (ExceptT ProtocolParametersConversionError IO (Tx era)
 -> ExceptT CompatibleTransactionError IO (Tx era))
-> (Either ProtocolParametersConversionError (Tx era)
    -> ExceptT ProtocolParametersConversionError IO (Tx era))
-> Either ProtocolParametersConversionError (Tx era)
-> ExceptT CompatibleTransactionError IO (Tx era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either ProtocolParametersConversionError (Tx era)
-> ExceptT ProtocolParametersConversionError IO (Tx era)
forall (m :: * -> *) x a. Monad m => Either x a -> ExceptT x m a
hoistEither (Either ProtocolParametersConversionError (Tx era)
 -> ExceptT CompatibleTransactionError IO (Tx era))
-> Either ProtocolParametersConversionError (Tx era)
-> ExceptT CompatibleTransactionError IO (Tx era)
forall a b. (a -> b) -> a -> b
$
        ShelleyBasedEra era
-> [TxIn]
-> [TxOut CtxTx era]
-> [KeyWitness era]
-> Coin
-> AnyProtocolUpdate era
-> AnyVote era
-> Either ProtocolParametersConversionError (Tx era)
forall era.
ShelleyBasedEra era
-> [TxIn]
-> [TxOut CtxTx era]
-> [KeyWitness era]
-> Coin
-> AnyProtocolUpdate era
-> AnyVote era
-> Either ProtocolParametersConversionError (Tx era)
createCompatibleSignedTx ShelleyBasedEra era
sbe [TxIn]
ins [TxOut CtxTx era]
allOuts [KeyWitness era]
allKeyWits Coin
fee AnyProtocolUpdate era
protocolUpdates AnyVote era
votes

    (FileError () -> CompatibleTransactionError)
-> ExceptT (FileError ()) IO ()
-> ExceptT CompatibleTransactionError IO ()
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError () -> CompatibleTransactionError
forall err.
Error err =>
FileError err -> CompatibleTransactionError
CompatibleFileError (ExceptT (FileError ()) IO ()
 -> ExceptT CompatibleTransactionError IO ())
-> ExceptT (FileError ()) IO ()
-> ExceptT CompatibleTransactionError IO ()
forall a b. (a -> b) -> a -> b
$
      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
$
        ShelleyBasedEra era
-> File () 'Out -> Tx era -> IO (Either (FileError ()) ())
forall era content.
ShelleyBasedEra era
-> File content 'Out -> Tx era -> IO (Either (FileError ()) ())
writeTxFileTextEnvelopeCddl ShelleyBasedEra era
sbe File () 'Out
outputFp Tx era
signedTx

readUpdateProposalFile
  :: Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)
  -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readUpdateProposalFile :: forall era.
Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readUpdateProposalFile (Featured ShelleyToBabbageEra era
sToB Maybe UpdateProposalFile
Nothing) =
  AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> AnyProtocolUpdate era
forall era. ShelleyBasedEra era -> AnyProtocolUpdate era
NoPParamsUpdate (ShelleyBasedEra era -> AnyProtocolUpdate era)
-> ShelleyBasedEra era -> AnyProtocolUpdate era
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era -> ShelleyBasedEra era
forall era. ShelleyToBabbageEra era -> ShelleyBasedEra era
shelleyToBabbageEraToShelleyBasedEra ShelleyToBabbageEra era
sToB
readUpdateProposalFile (Featured ShelleyToBabbageEra era
sToB (Just UpdateProposalFile
updateProposalFile)) = do
  TxUpdateProposal era
prop <- (FileError TextEnvelopeError -> CompatibleTransactionError)
-> ExceptT (FileError TextEnvelopeError) IO (TxUpdateProposal era)
-> ExceptT CompatibleTransactionError IO (TxUpdateProposal era)
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT FileError TextEnvelopeError -> CompatibleTransactionError
forall err.
Error err =>
FileError err -> CompatibleTransactionError
CompatibleFileError (ExceptT (FileError TextEnvelopeError) IO (TxUpdateProposal era)
 -> ExceptT CompatibleTransactionError IO (TxUpdateProposal era))
-> ExceptT (FileError TextEnvelopeError) IO (TxUpdateProposal era)
-> ExceptT CompatibleTransactionError IO (TxUpdateProposal era)
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era
-> UpdateProposalFile
-> ExceptT (FileError TextEnvelopeError) IO (TxUpdateProposal era)
forall era.
ShelleyToBabbageEra era
-> UpdateProposalFile
-> ExceptT (FileError TextEnvelopeError) IO (TxUpdateProposal era)
readTxUpdateProposal ShelleyToBabbageEra era
sToB UpdateProposalFile
updateProposalFile
  case TxUpdateProposal era
prop of
    TxUpdateProposal era
TxUpdateProposalNone -> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> AnyProtocolUpdate era
forall era. ShelleyBasedEra era -> AnyProtocolUpdate era
NoPParamsUpdate (ShelleyBasedEra era -> AnyProtocolUpdate era)
-> ShelleyBasedEra era -> AnyProtocolUpdate era
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era -> ShelleyBasedEra era
forall era. ShelleyToBabbageEra era -> ShelleyBasedEra era
shelleyToBabbageEraToShelleyBasedEra ShelleyToBabbageEra era
sToB
    TxUpdateProposal ShelleyToBabbageEra era
_ UpdateProposal
proposal -> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyToBabbageEra era -> UpdateProposal -> AnyProtocolUpdate era
forall era.
ShelleyToBabbageEra era -> UpdateProposal -> AnyProtocolUpdate era
ProtocolUpdate ShelleyToBabbageEra era
sToB UpdateProposal
proposal

readProposalProcedureFile
  :: Featured ConwayEraOnwards era [(ProposalFile In, Maybe (ScriptWitnessFiles WitCtxStake))]
  -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readProposalProcedureFile :: forall era.
Featured
  ConwayEraOnwards
  era
  [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
readProposalProcedureFile (Featured ConwayEraOnwards era
cEraOnwards []) =
  let sbe :: ShelleyBasedEra era
sbe = ConwayEraOnwards era -> ShelleyBasedEra era
forall era. ConwayEraOnwards era -> ShelleyBasedEra era
conwayEraOnwardsToShelleyBasedEra ConwayEraOnwards era
cEraOnwards
   in AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> AnyProtocolUpdate era
forall era. ShelleyBasedEra era -> AnyProtocolUpdate era
NoPParamsUpdate ShelleyBasedEra era
sbe
readProposalProcedureFile (Featured ConwayEraOnwards era
cEraOnwards [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
proposals) = do
  [(Proposal era, Maybe (ScriptWitness WitCtxStake era))]
props <-
    ((ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
 -> ExceptT
      CompatibleTransactionError
      IO
      (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
-> [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
-> ExceptT
     CompatibleTransactionError
     IO
     [(Proposal era, Maybe (ScriptWitness WitCtxStake era))]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM
      ((ProposalError -> CompatibleTransactionError)
-> ExceptT
     ProposalError
     IO
     (Proposal era, Maybe (ScriptWitness WitCtxStake era))
-> ExceptT
     CompatibleTransactionError
     IO
     (Proposal era, Maybe (ScriptWitness WitCtxStake era))
forall (m :: * -> *) x y a.
Functor m =>
(x -> y) -> ExceptT x m a -> ExceptT y m a
firstExceptT ProposalError -> CompatibleTransactionError
CompatibleProposalError (ExceptT
   ProposalError
   IO
   (Proposal era, Maybe (ScriptWitness WitCtxStake era))
 -> ExceptT
      CompatibleTransactionError
      IO
      (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
-> ((ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
    -> ExceptT
         ProposalError
         IO
         (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
-> (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
-> ExceptT
     CompatibleTransactionError
     IO
     (Proposal era, Maybe (ScriptWitness WitCtxStake era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO
  (Either
     ProposalError
     (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
-> ExceptT
     ProposalError
     IO
     (Proposal era, Maybe (ScriptWitness WitCtxStake era))
forall (m :: * -> *) x a. m (Either x a) -> ExceptT x m a
newExceptT (IO
   (Either
      ProposalError
      (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
 -> ExceptT
      ProposalError
      IO
      (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
-> ((ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
    -> IO
         (Either
            ProposalError
            (Proposal era, Maybe (ScriptWitness WitCtxStake era))))
-> (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
-> ExceptT
     ProposalError
     IO
     (Proposal era, Maybe (ScriptWitness WitCtxStake era))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ConwayEraOnwards era
-> (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
-> IO
     (Either
        ProposalError
        (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
forall era.
ConwayEraOnwards era
-> (ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))
-> IO
     (Either
        ProposalError
        (Proposal era, Maybe (ScriptWitness WitCtxStake era)))
readProposal ConwayEraOnwards era
cEraOnwards)
      [(ProposalFile 'In, Maybe (ScriptWitnessFiles WitCtxStake))]
proposals
  AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a. a -> ExceptT CompatibleTransactionError IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyProtocolUpdate era
 -> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era))
-> AnyProtocolUpdate era
-> ExceptT CompatibleTransactionError IO (AnyProtocolUpdate era)
forall a b. (a -> b) -> a -> b
$
    ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era => AnyProtocolUpdate era)
-> AnyProtocolUpdate era
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
cEraOnwards ((ConwayEraOnwardsConstraints era => AnyProtocolUpdate era)
 -> AnyProtocolUpdate era)
-> (ConwayEraOnwardsConstraints era => AnyProtocolUpdate era)
-> AnyProtocolUpdate era
forall a b. (a -> b) -> a -> b
$
      ConwayEraOnwards era
-> TxProposalProcedures BuildTx era -> AnyProtocolUpdate era
forall era.
ConwayEraOnwards era
-> TxProposalProcedures BuildTx era -> AnyProtocolUpdate era
ProposalProcedures ConwayEraOnwards era
cEraOnwards (TxProposalProcedures BuildTx era -> AnyProtocolUpdate era)
-> TxProposalProcedures BuildTx era -> AnyProtocolUpdate era
forall a b. (a -> b) -> a -> b
$
        [(ProposalProcedure (ShelleyLedgerEra era),
  Maybe (ScriptWitness WitCtxStake era))]
-> TxProposalProcedures BuildTx era
forall era build.
(Applicative (BuildTxWith build), IsShelleyBasedEra era) =>
[(ProposalProcedure (ShelleyLedgerEra era),
  Maybe (ScriptWitness WitCtxStake era))]
-> TxProposalProcedures build era
mkTxProposalProcedures [(ProposalProcedure (ShelleyLedgerEra era)
govProp, Maybe (ScriptWitness WitCtxStake era)
mScriptWit) | (Proposal ProposalProcedure (ShelleyLedgerEra era)
govProp, Maybe (ScriptWitness WitCtxStake era)
mScriptWit) <- [(Proposal era, Maybe (ScriptWitness WitCtxStake era))]
props]