{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Cardano.CLI.Shelley.Parsers
  ( -- * CLI command parser
    parseShelleyCommands

    -- * CLI command and flag types
  , module Cardano.CLI.Shelley.Commands

    -- * Field parser and renderers
  , parseTxIn
  , renderTxIn
  ) where

import           Cardano.Prelude hiding (All, Any, option)
import           Prelude (String)

import           Cardano.Api.MetaData
import           Cardano.Api.Protocol (Protocol (..))
import           Cardano.Api.Typed hiding (PoolId)
import           Cardano.Chain.Slotting (EpochSlots (..))
import           Cardano.CLI.Shelley.Commands
import           Cardano.CLI.Shelley.Key (InputFormat (..), VerificationKeyOrFile (..),
                     VerificationKeyOrHashOrFile (..), VerificationKeyTextOrFile (..),
                     deserialiseInput, renderInputDecodeError)
import           Cardano.CLI.Types
import           Control.Monad.Fail (fail)
import           Data.Attoparsec.Combinator ((<?>))
import           Data.Time.Clock (UTCTime)
import           Data.Time.Format (defaultTimeLocale, iso8601DateFormat, parseTimeOrError)
import           Network.Socket (PortNumber)
import           Network.URI (URI, parseURI)
import           Options.Applicative hiding (str)
import           Ouroboros.Consensus.BlockchainTime (SystemStart (..))

import qualified Cardano.Crypto.Hash as Crypto (Blake2b_256, Hash (..), hashFromBytesAsHex)
import qualified Data.Attoparsec.ByteString.Char8 as Atto
import qualified Data.ByteString.Char8 as BSC
import qualified Data.Char as Char
import qualified Data.IP as IP
import qualified Data.List.NonEmpty as NE
import qualified Data.Set as Set
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Options.Applicative as Opt
import qualified Shelley.Spec.Ledger.BaseTypes as Shelley
import qualified Shelley.Spec.Ledger.TxBody as Shelley

--
-- Shelley CLI command parsers
--

parseShelleyCommands :: Parser ShelleyCommand
parseShelleyCommands :: Parser ShelleyCommand
parseShelleyCommands =
  Mod CommandFields ShelleyCommand -> Parser ShelleyCommand
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields ShelleyCommand -> Parser ShelleyCommand)
-> Mod CommandFields ShelleyCommand -> Parser ShelleyCommand
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields ShelleyCommand]
-> Mod CommandFields ShelleyCommand
forall a. Monoid a => [a] -> a
mconcat
      [ String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"address"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (AddressCmd -> ShelleyCommand
AddressCmd (AddressCmd -> ShelleyCommand)
-> Parser AddressCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser AddressCmd
pAddressCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley payment address commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"stake-address"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (StakeAddressCmd -> ShelleyCommand
StakeAddressCmd (StakeAddressCmd -> ShelleyCommand)
-> Parser StakeAddressCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser StakeAddressCmd
pStakeAddress) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley stake address commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (KeyCmd -> ShelleyCommand
KeyCmd (KeyCmd -> ShelleyCommand)
-> Parser KeyCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser KeyCmd
pKeyCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley key utility commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"transaction"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (TransactionCmd -> ShelleyCommand
TransactionCmd (TransactionCmd -> ShelleyCommand)
-> Parser TransactionCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser TransactionCmd
pTransaction) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley transaction commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"node"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (NodeCmd -> ShelleyCommand
NodeCmd (NodeCmd -> ShelleyCommand)
-> Parser NodeCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser NodeCmd
pNodeCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley node operaton commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"stake-pool"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (PoolCmd -> ShelleyCommand
PoolCmd (PoolCmd -> ShelleyCommand)
-> Parser PoolCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser PoolCmd
pPoolCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley stake pool commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"query"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (QueryCmd -> ShelleyCommand
QueryCmd (QueryCmd -> ShelleyCommand)
-> Parser QueryCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser QueryCmd
pQueryCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> (String -> InfoMod ShelleyCommand)
-> String
-> ParserInfo ShelleyCommand
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc (String -> ParserInfo ShelleyCommand)
-> String -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$
             [String] -> String
forall a. Monoid a => [a] -> a
mconcat
               [ String
"Shelley node query commands. Will query the local node whose Unix domain socket "
               , String
"is obtained from the CARDANO_NODE_SOCKET_PATH enviromnent variable."
               ]
            )
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"genesis"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (GenesisCmd -> ShelleyCommand
GenesisCmd (GenesisCmd -> ShelleyCommand)
-> Parser GenesisCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser GenesisCmd
pGenesisCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley genesis block commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"governance"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (GovernanceCmd -> ShelleyCommand
GovernanceCmd (GovernanceCmd -> ShelleyCommand)
-> Parser GovernanceCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser GovernanceCmd
pGovernanceCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$ String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc String
"Shelley governance commands")
      , String
-> ParserInfo ShelleyCommand -> Mod CommandFields ShelleyCommand
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"text-view"
          (Parser ShelleyCommand
-> InfoMod ShelleyCommand -> ParserInfo ShelleyCommand
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (TextViewCmd -> ShelleyCommand
TextViewCmd (TextViewCmd -> ShelleyCommand)
-> Parser TextViewCmd -> Parser ShelleyCommand
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser TextViewCmd
pTextViewCmd) (InfoMod ShelleyCommand -> ParserInfo ShelleyCommand)
-> (String -> InfoMod ShelleyCommand)
-> String
-> ParserInfo ShelleyCommand
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> InfoMod ShelleyCommand
forall a. String -> InfoMod a
Opt.progDesc (String -> ParserInfo ShelleyCommand)
-> String -> ParserInfo ShelleyCommand
forall a b. (a -> b) -> a -> b
$
             [String] -> String
forall a. Monoid a => [a] -> a
mconcat
               [ String
"Commands for dealing with Shelley TextView files. "
               , String
"Transactions, addresses etc are stored on disk as TextView files."
               ]
            )

      ]

pTextViewCmd :: Parser TextViewCmd
pTextViewCmd :: Parser TextViewCmd
pTextViewCmd =
  Mod CommandFields TextViewCmd -> Parser TextViewCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields TextViewCmd -> Parser TextViewCmd)
-> Mod CommandFields TextViewCmd -> Parser TextViewCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields TextViewCmd] -> Mod CommandFields TextViewCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo TextViewCmd -> Mod CommandFields TextViewCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"decode-cbor"
          (Parser TextViewCmd -> InfoMod TextViewCmd -> ParserInfo TextViewCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info (String -> Maybe OutputFile -> TextViewCmd
TextViewInfo (String -> Maybe OutputFile -> TextViewCmd)
-> Parser String -> Parser (Maybe OutputFile -> TextViewCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String
pCBORInFile Parser (Maybe OutputFile -> TextViewCmd)
-> Parser (Maybe OutputFile) -> Parser TextViewCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile)
            (InfoMod TextViewCmd -> ParserInfo TextViewCmd)
-> InfoMod TextViewCmd -> ParserInfo TextViewCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TextViewCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print a TextView file as decoded CBOR."
            )
      ]

pCBORInFile :: Parser FilePath
pCBORInFile :: Parser String
pCBORInFile =
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
    (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"in-file"
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"CBOR input file."
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
    )
  Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
    (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"file"
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
    )

pAddressCmd :: Parser AddressCmd
pAddressCmd :: Parser AddressCmd
pAddressCmd =
  Mod CommandFields AddressCmd -> Parser AddressCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields AddressCmd -> Parser AddressCmd)
-> Mod CommandFields AddressCmd -> Parser AddressCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields AddressCmd] -> Mod CommandFields AddressCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo AddressCmd -> Mod CommandFields AddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen"
          (Parser AddressCmd -> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser AddressCmd
pAddressKeyGen (InfoMod AddressCmd -> ParserInfo AddressCmd)
-> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod AddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create an address key pair.")
      , String -> ParserInfo AddressCmd -> Mod CommandFields AddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-hash"
          (Parser AddressCmd -> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser AddressCmd
pAddressKeyHash (InfoMod AddressCmd -> ParserInfo AddressCmd)
-> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod AddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print the hash of an address key.")
      , String -> ParserInfo AddressCmd -> Mod CommandFields AddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"build"
          (Parser AddressCmd -> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser AddressCmd
pAddressBuild (InfoMod AddressCmd -> ParserInfo AddressCmd)
-> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod AddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Build a Shelley payment address, with optional delegation to a stake address.")
      , String -> ParserInfo AddressCmd -> Mod CommandFields AddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"build-script"
          (Parser AddressCmd -> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser AddressCmd
pAddressBuildScript (InfoMod AddressCmd -> ParserInfo AddressCmd)
-> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod AddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Build a Shelley script address.")
      , String -> ParserInfo AddressCmd -> Mod CommandFields AddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"info"
          (Parser AddressCmd -> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser AddressCmd
pAddressInfo (InfoMod AddressCmd -> ParserInfo AddressCmd)
-> InfoMod AddressCmd -> ParserInfo AddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod AddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print information about an address.")
      ]
  where
    pAddressKeyGen :: Parser AddressCmd
    pAddressKeyGen :: Parser AddressCmd
pAddressKeyGen = AddressKeyType
-> VerificationKeyFile -> SigningKeyFile -> AddressCmd
AddressKeyGen (AddressKeyType
 -> VerificationKeyFile -> SigningKeyFile -> AddressCmd)
-> Parser AddressKeyType
-> Parser (VerificationKeyFile -> SigningKeyFile -> AddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser AddressKeyType
pAddressKeyType
                                   Parser (VerificationKeyFile -> SigningKeyFile -> AddressCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> AddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output
                                   Parser (SigningKeyFile -> AddressCmd)
-> Parser SigningKeyFile -> Parser AddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pAddressKeyHash :: Parser AddressCmd
    pAddressKeyHash :: Parser AddressCmd
pAddressKeyHash =
      VerificationKeyTextOrFile -> Maybe OutputFile -> AddressCmd
AddressKeyHash
        (VerificationKeyTextOrFile -> Maybe OutputFile -> AddressCmd)
-> Parser VerificationKeyTextOrFile
-> Parser (Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyTextOrFile
pPaymentVerificationKeyTextOrFile
        Parser (Maybe OutputFile -> AddressCmd)
-> Parser (Maybe OutputFile) -> Parser AddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pAddressBuild :: Parser AddressCmd
    pAddressBuild :: Parser AddressCmd
pAddressBuild =
      VerificationKeyTextOrFile
-> Maybe (VerificationKeyOrFile StakeKey)
-> NetworkId
-> Maybe OutputFile
-> AddressCmd
AddressBuild
        (VerificationKeyTextOrFile
 -> Maybe (VerificationKeyOrFile StakeKey)
 -> NetworkId
 -> Maybe OutputFile
 -> AddressCmd)
-> Parser VerificationKeyTextOrFile
-> Parser
     (Maybe (VerificationKeyOrFile StakeKey)
      -> NetworkId -> Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyTextOrFile
pPaymentVerificationKeyTextOrFile
        Parser
  (Maybe (VerificationKeyOrFile StakeKey)
   -> NetworkId -> Maybe OutputFile -> AddressCmd)
-> Parser (Maybe (VerificationKeyOrFile StakeKey))
-> Parser (NetworkId -> Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile StakeKey)
-> Parser (Maybe (VerificationKeyOrFile StakeKey))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
Opt.optional Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile
        Parser (NetworkId -> Maybe OutputFile -> AddressCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
        Parser (Maybe OutputFile -> AddressCmd)
-> Parser (Maybe OutputFile) -> Parser AddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pAddressBuildScript :: Parser AddressCmd
    pAddressBuildScript :: Parser AddressCmd
pAddressBuildScript = ScriptFile -> NetworkId -> Maybe OutputFile -> AddressCmd
AddressBuildMultiSig
                            (ScriptFile -> NetworkId -> Maybe OutputFile -> AddressCmd)
-> Parser ScriptFile
-> Parser (NetworkId -> Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ScriptFile
pScript
                            Parser (NetworkId -> Maybe OutputFile -> AddressCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
                            Parser (Maybe OutputFile -> AddressCmd)
-> Parser (Maybe OutputFile) -> Parser AddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pAddressInfo :: Parser AddressCmd
    pAddressInfo :: Parser AddressCmd
pAddressInfo = Text -> Maybe OutputFile -> AddressCmd
AddressInfo (Text -> Maybe OutputFile -> AddressCmd)
-> Parser Text -> Parser (Maybe OutputFile -> AddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text
pAddress Parser (Maybe OutputFile -> AddressCmd)
-> Parser (Maybe OutputFile) -> Parser AddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

pPaymentVerificationKeyTextOrFile :: Parser VerificationKeyTextOrFile
pPaymentVerificationKeyTextOrFile :: Parser VerificationKeyTextOrFile
pPaymentVerificationKeyTextOrFile =
  Text -> VerificationKeyTextOrFile
VktofVerificationKeyText (Text -> VerificationKeyTextOrFile)
-> Parser Text -> Parser VerificationKeyTextOrFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text
pPaymentVerificationKeyText
    Parser VerificationKeyTextOrFile
-> Parser VerificationKeyTextOrFile
-> Parser VerificationKeyTextOrFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyTextOrFile
VktofVerificationKeyFile (VerificationKeyFile -> VerificationKeyTextOrFile)
-> Parser VerificationKeyFile -> Parser VerificationKeyTextOrFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pPaymentVerificationKeyFile

pPaymentVerificationKeyText :: Parser Text
pPaymentVerificationKeyText :: Parser Text
pPaymentVerificationKeyText =
  String -> Text
Text.pack (String -> Text) -> Parser String -> Parser Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"payment-verification-key"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Payment verification key (Bech32-encoded)"
      )

pPaymentVerificationKeyFile :: Parser VerificationKeyFile
pPaymentVerificationKeyFile :: Parser VerificationKeyFile
pPaymentVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"payment-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the payment verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )

pScript :: Parser ScriptFile
pScript :: Parser ScriptFile
pScript = String -> ScriptFile
ScriptFile (String -> ScriptFile) -> Parser String -> Parser ScriptFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
  (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"script-file"
  Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
  Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the script."
  Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
  )

pStakeAddress :: Parser StakeAddressCmd
pStakeAddress :: Parser StakeAddressCmd
pStakeAddress =
  Mod CommandFields StakeAddressCmd -> Parser StakeAddressCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields StakeAddressCmd -> Parser StakeAddressCmd)
-> Mod CommandFields StakeAddressCmd -> Parser StakeAddressCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields StakeAddressCmd]
-> Mod CommandFields StakeAddressCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressKeyGen (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake address key pair")
      , String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"build"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressBuild (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Build a stake address")
      , String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-hash"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressKeyHash (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print the hash of a stake address key.")
      , String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"registration-certificate"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressRegistrationCert (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake address registration certificate")
      , String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"deregistration-certificate"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressDeregistrationCert (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake address deregistration certificate")
      , String
-> ParserInfo StakeAddressCmd -> Mod CommandFields StakeAddressCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"delegation-certificate"
          (Parser StakeAddressCmd
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser StakeAddressCmd
pStakeAddressDelegationCert (InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd)
-> InfoMod StakeAddressCmd -> ParserInfo StakeAddressCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod StakeAddressCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake address delegation certificate")
      ]
  where
    pStakeAddressKeyGen :: Parser StakeAddressCmd
    pStakeAddressKeyGen :: Parser StakeAddressCmd
pStakeAddressKeyGen = VerificationKeyFile -> SigningKeyFile -> StakeAddressCmd
StakeAddressKeyGen
                            (VerificationKeyFile -> SigningKeyFile -> StakeAddressCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output
                            Parser (SigningKeyFile -> StakeAddressCmd)
-> Parser SigningKeyFile -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pStakeAddressKeyHash :: Parser StakeAddressCmd
    pStakeAddressKeyHash :: Parser StakeAddressCmd
pStakeAddressKeyHash = VerificationKeyOrFile StakeKey
-> Maybe OutputFile -> StakeAddressCmd
StakeAddressKeyHash (VerificationKeyOrFile StakeKey
 -> Maybe OutputFile -> StakeAddressCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (Maybe OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile Parser (Maybe OutputFile -> StakeAddressCmd)
-> Parser (Maybe OutputFile) -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pStakeAddressBuild :: Parser StakeAddressCmd
    pStakeAddressBuild :: Parser StakeAddressCmd
pStakeAddressBuild = VerificationKeyOrFile StakeKey
-> NetworkId -> Maybe OutputFile -> StakeAddressCmd
StakeAddressBuild (VerificationKeyOrFile StakeKey
 -> NetworkId -> Maybe OutputFile -> StakeAddressCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (NetworkId -> Maybe OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile
                                           Parser (NetworkId -> Maybe OutputFile -> StakeAddressCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
                                           Parser (Maybe OutputFile -> StakeAddressCmd)
-> Parser (Maybe OutputFile) -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pStakeAddressRegistrationCert :: Parser StakeAddressCmd
    pStakeAddressRegistrationCert :: Parser StakeAddressCmd
pStakeAddressRegistrationCert = VerificationKeyOrFile StakeKey -> OutputFile -> StakeAddressCmd
StakeKeyRegistrationCert
                                      (VerificationKeyOrFile StakeKey -> OutputFile -> StakeAddressCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile
                                      Parser (OutputFile -> StakeAddressCmd)
-> Parser OutputFile -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pStakeAddressDeregistrationCert :: Parser StakeAddressCmd
    pStakeAddressDeregistrationCert :: Parser StakeAddressCmd
pStakeAddressDeregistrationCert = VerificationKeyOrFile StakeKey -> OutputFile -> StakeAddressCmd
StakeKeyDeRegistrationCert
                                        (VerificationKeyOrFile StakeKey -> OutputFile -> StakeAddressCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile
                                        Parser (OutputFile -> StakeAddressCmd)
-> Parser OutputFile -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pStakeAddressDelegationCert :: Parser StakeAddressCmd
    pStakeAddressDelegationCert :: Parser StakeAddressCmd
pStakeAddressDelegationCert = VerificationKeyOrFile StakeKey
-> VerificationKeyOrHashOrFile StakePoolKey
-> OutputFile
-> StakeAddressCmd
StakeKeyDelegationCert
                                    (VerificationKeyOrFile StakeKey
 -> VerificationKeyOrHashOrFile StakePoolKey
 -> OutputFile
 -> StakeAddressCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser
     (VerificationKeyOrHashOrFile StakePoolKey
      -> OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile
                                    Parser
  (VerificationKeyOrHashOrFile StakePoolKey
   -> OutputFile -> StakeAddressCmd)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (OutputFile -> StakeAddressCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrHashOrFile StakePoolKey)
pStakePoolVerificationKeyOrHashOrFile
                                    Parser (OutputFile -> StakeAddressCmd)
-> Parser OutputFile -> Parser StakeAddressCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

pKeyCmd :: Parser KeyCmd
pKeyCmd :: Parser KeyCmd
pKeyCmd =
  Mod CommandFields KeyCmd -> Parser KeyCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields KeyCmd -> Parser KeyCmd)
-> Mod CommandFields KeyCmd -> Parser KeyCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields KeyCmd] -> Mod CommandFields KeyCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"verification-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyGetVerificationKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Get a verification key from a signing key. This "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" supports all key types."

      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"non-extended-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyNonExtendedKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Get a non-extended verification key from an "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"extended verification key. This supports all "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"extended key types."

      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-byron-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertByronKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert a Byron payment, genesis or genesis "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"delegate key (signing or verification) to a "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"corresponding Shelley-format key."

      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-byron-genesis-vkey" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertByronGenesisVKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert a Base64-encoded Byron genesis "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"verification key to a Shelley genesis "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"verification key"

      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-itn-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertITNKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert an Incentivized Testnet (ITN) non-extended "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(Ed25519) signing or verification key to a "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"corresponding Shelley stake key"
      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-itn-extended-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertITNExtendedKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert an Incentivized Testnet (ITN) extended "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(Ed25519Extended) signing key to a corresponding "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Shelley stake signing key"
      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-itn-bip32-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertITNBip32Key (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert an Incentivized Testnet (ITN) BIP32 "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"(Ed25519Bip32) signing key to a corresponding "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"Shelley stake signing key"

      , String -> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"convert-cardano-address-key" (ParserInfo KeyCmd -> Mod CommandFields KeyCmd)
-> ParserInfo KeyCmd -> Mod CommandFields KeyCmd
forall a b. (a -> b) -> a -> b
$
          Parser KeyCmd -> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser KeyCmd
pKeyConvertCardanoAddressSigningKey (InfoMod KeyCmd -> ParserInfo KeyCmd)
-> InfoMod KeyCmd -> ParserInfo KeyCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod KeyCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod KeyCmd) -> String -> InfoMod KeyCmd
forall a b. (a -> b) -> a -> b
$ String
"Convert a cardano-address extended signing key "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"to a corresponding Shelley-format key."
      ]
  where
    pKeyGetVerificationKey :: Parser KeyCmd
    pKeyGetVerificationKey :: Parser KeyCmd
pKeyGetVerificationKey =
      SigningKeyFile -> VerificationKeyFile -> KeyCmd
KeyGetVerificationKey
        (SigningKeyFile -> VerificationKeyFile -> KeyCmd)
-> Parser SigningKeyFile -> Parser (VerificationKeyFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser SigningKeyFile
pSigningKeyFile      FileDirection
Input
        Parser (VerificationKeyFile -> KeyCmd)
-> Parser VerificationKeyFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output

    pKeyNonExtendedKey :: Parser KeyCmd
    pKeyNonExtendedKey :: Parser KeyCmd
pKeyNonExtendedKey =
      VerificationKeyFile -> VerificationKeyFile -> KeyCmd
KeyNonExtendedKey
        (VerificationKeyFile -> VerificationKeyFile -> KeyCmd)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pExtendedVerificationKeyFile FileDirection
Input
        Parser (VerificationKeyFile -> KeyCmd)
-> Parser VerificationKeyFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output

    pKeyConvertByronKey :: Parser KeyCmd
    pKeyConvertByronKey :: Parser KeyCmd
pKeyConvertByronKey =
      Maybe Text -> ByronKeyType -> SomeKeyFile -> OutputFile -> KeyCmd
KeyConvertByronKey
        (Maybe Text -> ByronKeyType -> SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser (Maybe Text)
-> Parser (ByronKeyType -> SomeKeyFile -> OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Text -> Parser (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Text
pPassword
        Parser (ByronKeyType -> SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser ByronKeyType
-> Parser (SomeKeyFile -> OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser ByronKeyType
pByronKeyType
        Parser (SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser SomeKeyFile -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SomeKeyFile
pByronKeyFile
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pPassword :: Parser Text
    pPassword :: Parser Text
pPassword = Mod OptionFields Text -> Parser Text
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
                  (  String -> Mod OptionFields Text
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"password"
                  Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Text
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"TEXT"
                  Mod OptionFields Text
-> Mod OptionFields Text -> Mod OptionFields Text
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Text
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Password for signing key (if applicable)."
                  )

    pByronKeyType :: Parser ByronKeyType
    pByronKeyType :: Parser ByronKeyType
pByronKeyType =
          ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronPaymentKey ByronKeyFormat
NonLegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-payment-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era payment key."
            )
      Parser ByronKeyType -> Parser ByronKeyType -> Parser ByronKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronPaymentKey ByronKeyFormat
LegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"legacy-byron-payment-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era payment key, in legacy SL format."
            )
      Parser ByronKeyType -> Parser ByronKeyType -> Parser ByronKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronGenesisKey ByronKeyFormat
NonLegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-genesis-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era genesis key."
            )
      Parser ByronKeyType -> Parser ByronKeyType -> Parser ByronKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronGenesisKey ByronKeyFormat
LegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"legacy-byron-genesis-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era genesis key, in legacy SL format."
            )
      Parser ByronKeyType -> Parser ByronKeyType -> Parser ByronKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronDelegateKey ByronKeyFormat
NonLegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-genesis-delegate-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era genesis delegate key."
            )
      Parser ByronKeyType -> Parser ByronKeyType -> Parser ByronKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ByronKeyType -> Mod FlagFields ByronKeyType -> Parser ByronKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' (ByronKeyFormat -> ByronKeyType
ByronDelegateKey ByronKeyFormat
LegacyByronKeyFormat)
            (  String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"legacy-byron-genesis-delegate-key-type"
            Mod FlagFields ByronKeyType
-> Mod FlagFields ByronKeyType -> Mod FlagFields ByronKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ByronKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era genesis delegate key, in legacy SL format."
            )

    pByronKeyFile :: Parser SomeKeyFile
    pByronKeyFile :: Parser SomeKeyFile
pByronKeyFile =
          (SigningKeyFile -> SomeKeyFile
ASigningKeyFile      (SigningKeyFile -> SomeKeyFile)
-> Parser SigningKeyFile -> Parser SomeKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SigningKeyFile
pByronSigningKeyFile)
      Parser SomeKeyFile -> Parser SomeKeyFile -> Parser SomeKeyFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (VerificationKeyFile -> SomeKeyFile
AVerificationKeyFile (VerificationKeyFile -> SomeKeyFile)
-> Parser VerificationKeyFile -> Parser SomeKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pByronVerificationKeyFile)

    pByronSigningKeyFile :: Parser SigningKeyFile
    pByronSigningKeyFile :: Parser SigningKeyFile
pByronSigningKeyFile =
      String -> SigningKeyFile
SigningKeyFile (String -> SigningKeyFile)
-> Parser String -> Parser SigningKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-signing-key-file"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Input filepath of the Byron-format signing key."
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
          )

    pByronVerificationKeyFile :: Parser VerificationKeyFile
    pByronVerificationKeyFile :: Parser VerificationKeyFile
pByronVerificationKeyFile =
      String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-verification-key-file"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Input filepath of the Byron-format verification key."
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
          )

    pKeyConvertByronGenesisVKey :: Parser KeyCmd
    pKeyConvertByronGenesisVKey :: Parser KeyCmd
pKeyConvertByronGenesisVKey =
      VerificationKeyBase64 -> OutputFile -> KeyCmd
KeyConvertByronGenesisVKey
        (VerificationKeyBase64 -> OutputFile -> KeyCmd)
-> Parser VerificationKeyBase64 -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyBase64
pByronGenesisVKeyBase64
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pByronGenesisVKeyBase64 :: Parser VerificationKeyBase64
    pByronGenesisVKeyBase64 :: Parser VerificationKeyBase64
pByronGenesisVKeyBase64 =
      String -> VerificationKeyBase64
VerificationKeyBase64 (String -> VerificationKeyBase64)
-> Parser String -> Parser VerificationKeyBase64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-genesis-verification-key"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"BASE64"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Base64 string for the Byron genesis verification key."
          )

    pKeyConvertITNKey :: Parser KeyCmd
    pKeyConvertITNKey :: Parser KeyCmd
pKeyConvertITNKey =
      SomeKeyFile -> OutputFile -> KeyCmd
KeyConvertITNStakeKey
        (SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser SomeKeyFile -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SomeKeyFile
pITNKeyFIle
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pKeyConvertITNExtendedKey :: Parser KeyCmd
    pKeyConvertITNExtendedKey :: Parser KeyCmd
pKeyConvertITNExtendedKey =
      SomeKeyFile -> OutputFile -> KeyCmd
KeyConvertITNExtendedToStakeKey
        (SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser SomeKeyFile -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SomeKeyFile
pITNSigningKeyFile
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pKeyConvertITNBip32Key :: Parser KeyCmd
    pKeyConvertITNBip32Key :: Parser KeyCmd
pKeyConvertITNBip32Key =
      SomeKeyFile -> OutputFile -> KeyCmd
KeyConvertITNBip32ToStakeKey
        (SomeKeyFile -> OutputFile -> KeyCmd)
-> Parser SomeKeyFile -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser SomeKeyFile
pITNSigningKeyFile
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pITNKeyFIle :: Parser SomeKeyFile
    pITNKeyFIle :: Parser SomeKeyFile
pITNKeyFIle = Parser SomeKeyFile
pITNSigningKeyFile
              Parser SomeKeyFile -> Parser SomeKeyFile -> Parser SomeKeyFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser SomeKeyFile
pITNVerificationKeyFile

    pITNSigningKeyFile :: Parser SomeKeyFile
    pITNSigningKeyFile :: Parser SomeKeyFile
pITNSigningKeyFile =
      SigningKeyFile -> SomeKeyFile
ASigningKeyFile (SigningKeyFile -> SomeKeyFile)
-> (String -> SigningKeyFile) -> String -> SomeKeyFile
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> SigningKeyFile
SigningKeyFile (String -> SomeKeyFile) -> Parser String -> Parser SomeKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"itn-signing-key-file"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the ITN signing key."
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
          )

    pITNVerificationKeyFile :: Parser SomeKeyFile
    pITNVerificationKeyFile :: Parser SomeKeyFile
pITNVerificationKeyFile =
      VerificationKeyFile -> SomeKeyFile
AVerificationKeyFile (VerificationKeyFile -> SomeKeyFile)
-> (String -> VerificationKeyFile) -> String -> SomeKeyFile
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> VerificationKeyFile
VerificationKeyFile (String -> SomeKeyFile) -> Parser String -> Parser SomeKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"itn-verification-key-file"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the ITN verification key."
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
          )

    pKeyConvertCardanoAddressSigningKey :: Parser KeyCmd
    pKeyConvertCardanoAddressSigningKey :: Parser KeyCmd
pKeyConvertCardanoAddressSigningKey =
      CardanoAddressKeyType -> SigningKeyFile -> OutputFile -> KeyCmd
KeyConvertCardanoAddressSigningKey
        (CardanoAddressKeyType -> SigningKeyFile -> OutputFile -> KeyCmd)
-> Parser CardanoAddressKeyType
-> Parser (SigningKeyFile -> OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser CardanoAddressKeyType
pCardanoAddressKeyType
        Parser (SigningKeyFile -> OutputFile -> KeyCmd)
-> Parser SigningKeyFile -> Parser (OutputFile -> KeyCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Input
        Parser (OutputFile -> KeyCmd) -> Parser OutputFile -> Parser KeyCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pCardanoAddressKeyType :: Parser CardanoAddressKeyType
    pCardanoAddressKeyType :: Parser CardanoAddressKeyType
pCardanoAddressKeyType =
          CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Parser CardanoAddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' CardanoAddressKeyType
CardanoAddressShelleyPaymentKey
            (  String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"shelley-payment-key"
            Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Shelley-era extended payment key."
            )
      Parser CardanoAddressKeyType
-> Parser CardanoAddressKeyType -> Parser CardanoAddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Parser CardanoAddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' CardanoAddressKeyType
CardanoAddressShelleyStakeKey
            (  String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"shelley-stake-key"
            Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Shelley-era extended stake key."
            )
      Parser CardanoAddressKeyType
-> Parser CardanoAddressKeyType -> Parser CardanoAddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Parser CardanoAddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' CardanoAddressKeyType
CardanoAddressIcarusPaymentKey
            (  String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"icarus-payment-key"
            Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era extended payment key formatted in the Icarus style."
            )
      Parser CardanoAddressKeyType
-> Parser CardanoAddressKeyType -> Parser CardanoAddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Parser CardanoAddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' CardanoAddressKeyType
CardanoAddressByronPaymentKey
            (  String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-payment-key"
            Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
-> Mod FlagFields CardanoAddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields CardanoAddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era extended payment key formatted in the deprecated Byron style."
            )

pTransaction :: Parser TransactionCmd
pTransaction :: Parser TransactionCmd
pTransaction =
  [Parser TransactionCmd] -> Parser TransactionCmd
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
    [ String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"build-raw"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionBuild (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Build a transaction (low-level, inconvenient)")
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"sign"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionSign (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Sign a transaction")
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"witness"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionCreateWitness (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a transaction witness")
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"assemble"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionAssembleTxBodyWit
          (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Assemble a tx body and witness(es) to form a transaction")
    , Parser TransactionCmd
pSignWitnessBackwardCompatible
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"submit"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionSubmit (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> (String -> InfoMod TransactionCmd)
-> String
-> ParserInfo TransactionCmd
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc (String -> ParserInfo TransactionCmd)
-> String -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$
           [String] -> String
forall a. Monoid a => [a] -> a
mconcat
             [ String
"Submit a transaction to the local node whose Unix domain socket "
             , String
"is obtained from the CARDANO_NODE_SOCKET_PATH enviromnent variable."
             ]
          )
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"calculate-min-fee"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionCalculateMinFee (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Calculate the minimum fee for a transaction")
    , String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
"txid"
        (Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionId (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print a transaction identifier")
    ]
 where
  subParser :: String -> ParserInfo TransactionCmd -> Parser TransactionCmd
  subParser :: String -> ParserInfo TransactionCmd -> Parser TransactionCmd
subParser String
name ParserInfo TransactionCmd
pInfo = Mod CommandFields TransactionCmd -> Parser TransactionCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields TransactionCmd -> Parser TransactionCmd)
-> Mod CommandFields TransactionCmd -> Parser TransactionCmd
forall a b. (a -> b) -> a -> b
$ String
-> ParserInfo TransactionCmd -> Mod CommandFields TransactionCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
name ParserInfo TransactionCmd
pInfo

  assembleInfo :: ParserInfo TransactionCmd
  assembleInfo :: ParserInfo TransactionCmd
assembleInfo =
    Parser TransactionCmd
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser TransactionCmd
pTransactionAssembleTxBodyWit
      (InfoMod TransactionCmd -> ParserInfo TransactionCmd)
-> InfoMod TransactionCmd -> ParserInfo TransactionCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod TransactionCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Assemble a tx body and witness(es) to form a transaction"

  pSignWitnessBackwardCompatible :: Parser TransactionCmd
  pSignWitnessBackwardCompatible :: Parser TransactionCmd
pSignWitnessBackwardCompatible =
    Mod CommandFields TransactionCmd -> Parser TransactionCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser
      (Mod CommandFields TransactionCmd -> Parser TransactionCmd)
-> Mod CommandFields TransactionCmd -> Parser TransactionCmd
forall a b. (a -> b) -> a -> b
$ String
-> ParserInfo TransactionCmd -> Mod CommandFields TransactionCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"sign-witness" ParserInfo TransactionCmd
assembleInfo Mod CommandFields TransactionCmd
-> Mod CommandFields TransactionCmd
-> Mod CommandFields TransactionCmd
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields TransactionCmd
forall (f :: * -> *) a. Mod f a
Opt.internal

  pTransactionBuild :: Parser TransactionCmd
  pTransactionBuild :: Parser TransactionCmd
pTransactionBuild = [TxIn]
-> [TxOut Shelley]
-> SlotNo
-> Lovelace
-> [CertificateFile]
-> [(StakeAddress, Lovelace)]
-> TxMetadataJsonSchema
-> [MetaDataFile]
-> Maybe UpdateProposalFile
-> TxBodyFile
-> TransactionCmd
TxBuildRaw ([TxIn]
 -> [TxOut Shelley]
 -> SlotNo
 -> Lovelace
 -> [CertificateFile]
 -> [(StakeAddress, Lovelace)]
 -> TxMetadataJsonSchema
 -> [MetaDataFile]
 -> Maybe UpdateProposalFile
 -> TxBodyFile
 -> TransactionCmd)
-> Parser [TxIn]
-> Parser
     ([TxOut Shelley]
      -> SlotNo
      -> Lovelace
      -> [CertificateFile]
      -> [(StakeAddress, Lovelace)]
      -> TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser TxIn -> Parser [TxIn]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser TxIn
pTxIn
                                 Parser
  ([TxOut Shelley]
   -> SlotNo
   -> Lovelace
   -> [CertificateFile]
   -> [(StakeAddress, Lovelace)]
   -> TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser [TxOut Shelley]
-> Parser
     (SlotNo
      -> Lovelace
      -> [CertificateFile]
      -> [(StakeAddress, Lovelace)]
      -> TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (TxOut Shelley) -> Parser [TxOut Shelley]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser (TxOut Shelley)
pTxOut
                                 Parser
  (SlotNo
   -> Lovelace
   -> [CertificateFile]
   -> [(StakeAddress, Lovelace)]
   -> TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser SlotNo
-> Parser
     (Lovelace
      -> [CertificateFile]
      -> [(StakeAddress, Lovelace)]
      -> TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SlotNo
pTxTTL
                                 Parser
  (Lovelace
   -> [CertificateFile]
   -> [(StakeAddress, Lovelace)]
   -> TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser Lovelace
-> Parser
     ([CertificateFile]
      -> [(StakeAddress, Lovelace)]
      -> TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace
pTxFee
                                 Parser
  ([CertificateFile]
   -> [(StakeAddress, Lovelace)]
   -> TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser [CertificateFile]
-> Parser
     ([(StakeAddress, Lovelace)]
      -> TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser CertificateFile -> Parser [CertificateFile]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser CertificateFile
pCertificateFile
                                 Parser
  ([(StakeAddress, Lovelace)]
   -> TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser [(StakeAddress, Lovelace)]
-> Parser
     (TxMetadataJsonSchema
      -> [MetaDataFile]
      -> Maybe UpdateProposalFile
      -> TxBodyFile
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (StakeAddress, Lovelace)
-> Parser [(StakeAddress, Lovelace)]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser (StakeAddress, Lovelace)
pWithdrawal
                                 Parser
  (TxMetadataJsonSchema
   -> [MetaDataFile]
   -> Maybe UpdateProposalFile
   -> TxBodyFile
   -> TransactionCmd)
-> Parser TxMetadataJsonSchema
-> Parser
     ([MetaDataFile]
      -> Maybe UpdateProposalFile -> TxBodyFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxMetadataJsonSchema
pTxMetadataJsonSchema
                                 Parser
  ([MetaDataFile]
   -> Maybe UpdateProposalFile -> TxBodyFile -> TransactionCmd)
-> Parser [MetaDataFile]
-> Parser
     (Maybe UpdateProposalFile -> TxBodyFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser MetaDataFile -> Parser [MetaDataFile]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser MetaDataFile
pMetaDataFile
                                 Parser (Maybe UpdateProposalFile -> TxBodyFile -> TransactionCmd)
-> Parser (Maybe UpdateProposalFile)
-> Parser (TxBodyFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser UpdateProposalFile -> Parser (Maybe UpdateProposalFile)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser UpdateProposalFile
pUpdateProposalFile
                                 Parser (TxBodyFile -> TransactionCmd)
-> Parser TxBodyFile -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Output

  pTransactionSign  :: Parser TransactionCmd
  pTransactionSign :: Parser TransactionCmd
pTransactionSign = TxBodyFile
-> [WitnessSigningData]
-> Maybe NetworkId
-> TxFile
-> TransactionCmd
TxSign (TxBodyFile
 -> [WitnessSigningData]
 -> Maybe NetworkId
 -> TxFile
 -> TransactionCmd)
-> Parser TxBodyFile
-> Parser
     ([WitnessSigningData]
      -> Maybe NetworkId -> TxFile -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Input
                            Parser
  ([WitnessSigningData]
   -> Maybe NetworkId -> TxFile -> TransactionCmd)
-> Parser [WitnessSigningData]
-> Parser (Maybe NetworkId -> TxFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser [WitnessSigningData]
pSomeWitnessSigningData
                            Parser (Maybe NetworkId -> TxFile -> TransactionCmd)
-> Parser (Maybe NetworkId) -> Parser (TxFile -> TransactionCmd)
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 Parser NetworkId
pNetworkId
                            Parser (TxFile -> TransactionCmd)
-> Parser TxFile -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser TxFile
pTxFile FileDirection
Output

  pTransactionCreateWitness :: Parser TransactionCmd
  pTransactionCreateWitness :: Parser TransactionCmd
pTransactionCreateWitness = TxBodyFile
-> WitnessSigningData
-> Maybe NetworkId
-> OutputFile
-> TransactionCmd
TxCreateWitness
                                (TxBodyFile
 -> WitnessSigningData
 -> Maybe NetworkId
 -> OutputFile
 -> TransactionCmd)
-> Parser TxBodyFile
-> Parser
     (WitnessSigningData
      -> Maybe NetworkId -> OutputFile -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Input
                                Parser
  (WitnessSigningData
   -> Maybe NetworkId -> OutputFile -> TransactionCmd)
-> Parser WitnessSigningData
-> Parser (Maybe NetworkId -> OutputFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser WitnessSigningData
pWitnessSigningData
                                Parser (Maybe NetworkId -> OutputFile -> TransactionCmd)
-> Parser (Maybe NetworkId)
-> Parser (OutputFile -> TransactionCmd)
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 Parser NetworkId
pNetworkId
                                Parser (OutputFile -> TransactionCmd)
-> Parser OutputFile -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

  pTransactionAssembleTxBodyWit :: Parser TransactionCmd
  pTransactionAssembleTxBodyWit :: Parser TransactionCmd
pTransactionAssembleTxBodyWit = TxBodyFile -> [WitnessFile] -> OutputFile -> TransactionCmd
TxAssembleTxBodyWitness
                                    (TxBodyFile -> [WitnessFile] -> OutputFile -> TransactionCmd)
-> Parser TxBodyFile
-> Parser ([WitnessFile] -> OutputFile -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Input
                                    Parser ([WitnessFile] -> OutputFile -> TransactionCmd)
-> Parser [WitnessFile] -> Parser (OutputFile -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser WitnessFile -> Parser [WitnessFile]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser WitnessFile
pWitnessFile
                                    Parser (OutputFile -> TransactionCmd)
-> Parser OutputFile -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

  pTransactionSubmit  :: Parser TransactionCmd
  pTransactionSubmit :: Parser TransactionCmd
pTransactionSubmit = Protocol -> NetworkId -> String -> TransactionCmd
TxSubmit (Protocol -> NetworkId -> String -> TransactionCmd)
-> Parser Protocol
-> Parser (NetworkId -> String -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol
                                Parser (NetworkId -> String -> TransactionCmd)
-> Parser NetworkId -> Parser (String -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
                                Parser (String -> TransactionCmd)
-> Parser String -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser String
pTxSubmitFile

  pTransactionCalculateMinFee :: Parser TransactionCmd
  pTransactionCalculateMinFee :: Parser TransactionCmd
pTransactionCalculateMinFee =
    TxBodyFile
-> Maybe NetworkId
-> ProtocolParamsFile
-> TxInCount
-> TxOutCount
-> TxShelleyWitnessCount
-> TxByronWitnessCount
-> TransactionCmd
TxCalculateMinFee
      (TxBodyFile
 -> Maybe NetworkId
 -> ProtocolParamsFile
 -> TxInCount
 -> TxOutCount
 -> TxShelleyWitnessCount
 -> TxByronWitnessCount
 -> TransactionCmd)
-> Parser TxBodyFile
-> Parser
     (Maybe NetworkId
      -> ProtocolParamsFile
      -> TxInCount
      -> TxOutCount
      -> TxShelleyWitnessCount
      -> TxByronWitnessCount
      -> TransactionCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Input
      Parser
  (Maybe NetworkId
   -> ProtocolParamsFile
   -> TxInCount
   -> TxOutCount
   -> TxShelleyWitnessCount
   -> TxByronWitnessCount
   -> TransactionCmd)
-> Parser (Maybe NetworkId)
-> Parser
     (ProtocolParamsFile
      -> TxInCount
      -> TxOutCount
      -> TxShelleyWitnessCount
      -> TxByronWitnessCount
      -> TransactionCmd)
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 Parser NetworkId
pNetworkId
      Parser
  (ProtocolParamsFile
   -> TxInCount
   -> TxOutCount
   -> TxShelleyWitnessCount
   -> TxByronWitnessCount
   -> TransactionCmd)
-> Parser ProtocolParamsFile
-> Parser
     (TxInCount
      -> TxOutCount
      -> TxShelleyWitnessCount
      -> TxByronWitnessCount
      -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser ProtocolParamsFile
pProtocolParamsFile
      Parser
  (TxInCount
   -> TxOutCount
   -> TxShelleyWitnessCount
   -> TxByronWitnessCount
   -> TransactionCmd)
-> Parser TxInCount
-> Parser
     (TxOutCount
      -> TxShelleyWitnessCount -> TxByronWitnessCount -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxInCount
pTxInCount
      Parser
  (TxOutCount
   -> TxShelleyWitnessCount -> TxByronWitnessCount -> TransactionCmd)
-> Parser TxOutCount
-> Parser
     (TxShelleyWitnessCount -> TxByronWitnessCount -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxOutCount
pTxOutCount
      Parser
  (TxShelleyWitnessCount -> TxByronWitnessCount -> TransactionCmd)
-> Parser TxShelleyWitnessCount
-> Parser (TxByronWitnessCount -> TransactionCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxShelleyWitnessCount
pTxShelleyWitnessCount
      Parser (TxByronWitnessCount -> TransactionCmd)
-> Parser TxByronWitnessCount -> Parser TransactionCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser TxByronWitnessCount
pTxByronWitnessCount

  pTransactionId  :: Parser TransactionCmd
  pTransactionId :: Parser TransactionCmd
pTransactionId = TxBodyFile -> TransactionCmd
TxGetTxId (TxBodyFile -> TransactionCmd)
-> Parser TxBodyFile -> Parser TransactionCmd
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
Input


pNodeCmd :: Parser NodeCmd
pNodeCmd :: Parser NodeCmd
pNodeCmd =
  Mod CommandFields NodeCmd -> Parser NodeCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields NodeCmd -> Parser NodeCmd)
-> Mod CommandFields NodeCmd -> Parser NodeCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields NodeCmd] -> Mod CommandFields NodeCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pKeyGenOperator (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a key pair for a node operator's offline \
                         \ key and a new certificate issue counter")
      , String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen-KES"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pKeyGenKES (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a key pair for a node KES operational key")
      , String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen-VRF"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pKeyGenVRF (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a key pair for a node VRF operational key")
      , String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-hash-VRF"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pKeyHashVRF (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print hash of a node's operational VRF key.")
      , String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"new-counter"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pNewCounter (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a new certificate issue counter")
      , String -> ParserInfo NodeCmd -> Mod CommandFields NodeCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"issue-op-cert"
          (Parser NodeCmd -> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser NodeCmd
pIssueOpCert (InfoMod NodeCmd -> ParserInfo NodeCmd)
-> InfoMod NodeCmd -> ParserInfo NodeCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod NodeCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Issue a node operational certificate")
      ]
  where
    pKeyGenOperator :: Parser NodeCmd
    pKeyGenOperator :: Parser NodeCmd
pKeyGenOperator =
      VerificationKeyFile
-> SigningKeyFile -> OpCertCounterFile -> NodeCmd
NodeKeyGenCold (VerificationKeyFile
 -> SigningKeyFile -> OpCertCounterFile -> NodeCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> OpCertCounterFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pColdVerificationKeyFile
                     Parser (SigningKeyFile -> OpCertCounterFile -> NodeCmd)
-> Parser SigningKeyFile -> Parser (OpCertCounterFile -> NodeCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SigningKeyFile
pColdSigningKeyFile
                     Parser (OpCertCounterFile -> NodeCmd)
-> Parser OpCertCounterFile -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OpCertCounterFile
pOperatorCertIssueCounterFile

    pKeyGenKES :: Parser NodeCmd
    pKeyGenKES :: Parser NodeCmd
pKeyGenKES =
      VerificationKeyFile -> SigningKeyFile -> NodeCmd
NodeKeyGenKES (VerificationKeyFile -> SigningKeyFile -> NodeCmd)
-> Parser VerificationKeyFile -> Parser (SigningKeyFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output Parser (SigningKeyFile -> NodeCmd)
-> Parser SigningKeyFile -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pKeyGenVRF :: Parser NodeCmd
    pKeyGenVRF :: Parser NodeCmd
pKeyGenVRF =
      VerificationKeyFile -> SigningKeyFile -> NodeCmd
NodeKeyGenVRF (VerificationKeyFile -> SigningKeyFile -> NodeCmd)
-> Parser VerificationKeyFile -> Parser (SigningKeyFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output Parser (SigningKeyFile -> NodeCmd)
-> Parser SigningKeyFile -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pKeyHashVRF :: Parser NodeCmd
    pKeyHashVRF :: Parser NodeCmd
pKeyHashVRF =
      VerificationKeyOrFile VrfKey -> Maybe OutputFile -> NodeCmd
NodeKeyHashVRF (VerificationKeyOrFile VrfKey -> Maybe OutputFile -> NodeCmd)
-> Parser (VerificationKeyOrFile VrfKey)
-> Parser (Maybe OutputFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType VrfKey -> Parser (VerificationKeyOrFile VrfKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> Parser (VerificationKeyOrFile keyrole)
pVerificationKeyOrFile AsType VrfKey
AsVrfKey Parser (Maybe OutputFile -> NodeCmd)
-> Parser (Maybe OutputFile) -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pNewCounter :: Parser NodeCmd
    pNewCounter :: Parser NodeCmd
pNewCounter =
      ColdVerificationKeyOrFile -> Word -> OpCertCounterFile -> NodeCmd
NodeNewCounter (ColdVerificationKeyOrFile -> Word -> OpCertCounterFile -> NodeCmd)
-> Parser ColdVerificationKeyOrFile
-> Parser (Word -> OpCertCounterFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ColdVerificationKeyOrFile
pColdVerificationKeyOrFile
                     Parser (Word -> OpCertCounterFile -> NodeCmd)
-> Parser Word -> Parser (OpCertCounterFile -> NodeCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Word
pCounterValue
                     Parser (OpCertCounterFile -> NodeCmd)
-> Parser OpCertCounterFile -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OpCertCounterFile
pOperatorCertIssueCounterFile

    pCounterValue :: Parser Word
    pCounterValue :: Parser Word
pCounterValue =
        ReadM Word -> Mod OptionFields Word -> Parser Word
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word
forall a. Read a => ReadM a
Opt.auto
          (  String -> Mod OptionFields Word
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"counter-value"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"INT"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The next certificate issue counter value to use."
          )

    pIssueOpCert :: Parser NodeCmd
    pIssueOpCert :: Parser NodeCmd
pIssueOpCert =
      VerificationKeyOrFile KesKey
-> SigningKeyFile
-> OpCertCounterFile
-> KESPeriod
-> OutputFile
-> NodeCmd
NodeIssueOpCert (VerificationKeyOrFile KesKey
 -> SigningKeyFile
 -> OpCertCounterFile
 -> KESPeriod
 -> OutputFile
 -> NodeCmd)
-> Parser (VerificationKeyOrFile KesKey)
-> Parser
     (SigningKeyFile
      -> OpCertCounterFile -> KESPeriod -> OutputFile -> NodeCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile KesKey)
pKesVerificationKeyOrFile
                      Parser
  (SigningKeyFile
   -> OpCertCounterFile -> KESPeriod -> OutputFile -> NodeCmd)
-> Parser SigningKeyFile
-> Parser (OpCertCounterFile -> KESPeriod -> OutputFile -> NodeCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser SigningKeyFile
pColdSigningKeyFile
                      Parser (OpCertCounterFile -> KESPeriod -> OutputFile -> NodeCmd)
-> Parser OpCertCounterFile
-> Parser (KESPeriod -> OutputFile -> NodeCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OpCertCounterFile
pOperatorCertIssueCounterFile
                      Parser (KESPeriod -> OutputFile -> NodeCmd)
-> Parser KESPeriod -> Parser (OutputFile -> NodeCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser KESPeriod
pKesPeriod
                      Parser (OutputFile -> NodeCmd)
-> Parser OutputFile -> Parser NodeCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile


pPoolCmd :: Parser PoolCmd
pPoolCmd :: Parser PoolCmd
pPoolCmd =
  Mod CommandFields PoolCmd -> Parser PoolCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields PoolCmd -> Parser PoolCmd)
-> Mod CommandFields PoolCmd -> Parser PoolCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields PoolCmd] -> Mod CommandFields PoolCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo PoolCmd -> Mod CommandFields PoolCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"registration-certificate"
          (Parser PoolCmd -> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser PoolCmd
pStakePoolRegistrationCert (InfoMod PoolCmd -> ParserInfo PoolCmd)
-> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod PoolCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake pool registration certificate")
      , String -> ParserInfo PoolCmd -> Mod CommandFields PoolCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"deregistration-certificate"
          (Parser PoolCmd -> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser PoolCmd
pStakePoolRetirementCert (InfoMod PoolCmd -> ParserInfo PoolCmd)
-> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod PoolCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake pool deregistration certificate")
      , String -> ParserInfo PoolCmd -> Mod CommandFields PoolCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"id"
          (Parser PoolCmd -> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser PoolCmd
pId (InfoMod PoolCmd -> ParserInfo PoolCmd)
-> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod PoolCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Build pool id from the offline key")
      , String -> ParserInfo PoolCmd -> Mod CommandFields PoolCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"metadata-hash"
          (Parser PoolCmd -> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser PoolCmd
pPoolMetaDataHashSubCmd (InfoMod PoolCmd -> ParserInfo PoolCmd)
-> InfoMod PoolCmd -> ParserInfo PoolCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod PoolCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print the hash of pool metadata.")
      ]
  where
    pId :: Parser PoolCmd
    pId :: Parser PoolCmd
pId = VerificationKeyOrFile StakePoolKey -> OutputFormat -> PoolCmd
PoolGetId (VerificationKeyOrFile StakePoolKey -> OutputFormat -> PoolCmd)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser (OutputFormat -> PoolCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile Parser (OutputFormat -> PoolCmd)
-> Parser OutputFormat -> Parser PoolCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFormat
pOutputFormat

    pPoolMetaDataHashSubCmd :: Parser PoolCmd
    pPoolMetaDataHashSubCmd :: Parser PoolCmd
pPoolMetaDataHashSubCmd = PoolMetaDataFile -> Maybe OutputFile -> PoolCmd
PoolMetaDataHash (PoolMetaDataFile -> Maybe OutputFile -> PoolCmd)
-> Parser PoolMetaDataFile -> Parser (Maybe OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser PoolMetaDataFile
pPoolMetaDataFile Parser (Maybe OutputFile -> PoolCmd)
-> Parser (Maybe OutputFile) -> Parser PoolCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile


pQueryCmd :: Parser QueryCmd
pQueryCmd :: Parser QueryCmd
pQueryCmd =
  Mod CommandFields QueryCmd -> Parser QueryCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields QueryCmd -> Parser QueryCmd)
-> Mod CommandFields QueryCmd -> Parser QueryCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields QueryCmd] -> Mod CommandFields QueryCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"protocol-parameters"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryProtocolParameters (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the node's current protocol parameters")
      , String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"tip"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryTip (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the node's current tip (slot no, hash, block no)")
      , String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"stake-distribution"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryStakeDistribution (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the node's current aggregated stake distribution")
      , String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"stake-address-info"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryStakeAddressInfo (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the current delegations and \
                                                          \reward accounts filtered by stake \
                                                          \address.")
      , String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"utxo"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryUTxO (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the node's current UTxO with the option of \
                                              \filtering by address(es)")
      , String -> ParserInfo QueryCmd -> Mod CommandFields QueryCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"ledger-state"
          (Parser QueryCmd -> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser QueryCmd
pQueryLedgerState (InfoMod QueryCmd -> ParserInfo QueryCmd)
-> InfoMod QueryCmd -> ParserInfo QueryCmd
forall a b. (a -> b) -> a -> b
$ String -> InfoMod QueryCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Dump the current state of the node")
      ]
  where
    pQueryProtocolParameters :: Parser QueryCmd
    pQueryProtocolParameters :: Parser QueryCmd
pQueryProtocolParameters =
      Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryProtocolParameters
        (Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol
        Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
        Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pQueryTip :: Parser QueryCmd
    pQueryTip :: Parser QueryCmd
pQueryTip = Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryTip (Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pQueryUTxO :: Parser QueryCmd
    pQueryUTxO :: Parser QueryCmd
pQueryUTxO =
      Protocol
-> QueryFilter -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryUTxO
        (Protocol
 -> QueryFilter -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser
     (QueryFilter -> NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol
        Parser (QueryFilter -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser QueryFilter
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser QueryFilter
pQueryFilter
        Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
        Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pQueryStakeDistribution :: Parser QueryCmd
    pQueryStakeDistribution :: Parser QueryCmd
pQueryStakeDistribution =
      Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryStakeDistribution
        (Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol
        Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
        Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pQueryStakeAddressInfo :: Parser QueryCmd
    pQueryStakeAddressInfo :: Parser QueryCmd
pQueryStakeAddressInfo =
      Protocol
-> StakeAddress -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryStakeAddressInfo
        (Protocol
 -> StakeAddress -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser
     (StakeAddress -> NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol
        Parser (StakeAddress -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser StakeAddress
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser StakeAddress
pFilterByStakeAddress
        Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
        Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pQueryLedgerState :: Parser QueryCmd
    pQueryLedgerState :: Parser QueryCmd
pQueryLedgerState = Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd
QueryLedgerState (Protocol -> NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser Protocol
-> Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Protocol
pProtocol Parser (NetworkId -> Maybe OutputFile -> QueryCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> QueryCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId Parser (Maybe OutputFile -> QueryCmd)
-> Parser (Maybe OutputFile) -> Parser QueryCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

pGovernanceCmd :: Parser GovernanceCmd
pGovernanceCmd :: Parser GovernanceCmd
pGovernanceCmd =
  Mod CommandFields GovernanceCmd -> Parser GovernanceCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields GovernanceCmd -> Parser GovernanceCmd)
-> Mod CommandFields GovernanceCmd -> Parser GovernanceCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields GovernanceCmd]
-> Mod CommandFields GovernanceCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String
-> ParserInfo GovernanceCmd -> Mod CommandFields GovernanceCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"create-mir-certificate"
          (Parser GovernanceCmd
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GovernanceCmd
pMIRCertificate (InfoMod GovernanceCmd -> ParserInfo GovernanceCmd)
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod GovernanceCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create an MIR (Move Instantaneous Rewards) certificate")
      , String
-> ParserInfo GovernanceCmd -> Mod CommandFields GovernanceCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"create-genesis-key-delegation-certificate"
          (Parser GovernanceCmd
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GovernanceCmd
pGovernanceGenesisKeyDelegationCertificate (InfoMod GovernanceCmd -> ParserInfo GovernanceCmd)
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod GovernanceCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a genesis key delegation certificate")
      , String
-> ParserInfo GovernanceCmd -> Mod CommandFields GovernanceCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"create-update-proposal"
          (Parser GovernanceCmd
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GovernanceCmd
pUpdateProposal (InfoMod GovernanceCmd -> ParserInfo GovernanceCmd)
-> InfoMod GovernanceCmd -> ParserInfo GovernanceCmd
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod GovernanceCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create an update proposal")
      ]
  where
    pMIRCertificate :: Parser GovernanceCmd
    pMIRCertificate :: Parser GovernanceCmd
pMIRCertificate = MIRPot
-> [VerificationKeyFile]
-> [Lovelace]
-> OutputFile
-> GovernanceCmd
GovernanceMIRCertificate
                        (MIRPot
 -> [VerificationKeyFile]
 -> [Lovelace]
 -> OutputFile
 -> GovernanceCmd)
-> Parser MIRPot
-> Parser
     ([VerificationKeyFile]
      -> [Lovelace] -> OutputFile -> GovernanceCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MIRPot
pMIRPot
                        Parser
  ([VerificationKeyFile]
   -> [Lovelace] -> OutputFile -> GovernanceCmd)
-> Parser [VerificationKeyFile]
-> Parser ([Lovelace] -> OutputFile -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser VerificationKeyFile -> Parser [VerificationKeyFile]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser VerificationKeyFile
pStakeVerificationKeyFile
                        Parser ([Lovelace] -> OutputFile -> GovernanceCmd)
-> Parser [Lovelace] -> Parser (OutputFile -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace -> Parser [Lovelace]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser Lovelace
pRewardAmt
                        Parser (OutputFile -> GovernanceCmd)
-> Parser OutputFile -> Parser GovernanceCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pGovernanceGenesisKeyDelegationCertificate :: Parser GovernanceCmd
    pGovernanceGenesisKeyDelegationCertificate :: Parser GovernanceCmd
pGovernanceGenesisKeyDelegationCertificate =
      VerificationKeyOrHashOrFile GenesisKey
-> VerificationKeyOrHashOrFile GenesisDelegateKey
-> VerificationKeyOrHashOrFile VrfKey
-> OutputFile
-> GovernanceCmd
GovernanceGenesisKeyDelegationCertificate
        (VerificationKeyOrHashOrFile GenesisKey
 -> VerificationKeyOrHashOrFile GenesisDelegateKey
 -> VerificationKeyOrHashOrFile VrfKey
 -> OutputFile
 -> GovernanceCmd)
-> Parser (VerificationKeyOrHashOrFile GenesisKey)
-> Parser
     (VerificationKeyOrHashOrFile GenesisDelegateKey
      -> VerificationKeyOrHashOrFile VrfKey
      -> OutputFile
      -> GovernanceCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrHashOrFile GenesisKey)
pGenesisVerificationKeyOrHashOrFile
        Parser
  (VerificationKeyOrHashOrFile GenesisDelegateKey
   -> VerificationKeyOrHashOrFile VrfKey
   -> OutputFile
   -> GovernanceCmd)
-> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
-> Parser
     (VerificationKeyOrHashOrFile VrfKey -> OutputFile -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrHashOrFile
        Parser
  (VerificationKeyOrHashOrFile VrfKey -> OutputFile -> GovernanceCmd)
-> Parser (VerificationKeyOrHashOrFile VrfKey)
-> Parser (OutputFile -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrHashOrFile VrfKey)
pVrfVerificationKeyOrHashOrFile
        Parser (OutputFile -> GovernanceCmd)
-> Parser OutputFile -> Parser GovernanceCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

    pMIRPot :: Parser Shelley.MIRPot
    pMIRPot :: Parser MIRPot
pMIRPot =
          MIRPot -> Mod FlagFields MIRPot -> Parser MIRPot
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' MIRPot
Shelley.ReservesMIR
            (  String -> Mod FlagFields MIRPot
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"reserves"
            Mod FlagFields MIRPot
-> Mod FlagFields MIRPot -> Mod FlagFields MIRPot
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields MIRPot
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use the reserves pot."
            )
      Parser MIRPot -> Parser MIRPot -> Parser MIRPot
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> MIRPot -> Mod FlagFields MIRPot -> Parser MIRPot
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' MIRPot
Shelley.TreasuryMIR
            (  String -> Mod FlagFields MIRPot
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"treasury"
            Mod FlagFields MIRPot
-> Mod FlagFields MIRPot -> Mod FlagFields MIRPot
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields MIRPot
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use the treasury pot."
            )

    pUpdateProposal :: Parser GovernanceCmd
    pUpdateProposal :: Parser GovernanceCmd
pUpdateProposal = OutputFile
-> EpochNo
-> [VerificationKeyFile]
-> ProtocolParametersUpdate
-> GovernanceCmd
GovernanceUpdateProposal
                        (OutputFile
 -> EpochNo
 -> [VerificationKeyFile]
 -> ProtocolParametersUpdate
 -> GovernanceCmd)
-> Parser OutputFile
-> Parser
     (EpochNo
      -> [VerificationKeyFile]
      -> ProtocolParametersUpdate
      -> GovernanceCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser OutputFile
pOutputFile
                        Parser
  (EpochNo
   -> [VerificationKeyFile]
   -> ProtocolParametersUpdate
   -> GovernanceCmd)
-> Parser EpochNo
-> Parser
     ([VerificationKeyFile]
      -> ProtocolParametersUpdate -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser EpochNo
pEpochNoUpdateProp
                        Parser
  ([VerificationKeyFile]
   -> ProtocolParametersUpdate -> GovernanceCmd)
-> Parser [VerificationKeyFile]
-> Parser (ProtocolParametersUpdate -> GovernanceCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser VerificationKeyFile -> Parser [VerificationKeyFile]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser VerificationKeyFile
pGenesisVerificationKeyFile
                        Parser (ProtocolParametersUpdate -> GovernanceCmd)
-> Parser ProtocolParametersUpdate -> Parser GovernanceCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser ProtocolParametersUpdate
pShelleyProtocolParametersUpdate

pRewardAmt :: Parser Lovelace
pRewardAmt :: Parser Lovelace
pRewardAmt =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"reward"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The reward for the relevant reward account."
      )

pGenesisCmd :: Parser GenesisCmd
pGenesisCmd :: Parser GenesisCmd
pGenesisCmd =
  Mod CommandFields GenesisCmd -> Parser GenesisCmd
forall a. Mod CommandFields a -> Parser a
Opt.subparser (Mod CommandFields GenesisCmd -> Parser GenesisCmd)
-> Mod CommandFields GenesisCmd -> Parser GenesisCmd
forall a b. (a -> b) -> a -> b
$
    [Mod CommandFields GenesisCmd] -> Mod CommandFields GenesisCmd
forall a. Monoid a => [a] -> a
mconcat
      [ String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen-genesis"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisKeyGen (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a Shelley genesis key pair")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen-delegate"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisDelegateKeyGen (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a Shelley genesis delegate key pair")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-gen-utxo"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisUTxOKeyGen (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Create a Shelley genesis UTxO key pair")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"key-hash"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisKeyHash (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Print the identifier (hash) of a public key")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"get-ver-key"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisVerKey (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Derive the verification key from a signing key")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"initial-addr"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisAddr (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the address for an initial UTxO based on the verification key")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"initial-txin"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisTxIn (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Get the TxIn for an initial UTxO based on the verification key")
      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"create"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisCreate (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc (String
"Create a Shelley genesis file from a genesis "
                        String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"template and genesis/delegation/spending keys."))

      , String -> ParserInfo GenesisCmd -> Mod CommandFields GenesisCmd
forall a. String -> ParserInfo a -> Mod CommandFields a
Opt.command String
"hash"
          (Parser GenesisCmd -> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser GenesisCmd
pGenesisHash (InfoMod GenesisCmd -> ParserInfo GenesisCmd)
-> InfoMod GenesisCmd -> ParserInfo GenesisCmd
forall a b. (a -> b) -> a -> b
$
             String -> InfoMod GenesisCmd
forall a. String -> InfoMod a
Opt.progDesc String
"Compute the hash of a genesis file")
      ]
  where
    pGenesisKeyGen :: Parser GenesisCmd
    pGenesisKeyGen :: Parser GenesisCmd
pGenesisKeyGen =
      VerificationKeyFile -> SigningKeyFile -> GenesisCmd
GenesisKeyGenGenesis (VerificationKeyFile -> SigningKeyFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output Parser (SigningKeyFile -> GenesisCmd)
-> Parser SigningKeyFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pGenesisDelegateKeyGen :: Parser GenesisCmd
    pGenesisDelegateKeyGen :: Parser GenesisCmd
pGenesisDelegateKeyGen =
      VerificationKeyFile
-> SigningKeyFile -> OpCertCounterFile -> GenesisCmd
GenesisKeyGenDelegate (VerificationKeyFile
 -> SigningKeyFile -> OpCertCounterFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> OpCertCounterFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output
                            Parser (SigningKeyFile -> OpCertCounterFile -> GenesisCmd)
-> Parser SigningKeyFile
-> Parser (OpCertCounterFile -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output
                            Parser (OpCertCounterFile -> GenesisCmd)
-> Parser OpCertCounterFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OpCertCounterFile
pOperatorCertIssueCounterFile

    pGenesisUTxOKeyGen :: Parser GenesisCmd
    pGenesisUTxOKeyGen :: Parser GenesisCmd
pGenesisUTxOKeyGen =
      VerificationKeyFile -> SigningKeyFile -> GenesisCmd
GenesisKeyGenUTxO (VerificationKeyFile -> SigningKeyFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output Parser (SigningKeyFile -> GenesisCmd)
-> Parser SigningKeyFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pGenesisKeyHash :: Parser GenesisCmd
    pGenesisKeyHash :: Parser GenesisCmd
pGenesisKeyHash =
      VerificationKeyFile -> GenesisCmd
GenesisCmdKeyHash (VerificationKeyFile -> GenesisCmd)
-> Parser VerificationKeyFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Input

    pGenesisVerKey :: Parser GenesisCmd
    pGenesisVerKey :: Parser GenesisCmd
pGenesisVerKey =
      VerificationKeyFile -> SigningKeyFile -> GenesisCmd
GenesisVerKey (VerificationKeyFile -> SigningKeyFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (SigningKeyFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Output Parser (SigningKeyFile -> GenesisCmd)
-> Parser SigningKeyFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
Output

    pGenesisAddr :: Parser GenesisCmd
    pGenesisAddr :: Parser GenesisCmd
pGenesisAddr =
      VerificationKeyFile -> NetworkId -> Maybe OutputFile -> GenesisCmd
GenesisAddr (VerificationKeyFile
 -> NetworkId -> Maybe OutputFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (NetworkId -> Maybe OutputFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Input Parser (NetworkId -> Maybe OutputFile -> GenesisCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId Parser (Maybe OutputFile -> GenesisCmd)
-> Parser (Maybe OutputFile) -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pGenesisTxIn :: Parser GenesisCmd
    pGenesisTxIn :: Parser GenesisCmd
pGenesisTxIn =
      VerificationKeyFile -> NetworkId -> Maybe OutputFile -> GenesisCmd
GenesisTxIn (VerificationKeyFile
 -> NetworkId -> Maybe OutputFile -> GenesisCmd)
-> Parser VerificationKeyFile
-> Parser (NetworkId -> Maybe OutputFile -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Input Parser (NetworkId -> Maybe OutputFile -> GenesisCmd)
-> Parser NetworkId -> Parser (Maybe OutputFile -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId Parser (Maybe OutputFile -> GenesisCmd)
-> Parser (Maybe OutputFile) -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe OutputFile)
pMaybeOutputFile

    pGenesisCreate :: Parser GenesisCmd
    pGenesisCreate :: Parser GenesisCmd
pGenesisCreate =
      GenesisDir
-> Word
-> Word
-> Maybe SystemStart
-> Maybe Lovelace
-> NetworkId
-> GenesisCmd
GenesisCreate (GenesisDir
 -> Word
 -> Word
 -> Maybe SystemStart
 -> Maybe Lovelace
 -> NetworkId
 -> GenesisCmd)
-> Parser GenesisDir
-> Parser
     (Word
      -> Word
      -> Maybe SystemStart
      -> Maybe Lovelace
      -> NetworkId
      -> GenesisCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser GenesisDir
pGenesisDir
                    Parser
  (Word
   -> Word
   -> Maybe SystemStart
   -> Maybe Lovelace
   -> NetworkId
   -> GenesisCmd)
-> Parser Word
-> Parser
     (Word
      -> Maybe SystemStart -> Maybe Lovelace -> NetworkId -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Word
pGenesisNumGenesisKeys
                    Parser
  (Word
   -> Maybe SystemStart -> Maybe Lovelace -> NetworkId -> GenesisCmd)
-> Parser Word
-> Parser
     (Maybe SystemStart -> Maybe Lovelace -> NetworkId -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Word
pGenesisNumUTxOKeys
                    Parser
  (Maybe SystemStart -> Maybe Lovelace -> NetworkId -> GenesisCmd)
-> Parser (Maybe SystemStart)
-> Parser (Maybe Lovelace -> NetworkId -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe SystemStart)
pMaybeSystemStart
                    Parser (Maybe Lovelace -> NetworkId -> GenesisCmd)
-> Parser (Maybe Lovelace) -> Parser (NetworkId -> GenesisCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe Lovelace)
pInitialSupply
                    Parser (NetworkId -> GenesisCmd)
-> Parser NetworkId -> Parser GenesisCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId

    pGenesisHash :: Parser GenesisCmd
    pGenesisHash :: Parser GenesisCmd
pGenesisHash =
      GenesisFile -> GenesisCmd
GenesisHashFile (GenesisFile -> GenesisCmd)
-> Parser GenesisFile -> Parser GenesisCmd
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser GenesisFile
pGenesisFile

    pGenesisDir :: Parser GenesisDir
    pGenesisDir :: Parser GenesisDir
pGenesisDir =
      String -> GenesisDir
GenesisDir (String -> GenesisDir) -> Parser String -> Parser GenesisDir
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-dir"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DIR"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The genesis directory containing the genesis template and required genesis/delegation/spending keys."
          )

    pMaybeSystemStart :: Parser (Maybe SystemStart)
    pMaybeSystemStart :: Parser (Maybe SystemStart)
pMaybeSystemStart =
      Parser SystemStart -> Parser (Maybe SystemStart)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
Opt.optional (Parser SystemStart -> Parser (Maybe SystemStart))
-> Parser SystemStart -> Parser (Maybe SystemStart)
forall a b. (a -> b) -> a -> b
$
        UTCTime -> SystemStart
SystemStart (UTCTime -> SystemStart)
-> (String -> UTCTime) -> String -> SystemStart
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> UTCTime
convertTime (String -> SystemStart) -> Parser String -> Parser SystemStart
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
          Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
            (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"start-time"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"UTC-TIME"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The genesis start time in YYYY-MM-DDThh:mm:ssZ format. If unspecified, will be the current time +30 seconds."
            )

    pGenesisNumGenesisKeys :: Parser Word
    pGenesisNumGenesisKeys :: Parser Word
pGenesisNumGenesisKeys =
        ReadM Word -> Mod OptionFields Word -> Parser Word
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word
forall a. Read a => ReadM a
Opt.auto
          (  String -> Mod OptionFields Word
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"gen-genesis-keys"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"INT"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of genesis keys to make [default is 0]."
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> Word -> Mod OptionFields Word
forall (f :: * -> *) a. HasValue f => a -> Mod f a
Opt.value Word
0
          )

    pGenesisNumUTxOKeys :: Parser Word
    pGenesisNumUTxOKeys :: Parser Word
pGenesisNumUTxOKeys =
        ReadM Word -> Mod OptionFields Word -> Parser Word
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word
forall a. Read a => ReadM a
Opt.auto
          (  String -> Mod OptionFields Word
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"gen-utxo-keys"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"INT"
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of UTxO keys to make [default is 0]."
          Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> Word -> Mod OptionFields Word
forall (f :: * -> *) a. HasValue f => a -> Mod f a
Opt.value Word
0
          )

    convertTime :: String -> UTCTime
    convertTime :: String -> UTCTime
convertTime =
      Bool -> TimeLocale -> String -> String -> UTCTime
forall t.
ParseTime t =>
Bool -> TimeLocale -> String -> String -> t
parseTimeOrError Bool
False TimeLocale
defaultTimeLocale (Maybe String -> String
iso8601DateFormat (Maybe String -> String) -> Maybe String -> String
forall a b. (a -> b) -> a -> b
$ String -> Maybe String
forall a. a -> Maybe a
Just String
"%H:%M:%SZ")

    pInitialSupply :: Parser (Maybe Lovelace)
    pInitialSupply :: Parser (Maybe Lovelace)
pInitialSupply =
      Parser Lovelace -> Parser (Maybe Lovelace)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
Opt.optional (Parser Lovelace -> Parser (Maybe Lovelace))
-> Parser Lovelace -> Parser (Maybe Lovelace)
forall a b. (a -> b) -> a -> b
$
      Integer -> Lovelace
Lovelace (Integer -> Lovelace) -> Parser Integer -> Parser Lovelace
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        ReadM Integer -> Mod OptionFields Integer -> Parser Integer
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Integer
forall a. Read a => ReadM a
Opt.auto
          (  String -> Mod OptionFields Integer
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"supply"
          Mod OptionFields Integer
-> Mod OptionFields Integer -> Mod OptionFields Integer
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Integer
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
          Mod OptionFields Integer
-> Mod OptionFields Integer -> Mod OptionFields Integer
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Integer
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The initial coin supply in Lovelace which will be evenly distributed across initial stake holders."
          )


--
-- Shelley CLI flag parsers
--

data FileDirection
  = Input
  | Output
  deriving (FileDirection -> FileDirection -> Bool
(FileDirection -> FileDirection -> Bool)
-> (FileDirection -> FileDirection -> Bool) -> Eq FileDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileDirection -> FileDirection -> Bool
$c/= :: FileDirection -> FileDirection -> Bool
== :: FileDirection -> FileDirection -> Bool
$c== :: FileDirection -> FileDirection -> Bool
Eq, Int -> FileDirection -> String -> String
[FileDirection] -> String -> String
FileDirection -> String
(Int -> FileDirection -> String -> String)
-> (FileDirection -> String)
-> ([FileDirection] -> String -> String)
-> Show FileDirection
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [FileDirection] -> String -> String
$cshowList :: [FileDirection] -> String -> String
show :: FileDirection -> String
$cshow :: FileDirection -> String
showsPrec :: Int -> FileDirection -> String -> String
$cshowsPrec :: Int -> FileDirection -> String -> String
Show)

pAddressKeyType :: Parser AddressKeyType
pAddressKeyType :: Parser AddressKeyType
pAddressKeyType =
    AddressKeyType
-> Mod FlagFields AddressKeyType -> Parser AddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' AddressKeyType
AddressKeyShelley
      (  String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"normal-key"
      Mod FlagFields AddressKeyType
-> Mod FlagFields AddressKeyType -> Mod FlagFields AddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a normal Shelley-era key (default)."
      )
  Parser AddressKeyType
-> Parser AddressKeyType -> Parser AddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    AddressKeyType
-> Mod FlagFields AddressKeyType -> Parser AddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' AddressKeyType
AddressKeyShelleyExtended
      (  String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"extended-key"
      Mod FlagFields AddressKeyType
-> Mod FlagFields AddressKeyType -> Mod FlagFields AddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use an extended ed25519 Shelley-era key."
      )
  Parser AddressKeyType
-> Parser AddressKeyType -> Parser AddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    AddressKeyType
-> Mod FlagFields AddressKeyType -> Parser AddressKeyType
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' AddressKeyType
AddressKeyByron
      (  String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-key"
      Mod FlagFields AddressKeyType
-> Mod FlagFields AddressKeyType -> Mod FlagFields AddressKeyType
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields AddressKeyType
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use a Byron-era key."
      )
  Parser AddressKeyType
-> Parser AddressKeyType -> Parser AddressKeyType
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    AddressKeyType -> Parser AddressKeyType
forall (f :: * -> *) a. Applicative f => a -> f a
pure AddressKeyType
AddressKeyShelley


pProtocolParamsFile :: Parser ProtocolParamsFile
pProtocolParamsFile :: Parser ProtocolParamsFile
pProtocolParamsFile =
  String -> ProtocolParamsFile
ProtocolParamsFile (String -> ProtocolParamsFile)
-> Parser String -> Parser ProtocolParamsFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"protocol-params-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the JSON-encoded protocol parameters file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pCertificateFile :: Parser CertificateFile
pCertificateFile :: Parser CertificateFile
pCertificateFile =
  String -> CertificateFile
CertificateFile (String -> CertificateFile)
-> Parser String -> Parser CertificateFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    (  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
         (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"certificate-file"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the certificate. This encompasses all \
                     \types of certificates (stake pool certificates, \
                     \stake key certificates etc)"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
         )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
       Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
         (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"certificate"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
         )
    )

pPoolMetaDataFile :: Parser PoolMetaDataFile
pPoolMetaDataFile :: Parser PoolMetaDataFile
pPoolMetaDataFile =
  String -> PoolMetaDataFile
PoolMetaDataFile (String -> PoolMetaDataFile)
-> Parser String -> Parser PoolMetaDataFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-metadata-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the pool metadata."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pTxMetadataJsonSchema :: Parser TxMetadataJsonSchema
pTxMetadataJsonSchema :: Parser TxMetadataJsonSchema
pTxMetadataJsonSchema =
    (  () -> Mod FlagFields () -> Parser ()
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' ()
        (  String -> Mod FlagFields ()
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"json-metadata-no-schema"
        Mod FlagFields () -> Mod FlagFields () -> Mod FlagFields ()
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ()
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use the \"no schema\" conversion from JSON to tx metadata."
        )
    Parser ()
-> Parser TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMetadataJsonSchema
TxMetadataJsonNoSchema
    )
  Parser TxMetadataJsonSchema
-> Parser TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    (  () -> Mod FlagFields () -> Parser ()
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' ()
        (  String -> Mod FlagFields ()
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"json-metadata-detailed-schema"
        Mod FlagFields () -> Mod FlagFields () -> Mod FlagFields ()
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ()
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use the \"detailed schema\" conversion from JSON to tx metadata."
        )
    Parser ()
-> Parser TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMetadataJsonSchema
TxMetadataJsonDetailedSchema
    )
  Parser TxMetadataJsonSchema
-> Parser TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    -- Default to the no-schema conversion.
    TxMetadataJsonSchema -> Parser TxMetadataJsonSchema
forall (f :: * -> *) a. Applicative f => a -> f a
pure TxMetadataJsonSchema
TxMetadataJsonNoSchema

pMetaDataFile :: Parser MetaDataFile
pMetaDataFile :: Parser MetaDataFile
pMetaDataFile =
      String -> MetaDataFile
MetaDataFileJSON (String -> MetaDataFile) -> Parser String -> Parser MetaDataFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
            (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"metadata-json-file"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the metadata file, in JSON format."
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
            )
        Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
          Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
            (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"metadata-file" -- backward compat name
            Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
            )
        )
  Parser MetaDataFile -> Parser MetaDataFile -> Parser MetaDataFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      String -> MetaDataFile
MetaDataFileCBOR (String -> MetaDataFile) -> Parser String -> Parser MetaDataFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"metadata-cbor-file"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the metadata, in raw CBOR format."
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
          )

pWithdrawal :: Parser (StakeAddress, Lovelace)
pWithdrawal :: Parser (StakeAddress, Lovelace)
pWithdrawal =
    ReadM (StakeAddress, Lovelace)
-> Mod OptionFields (StakeAddress, Lovelace)
-> Parser (StakeAddress, Lovelace)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser (StakeAddress, Lovelace) -> ReadM (StakeAddress, Lovelace)
forall a. Parser a -> ReadM a
readerFromAttoParser Parser (StakeAddress, Lovelace)
parseWithdrawal)
      (  String -> Mod OptionFields (StakeAddress, Lovelace)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"withdrawal"
      Mod OptionFields (StakeAddress, Lovelace)
-> Mod OptionFields (StakeAddress, Lovelace)
-> Mod OptionFields (StakeAddress, Lovelace)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (StakeAddress, Lovelace)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"WITHDRAWAL"
      Mod OptionFields (StakeAddress, Lovelace)
-> Mod OptionFields (StakeAddress, Lovelace)
-> Mod OptionFields (StakeAddress, Lovelace)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (StakeAddress, Lovelace)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The reward withdrawal as StakeAddress+Lovelace where \
                  \StakeAddress is the Bech32-encoded stake address \
                  \followed by the amount in Lovelace."
      )
  where
    parseWithdrawal :: Atto.Parser (StakeAddress, Lovelace)
    parseWithdrawal :: Parser (StakeAddress, Lovelace)
parseWithdrawal =
      (,) (StakeAddress -> Lovelace -> (StakeAddress, Lovelace))
-> Parser ByteString StakeAddress
-> Parser ByteString (Lovelace -> (StakeAddress, Lovelace))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString StakeAddress
parseStakeAddress Parser ByteString (Lovelace -> (StakeAddress, Lovelace))
-> Parser ByteString Char
-> Parser ByteString (Lovelace -> (StakeAddress, Lovelace))
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> Parser ByteString Char
Atto.char Char
'+' Parser ByteString (Lovelace -> (StakeAddress, Lovelace))
-> Parser Lovelace -> Parser (StakeAddress, Lovelace)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace
parseLovelace


pUpdateProposalFile :: Parser UpdateProposalFile
pUpdateProposalFile :: Parser UpdateProposalFile
pUpdateProposalFile =
  String -> UpdateProposalFile
UpdateProposalFile (String -> UpdateProposalFile)
-> Parser String -> Parser UpdateProposalFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
  ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
     (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"update-proposal-file"
     Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
     Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the update proposal."
     Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
     )
  Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"update-proposal"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
      )
  )


pColdSigningKeyFile :: Parser SigningKeyFile
pColdSigningKeyFile :: Parser SigningKeyFile
pColdSigningKeyFile =
  String -> SigningKeyFile
SigningKeyFile (String -> SigningKeyFile)
-> Parser String -> Parser SigningKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"cold-signing-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the cold signing key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"signing-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
      )
    )

pSomeWitnessSigningData :: Parser [WitnessSigningData]
pSomeWitnessSigningData :: Parser [WitnessSigningData]
pSomeWitnessSigningData =
  Parser WitnessSigningData -> Parser [WitnessSigningData]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (Parser WitnessSigningData -> Parser [WitnessSigningData])
-> Parser WitnessSigningData -> Parser [WitnessSigningData]
forall a b. (a -> b) -> a -> b
$
      SigningKeyFile -> Maybe (Address Byron) -> WitnessSigningData
KeyWitnessSigningData
        (SigningKeyFile -> Maybe (Address Byron) -> WitnessSigningData)
-> Parser SigningKeyFile
-> Parser (Maybe (Address Byron) -> WitnessSigningData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
          ( String -> SigningKeyFile
SigningKeyFile (String -> SigningKeyFile)
-> Parser String -> Parser SigningKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
              Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
                (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"signing-key-file"
                Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
                Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Input filepath of the signing key (one or more)."
                Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
                )
          )
        Parser (Maybe (Address Byron) -> WitnessSigningData)
-> Parser (Maybe (Address Byron)) -> Parser WitnessSigningData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
          Parser (Address Byron) -> Parser (Maybe (Address Byron))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (Address Byron)
pByronAddress
    Parser WitnessSigningData
-> Parser WitnessSigningData -> Parser WitnessSigningData
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      ScriptFile -> WitnessSigningData
ScriptWitnessSigningData (ScriptFile -> WitnessSigningData)
-> Parser ScriptFile -> Parser WitnessSigningData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ScriptFile
pScript

pSigningKeyFile :: FileDirection -> Parser SigningKeyFile
pSigningKeyFile :: FileDirection -> Parser SigningKeyFile
pSigningKeyFile FileDirection
fdir =
  String -> SigningKeyFile
SigningKeyFile (String -> SigningKeyFile)
-> Parser String -> Parser SigningKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"signing-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help (FileDirection -> String
forall a b. (Show a, ConvertText String b) => a -> b
show FileDirection
fdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" filepath of the signing key.")
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pWitnessSigningData :: Parser WitnessSigningData
pWitnessSigningData :: Parser WitnessSigningData
pWitnessSigningData =
    SigningKeyFile -> Maybe (Address Byron) -> WitnessSigningData
KeyWitnessSigningData
      (SigningKeyFile -> Maybe (Address Byron) -> WitnessSigningData)
-> Parser SigningKeyFile
-> Parser (Maybe (Address Byron) -> WitnessSigningData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        ( String -> SigningKeyFile
SigningKeyFile (String -> SigningKeyFile)
-> Parser String -> Parser SigningKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
            Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
              (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"signing-key-file"
              Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
              Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the signing key to be used in witness construction."
              Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
              )
        )
      Parser (Maybe (Address Byron) -> WitnessSigningData)
-> Parser (Maybe (Address Byron)) -> Parser WitnessSigningData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
        Parser (Address Byron) -> Parser (Maybe (Address Byron))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (Address Byron)
pByronAddress
  Parser WitnessSigningData
-> Parser WitnessSigningData -> Parser WitnessSigningData
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    ScriptFile -> WitnessSigningData
ScriptWitnessSigningData (ScriptFile -> WitnessSigningData)
-> Parser ScriptFile -> Parser WitnessSigningData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ScriptFile
pScript

pKesPeriod :: Parser KESPeriod
pKesPeriod :: Parser KESPeriod
pKesPeriod =
  Word -> KESPeriod
KESPeriod (Word -> KESPeriod) -> Parser Word -> Parser KESPeriod
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word -> Mod OptionFields Word -> Parser Word
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"kes-period"
      Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Word
-> Mod OptionFields Word -> Mod OptionFields Word
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The start of the KES key validity period."
      )

pEpochNo :: Parser EpochNo
pEpochNo :: Parser EpochNo
pEpochNo =
  Word64 -> EpochNo
EpochNo (Word64 -> EpochNo) -> Parser Word64 -> Parser EpochNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word64
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"epoch"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The epoch number."
      )


pEpochNoUpdateProp :: Parser EpochNo
pEpochNoUpdateProp :: Parser EpochNo
pEpochNoUpdateProp =
  Word64 -> EpochNo
EpochNo (Word64 -> EpochNo) -> Parser Word64 -> Parser EpochNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word64
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"epoch"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The epoch number in which the update proposal is valid."
      )

pGenesisFile :: Parser GenesisFile
pGenesisFile :: Parser GenesisFile
pGenesisFile =
  String -> GenesisFile
GenesisFile (String -> GenesisFile) -> Parser String -> Parser GenesisFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The genesis file."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pOperatorCertIssueCounterFile :: Parser OpCertCounterFile
pOperatorCertIssueCounterFile :: Parser OpCertCounterFile
pOperatorCertIssueCounterFile =
  String -> OpCertCounterFile
OpCertCounterFile (String -> OpCertCounterFile)
-> Parser String -> Parser OpCertCounterFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"operational-certificate-issue-counter-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The file with the issue counter for the operational certificate."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"operational-certificate-issue-counter"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )


pOutputFormat :: Parser OutputFormat
pOutputFormat :: Parser OutputFormat
pOutputFormat =
  ReadM OutputFormat
-> Mod OptionFields OutputFormat -> Parser OutputFormat
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM OutputFormat
readOutputFormat
    (  String -> Mod OptionFields OutputFormat
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"output-format"
    Mod OptionFields OutputFormat
-> Mod OptionFields OutputFormat -> Mod OptionFields OutputFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields OutputFormat
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
    Mod OptionFields OutputFormat
-> Mod OptionFields OutputFormat -> Mod OptionFields OutputFormat
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields OutputFormat
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Optional output format. Accepted output formats are \"hex\" \
                \and \"bech32\" (default is \"bech32\")."
    Mod OptionFields OutputFormat
-> Mod OptionFields OutputFormat -> Mod OptionFields OutputFormat
forall a. Semigroup a => a -> a -> a
<> OutputFormat -> Mod OptionFields OutputFormat
forall (f :: * -> *) a. HasValue f => a -> Mod f a
Opt.value OutputFormat
OutputFormatBech32
    )


pMaybeOutputFile :: Parser (Maybe OutputFile)
pMaybeOutputFile :: Parser (Maybe OutputFile)
pMaybeOutputFile =
  Parser OutputFile -> Parser (Maybe OutputFile)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser OutputFile -> Parser (Maybe OutputFile))
-> Parser OutputFile -> Parser (Maybe OutputFile)
forall a b. (a -> b) -> a -> b
$
    String -> OutputFile
OutputFile (String -> OutputFile) -> Parser String -> Parser OutputFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"out-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Optional output file. Default is to write to stdout."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )

pOutputFile :: Parser OutputFile
pOutputFile :: Parser OutputFile
pOutputFile =
  String -> OutputFile
OutputFile (String -> OutputFile) -> Parser String -> Parser OutputFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"out-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The output file."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pColdVerificationKeyOrFile :: Parser ColdVerificationKeyOrFile
pColdVerificationKeyOrFile :: Parser ColdVerificationKeyOrFile
pColdVerificationKeyOrFile =
  VerificationKey StakePoolKey -> ColdVerificationKeyOrFile
ColdStakePoolVerificationKey (VerificationKey StakePoolKey -> ColdVerificationKeyOrFile)
-> Parser (VerificationKey StakePoolKey)
-> Parser ColdVerificationKeyOrFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey StakePoolKey)
pStakePoolVerificationKey
    Parser ColdVerificationKeyOrFile
-> Parser ColdVerificationKeyOrFile
-> Parser ColdVerificationKeyOrFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKey GenesisDelegateKey -> ColdVerificationKeyOrFile
ColdGenesisDelegateVerificationKey (VerificationKey GenesisDelegateKey -> ColdVerificationKeyOrFile)
-> Parser (VerificationKey GenesisDelegateKey)
-> Parser ColdVerificationKeyOrFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey GenesisDelegateKey)
pGenesisDelegateVerificationKey
    Parser ColdVerificationKeyOrFile
-> Parser ColdVerificationKeyOrFile
-> Parser ColdVerificationKeyOrFile
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> ColdVerificationKeyOrFile
ColdVerificationKeyFile (VerificationKeyFile -> ColdVerificationKeyOrFile)
-> Parser VerificationKeyFile -> Parser ColdVerificationKeyOrFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pColdVerificationKeyFile

pColdVerificationKeyFile :: Parser VerificationKeyFile
pColdVerificationKeyFile :: Parser VerificationKeyFile
pColdVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"cold-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the cold verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )

pVerificationKey
  :: forall keyrole. SerialiseAsBech32 (VerificationKey keyrole)
  => AsType keyrole
  -> Parser (VerificationKey keyrole)
pVerificationKey :: AsType keyrole -> Parser (VerificationKey keyrole)
pVerificationKey AsType keyrole
asType =
  ReadM (VerificationKey keyrole)
-> Mod OptionFields (VerificationKey keyrole)
-> Parser (VerificationKey keyrole)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType keyrole -> ReadM (VerificationKey keyrole)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType keyrole
asType)
      (  String -> Mod OptionFields (VerificationKey keyrole)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"verification-key"
      Mod OptionFields (VerificationKey keyrole)
-> Mod OptionFields (VerificationKey keyrole)
-> Mod OptionFields (VerificationKey keyrole)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey keyrole)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey keyrole)
-> Mod OptionFields (VerificationKey keyrole)
-> Mod OptionFields (VerificationKey keyrole)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey keyrole)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Verification key (Bech32 or hex-encoded)."
      )

pVerificationKeyOrFile
  :: SerialiseAsBech32 (VerificationKey keyrole)
  => AsType keyrole
  -> Parser (VerificationKeyOrFile keyrole)
pVerificationKeyOrFile :: AsType keyrole -> Parser (VerificationKeyOrFile keyrole)
pVerificationKeyOrFile AsType keyrole
asType =
  VerificationKey keyrole -> VerificationKeyOrFile keyrole
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey keyrole -> VerificationKeyOrFile keyrole)
-> Parser (VerificationKey keyrole)
-> Parser (VerificationKeyOrFile keyrole)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> AsType keyrole -> Parser (VerificationKey keyrole)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> Parser (VerificationKey keyrole)
pVerificationKey AsType keyrole
asType
    Parser (VerificationKeyOrFile keyrole)
-> Parser (VerificationKeyOrFile keyrole)
-> Parser (VerificationKeyOrFile keyrole)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile keyrole
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile keyrole)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile keyrole)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
Input

pVerificationKeyFile :: FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile :: FileDirection -> Parser VerificationKeyFile
pVerificationKeyFile FileDirection
fdir =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"verification-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help (FileDirection -> String
forall a b. (Show a, ConvertText String b) => a -> b
show FileDirection
fdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" filepath of the verification key.")
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pExtendedVerificationKeyFile :: FileDirection -> Parser VerificationKeyFile
pExtendedVerificationKeyFile :: FileDirection -> Parser VerificationKeyFile
pExtendedVerificationKeyFile FileDirection
fdir =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"extended-verification-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help (FileDirection -> String
forall a b. (Show a, ConvertText String b) => a -> b
show FileDirection
fdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" filepath of the ed25519-bip32 verification key.")
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pGenesisVerificationKeyFile :: Parser VerificationKeyFile
pGenesisVerificationKeyFile :: Parser VerificationKeyFile
pGenesisVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-verification-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the genesis verification key."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pGenesisVerificationKeyHash :: Parser (Hash GenesisKey)
pGenesisVerificationKeyHash :: Parser (Hash GenesisKey)
pGenesisVerificationKeyHash =
    ReadM (Hash GenesisKey)
-> Mod OptionFields (Hash GenesisKey) -> Parser (Hash GenesisKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (Hash GenesisKey))
-> ReadM (Hash GenesisKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (Hash GenesisKey)
deserialiseFromHex)
        (  String -> Mod OptionFields (Hash GenesisKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-verification-key-hash"
        Mod OptionFields (Hash GenesisKey)
-> Mod OptionFields (Hash GenesisKey)
-> Mod OptionFields (Hash GenesisKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash GenesisKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (Hash GenesisKey)
-> Mod OptionFields (Hash GenesisKey)
-> Mod OptionFields (Hash GenesisKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash GenesisKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Genesis verification key hash (hex-encoded)."
        )
  where
    deserialiseFromHex :: String -> Either String (Hash GenesisKey)
    deserialiseFromHex :: String -> Either String (Hash GenesisKey)
deserialiseFromHex =
      Either String (Hash GenesisKey)
-> (Hash GenesisKey -> Either String (Hash GenesisKey))
-> Maybe (Hash GenesisKey)
-> Either String (Hash GenesisKey)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (Hash GenesisKey)
forall a b. a -> Either a b
Left String
"Invalid genesis verification key hash.") Hash GenesisKey -> Either String (Hash GenesisKey)
forall a b. b -> Either a b
Right
        (Maybe (Hash GenesisKey) -> Either String (Hash GenesisKey))
-> (String -> Maybe (Hash GenesisKey))
-> String
-> Either String (Hash GenesisKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (Hash GenesisKey) -> ByteString -> Maybe (Hash GenesisKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType GenesisKey -> AsType (Hash GenesisKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType GenesisKey
AsGenesisKey)
        (ByteString -> Maybe (Hash GenesisKey))
-> (String -> ByteString) -> String -> Maybe (Hash GenesisKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

pGenesisVerificationKey :: Parser (VerificationKey GenesisKey)
pGenesisVerificationKey :: Parser (VerificationKey GenesisKey)
pGenesisVerificationKey =
    ReadM (VerificationKey GenesisKey)
-> Mod OptionFields (VerificationKey GenesisKey)
-> Parser (VerificationKey GenesisKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (VerificationKey GenesisKey))
-> ReadM (VerificationKey GenesisKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (VerificationKey GenesisKey)
deserialiseFromHex)
        (  String -> Mod OptionFields (VerificationKey GenesisKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-verification-key"
        Mod OptionFields (VerificationKey GenesisKey)
-> Mod OptionFields (VerificationKey GenesisKey)
-> Mod OptionFields (VerificationKey GenesisKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey GenesisKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (VerificationKey GenesisKey)
-> Mod OptionFields (VerificationKey GenesisKey)
-> Mod OptionFields (VerificationKey GenesisKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey GenesisKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Genesis verification key (hex-encoded)."
        )
  where
    deserialiseFromHex :: String -> Either String (VerificationKey GenesisKey)
    deserialiseFromHex :: String -> Either String (VerificationKey GenesisKey)
deserialiseFromHex =
      Either String (VerificationKey GenesisKey)
-> (VerificationKey GenesisKey
    -> Either String (VerificationKey GenesisKey))
-> Maybe (VerificationKey GenesisKey)
-> Either String (VerificationKey GenesisKey)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (VerificationKey GenesisKey)
forall a b. a -> Either a b
Left String
"Invalid genesis verification key.") VerificationKey GenesisKey
-> Either String (VerificationKey GenesisKey)
forall a b. b -> Either a b
Right
        (Maybe (VerificationKey GenesisKey)
 -> Either String (VerificationKey GenesisKey))
-> (String -> Maybe (VerificationKey GenesisKey))
-> String
-> Either String (VerificationKey GenesisKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (VerificationKey GenesisKey)
-> ByteString -> Maybe (VerificationKey GenesisKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType GenesisKey -> AsType (VerificationKey GenesisKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType GenesisKey
AsGenesisKey)
        (ByteString -> Maybe (VerificationKey GenesisKey))
-> (String -> ByteString)
-> String
-> Maybe (VerificationKey GenesisKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

pGenesisVerificationKeyOrFile :: Parser (VerificationKeyOrFile GenesisKey)
pGenesisVerificationKeyOrFile :: Parser (VerificationKeyOrFile GenesisKey)
pGenesisVerificationKeyOrFile =
  VerificationKey GenesisKey -> VerificationKeyOrFile GenesisKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey GenesisKey -> VerificationKeyOrFile GenesisKey)
-> Parser (VerificationKey GenesisKey)
-> Parser (VerificationKeyOrFile GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey GenesisKey)
pGenesisVerificationKey
    Parser (VerificationKeyOrFile GenesisKey)
-> Parser (VerificationKeyOrFile GenesisKey)
-> Parser (VerificationKeyOrFile GenesisKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile GenesisKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile GenesisKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pGenesisVerificationKeyFile

pGenesisVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile GenesisKey)
pGenesisVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile GenesisKey)
pGenesisVerificationKeyOrHashOrFile =
  VerificationKeyOrFile GenesisKey
-> VerificationKeyOrHashOrFile GenesisKey
forall keyrole.
VerificationKeyOrFile keyrole
-> VerificationKeyOrHashOrFile keyrole
VerificationKeyOrFile (VerificationKeyOrFile GenesisKey
 -> VerificationKeyOrHashOrFile GenesisKey)
-> Parser (VerificationKeyOrFile GenesisKey)
-> Parser (VerificationKeyOrHashOrFile GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile GenesisKey)
pGenesisVerificationKeyOrFile
    Parser (VerificationKeyOrHashOrFile GenesisKey)
-> Parser (VerificationKeyOrHashOrFile GenesisKey)
-> Parser (VerificationKeyOrHashOrFile GenesisKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Hash GenesisKey -> VerificationKeyOrHashOrFile GenesisKey
forall keyrole. Hash keyrole -> VerificationKeyOrHashOrFile keyrole
VerificationKeyHash (Hash GenesisKey -> VerificationKeyOrHashOrFile GenesisKey)
-> Parser (Hash GenesisKey)
-> Parser (VerificationKeyOrHashOrFile GenesisKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Hash GenesisKey)
pGenesisVerificationKeyHash

pGenesisDelegateVerificationKeyFile :: Parser VerificationKeyFile
pGenesisDelegateVerificationKeyFile :: Parser VerificationKeyFile
pGenesisDelegateVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-delegate-verification-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the genesis delegate verification key."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pGenesisDelegateVerificationKeyHash :: Parser (Hash GenesisDelegateKey)
pGenesisDelegateVerificationKeyHash :: Parser (Hash GenesisDelegateKey)
pGenesisDelegateVerificationKeyHash =
    ReadM (Hash GenesisDelegateKey)
-> Mod OptionFields (Hash GenesisDelegateKey)
-> Parser (Hash GenesisDelegateKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (Hash GenesisDelegateKey))
-> ReadM (Hash GenesisDelegateKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (Hash GenesisDelegateKey)
deserialiseFromHex)
        (  String -> Mod OptionFields (Hash GenesisDelegateKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-delegate-verification-key-hash"
        Mod OptionFields (Hash GenesisDelegateKey)
-> Mod OptionFields (Hash GenesisDelegateKey)
-> Mod OptionFields (Hash GenesisDelegateKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash GenesisDelegateKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (Hash GenesisDelegateKey)
-> Mod OptionFields (Hash GenesisDelegateKey)
-> Mod OptionFields (Hash GenesisDelegateKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash GenesisDelegateKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Genesis delegate verification key hash (hex-encoded)."
        )
  where
    deserialiseFromHex :: String -> Either String (Hash GenesisDelegateKey)
    deserialiseFromHex :: String -> Either String (Hash GenesisDelegateKey)
deserialiseFromHex =
      Either String (Hash GenesisDelegateKey)
-> (Hash GenesisDelegateKey
    -> Either String (Hash GenesisDelegateKey))
-> Maybe (Hash GenesisDelegateKey)
-> Either String (Hash GenesisDelegateKey)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (Hash GenesisDelegateKey)
forall a b. a -> Either a b
Left String
"Invalid genesis delegate verification key hash.") Hash GenesisDelegateKey -> Either String (Hash GenesisDelegateKey)
forall a b. b -> Either a b
Right
        (Maybe (Hash GenesisDelegateKey)
 -> Either String (Hash GenesisDelegateKey))
-> (String -> Maybe (Hash GenesisDelegateKey))
-> String
-> Either String (Hash GenesisDelegateKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (Hash GenesisDelegateKey)
-> ByteString -> Maybe (Hash GenesisDelegateKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType GenesisDelegateKey -> AsType (Hash GenesisDelegateKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType GenesisDelegateKey
AsGenesisDelegateKey)
        (ByteString -> Maybe (Hash GenesisDelegateKey))
-> (String -> ByteString)
-> String
-> Maybe (Hash GenesisDelegateKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

pGenesisDelegateVerificationKey :: Parser (VerificationKey GenesisDelegateKey)
pGenesisDelegateVerificationKey :: Parser (VerificationKey GenesisDelegateKey)
pGenesisDelegateVerificationKey =
    ReadM (VerificationKey GenesisDelegateKey)
-> Mod OptionFields (VerificationKey GenesisDelegateKey)
-> Parser (VerificationKey GenesisDelegateKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (VerificationKey GenesisDelegateKey))
-> ReadM (VerificationKey GenesisDelegateKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (VerificationKey GenesisDelegateKey)
deserialiseFromHex)
        (  String -> Mod OptionFields (VerificationKey GenesisDelegateKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"genesis-delegate-verification-key"
        Mod OptionFields (VerificationKey GenesisDelegateKey)
-> Mod OptionFields (VerificationKey GenesisDelegateKey)
-> Mod OptionFields (VerificationKey GenesisDelegateKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey GenesisDelegateKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (VerificationKey GenesisDelegateKey)
-> Mod OptionFields (VerificationKey GenesisDelegateKey)
-> Mod OptionFields (VerificationKey GenesisDelegateKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey GenesisDelegateKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Genesis delegate verification key (hex-encoded)."
        )
  where
    deserialiseFromHex
      :: String
      -> Either String (VerificationKey GenesisDelegateKey)
    deserialiseFromHex :: String -> Either String (VerificationKey GenesisDelegateKey)
deserialiseFromHex =
      Either String (VerificationKey GenesisDelegateKey)
-> (VerificationKey GenesisDelegateKey
    -> Either String (VerificationKey GenesisDelegateKey))
-> Maybe (VerificationKey GenesisDelegateKey)
-> Either String (VerificationKey GenesisDelegateKey)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (VerificationKey GenesisDelegateKey)
forall a b. a -> Either a b
Left String
"Invalid genesis delegate verification key.") VerificationKey GenesisDelegateKey
-> Either String (VerificationKey GenesisDelegateKey)
forall a b. b -> Either a b
Right
        (Maybe (VerificationKey GenesisDelegateKey)
 -> Either String (VerificationKey GenesisDelegateKey))
-> (String -> Maybe (VerificationKey GenesisDelegateKey))
-> String
-> Either String (VerificationKey GenesisDelegateKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (VerificationKey GenesisDelegateKey)
-> ByteString -> Maybe (VerificationKey GenesisDelegateKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType GenesisDelegateKey
-> AsType (VerificationKey GenesisDelegateKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType GenesisDelegateKey
AsGenesisDelegateKey)
        (ByteString -> Maybe (VerificationKey GenesisDelegateKey))
-> (String -> ByteString)
-> String
-> Maybe (VerificationKey GenesisDelegateKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

pGenesisDelegateVerificationKeyOrFile
  :: Parser (VerificationKeyOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrFile :: Parser (VerificationKeyOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrFile =
  VerificationKey GenesisDelegateKey
-> VerificationKeyOrFile GenesisDelegateKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey GenesisDelegateKey
 -> VerificationKeyOrFile GenesisDelegateKey)
-> Parser (VerificationKey GenesisDelegateKey)
-> Parser (VerificationKeyOrFile GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey GenesisDelegateKey)
pGenesisDelegateVerificationKey
    Parser (VerificationKeyOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrFile GenesisDelegateKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile GenesisDelegateKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile GenesisDelegateKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pGenesisDelegateVerificationKeyFile

pGenesisDelegateVerificationKeyOrHashOrFile
  :: Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrHashOrFile =
  VerificationKeyOrFile GenesisDelegateKey
-> VerificationKeyOrHashOrFile GenesisDelegateKey
forall keyrole.
VerificationKeyOrFile keyrole
-> VerificationKeyOrHashOrFile keyrole
VerificationKeyOrFile (VerificationKeyOrFile GenesisDelegateKey
 -> VerificationKeyOrHashOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile GenesisDelegateKey)
pGenesisDelegateVerificationKeyOrFile
    Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
-> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Hash GenesisDelegateKey
-> VerificationKeyOrHashOrFile GenesisDelegateKey
forall keyrole. Hash keyrole -> VerificationKeyOrHashOrFile keyrole
VerificationKeyHash (Hash GenesisDelegateKey
 -> VerificationKeyOrHashOrFile GenesisDelegateKey)
-> Parser (Hash GenesisDelegateKey)
-> Parser (VerificationKeyOrHashOrFile GenesisDelegateKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Hash GenesisDelegateKey)
pGenesisDelegateVerificationKeyHash

pKesVerificationKeyOrFile :: Parser (VerificationKeyOrFile KesKey)
pKesVerificationKeyOrFile :: Parser (VerificationKeyOrFile KesKey)
pKesVerificationKeyOrFile =
  VerificationKey KesKey -> VerificationKeyOrFile KesKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey KesKey -> VerificationKeyOrFile KesKey)
-> Parser (VerificationKey KesKey)
-> Parser (VerificationKeyOrFile KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey KesKey)
pKesVerificationKey
    Parser (VerificationKeyOrFile KesKey)
-> Parser (VerificationKeyOrFile KesKey)
-> Parser (VerificationKeyOrFile KesKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile KesKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile KesKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile KesKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pKesVerificationKeyFile

pKesVerificationKey :: Parser (VerificationKey KesKey)
pKesVerificationKey :: Parser (VerificationKey KesKey)
pKesVerificationKey =
    ReadM (VerificationKey KesKey)
-> Mod OptionFields (VerificationKey KesKey)
-> Parser (VerificationKey KesKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (VerificationKey KesKey))
-> ReadM (VerificationKey KesKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (VerificationKey KesKey)
deserialiseVerKey)
        (  String -> Mod OptionFields (VerificationKey KesKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"kes-verification-key"
        Mod OptionFields (VerificationKey KesKey)
-> Mod OptionFields (VerificationKey KesKey)
-> Mod OptionFields (VerificationKey KesKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey KesKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (VerificationKey KesKey)
-> Mod OptionFields (VerificationKey KesKey)
-> Mod OptionFields (VerificationKey KesKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey KesKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"A Bech32 or hex-encoded hot KES verification key."
        )
  where
    asType :: AsType (VerificationKey KesKey)
    asType :: AsType (VerificationKey KesKey)
asType = AsType KesKey -> AsType (VerificationKey KesKey)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType KesKey
AsKesKey

    deserialiseVerKey :: String -> Either String (VerificationKey KesKey)
    deserialiseVerKey :: String -> Either String (VerificationKey KesKey)
deserialiseVerKey String
str =
      case AsType (VerificationKey KesKey)
-> Text -> Either Bech32DecodeError (VerificationKey KesKey)
forall a.
SerialiseAsBech32 a =>
AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 AsType (VerificationKey KesKey)
asType (String -> Text
Text.pack String
str) of
        Right VerificationKey KesKey
res -> VerificationKey KesKey -> Either String (VerificationKey KesKey)
forall a b. b -> Either a b
Right VerificationKey KesKey
res

        -- The input was valid Bech32, but some other error occurred.
        Left err :: Bech32DecodeError
err@(Bech32UnexpectedPrefix Text
_ Set Text
_) -> String -> Either String (VerificationKey KesKey)
forall a b. a -> Either a b
Left (Bech32DecodeError -> String
forall e. Error e => e -> String
displayError Bech32DecodeError
err)
        Left err :: Bech32DecodeError
err@(Bech32DataPartToBytesError Text
_) -> String -> Either String (VerificationKey KesKey)
forall a b. a -> Either a b
Left (Bech32DecodeError -> String
forall e. Error e => e -> String
displayError Bech32DecodeError
err)
        Left err :: Bech32DecodeError
err@(Bech32DeserialiseFromBytesError ByteString
_) -> String -> Either String (VerificationKey KesKey)
forall a b. a -> Either a b
Left (Bech32DecodeError -> String
forall e. Error e => e -> String
displayError Bech32DecodeError
err)
        Left err :: Bech32DecodeError
err@(Bech32WrongPrefix Text
_ Text
_) -> String -> Either String (VerificationKey KesKey)
forall a b. a -> Either a b
Left (Bech32DecodeError -> String
forall e. Error e => e -> String
displayError Bech32DecodeError
err)

        -- The input was not valid Bech32. Attempt to deserialize it as hex.
        Left (Bech32DecodingError DecodingError
_) ->
          case AsType (VerificationKey KesKey)
-> ByteString -> Maybe (VerificationKey KesKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex AsType (VerificationKey KesKey)
asType (String -> ByteString
BSC.pack String
str) of
            Just VerificationKey KesKey
res' -> VerificationKey KesKey -> Either String (VerificationKey KesKey)
forall a b. b -> Either a b
Right VerificationKey KesKey
res'
            Maybe (VerificationKey KesKey)
Nothing -> String -> Either String (VerificationKey KesKey)
forall a b. a -> Either a b
Left String
"Invalid stake pool verification key."

pKesVerificationKeyFile :: Parser VerificationKeyFile
pKesVerificationKeyFile :: Parser VerificationKeyFile
pKesVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"kes-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the hot KES verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"hot-kes-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )

pNetworkId :: Parser NetworkId
pNetworkId :: Parser NetworkId
pNetworkId =
  Parser NetworkId
pMainnet Parser NetworkId -> Parser NetworkId -> Parser NetworkId
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (NetworkMagic -> NetworkId)
-> Parser NetworkMagic -> Parser NetworkId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap NetworkMagic -> NetworkId
Testnet Parser NetworkMagic
pTestnetMagic
 where
   pMainnet :: Parser NetworkId
   pMainnet :: Parser NetworkId
pMainnet =
    NetworkId -> Mod FlagFields NetworkId -> Parser NetworkId
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' NetworkId
Mainnet
      (  String -> Mod FlagFields NetworkId
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"mainnet"
      Mod FlagFields NetworkId
-> Mod FlagFields NetworkId -> Mod FlagFields NetworkId
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields NetworkId
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Use the mainnet magic id."
      )

pTestnetMagic :: Parser NetworkMagic
pTestnetMagic :: Parser NetworkMagic
pTestnetMagic =
  Word32 -> NetworkMagic
NetworkMagic (Word32 -> NetworkMagic) -> Parser Word32 -> Parser NetworkMagic
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word32 -> Mod OptionFields Word32 -> Parser Word32
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word32
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word32
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"testnet-magic"
      Mod OptionFields Word32
-> Mod OptionFields Word32 -> Mod OptionFields Word32
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word32
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Word32
-> Mod OptionFields Word32 -> Mod OptionFields Word32
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word32
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Specify a testnet magic id."
      )

pTxSubmitFile :: Parser FilePath
pTxSubmitFile :: Parser String
pTxSubmitFile =
  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
    (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-file"
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the transaction you intend to submit."
    Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
    )

pTxIn :: Parser TxIn
pTxIn :: Parser TxIn
pTxIn =
  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
readerFromAttoParser 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
"The input transaction as TxId#TxIx where TxId is the transaction hash and TxIx is the index."
    )

parseTxIn :: Atto.Parser TxIn
parseTxIn :: Parser TxIn
parseTxIn = TxId -> TxIx -> TxIn
TxIn (TxId -> TxIx -> TxIn)
-> Parser ByteString TxId -> Parser ByteString (TxIx -> TxIn)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString TxId
parseTxId Parser ByteString (TxIx -> TxIn)
-> Parser ByteString TxIx -> Parser TxIn
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Char -> Parser ByteString Char
Atto.char Char
'#' Parser ByteString Char
-> Parser ByteString TxIx -> Parser ByteString TxIx
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser ByteString TxIx
parseTxIx)

renderTxIn :: TxIn -> Text
renderTxIn :: TxIn -> Text
renderTxIn (TxIn TxId
txid (TxIx Word
txix)) =
  [Text] -> Text
forall a. Monoid a => [a] -> a
mconcat
    [ ByteString -> Text
Text.decodeUtf8 (TxId -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
serialiseToRawBytesHex TxId
txid)
    , Text
"#"
    , String -> Text
Text.pack (Word -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Word
txix)
    ]

parseTxId :: Atto.Parser TxId
parseTxId :: Parser ByteString TxId
parseTxId = (Parser ByteString TxId -> String -> Parser ByteString TxId
forall i a. Parser i a -> String -> Parser i a
<?> String
"Transaction ID (hexadecimal)") (Parser ByteString TxId -> Parser ByteString TxId)
-> Parser ByteString TxId -> Parser ByteString TxId
forall a b. (a -> b) -> a -> b
$ do
  ByteString
bstr <- (Char -> Bool) -> Parser ByteString
Atto.takeWhile1 Char -> Bool
Char.isHexDigit
  case AsType TxId -> ByteString -> Maybe TxId
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex AsType TxId
AsTxId ByteString
bstr of
    Just TxId
addr -> TxId -> Parser ByteString TxId
forall (m :: * -> *) a. Monad m => a -> m a
return TxId
addr
    Maybe TxId
Nothing -> String -> Parser ByteString TxId
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ByteString TxId)
-> String -> Parser ByteString TxId
forall a b. (a -> b) -> a -> b
$ String
"Incorrect transaction id format:: " String -> String -> String
forall a. [a] -> [a] -> [a]
++ ByteString -> String
forall a b. (Show a, ConvertText String b) => a -> b
show ByteString
bstr

parseTxIx :: Atto.Parser TxIx
parseTxIx :: Parser ByteString TxIx
parseTxIx = Int -> TxIx
forall a. Enum a => Int -> a
toEnum (Int -> TxIx) -> Parser ByteString Int -> Parser ByteString TxIx
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString Int
forall a. Integral a => Parser a
Atto.decimal


pTxOut :: Parser (TxOut Shelley)
pTxOut :: Parser (TxOut Shelley)
pTxOut =
  ReadM (TxOut Shelley)
-> Mod OptionFields (TxOut Shelley) -> Parser (TxOut Shelley)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser (TxOut Shelley) -> ReadM (TxOut Shelley)
forall a. Parser a -> ReadM a
readerFromAttoParser Parser (TxOut Shelley)
parseTxOut)
    (  String -> Mod OptionFields (TxOut Shelley)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-out"
    Mod OptionFields (TxOut Shelley)
-> Mod OptionFields (TxOut Shelley)
-> Mod OptionFields (TxOut Shelley)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (TxOut Shelley)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"TX-OUT"
    Mod OptionFields (TxOut Shelley)
-> Mod OptionFields (TxOut Shelley)
-> Mod OptionFields (TxOut Shelley)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (TxOut Shelley)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The ouput transaction as Address+Lovelace where Address is \
                \the Bech32-encoded address followed by the amount in \
                \Lovelace."
    )
  where
    parseTxOut :: Atto.Parser (TxOut Shelley)
    parseTxOut :: Parser (TxOut Shelley)
parseTxOut =
      Address Shelley -> Lovelace -> TxOut Shelley
forall era. Address era -> Lovelace -> TxOut era
TxOut (Address Shelley -> Lovelace -> TxOut Shelley)
-> Parser ByteString (Address Shelley)
-> Parser ByteString (Lovelace -> TxOut Shelley)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString (Address Shelley)
parseAddress Parser ByteString (Lovelace -> TxOut Shelley)
-> Parser ByteString Char
-> Parser ByteString (Lovelace -> TxOut Shelley)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> Parser ByteString Char
Atto.char Char
'+' Parser ByteString (Lovelace -> TxOut Shelley)
-> Parser Lovelace -> Parser (TxOut Shelley)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace
parseLovelace

pTxTTL :: Parser SlotNo
pTxTTL :: Parser SlotNo
pTxTTL =
  Word64 -> SlotNo
SlotNo (Word64 -> SlotNo) -> Parser Word64 -> Parser SlotNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word64
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"ttl"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"SLOT"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Time to live (in slots)."
      )

pTxFee :: Parser Lovelace
pTxFee :: Parser Lovelace
pTxFee =
  Integer -> Lovelace
Lovelace (Integer -> Lovelace)
-> (Natural -> Integer) -> Natural -> Lovelace
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. (Natural -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral :: Natural -> Integer) (Natural -> Lovelace) -> Parser Natural -> Parser Lovelace
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"fee"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The fee amount in Lovelace."
      )

pWitnessFile :: Parser WitnessFile
pWitnessFile :: Parser WitnessFile
pWitnessFile =
  String -> WitnessFile
WitnessFile (String -> WitnessFile) -> Parser String -> Parser WitnessFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"witness-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the witness"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pTxBodyFile :: FileDirection -> Parser TxBodyFile
pTxBodyFile :: FileDirection -> Parser TxBodyFile
pTxBodyFile FileDirection
fdir =
    String -> TxBodyFile
TxBodyFile (String -> TxBodyFile) -> Parser String -> Parser TxBodyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
           (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
optName
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help (FileDirection -> String
forall a b. (Show a, ConvertText String b) => a -> b
show FileDirection
fdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" filepath of the TxBody.")
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
           )
      Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
           (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-body-file"
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
           )
      )
  where
    optName :: String
optName =
      case FileDirection
fdir of
        FileDirection
Input -> String
"tx-body-file"
        FileDirection
Output -> String
"out-file"


pTxFile :: FileDirection -> Parser TxFile
pTxFile :: FileDirection -> Parser TxFile
pTxFile FileDirection
fdir =
    String -> TxFile
TxFile (String -> TxFile) -> Parser String -> Parser TxFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
      (  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
           (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
optName
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help (FileDirection -> String
forall a b. (Show a, ConvertText String b) => a -> b
show FileDirection
fdir String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" filepath of the Tx.")
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
           )
      Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
           (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-file"
           Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
           )
      )
  where
    optName :: String
optName =
      case FileDirection
fdir of
        FileDirection
Input -> String
"tx-file"
        FileDirection
Output -> String
"out-file"

pTxInCount :: Parser TxInCount
pTxInCount :: Parser TxInCount
pTxInCount =
  Int -> TxInCount
TxInCount (Int -> TxInCount) -> Parser Int -> Parser TxInCount
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Int
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-in-count"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of transaction inputs."
      )

pTxOutCount :: Parser TxOutCount
pTxOutCount :: Parser TxOutCount
pTxOutCount =
  Int -> TxOutCount
TxOutCount (Int -> TxOutCount) -> Parser Int -> Parser TxOutCount
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Int
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"tx-out-count"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of transaction outputs."
      )

pTxShelleyWitnessCount :: Parser TxShelleyWitnessCount
pTxShelleyWitnessCount :: Parser TxShelleyWitnessCount
pTxShelleyWitnessCount =
  Int -> TxShelleyWitnessCount
TxShelleyWitnessCount (Int -> TxShelleyWitnessCount)
-> Parser Int -> Parser TxShelleyWitnessCount
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Int
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"witness-count"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of Shelley key witnesses."
      )

pTxByronWitnessCount :: Parser TxByronWitnessCount
pTxByronWitnessCount :: Parser TxByronWitnessCount
pTxByronWitnessCount =
  Int -> TxByronWitnessCount
TxByronWitnessCount (Int -> TxByronWitnessCount)
-> Parser Int -> Parser TxByronWitnessCount
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Int
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-witness-count"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of Byron key witnesses (default is 0)."
      Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> Int -> Mod OptionFields Int
forall (f :: * -> *) a. HasValue f => a -> Mod f a
Opt.value Int
0
      )

pQueryFilter :: Parser QueryFilter
pQueryFilter :: Parser QueryFilter
pQueryFilter = Parser QueryFilter
pAddresses Parser QueryFilter -> Parser QueryFilter -> Parser QueryFilter
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> QueryFilter -> Parser QueryFilter
forall (f :: * -> *) a. Applicative f => a -> f a
pure QueryFilter
NoFilter
  where
    pAddresses :: Parser QueryFilter
    pAddresses :: Parser QueryFilter
pAddresses = Set (Address Shelley) -> QueryFilter
FilterByAddress (Set (Address Shelley) -> QueryFilter)
-> ([Address Shelley] -> Set (Address Shelley))
-> [Address Shelley]
-> QueryFilter
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. [Address Shelley] -> Set (Address Shelley)
forall a. Ord a => [a] -> Set a
Set.fromList ([Address Shelley] -> QueryFilter)
-> Parser [Address Shelley] -> Parser QueryFilter
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
                   Parser (Address Shelley) -> Parser [Address Shelley]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser (Address Shelley)
pFilterByAddress

pFilterByAddress :: Parser (Address Shelley)
pFilterByAddress :: Parser (Address Shelley)
pFilterByAddress =
    ReadM (Address Shelley)
-> Mod OptionFields (Address Shelley) -> Parser (Address Shelley)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser ByteString (Address Shelley) -> ReadM (Address Shelley)
forall a. Parser a -> ReadM a
readerFromAttoParser Parser ByteString (Address Shelley)
parseAddress)
      (  String -> Mod OptionFields (Address Shelley)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"address"
      Mod OptionFields (Address Shelley)
-> Mod OptionFields (Address Shelley)
-> Mod OptionFields (Address Shelley)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Address Shelley)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"ADDRESS"
      Mod OptionFields (Address Shelley)
-> Mod OptionFields (Address Shelley)
-> Mod OptionFields (Address Shelley)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Address Shelley)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filter by Cardano address(es) (Bech32-encoded)."
      )

pFilterByStakeAddress :: Parser StakeAddress
pFilterByStakeAddress :: Parser StakeAddress
pFilterByStakeAddress =
    ReadM StakeAddress
-> Mod OptionFields StakeAddress -> Parser StakeAddress
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser ByteString StakeAddress -> ReadM StakeAddress
forall a. Parser a -> ReadM a
readerFromAttoParser Parser ByteString StakeAddress
parseStakeAddress)
      (  String -> Mod OptionFields StakeAddress
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"address"
      Mod OptionFields StakeAddress
-> Mod OptionFields StakeAddress -> Mod OptionFields StakeAddress
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StakeAddress
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"ADDRESS"
      Mod OptionFields StakeAddress
-> Mod OptionFields StakeAddress -> Mod OptionFields StakeAddress
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields StakeAddress
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filter by Cardano stake address (Bech32-encoded)."
      )

pByronAddress :: Parser (Address Byron)
pByronAddress :: Parser (Address Byron)
pByronAddress =
    ReadM (Address Byron)
-> Mod OptionFields (Address Byron) -> Parser (Address Byron)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (Address Byron)) -> ReadM (Address Byron)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (Address Byron)
deserialise)
        (  String -> Mod OptionFields (Address Byron)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"address"
        Mod OptionFields (Address Byron)
-> Mod OptionFields (Address Byron)
-> Mod OptionFields (Address Byron)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Address Byron)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (Address Byron)
-> Mod OptionFields (Address Byron)
-> Mod OptionFields (Address Byron)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Address Byron)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Byron address (Base58-encoded)."
        )
  where
    deserialise :: String -> Either String (Address Byron)
    deserialise :: String -> Either String (Address Byron)
deserialise =
      Either String (Address Byron)
-> (Address Byron -> Either String (Address Byron))
-> Maybe (Address Byron)
-> Either String (Address Byron)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (Address Byron)
forall a b. a -> Either a b
Left String
"Invalid Byron address.") Address Byron -> Either String (Address Byron)
forall a b. b -> Either a b
Right
        (Maybe (Address Byron) -> Either String (Address Byron))
-> (String -> Maybe (Address Byron))
-> String
-> Either String (Address Byron)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (Address Byron) -> Text -> Maybe (Address Byron)
forall addr.
SerialiseAddress addr =>
AsType addr -> Text -> Maybe addr
deserialiseAddress AsType (Address Byron)
AsByronAddress
        (Text -> Maybe (Address Byron))
-> (String -> Text) -> String -> Maybe (Address Byron)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> Text
Text.pack

pAddress :: Parser Text
pAddress :: Parser Text
pAddress =
  String -> Text
Text.pack (String -> Text) -> Parser String -> Parser Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"address"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"ADDRESS"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"A Cardano address"
      )

pStakeVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pStakeVerificationKeyOrFile =
  VerificationKey StakeKey -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey StakeKey -> VerificationKeyOrFile StakeKey)
-> Parser (VerificationKey StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey StakeKey)
pStakeVerificationKey
    Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile StakeKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pStakeVerificationKeyFile

pStakeVerificationKey :: Parser (VerificationKey StakeKey)
pStakeVerificationKey :: Parser (VerificationKey StakeKey)
pStakeVerificationKey =
  ReadM (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Parser (VerificationKey StakeKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType StakeKey -> ReadM (VerificationKey StakeKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType StakeKey
AsStakeKey)
      (  String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"stake-verification-key"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Stake verification key (Bech32 or hex-encoded)."
      )

pStakeVerificationKeyFile :: Parser VerificationKeyFile
pStakeVerificationKeyFile :: Parser VerificationKeyFile
pStakeVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"stake-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the staking verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"staking-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )


pStakePoolVerificationKeyFile :: Parser VerificationKeyFile
pStakePoolVerificationKeyFile :: Parser VerificationKeyFile
pStakePoolVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    (  Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
         (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"cold-verification-key-file"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the stake pool verification key."
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
         )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
       Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
         (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"stake-pool-verification-key-file"
         Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
         )
    )

pStakePoolVerificationKeyHash :: Parser (Hash StakePoolKey)
pStakePoolVerificationKeyHash :: Parser (Hash StakePoolKey)
pStakePoolVerificationKeyHash =
    ReadM (Hash StakePoolKey)
-> Mod OptionFields (Hash StakePoolKey)
-> Parser (Hash StakePoolKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Maybe (Hash StakePoolKey)) -> ReadM (Hash StakePoolKey)
forall a. (String -> Maybe a) -> ReadM a
Opt.maybeReader String -> Maybe (Hash StakePoolKey)
pBech32OrHexStakePoolId)
        (  String -> Mod OptionFields (Hash StakePoolKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"stake-pool-id"
        Mod OptionFields (Hash StakePoolKey)
-> Mod OptionFields (Hash StakePoolKey)
-> Mod OptionFields (Hash StakePoolKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash StakePoolKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STAKE-POOL-ID"
        Mod OptionFields (Hash StakePoolKey)
-> Mod OptionFields (Hash StakePoolKey)
-> Mod OptionFields (Hash StakePoolKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash StakePoolKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Stake pool ID/verification key hash (either \
                    \Bech32-encoded or hex-encoded)."
        )
  where
    pBech32OrHexStakePoolId :: String -> Maybe (Hash StakePoolKey)
    pBech32OrHexStakePoolId :: String -> Maybe (Hash StakePoolKey)
pBech32OrHexStakePoolId String
str =
      String -> Maybe (Hash StakePoolKey)
pBech32StakePoolId String
str Maybe (Hash StakePoolKey)
-> Maybe (Hash StakePoolKey) -> Maybe (Hash StakePoolKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> String -> Maybe (Hash StakePoolKey)
pHexStakePoolId String
str

    pHexStakePoolId :: String -> Maybe (Hash StakePoolKey)
    pHexStakePoolId :: String -> Maybe (Hash StakePoolKey)
pHexStakePoolId =
      AsType (Hash StakePoolKey)
-> ByteString -> Maybe (Hash StakePoolKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType StakePoolKey -> AsType (Hash StakePoolKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType StakePoolKey
AsStakePoolKey) (ByteString -> Maybe (Hash StakePoolKey))
-> (String -> ByteString) -> String -> Maybe (Hash StakePoolKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

    pBech32StakePoolId :: String -> Maybe (Hash StakePoolKey)
    pBech32StakePoolId :: String -> Maybe (Hash StakePoolKey)
pBech32StakePoolId =
      (Bech32DecodeError -> Maybe (Hash StakePoolKey))
-> (Hash StakePoolKey -> Maybe (Hash StakePoolKey))
-> Either Bech32DecodeError (Hash StakePoolKey)
-> Maybe (Hash StakePoolKey)
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe (Hash StakePoolKey)
-> Bech32DecodeError -> Maybe (Hash StakePoolKey)
forall a b. a -> b -> a
const Maybe (Hash StakePoolKey)
forall a. Maybe a
Nothing) Hash StakePoolKey -> Maybe (Hash StakePoolKey)
forall a. a -> Maybe a
Just
        (Either Bech32DecodeError (Hash StakePoolKey)
 -> Maybe (Hash StakePoolKey))
-> (String -> Either Bech32DecodeError (Hash StakePoolKey))
-> String
-> Maybe (Hash StakePoolKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (Hash StakePoolKey)
-> Text -> Either Bech32DecodeError (Hash StakePoolKey)
forall a.
SerialiseAsBech32 a =>
AsType a -> Text -> Either Bech32DecodeError a
deserialiseFromBech32 (AsType StakePoolKey -> AsType (Hash StakePoolKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType StakePoolKey
AsStakePoolKey)
        (Text -> Either Bech32DecodeError (Hash StakePoolKey))
-> (String -> Text)
-> String
-> Either Bech32DecodeError (Hash StakePoolKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> Text
Text.pack

pStakePoolVerificationKey :: Parser (VerificationKey StakePoolKey)
pStakePoolVerificationKey :: Parser (VerificationKey StakePoolKey)
pStakePoolVerificationKey =
  ReadM (VerificationKey StakePoolKey)
-> Mod OptionFields (VerificationKey StakePoolKey)
-> Parser (VerificationKey StakePoolKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType StakePoolKey -> ReadM (VerificationKey StakePoolKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType StakePoolKey
AsStakePoolKey)
      (  String -> Mod OptionFields (VerificationKey StakePoolKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"stake-pool-verification-key"
      Mod OptionFields (VerificationKey StakePoolKey)
-> Mod OptionFields (VerificationKey StakePoolKey)
-> Mod OptionFields (VerificationKey StakePoolKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakePoolKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey StakePoolKey)
-> Mod OptionFields (VerificationKey StakePoolKey)
-> Mod OptionFields (VerificationKey StakePoolKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakePoolKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Stake pool verification key (Bech32 or hex-encoded)."
      )

pStakePoolVerificationKeyOrFile
  :: Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile =
  VerificationKey StakePoolKey -> VerificationKeyOrFile StakePoolKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey StakePoolKey
 -> VerificationKeyOrFile StakePoolKey)
-> Parser (VerificationKey StakePoolKey)
-> Parser (VerificationKeyOrFile StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey StakePoolKey)
pStakePoolVerificationKey
    Parser (VerificationKeyOrFile StakePoolKey)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser (VerificationKeyOrFile StakePoolKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile StakePoolKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile StakePoolKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pStakePoolVerificationKeyFile

pStakePoolVerificationKeyOrHashOrFile
  :: Parser (VerificationKeyOrHashOrFile StakePoolKey)
pStakePoolVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile StakePoolKey)
pStakePoolVerificationKeyOrHashOrFile =
  VerificationKeyOrFile StakePoolKey
-> VerificationKeyOrHashOrFile StakePoolKey
forall keyrole.
VerificationKeyOrFile keyrole
-> VerificationKeyOrHashOrFile keyrole
VerificationKeyOrFile (VerificationKeyOrFile StakePoolKey
 -> VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile
    Parser (VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Hash StakePoolKey -> VerificationKeyOrHashOrFile StakePoolKey
forall keyrole. Hash keyrole -> VerificationKeyOrHashOrFile keyrole
VerificationKeyHash (Hash StakePoolKey -> VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (Hash StakePoolKey)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Hash StakePoolKey)
pStakePoolVerificationKeyHash

pVrfVerificationKeyFile :: Parser VerificationKeyFile
pVrfVerificationKeyFile :: Parser VerificationKeyFile
pVrfVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
      (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"vrf-verification-key-file"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the VRF verification key."
      Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
      )

pVrfVerificationKeyHash :: Parser (Hash VrfKey)
pVrfVerificationKeyHash :: Parser (Hash VrfKey)
pVrfVerificationKeyHash =
    ReadM (Hash VrfKey)
-> Mod OptionFields (Hash VrfKey) -> Parser (Hash VrfKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Either String (Hash VrfKey)) -> ReadM (Hash VrfKey)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (Hash VrfKey)
deserialiseFromHex)
        (  String -> Mod OptionFields (Hash VrfKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"vrf-verification-key-hash"
        Mod OptionFields (Hash VrfKey)
-> Mod OptionFields (Hash VrfKey) -> Mod OptionFields (Hash VrfKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash VrfKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
        Mod OptionFields (Hash VrfKey)
-> Mod OptionFields (Hash VrfKey) -> Mod OptionFields (Hash VrfKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash VrfKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"VRF verification key hash (hex-encoded)."
        )
  where
    deserialiseFromHex :: String -> Either String (Hash VrfKey)
    deserialiseFromHex :: String -> Either String (Hash VrfKey)
deserialiseFromHex =
      Either String (Hash VrfKey)
-> (Hash VrfKey -> Either String (Hash VrfKey))
-> Maybe (Hash VrfKey)
-> Either String (Hash VrfKey)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Either String (Hash VrfKey)
forall a b. a -> Either a b
Left String
"Invalid VRF verification key hash.") Hash VrfKey -> Either String (Hash VrfKey)
forall a b. b -> Either a b
Right
        (Maybe (Hash VrfKey) -> Either String (Hash VrfKey))
-> (String -> Maybe (Hash VrfKey))
-> String
-> Either String (Hash VrfKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. AsType (Hash VrfKey) -> ByteString -> Maybe (Hash VrfKey)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Maybe a
deserialiseFromRawBytesHex (AsType VrfKey -> AsType (Hash VrfKey)
forall a. AsType a -> AsType (Hash a)
AsHash AsType VrfKey
AsVrfKey)
        (ByteString -> Maybe (Hash VrfKey))
-> (String -> ByteString) -> String -> Maybe (Hash VrfKey)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

pVrfVerificationKey :: Parser (VerificationKey VrfKey)
pVrfVerificationKey :: Parser (VerificationKey VrfKey)
pVrfVerificationKey =
  ReadM (VerificationKey VrfKey)
-> Mod OptionFields (VerificationKey VrfKey)
-> Parser (VerificationKey VrfKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType VrfKey -> ReadM (VerificationKey VrfKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType VrfKey
AsVrfKey)
      (  String -> Mod OptionFields (VerificationKey VrfKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"vrf-verification-key"
      Mod OptionFields (VerificationKey VrfKey)
-> Mod OptionFields (VerificationKey VrfKey)
-> Mod OptionFields (VerificationKey VrfKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey VrfKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey VrfKey)
-> Mod OptionFields (VerificationKey VrfKey)
-> Mod OptionFields (VerificationKey VrfKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey VrfKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"VRF verification key (Bech32 or hex-encoded)."
      )

pVrfVerificationKeyOrFile :: Parser (VerificationKeyOrFile VrfKey)
pVrfVerificationKeyOrFile :: Parser (VerificationKeyOrFile VrfKey)
pVrfVerificationKeyOrFile =
  VerificationKey VrfKey -> VerificationKeyOrFile VrfKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey VrfKey -> VerificationKeyOrFile VrfKey)
-> Parser (VerificationKey VrfKey)
-> Parser (VerificationKeyOrFile VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey VrfKey)
pVrfVerificationKey
    Parser (VerificationKeyOrFile VrfKey)
-> Parser (VerificationKeyOrFile VrfKey)
-> Parser (VerificationKeyOrFile VrfKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile VrfKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile VrfKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pVrfVerificationKeyFile

pVrfVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile VrfKey)
pVrfVerificationKeyOrHashOrFile :: Parser (VerificationKeyOrHashOrFile VrfKey)
pVrfVerificationKeyOrHashOrFile =
  VerificationKeyOrFile VrfKey -> VerificationKeyOrHashOrFile VrfKey
forall keyrole.
VerificationKeyOrFile keyrole
-> VerificationKeyOrHashOrFile keyrole
VerificationKeyOrFile (VerificationKeyOrFile VrfKey
 -> VerificationKeyOrHashOrFile VrfKey)
-> Parser (VerificationKeyOrFile VrfKey)
-> Parser (VerificationKeyOrHashOrFile VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile VrfKey)
pVrfVerificationKeyOrFile
    Parser (VerificationKeyOrHashOrFile VrfKey)
-> Parser (VerificationKeyOrHashOrFile VrfKey)
-> Parser (VerificationKeyOrHashOrFile VrfKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Hash VrfKey -> VerificationKeyOrHashOrFile VrfKey
forall keyrole. Hash keyrole -> VerificationKeyOrHashOrFile keyrole
VerificationKeyHash (Hash VrfKey -> VerificationKeyOrHashOrFile VrfKey)
-> Parser (Hash VrfKey)
-> Parser (VerificationKeyOrHashOrFile VrfKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Hash VrfKey)
pVrfVerificationKeyHash

pRewardAcctVerificationKeyFile :: Parser VerificationKeyFile
pRewardAcctVerificationKeyFile :: Parser VerificationKeyFile
pRewardAcctVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-reward-account-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the reward account stake verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"reward-account-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
        )
    )

pRewardAcctVerificationKey :: Parser (VerificationKey StakeKey)
pRewardAcctVerificationKey :: Parser (VerificationKey StakeKey)
pRewardAcctVerificationKey =
  ReadM (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Parser (VerificationKey StakeKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType StakeKey -> ReadM (VerificationKey StakeKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType StakeKey
AsStakeKey)
      (  String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-reward-account-verification-key"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Reward account stake verification key (Bech32 or hex-encoded)."
      )

pRewardAcctVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pRewardAcctVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pRewardAcctVerificationKeyOrFile =
  VerificationKey StakeKey -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey StakeKey -> VerificationKeyOrFile StakeKey)
-> Parser (VerificationKey StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey StakeKey)
pRewardAcctVerificationKey
    Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile StakeKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pRewardAcctVerificationKeyFile

pPoolOwnerVerificationKeyFile :: Parser VerificationKeyFile
pPoolOwnerVerificationKeyFile :: Parser VerificationKeyFile
pPoolOwnerVerificationKeyFile =
  String -> VerificationKeyFile
VerificationKeyFile (String -> VerificationKeyFile)
-> Parser String -> Parser VerificationKeyFile
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ( Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
        (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-owner-stake-verification-key-file"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"FILE"
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Filepath of the pool owner stake verification key."
        Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Completer -> Mod OptionFields String
forall (f :: * -> *) a. HasCompleter f => Completer -> Mod f a
Opt.completer (String -> Completer
Opt.bashCompleter String
"file")
        )
    Parser String -> Parser String -> Parser String
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
Opt.strOption
          (  String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-owner-staking-verification-key"
          Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields String
forall (f :: * -> *) a. Mod f a
Opt.internal
          )
    )

pPoolOwnerVerificationKey :: Parser (VerificationKey StakeKey)
pPoolOwnerVerificationKey :: Parser (VerificationKey StakeKey)
pPoolOwnerVerificationKey =
  ReadM (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Parser (VerificationKey StakeKey)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
    (AsType StakeKey -> ReadM (VerificationKey StakeKey)
forall keyrole.
SerialiseAsBech32 (VerificationKey keyrole) =>
AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType StakeKey
AsStakeKey)
      (  String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-owner-verification-key"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
      Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
-> Mod OptionFields (VerificationKey StakeKey)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (VerificationKey StakeKey)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Pool owner stake verification key (Bech32 or hex-encoded)."
      )

pPoolOwnerVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pPoolOwnerVerificationKeyOrFile :: Parser (VerificationKeyOrFile StakeKey)
pPoolOwnerVerificationKeyOrFile =
  VerificationKey StakeKey -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKey keyrole -> VerificationKeyOrFile keyrole
VerificationKeyValue (VerificationKey StakeKey -> VerificationKeyOrFile StakeKey)
-> Parser (VerificationKey StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKey StakeKey)
pPoolOwnerVerificationKey
    Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> VerificationKeyFile -> VerificationKeyOrFile StakeKey
forall keyrole.
VerificationKeyFile -> VerificationKeyOrFile keyrole
VerificationKeyFilePath (VerificationKeyFile -> VerificationKeyOrFile StakeKey)
-> Parser VerificationKeyFile
-> Parser (VerificationKeyOrFile StakeKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser VerificationKeyFile
pPoolOwnerVerificationKeyFile

pPoolPledge :: Parser Lovelace
pPoolPledge :: Parser Lovelace
pPoolPledge =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-pledge"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool's pledge."
      )


pPoolCost :: Parser Lovelace
pPoolCost :: Parser Lovelace
pPoolCost =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-cost"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool's cost."
      )

pPoolMargin :: Parser Rational
pPoolMargin :: Parser Rational
pPoolMargin =
    ReadM Rational -> Mod OptionFields Rational -> Parser Rational
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Rational
readRationalUnitInterval
      (  String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-margin"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DOUBLE"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool's margin."
      )

pPoolRelay :: Parser StakePoolRelay
pPoolRelay :: Parser StakePoolRelay
pPoolRelay = Parser StakePoolRelay
pSingleHostAddress Parser StakePoolRelay
-> Parser StakePoolRelay -> Parser StakePoolRelay
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser StakePoolRelay
pSingleHostName Parser StakePoolRelay
-> Parser StakePoolRelay -> Parser StakePoolRelay
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser StakePoolRelay
pMultiHostName

pMultiHostName :: Parser StakePoolRelay
pMultiHostName :: Parser StakePoolRelay
pMultiHostName =
  ByteString -> StakePoolRelay
StakePoolRelayDnsSrvRecord (ByteString -> StakePoolRelay)
-> Parser ByteString -> Parser StakePoolRelay
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString
pDNSName
 where
  pDNSName :: Parser ByteString
  pDNSName :: Parser ByteString
pDNSName = ReadM ByteString
-> Mod OptionFields ByteString -> Parser ByteString
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ((String -> Either String ByteString) -> ReadM ByteString
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String ByteString
eDNSName)
               (  String -> Mod OptionFields ByteString
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"multi-host-pool-relay"
               Mod OptionFields ByteString
-> Mod OptionFields ByteString -> Mod OptionFields ByteString
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ByteString
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
               Mod OptionFields ByteString
-> Mod OptionFields ByteString -> Mod OptionFields ByteString
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ByteString
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool relay's DNS name that corresponds to \
                            \an SRV DNS record"
               )

pSingleHostName :: Parser StakePoolRelay
pSingleHostName :: Parser StakePoolRelay
pSingleHostName =
  ByteString -> Maybe PortNumber -> StakePoolRelay
StakePoolRelayDnsARecord (ByteString -> Maybe PortNumber -> StakePoolRelay)
-> Parser ByteString -> Parser (Maybe PortNumber -> StakePoolRelay)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString
pDNSName Parser (Maybe PortNumber -> StakePoolRelay)
-> Parser (Maybe PortNumber) -> Parser StakePoolRelay
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser PortNumber -> Parser (Maybe PortNumber)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser PortNumber
pPort
 where
  pDNSName :: Parser ByteString
  pDNSName :: Parser ByteString
pDNSName = ReadM ByteString
-> Mod OptionFields ByteString -> Parser ByteString
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ((String -> Either String ByteString) -> ReadM ByteString
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String ByteString
eDNSName)
               (  String -> Mod OptionFields ByteString
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"single-host-pool-relay"
               Mod OptionFields ByteString
-> Mod OptionFields ByteString -> Mod OptionFields ByteString
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ByteString
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
               Mod OptionFields ByteString
-> Mod OptionFields ByteString -> Mod OptionFields ByteString
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields ByteString
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool relay's DNS name that corresponds to an\
                            \ A or AAAA DNS record"
               )

eDNSName :: String -> Either String ByteString
eDNSName :: String -> Either String ByteString
eDNSName String
str =
  -- We're using 'Shelley.textToDns' to validate the string.
  case Text -> Maybe DnsName
Shelley.textToDns (String -> Text
forall a b. ConvertText a b => a -> b
toS String
str) of
    Maybe DnsName
Nothing -> String -> Either String ByteString
forall a b. a -> Either a b
Left String
"DNS name is more than 64 bytes"
    Just DnsName
dnsName -> ByteString -> Either String ByteString
forall a b. b -> Either a b
Right (ByteString -> Either String ByteString)
-> (DnsName -> ByteString) -> DnsName -> Either String ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. Text -> ByteString
Text.encodeUtf8 (Text -> ByteString) -> (DnsName -> Text) -> DnsName -> ByteString
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. DnsName -> Text
Shelley.dnsToText (DnsName -> Either String ByteString)
-> DnsName -> Either String ByteString
forall a b. (a -> b) -> a -> b
$ DnsName
dnsName

pSingleHostAddress :: Parser StakePoolRelay
pSingleHostAddress :: Parser StakePoolRelay
pSingleHostAddress = Maybe IPv4 -> Maybe IPv6 -> PortNumber -> StakePoolRelay
singleHostAddress
  (Maybe IPv4 -> Maybe IPv6 -> PortNumber -> StakePoolRelay)
-> Parser (Maybe IPv4)
-> Parser (Maybe IPv6 -> PortNumber -> StakePoolRelay)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser IPv4 -> Parser (Maybe IPv4)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser IPv4
pIpV4
  Parser (Maybe IPv6 -> PortNumber -> StakePoolRelay)
-> Parser (Maybe IPv6) -> Parser (PortNumber -> StakePoolRelay)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser IPv6 -> Parser (Maybe IPv6)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser IPv6
pIpV6
  Parser (PortNumber -> StakePoolRelay)
-> Parser PortNumber -> Parser StakePoolRelay
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser PortNumber
pPort
 where
  singleHostAddress :: Maybe IP.IPv4 -> Maybe IP.IPv6 -> PortNumber -> StakePoolRelay
  singleHostAddress :: Maybe IPv4 -> Maybe IPv6 -> PortNumber -> StakePoolRelay
singleHostAddress Maybe IPv4
ipv4 Maybe IPv6
ipv6 PortNumber
port =
    case (Maybe IPv4
ipv4, Maybe IPv6
ipv6) of
      (Maybe IPv4
Nothing, Maybe IPv6
Nothing) ->
        Text -> StakePoolRelay
forall a. HasCallStack => Text -> a
panic Text
"Please enter either an IPv4 or IPv6 address for the pool relay"
      (Just IPv4
i4, Maybe IPv6
Nothing) ->
        Maybe IPv4 -> Maybe IPv6 -> Maybe PortNumber -> StakePoolRelay
StakePoolRelayIp (IPv4 -> Maybe IPv4
forall a. a -> Maybe a
Just IPv4
i4) Maybe IPv6
forall a. Maybe a
Nothing (PortNumber -> Maybe PortNumber
forall a. a -> Maybe a
Just PortNumber
port)
      (Maybe IPv4
Nothing, Just IPv6
i6) ->
        Maybe IPv4 -> Maybe IPv6 -> Maybe PortNumber -> StakePoolRelay
StakePoolRelayIp Maybe IPv4
forall a. Maybe a
Nothing (IPv6 -> Maybe IPv6
forall a. a -> Maybe a
Just IPv6
i6) (PortNumber -> Maybe PortNumber
forall a. a -> Maybe a
Just PortNumber
port)
      (Just IPv4
i4, Just IPv6
i6) ->
        Maybe IPv4 -> Maybe IPv6 -> Maybe PortNumber -> StakePoolRelay
StakePoolRelayIp (IPv4 -> Maybe IPv4
forall a. a -> Maybe a
Just IPv4
i4) (IPv6 -> Maybe IPv6
forall a. a -> Maybe a
Just IPv6
i6) (PortNumber -> Maybe PortNumber
forall a. a -> Maybe a
Just PortNumber
port)



pIpV4 :: Parser IP.IPv4
pIpV4 :: Parser IPv4
pIpV4 = ReadM IPv4 -> Mod OptionFields IPv4 -> Parser IPv4
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ((String -> Maybe IPv4) -> ReadM IPv4
forall a. (String -> Maybe a) -> ReadM a
Opt.maybeReader String -> Maybe IPv4
forall a. Read a => String -> Maybe a
readMaybe :: Opt.ReadM IP.IPv4)
          (  String -> Mod OptionFields IPv4
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-relay-ipv4"
          Mod OptionFields IPv4
-> Mod OptionFields IPv4 -> Mod OptionFields IPv4
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields IPv4
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
          Mod OptionFields IPv4
-> Mod OptionFields IPv4 -> Mod OptionFields IPv4
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields IPv4
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool relay's IPv4 address"
          )

pIpV6 :: Parser IP.IPv6
pIpV6 :: Parser IPv6
pIpV6 = ReadM IPv6 -> Mod OptionFields IPv6 -> Parser IPv6
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ((String -> Maybe IPv6) -> ReadM IPv6
forall a. (String -> Maybe a) -> ReadM a
Opt.maybeReader String -> Maybe IPv6
forall a. Read a => String -> Maybe a
readMaybe :: Opt.ReadM IP.IPv6)
           (  String -> Mod OptionFields IPv6
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-relay-ipv6"
           Mod OptionFields IPv6
-> Mod OptionFields IPv6 -> Mod OptionFields IPv6
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields IPv6
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"STRING"
           Mod OptionFields IPv6
-> Mod OptionFields IPv6 -> Mod OptionFields IPv6
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields IPv6
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool relay's IPv6 address"
           )

pPort :: Parser PortNumber
pPort :: Parser PortNumber
pPort = ReadM PortNumber
-> Mod OptionFields PortNumber -> Parser PortNumber
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Integer -> PortNumber
forall a. Num a => Integer -> a
fromInteger (Integer -> PortNumber) -> ReadM Integer -> ReadM PortNumber
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (String -> Either String Integer) -> ReadM Integer
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String Integer
forall a. Read a => String -> Either String a
readEither)
           (  String -> Mod OptionFields PortNumber
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-relay-port"
           Mod OptionFields PortNumber
-> Mod OptionFields PortNumber -> Mod OptionFields PortNumber
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields PortNumber
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"INT"
           Mod OptionFields PortNumber
-> Mod OptionFields PortNumber -> Mod OptionFields PortNumber
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields PortNumber
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The stake pool relay's port"
           )

pStakePoolMetadataReference :: Parser (Maybe StakePoolMetadataReference)
pStakePoolMetadataReference :: Parser (Maybe StakePoolMetadataReference)
pStakePoolMetadataReference =
  Parser StakePoolMetadataReference
-> Parser (Maybe StakePoolMetadataReference)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser StakePoolMetadataReference
 -> Parser (Maybe StakePoolMetadataReference))
-> Parser StakePoolMetadataReference
-> Parser (Maybe StakePoolMetadataReference)
forall a b. (a -> b) -> a -> b
$
    URI -> Hash StakePoolMetadata -> StakePoolMetadataReference
StakePoolMetadataReference
      (URI -> Hash StakePoolMetadata -> StakePoolMetadataReference)
-> Parser URI
-> Parser (Hash StakePoolMetadata -> StakePoolMetadataReference)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser URI
pStakePoolMetadataUrl
      Parser (Hash StakePoolMetadata -> StakePoolMetadataReference)
-> Parser (Hash StakePoolMetadata)
-> Parser StakePoolMetadataReference
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Hash StakePoolMetadata)
pStakePoolMetadataHash

pStakePoolMetadataUrl :: Parser URI
pStakePoolMetadataUrl :: Parser URI
pStakePoolMetadataUrl =
  ReadM URI -> Mod OptionFields URI -> Parser URI
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Int -> ReadM URI
readURIOfMaxLength Int
64)
    (  String -> Mod OptionFields URI
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"metadata-url"
    Mod OptionFields URI
-> Mod OptionFields URI -> Mod OptionFields URI
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields URI
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"URL"
    Mod OptionFields URI
-> Mod OptionFields URI -> Mod OptionFields URI
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields URI
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Pool metadata URL (maximum length of 64 characters)."
    )

pStakePoolMetadataHash :: Parser (Hash StakePoolMetadata)
pStakePoolMetadataHash :: Parser (Hash StakePoolMetadata)
pStakePoolMetadataHash =
    ReadM (Hash StakePoolMetadata)
-> Mod OptionFields (Hash StakePoolMetadata)
-> Parser (Hash StakePoolMetadata)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option
      ((String -> Maybe (Hash StakePoolMetadata))
-> ReadM (Hash StakePoolMetadata)
forall a. (String -> Maybe a) -> ReadM a
Opt.maybeReader String -> Maybe (Hash StakePoolMetadata)
metadataHash)
        (  String -> Mod OptionFields (Hash StakePoolMetadata)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"metadata-hash"
        Mod OptionFields (Hash StakePoolMetadata)
-> Mod OptionFields (Hash StakePoolMetadata)
-> Mod OptionFields (Hash StakePoolMetadata)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash StakePoolMetadata)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"HASH"
        Mod OptionFields (Hash StakePoolMetadata)
-> Mod OptionFields (Hash StakePoolMetadata)
-> Mod OptionFields (Hash StakePoolMetadata)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Hash StakePoolMetadata)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Pool metadata hash."
        )
  where
    getHashFromHexString :: String -> Maybe (Crypto.Hash Crypto.Blake2b_256 ByteString)
    getHashFromHexString :: String -> Maybe (Hash Blake2b_256 ByteString)
getHashFromHexString = ByteString -> Maybe (Hash Blake2b_256 ByteString)
forall h a. HashAlgorithm h => ByteString -> Maybe (Hash h a)
Crypto.hashFromBytesAsHex (ByteString -> Maybe (Hash Blake2b_256 ByteString))
-> (String -> ByteString)
-> String
-> Maybe (Hash Blake2b_256 ByteString)
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack

    metadataHash :: String -> Maybe (Hash StakePoolMetadata)
    metadataHash :: String -> Maybe (Hash StakePoolMetadata)
metadataHash String
str = Hash Blake2b_256 ByteString -> Hash StakePoolMetadata
Hash StandardCrypto ByteString -> Hash StakePoolMetadata
StakePoolMetadataHash (Hash Blake2b_256 ByteString -> Hash StakePoolMetadata)
-> Maybe (Hash Blake2b_256 ByteString)
-> Maybe (Hash StakePoolMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Maybe (Hash Blake2b_256 ByteString)
getHashFromHexString String
str

pStakePoolRegistrationCert :: Parser PoolCmd
pStakePoolRegistrationCert :: Parser PoolCmd
pStakePoolRegistrationCert =
  VerificationKeyOrFile StakePoolKey
-> VerificationKeyOrFile VrfKey
-> Lovelace
-> Lovelace
-> Rational
-> VerificationKeyOrFile StakeKey
-> [VerificationKeyOrFile StakeKey]
-> [StakePoolRelay]
-> Maybe StakePoolMetadataReference
-> NetworkId
-> OutputFile
-> PoolCmd
PoolRegistrationCert
    (VerificationKeyOrFile StakePoolKey
 -> VerificationKeyOrFile VrfKey
 -> Lovelace
 -> Lovelace
 -> Rational
 -> VerificationKeyOrFile StakeKey
 -> [VerificationKeyOrFile StakeKey]
 -> [StakePoolRelay]
 -> Maybe StakePoolMetadataReference
 -> NetworkId
 -> OutputFile
 -> PoolCmd)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser
     (VerificationKeyOrFile VrfKey
      -> Lovelace
      -> Lovelace
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile
    Parser
  (VerificationKeyOrFile VrfKey
   -> Lovelace
   -> Lovelace
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser (VerificationKeyOrFile VrfKey)
-> Parser
     (Lovelace
      -> Lovelace
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile VrfKey)
pVrfVerificationKeyOrFile
    Parser
  (Lovelace
   -> Lovelace
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser Lovelace
-> Parser
     (Lovelace
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace
pPoolPledge
    Parser
  (Lovelace
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser Lovelace
-> Parser
     (Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace
pPoolCost
    Parser
  (Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser Rational
-> Parser
     (VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational
pPoolMargin
    Parser
  (VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser
     ([VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile StakeKey)
pRewardAcctVerificationKeyOrFile
    Parser
  ([VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser [VerificationKeyOrFile StakeKey]
-> Parser
     ([StakePoolRelay]
      -> Maybe StakePoolMetadataReference
      -> NetworkId
      -> OutputFile
      -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile StakeKey)
-> Parser [VerificationKeyOrFile StakeKey]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser (VerificationKeyOrFile StakeKey)
pPoolOwnerVerificationKeyOrFile
    Parser
  ([StakePoolRelay]
   -> Maybe StakePoolMetadataReference
   -> NetworkId
   -> OutputFile
   -> PoolCmd)
-> Parser [StakePoolRelay]
-> Parser
     (Maybe StakePoolMetadataReference
      -> NetworkId -> OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser StakePoolRelay -> Parser [StakePoolRelay]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser StakePoolRelay
pPoolRelay
    Parser
  (Maybe StakePoolMetadataReference
   -> NetworkId -> OutputFile -> PoolCmd)
-> Parser (Maybe StakePoolMetadataReference)
-> Parser (NetworkId -> OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe StakePoolMetadataReference)
pStakePoolMetadataReference
    Parser (NetworkId -> OutputFile -> PoolCmd)
-> Parser NetworkId -> Parser (OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser NetworkId
pNetworkId
    Parser (OutputFile -> PoolCmd)
-> Parser OutputFile -> Parser PoolCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile

pStakePoolRetirementCert :: Parser PoolCmd
pStakePoolRetirementCert :: Parser PoolCmd
pStakePoolRetirementCert =
  VerificationKeyOrFile StakePoolKey
-> EpochNo -> OutputFile -> PoolCmd
PoolRetirementCert
    (VerificationKeyOrFile StakePoolKey
 -> EpochNo -> OutputFile -> PoolCmd)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser (EpochNo -> OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile
    Parser (EpochNo -> OutputFile -> PoolCmd)
-> Parser EpochNo -> Parser (OutputFile -> PoolCmd)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser EpochNo
pEpochNo
    Parser (OutputFile -> PoolCmd)
-> Parser OutputFile -> Parser PoolCmd
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser OutputFile
pOutputFile


pShelleyProtocolParametersUpdate :: Parser ProtocolParametersUpdate
pShelleyProtocolParametersUpdate :: Parser ProtocolParametersUpdate
pShelleyProtocolParametersUpdate =
  Maybe (Natural, Natural)
-> Maybe Rational
-> Maybe (Maybe ByteString)
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Natural
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe Lovelace
-> Maybe EpochNo
-> Maybe Natural
-> Maybe Rational
-> Maybe Rational
-> Maybe Rational
-> ProtocolParametersUpdate
ProtocolParametersUpdate
    (Maybe (Natural, Natural)
 -> Maybe Rational
 -> Maybe (Maybe ByteString)
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Natural
 -> Maybe Lovelace
 -> Maybe Lovelace
 -> Maybe Lovelace
 -> Maybe Lovelace
 -> Maybe EpochNo
 -> Maybe Natural
 -> Maybe Rational
 -> Maybe Rational
 -> Maybe Rational
 -> ProtocolParametersUpdate)
-> Parser (Maybe (Natural, Natural))
-> Parser
     (Maybe Rational
      -> Maybe (Maybe ByteString)
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Natural, Natural) -> Parser (Maybe (Natural, Natural))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (Natural, Natural)
pProtocolVersion
    Parser
  (Maybe Rational
   -> Maybe (Maybe ByteString)
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Rational)
-> Parser
     (Maybe (Maybe ByteString)
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational -> Parser (Maybe Rational)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Rational
pDecentralParam
    Parser
  (Maybe (Maybe ByteString)
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe (Maybe ByteString))
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe ByteString) -> Parser (Maybe (Maybe ByteString))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (Maybe ByteString)
pExtraEntropy
    Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pMaxBlockHeaderSize
    Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pMaxBodySize
    Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pMaxTransactionSize
    Parser
  (Maybe Natural
   -> Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Natural
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pMinFeeConstantFactor
    Parser
  (Maybe Natural
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pMinFeeLinearFactor
    Parser
  (Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Lovelace)
-> Parser
     (Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace -> Parser (Maybe Lovelace)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Lovelace
pMinUTxOValue
    Parser
  (Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Lovelace)
-> Parser
     (Maybe Lovelace
      -> Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace -> Parser (Maybe Lovelace)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Lovelace
pKeyRegistDeposit
    Parser
  (Maybe Lovelace
   -> Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Lovelace)
-> Parser
     (Maybe Lovelace
      -> Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace -> Parser (Maybe Lovelace)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Lovelace
pPoolDeposit
    Parser
  (Maybe Lovelace
   -> Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Lovelace)
-> Parser
     (Maybe EpochNo
      -> Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Lovelace -> Parser (Maybe Lovelace)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Lovelace
pMinPoolCost
    Parser
  (Maybe EpochNo
   -> Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe EpochNo)
-> Parser
     (Maybe Natural
      -> Maybe Rational
      -> Maybe Rational
      -> Maybe Rational
      -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser EpochNo -> Parser (Maybe EpochNo)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser EpochNo
pEpochBoundRetirement
    Parser
  (Maybe Natural
   -> Maybe Rational
   -> Maybe Rational
   -> Maybe Rational
   -> ProtocolParametersUpdate)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Rational
      -> Maybe Rational -> Maybe Rational -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural -> Parser (Maybe Natural)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Natural
pNumberOfPools
    Parser
  (Maybe Rational
   -> Maybe Rational -> Maybe Rational -> ProtocolParametersUpdate)
-> Parser (Maybe Rational)
-> Parser
     (Maybe Rational -> Maybe Rational -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational -> Parser (Maybe Rational)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Rational
pPoolInfluence
    Parser
  (Maybe Rational -> Maybe Rational -> ProtocolParametersUpdate)
-> Parser (Maybe Rational)
-> Parser (Maybe Rational -> ProtocolParametersUpdate)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational -> Parser (Maybe Rational)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Rational
pMonetaryExpansion
    Parser (Maybe Rational -> ProtocolParametersUpdate)
-> Parser (Maybe Rational) -> Parser ProtocolParametersUpdate
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational -> Parser (Maybe Rational)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser Rational
pTreasuryExpansion

pMinFeeLinearFactor :: Parser Natural
pMinFeeLinearFactor :: Parser Natural
pMinFeeLinearFactor =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"min-fee-linear"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The linear factor for the minimum fee calculation."
      )

pMinFeeConstantFactor :: Parser Natural
pMinFeeConstantFactor :: Parser Natural
pMinFeeConstantFactor =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"min-fee-constant"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"LOVELACE"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The constant factor for the minimum fee calculation."
      )

pMinUTxOValue :: Parser Lovelace
pMinUTxOValue :: Parser Lovelace
pMinUTxOValue =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"min-utxo-value"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The minimum allowed UTxO value."
      )

pMinPoolCost :: Parser Lovelace
pMinPoolCost :: Parser Lovelace
pMinPoolCost =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"min-pool-cost"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The minimum allowed cost parameter for stake pools."
      )

pMaxBodySize :: Parser Natural
pMaxBodySize :: Parser Natural
pMaxBodySize =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"max-block-body-size"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Maximal block body size."
      )

pMaxTransactionSize :: Parser Natural
pMaxTransactionSize :: Parser Natural
pMaxTransactionSize =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"max-tx-size"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Maximum transaction size."
      )

pMaxBlockHeaderSize :: Parser Natural
pMaxBlockHeaderSize :: Parser Natural
pMaxBlockHeaderSize =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"max-block-header-size"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Maximum block header size."
      )

pKeyRegistDeposit :: Parser Lovelace
pKeyRegistDeposit :: Parser Lovelace
pKeyRegistDeposit =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"key-reg-deposit-amt"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Key registration deposit amount."
      )

pPoolDeposit :: Parser Lovelace
pPoolDeposit :: Parser Lovelace
pPoolDeposit =
    ReadM Lovelace -> Mod OptionFields Lovelace -> Parser Lovelace
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (Parser Lovelace -> ReadM Lovelace
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Lovelace
parseLovelace)
      (  String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-reg-deposit"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Lovelace
-> Mod OptionFields Lovelace -> Mod OptionFields Lovelace
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Lovelace
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The amount of a pool registration deposit."
      )

pEpochBoundRetirement :: Parser EpochNo
pEpochBoundRetirement :: Parser EpochNo
pEpochBoundRetirement =
    Word64 -> EpochNo
EpochNo (Word64 -> EpochNo) -> Parser Word64 -> Parser EpochNo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
    ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word64
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-retirement-epoch-boundary"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"INT"
      Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Epoch bound on pool retirement."
      )

pNumberOfPools :: Parser Natural
pNumberOfPools :: Parser Natural
pNumberOfPools =
    ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
      (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"number-of-pools"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
      Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Desired number of pools."
      )

pPoolInfluence :: Parser Rational
pPoolInfluence :: Parser Rational
pPoolInfluence =
    ReadM Rational -> Mod OptionFields Rational -> Parser Rational
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Rational
readRational
      (  String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"pool-influence"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DOUBLE"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Pool influence."
      )

pTreasuryExpansion :: Parser Rational
pTreasuryExpansion :: Parser Rational
pTreasuryExpansion =
    ReadM Rational -> Mod OptionFields Rational -> Parser Rational
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Rational
readRationalUnitInterval
      (  String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"treasury-expansion"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DOUBLE"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Treasury expansion."
      )

pMonetaryExpansion :: Parser Rational
pMonetaryExpansion :: Parser Rational
pMonetaryExpansion =
    ReadM Rational -> Mod OptionFields Rational -> Parser Rational
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Rational
readRationalUnitInterval
      (  String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"monetary-expansion"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DOUBLE"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Monetary expansion."
      )

pDecentralParam :: Parser Rational
pDecentralParam :: Parser Rational
pDecentralParam =
    ReadM Rational -> Mod OptionFields Rational -> Parser Rational
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Rational
readRationalUnitInterval
      (  String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"decentralization-parameter"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"DOUBLE"
      Mod OptionFields Rational
-> Mod OptionFields Rational -> Mod OptionFields Rational
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Rational
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Decentralization parameter."
      )

pExtraEntropy :: Parser (Maybe ByteString)
pExtraEntropy :: Parser (Maybe ByteString)
pExtraEntropy =
      ReadM (Maybe ByteString)
-> Mod OptionFields (Maybe ByteString) -> Parser (Maybe ByteString)
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString)
-> ReadM ByteString -> ReadM (Maybe ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString -> ReadM ByteString
forall a. Parser a -> ReadM a
readerFromAttoParser Parser ByteString
parseEntropyBytes)
        (  String -> Mod OptionFields (Maybe ByteString)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"extra-entropy"
        Mod OptionFields (Maybe ByteString)
-> Mod OptionFields (Maybe ByteString)
-> Mod OptionFields (Maybe ByteString)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Maybe ByteString)
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"HEX"
        Mod OptionFields (Maybe ByteString)
-> Mod OptionFields (Maybe ByteString)
-> Mod OptionFields (Maybe ByteString)
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields (Maybe ByteString)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Praos extra entropy, as a hex byte string."
        )
  Parser (Maybe ByteString)
-> Parser (Maybe ByteString) -> Parser (Maybe ByteString)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe ByteString
-> Mod FlagFields (Maybe ByteString) -> Parser (Maybe ByteString)
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' Maybe ByteString
forall a. Maybe a
Nothing
        (  String -> Mod FlagFields (Maybe ByteString)
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"reset-extra-entropy"
        Mod FlagFields (Maybe ByteString)
-> Mod FlagFields (Maybe ByteString)
-> Mod FlagFields (Maybe ByteString)
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields (Maybe ByteString)
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Reset the Praos extra entropy to none."
        )
  where
    parseEntropyBytes :: Atto.Parser ByteString
    parseEntropyBytes :: Parser ByteString
parseEntropyBytes = (Char -> Bool) -> Parser ByteString
Atto.takeWhile1 Char -> Bool
Char.isHexDigit Parser ByteString
-> (ByteString -> Either String ByteString)
-> Parser ByteString (Either String ByteString)
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> ByteString -> Either String ByteString
decodeEitherBase16 Parser ByteString (Either String ByteString)
-> (Either String ByteString -> Parser ByteString)
-> Parser ByteString
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (String -> Parser ByteString)
-> (ByteString -> Parser ByteString)
-> Either String ByteString
-> Parser ByteString
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either String -> Parser ByteString
forall (m :: * -> *) a. MonadFail m => String -> m a
fail ByteString -> Parser ByteString
forall (m :: * -> *) a. Monad m => a -> m a
return

pProtocol :: Parser Protocol
pProtocol :: Parser Protocol
pProtocol =
    (  () -> Mod FlagFields () -> Parser ()
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' ()
        (  String -> Mod FlagFields ()
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"shelley-mode"
        Mod FlagFields () -> Mod FlagFields () -> Mod FlagFields ()
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ()
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"For talking to a node running in Shelley-only mode."
        )
    Parser () -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser Protocol
pShelley
    )
  Parser Protocol -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    (  () -> Mod FlagFields () -> Parser ()
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' ()
        (  String -> Mod FlagFields ()
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"byron-mode"
        Mod FlagFields () -> Mod FlagFields () -> Mod FlagFields ()
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ()
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"For talking to a node running in Byron-only mode."
        )
    Parser () -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser Protocol
pByron
    )
  Parser Protocol -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    (  () -> Mod FlagFields () -> Parser ()
forall a. a -> Mod FlagFields a -> Parser a
Opt.flag' ()
        (  String -> Mod FlagFields ()
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"cardano-mode"
        Mod FlagFields () -> Mod FlagFields () -> Mod FlagFields ()
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields ()
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"For talking to a node running in full Cardano mode (default)."
        )
    Parser () -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser Protocol
pCardano
    )
  Parser Protocol -> Parser Protocol -> Parser Protocol
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
    -- Default to the Cardano protocol.
    Protocol -> Parser Protocol
forall (f :: * -> *) a. Applicative f => a -> f a
pure
      (EpochSlots -> Protocol
CardanoProtocol
        (Word64 -> EpochSlots
EpochSlots Word64
defaultByronEpochSlots))
  where
    pByron :: Parser Protocol
    pByron :: Parser Protocol
pByron = EpochSlots -> Protocol
ByronProtocol (EpochSlots -> Protocol) -> Parser EpochSlots -> Parser Protocol
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser EpochSlots
pEpochSlots

    pShelley :: Parser Protocol
    pShelley :: Parser Protocol
pShelley = Protocol -> Parser Protocol
forall (f :: * -> *) a. Applicative f => a -> f a
pure Protocol
ShelleyProtocol

    pCardano :: Parser Protocol
    pCardano :: Parser Protocol
pCardano = EpochSlots -> Protocol
CardanoProtocol (EpochSlots -> Protocol) -> Parser EpochSlots -> Parser Protocol
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser EpochSlots
pEpochSlots

    pEpochSlots :: Parser EpochSlots
    pEpochSlots :: Parser EpochSlots
pEpochSlots =
      Word64 -> EpochSlots
EpochSlots (Word64 -> EpochSlots) -> Parser Word64 -> Parser EpochSlots
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
        ReadM Word64 -> Mod OptionFields Word64 -> Parser Word64
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Word64
forall a. Read a => ReadM a
Opt.auto
          (  String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"epoch-slots"
          Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
          Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Word64
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"The number of slots per epoch for the Byron era."
          Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> Word64 -> Mod OptionFields Word64
forall (f :: * -> *) a. HasValue f => a -> Mod f a
Opt.value Word64
defaultByronEpochSlots -- Default to the mainnet value.
          Mod OptionFields Word64
-> Mod OptionFields Word64 -> Mod OptionFields Word64
forall a. Semigroup a => a -> a -> a
<> Mod OptionFields Word64
forall a (f :: * -> *). Show a => Mod f a
Opt.showDefault
          )

    defaultByronEpochSlots :: Word64
    defaultByronEpochSlots :: Word64
defaultByronEpochSlots = Word64
21600

pProtocolVersion :: Parser (Natural, Natural)
pProtocolVersion :: Parser (Natural, Natural)
pProtocolVersion =
    (,) (Natural -> Natural -> (Natural, Natural))
-> Parser Natural -> Parser (Natural -> (Natural, Natural))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Natural
pProtocolMajorVersion Parser (Natural -> (Natural, Natural))
-> Parser Natural -> Parser (Natural, Natural)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Natural
pProtocolMinorVersion
  where
    pProtocolMajorVersion :: Parser Natural
pProtocolMajorVersion =
      ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
        (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"protocol-major-version"
        Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
        Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Major protocol version. An increase indicates a hard fork."
        )
    pProtocolMinorVersion :: Parser Natural
pProtocolMinorVersion =
      ReadM Natural -> Mod OptionFields Natural -> Parser Natural
forall a. ReadM a -> Mod OptionFields a -> Parser a
Opt.option ReadM Natural
forall a. Read a => ReadM a
Opt.auto
        (  String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasName f => String -> Mod f a
Opt.long String
"protocol-minor-version"
        Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
Opt.metavar String
"NATURAL"
        Mod OptionFields Natural
-> Mod OptionFields Natural -> Mod OptionFields Natural
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Natural
forall (f :: * -> *) a. String -> Mod f a
Opt.help String
"Minor protocol version. An increase indicates a soft fork\
                    \ (old software canvalidate but not produce new blocks)."
        )

--
-- Shelley CLI flag field parsers
--

parseLovelace :: Atto.Parser Lovelace
parseLovelace :: Parser Lovelace
parseLovelace = Integer -> Lovelace
Lovelace (Integer -> Lovelace)
-> Parser ByteString Integer -> Parser Lovelace
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser ByteString Integer
forall a. Integral a => Parser a
Atto.decimal

parseAddress :: Atto.Parser (Address Shelley)
parseAddress :: Parser ByteString (Address Shelley)
parseAddress = do
    Text
str <- Parser Text
lexPlausibleAddressString
    case AsType (Address Shelley) -> Text -> Maybe (Address Shelley)
forall addr.
SerialiseAddress addr =>
AsType addr -> Text -> Maybe addr
deserialiseAddress AsType (Address Shelley)
AsShelleyAddress Text
str of
      Maybe (Address Shelley)
Nothing   -> String -> Parser ByteString (Address Shelley)
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"invalid address"
      Just Address Shelley
addr -> Address Shelley -> Parser ByteString (Address Shelley)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Address Shelley
addr

parseStakeAddress :: Atto.Parser StakeAddress
parseStakeAddress :: Parser ByteString StakeAddress
parseStakeAddress = do
    Text
str <- Parser Text
lexPlausibleAddressString
    case AsType StakeAddress -> Text -> Maybe StakeAddress
forall addr.
SerialiseAddress addr =>
AsType addr -> Text -> Maybe addr
deserialiseAddress AsType StakeAddress
AsStakeAddress Text
str of
      Maybe StakeAddress
Nothing   -> String -> Parser ByteString StakeAddress
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"invalid address"
      Just StakeAddress
addr -> StakeAddress -> Parser ByteString StakeAddress
forall (f :: * -> *) a. Applicative f => a -> f a
pure StakeAddress
addr

lexPlausibleAddressString :: Atto.Parser Text
lexPlausibleAddressString :: Parser Text
lexPlausibleAddressString =
    ByteString -> Text
Text.decodeLatin1 (ByteString -> Text) -> Parser ByteString -> Parser Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parser ByteString
Atto.takeWhile1 Char -> Bool
isPlausibleAddressChar
  where
    -- Covers both base58 and bech32 (with constrained prefixes)
    isPlausibleAddressChar :: Char -> Bool
isPlausibleAddressChar Char
c =
         (Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= Char
'a' Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
'z')
      Bool -> Bool -> Bool
|| (Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= Char
'A' Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
'Z')
      Bool -> Bool -> Bool
|| (Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= Char
'0' Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
'9')
      Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'_'


--------------------------------------------------------------------------------
-- Helpers
--------------------------------------------------------------------------------

-- | Read a Bech32 or hex-encoded verification key.
readVerificationKey
  :: forall keyrole. SerialiseAsBech32 (VerificationKey keyrole)
  => AsType keyrole
  -> Opt.ReadM (VerificationKey keyrole)
readVerificationKey :: AsType keyrole -> ReadM (VerificationKey keyrole)
readVerificationKey AsType keyrole
asType =
    (String -> Either String (VerificationKey keyrole))
-> ReadM (VerificationKey keyrole)
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader String -> Either String (VerificationKey keyrole)
deserialiseFromBech32OrHex
  where
    keyFormats :: NonEmpty (InputFormat (VerificationKey keyrole))
    keyFormats :: NonEmpty (InputFormat (VerificationKey keyrole))
keyFormats = [InputFormat (VerificationKey keyrole)]
-> NonEmpty (InputFormat (VerificationKey keyrole))
forall a. [a] -> NonEmpty a
NE.fromList [InputFormat (VerificationKey keyrole)
forall a. SerialiseAsBech32 a => InputFormat a
InputFormatBech32, InputFormat (VerificationKey keyrole)
forall a. SerialiseAsRawBytes a => InputFormat a
InputFormatHex]

    deserialiseFromBech32OrHex
      :: String
      -> Either String (VerificationKey keyrole)
    deserialiseFromBech32OrHex :: String -> Either String (VerificationKey keyrole)
deserialiseFromBech32OrHex String
str =
      (InputDecodeError -> String)
-> Either InputDecodeError (VerificationKey keyrole)
-> Either String (VerificationKey keyrole)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first (Text -> String
Text.unpack (Text -> String)
-> (InputDecodeError -> Text) -> InputDecodeError -> String
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. InputDecodeError -> Text
renderInputDecodeError) (Either InputDecodeError (VerificationKey keyrole)
 -> Either String (VerificationKey keyrole))
-> Either InputDecodeError (VerificationKey keyrole)
-> Either String (VerificationKey keyrole)
forall a b. (a -> b) -> a -> b
$
        AsType (VerificationKey keyrole)
-> NonEmpty (InputFormat (VerificationKey keyrole))
-> ByteString
-> Either InputDecodeError (VerificationKey keyrole)
forall a.
AsType a
-> NonEmpty (InputFormat a)
-> ByteString
-> Either InputDecodeError a
deserialiseInput (AsType keyrole -> AsType (VerificationKey keyrole)
forall a. AsType a -> AsType (VerificationKey a)
AsVerificationKey AsType keyrole
asType) NonEmpty (InputFormat (VerificationKey keyrole))
keyFormats (String -> ByteString
BSC.pack String
str)

readOutputFormat :: Opt.ReadM OutputFormat
readOutputFormat :: ReadM OutputFormat
readOutputFormat = do
  String
s <- ReadM String
forall s. IsString s => ReadM s
Opt.str
  case String
s of
    String
"hex" -> OutputFormat -> ReadM OutputFormat
forall (f :: * -> *) a. Applicative f => a -> f a
pure OutputFormat
OutputFormatHex
    String
"bech32" -> OutputFormat -> ReadM OutputFormat
forall (f :: * -> *) a. Applicative f => a -> f a
pure OutputFormat
OutputFormatBech32
    String
_ ->
      String -> ReadM OutputFormat
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> ReadM OutputFormat) -> String -> ReadM OutputFormat
forall a b. (a -> b) -> a -> b
$ String
"Invalid output format: \""
        String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
s
        String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"\". Accepted output formats are \"hex\" and \"bech32\"."

readURIOfMaxLength :: Int -> Opt.ReadM URI
readURIOfMaxLength :: Int -> ReadM URI
readURIOfMaxLength Int
maxLen = do
  String
s <- Int -> ReadM String
readStringOfMaxLength Int
maxLen
  ReadM URI -> (URI -> ReadM URI) -> Maybe URI -> ReadM URI
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> ReadM URI
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"The provided string must be a valid URI.") URI -> ReadM URI
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> Maybe URI
parseURI String
s)

readStringOfMaxLength :: Int -> Opt.ReadM String
readStringOfMaxLength :: Int -> ReadM String
readStringOfMaxLength Int
maxLen = do
  String
s <- ReadM String
forall s. IsString s => ReadM s
Opt.str
  let strLen :: Int
strLen = String -> Int
forall a. HasLength a => a -> Int
length String
s
  if Int
strLen Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
maxLen
    then String -> ReadM String
forall (f :: * -> *) a. Applicative f => a -> f a
pure String
s
    else String -> ReadM String
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> ReadM String) -> String -> ReadM String
forall a b. (a -> b) -> a -> b
$
      String
"The provided string must have at most 64 characters, but it has "
        String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a b. (Show a, ConvertText String b) => a -> b
show Int
strLen
        String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" characters."

readRationalUnitInterval :: Opt.ReadM Rational
readRationalUnitInterval :: ReadM Rational
readRationalUnitInterval = ReadM Rational
readRational ReadM Rational -> (Rational -> ReadM Rational) -> ReadM Rational
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Rational -> ReadM Rational
checkUnitInterval
  where
   checkUnitInterval :: Rational -> Opt.ReadM Rational
   checkUnitInterval :: Rational -> ReadM Rational
checkUnitInterval Rational
q
     | Rational
q Rational -> Rational -> Bool
forall a. Ord a => a -> a -> Bool
>= Rational
0 Bool -> Bool -> Bool
&& Rational
q Rational -> Rational -> Bool
forall a. Ord a => a -> a -> Bool
<= Rational
1 = Rational -> ReadM Rational
forall (m :: * -> *) a. Monad m => a -> m a
return Rational
q
     | Bool
otherwise        = String -> ReadM Rational
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Please enter a value in the range [0,1]"

readRational :: Opt.ReadM Rational
readRational :: ReadM Rational
readRational = Scientific -> Rational
forall a. Real a => a -> Rational
toRational (Scientific -> Rational) -> ReadM Scientific -> ReadM Rational
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Scientific -> ReadM Scientific
forall a. Parser a -> ReadM a
readerFromAttoParser Parser Scientific
Atto.scientific

readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a
readerFromAttoParser :: Parser a -> ReadM a
readerFromAttoParser Parser a
p =
    (String -> Either String a) -> ReadM a
forall a. (String -> Either String a) -> ReadM a
Opt.eitherReader (Parser a -> ByteString -> Either String a
forall a. Parser a -> ByteString -> Either String a
Atto.parseOnly (Parser a
p Parser a -> Parser ByteString () -> Parser a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Parser ByteString ()
forall t. Chunk t => Parser t ()
Atto.endOfInput) (ByteString -> Either String a)
-> (String -> ByteString) -> String -> Either String a
forall k (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k).
Category cat =>
cat b c -> cat a b -> cat a c
. String -> ByteString
BSC.pack)