{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ScopedTypeVariables #-}

{- HLINT ignore "Use <$>" -}
{- HLINT ignore "Move brackets to avoid $" -}

module Cardano.CLI.EraBased.Options.StakePool
  ( pStakePoolCmds
  )
where

import           Cardano.Api
import qualified Cardano.Api.Ledger as L
import           Cardano.Api.Shelley (Hash (StakePoolMetadataHash))

import qualified Cardano.CLI.Commands.Hash as Cmd
import           Cardano.CLI.Environment (EnvCli (..))
import qualified Cardano.CLI.EraBased.Commands.StakePool as Cmd
import           Cardano.CLI.EraBased.Options.Common
import           Cardano.CLI.Parser

import qualified Data.Foldable as F
import           Options.Applicative hiding (help, str)
import qualified Options.Applicative as Opt

pStakePoolCmds
  :: ()
  => ShelleyBasedEra era
  -> EnvCli
  -> Maybe (Parser (Cmd.StakePoolCmds era))
pStakePoolCmds :: forall era.
ShelleyBasedEra era -> EnvCli -> Maybe (Parser (StakePoolCmds era))
pStakePoolCmds ShelleyBasedEra era
era EnvCli
envCli =
  String
-> InfoMod (StakePoolCmds era)
-> [Maybe (Parser (StakePoolCmds era))]
-> Maybe (Parser (StakePoolCmds era))
forall a.
String -> InfoMod a -> [Maybe (Parser a)] -> Maybe (Parser a)
subInfoParser
    String
"stake-pool"
    ( String -> InfoMod (StakePoolCmds era)
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod (StakePoolCmds era))
-> String -> InfoMod (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
        [String] -> String
forall a. Monoid a => [a] -> a
mconcat
          [ String
"Stake pool commands."
          ]
    )
    [ ShelleyBasedEra era -> EnvCli -> Maybe (Parser (StakePoolCmds era))
forall era.
ShelleyBasedEra era -> EnvCli -> Maybe (Parser (StakePoolCmds era))
pStakePoolRegistrationCertificateCmd ShelleyBasedEra era
era EnvCli
envCli
    , ShelleyBasedEra era -> Maybe (Parser (StakePoolCmds era))
forall era.
ShelleyBasedEra era -> Maybe (Parser (StakePoolCmds era))
pStakePoolDeregistrationCertificateCmd ShelleyBasedEra era
era
    , Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a. a -> Maybe a
Just (Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era)))
-> Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a b. (a -> b) -> a -> b
$
        String
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"id" (ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era))
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
          Parser (StakePoolCmds era)
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser (StakePoolCmds era)
forall era. Parser (StakePoolCmds era)
pStakePoolId (InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era))
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod (StakePoolCmds era)
forall a. String -> InfoMod a
Opt.progDesc String
"Build pool id from the offline key"
    , Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a. a -> Maybe a
Just (Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era)))
-> Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a b. (a -> b) -> a -> b
$
        String
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"metadata-hash" (ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era))
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
          Parser (StakePoolCmds era)
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info Parser (StakePoolCmds era)
forall era. Parser (StakePoolCmds era)
pStakePoolMetadataHashCmd (InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era))
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
            String -> InfoMod (StakePoolCmds era)
forall a. String -> InfoMod a
Opt.progDesc
              ( String
"Calculate the hash of a stake pool metadata file,"
                  String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" optionally checking the obtained hash against an expected value."
              )
    ]

pStakePoolId
  :: ()
  => Parser (Cmd.StakePoolCmds era)
pStakePoolId :: forall era. Parser (StakePoolCmds era)
pStakePoolId =
  (StakePoolIdCmdArgs era -> StakePoolCmds era)
-> Parser (StakePoolIdCmdArgs era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StakePoolIdCmdArgs era -> StakePoolCmds era
forall era. StakePoolIdCmdArgs era -> StakePoolCmds era
Cmd.StakePoolIdCmd (Parser (StakePoolIdCmdArgs era) -> Parser (StakePoolCmds era))
-> Parser (StakePoolIdCmdArgs era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
    VerificationKeyOrFile StakePoolKey
-> IdOutputFormat -> Maybe (File () 'Out) -> StakePoolIdCmdArgs era
forall era.
VerificationKeyOrFile StakePoolKey
-> IdOutputFormat -> Maybe (File () 'Out) -> StakePoolIdCmdArgs era
Cmd.StakePoolIdCmdArgs
      (VerificationKeyOrFile StakePoolKey
 -> IdOutputFormat
 -> Maybe (File () 'Out)
 -> StakePoolIdCmdArgs era)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser
     (IdOutputFormat -> Maybe (File () 'Out) -> StakePoolIdCmdArgs era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String -> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile Maybe String
forall a. Maybe a
Nothing
      Parser
  (IdOutputFormat -> Maybe (File () 'Out) -> StakePoolIdCmdArgs era)
-> Parser IdOutputFormat
-> Parser (Maybe (File () 'Out) -> StakePoolIdCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser IdOutputFormat
pPoolIdOutputFormat
      Parser (Maybe (File () 'Out) -> StakePoolIdCmdArgs era)
-> Parser (Maybe (File () 'Out)) -> Parser (StakePoolIdCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe (File () 'Out))
forall content. Parser (Maybe (File content 'Out))
pMaybeOutputFile

pStakePoolMetadataHashCmd
  :: ()
  => Parser (Cmd.StakePoolCmds era)
pStakePoolMetadataHashCmd :: forall era. Parser (StakePoolCmds era)
pStakePoolMetadataHashCmd =
  (StakePoolMetadataHashCmdArgs era -> StakePoolCmds era)
-> Parser (StakePoolMetadataHashCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StakePoolMetadataHashCmdArgs era -> StakePoolCmds era
forall era. StakePoolMetadataHashCmdArgs era -> StakePoolCmds era
Cmd.StakePoolMetadataHashCmd (Parser (StakePoolMetadataHashCmdArgs era)
 -> Parser (StakePoolCmds era))
-> Parser (StakePoolMetadataHashCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
    StakePoolMetadataSource
-> HashGoal (Hash StakePoolMetadata)
-> StakePoolMetadataHashCmdArgs era
forall era.
StakePoolMetadataSource
-> HashGoal (Hash StakePoolMetadata)
-> StakePoolMetadataHashCmdArgs era
Cmd.StakePoolMetadataHashCmdArgs
      (StakePoolMetadataSource
 -> HashGoal (Hash StakePoolMetadata)
 -> StakePoolMetadataHashCmdArgs era)
-> Parser StakePoolMetadataSource
-> Parser
     (HashGoal (Hash StakePoolMetadata)
      -> StakePoolMetadataHashCmdArgs era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser StakePoolMetadataSource
pPoolMetadataSource
      Parser
  (HashGoal (Hash StakePoolMetadata)
   -> StakePoolMetadataHashCmdArgs era)
-> Parser (HashGoal (Hash StakePoolMetadata))
-> Parser (StakePoolMetadataHashCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (HashGoal (Hash StakePoolMetadata))
pPoolMetadataHashGoal

pPoolMetadataSource :: Parser Cmd.StakePoolMetadataSource
pPoolMetadataSource :: Parser StakePoolMetadataSource
pPoolMetadataSource =
  [Parser StakePoolMetadataSource] -> Parser StakePoolMetadataSource
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
F.asum
    [ StakePoolMetadataFile 'In -> StakePoolMetadataSource
Cmd.StakePoolMetadataFileIn (StakePoolMetadataFile 'In -> StakePoolMetadataSource)
-> Parser (StakePoolMetadataFile 'In)
-> Parser StakePoolMetadataSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (StakePoolMetadataFile 'In)
pPoolMetadataFile
    , Url -> StakePoolMetadataSource
Cmd.StakePoolMetadataURL
        (Url -> StakePoolMetadataSource)
-> Parser Url -> Parser StakePoolMetadataSource
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> String -> Parser Url
pUrl String
"pool-metadata-url" String
"URL pointing to the JSON Metadata file to hash."
    ]

pPoolMetadataHashGoal :: Parser (Cmd.HashGoal (Hash StakePoolMetadata))
pPoolMetadataHashGoal :: Parser (HashGoal (Hash StakePoolMetadata))
pPoolMetadataHashGoal =
  [Parser (HashGoal (Hash StakePoolMetadata))]
-> Parser (HashGoal (Hash StakePoolMetadata))
forall (t :: * -> *) (f :: * -> *) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
F.asum
    [ Hash StakePoolMetadata -> HashGoal (Hash StakePoolMetadata)
forall hash. hash -> HashGoal hash
Cmd.CheckHash (Hash StakePoolMetadata -> HashGoal (Hash StakePoolMetadata))
-> Parser (Hash StakePoolMetadata)
-> Parser (HashGoal (Hash StakePoolMetadata))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (Hash StakePoolMetadata)
pExpectedStakePoolMetadataHash
    , File () 'Out -> HashGoal (Hash StakePoolMetadata)
forall hash. File () 'Out -> HashGoal hash
Cmd.HashToFile (File () 'Out -> HashGoal (Hash StakePoolMetadata))
-> Parser (File () 'Out)
-> Parser (HashGoal (Hash StakePoolMetadata))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser (File () 'Out)
forall content. Parser (File content 'Out)
pOutputFile
    ]
    Parser (HashGoal (Hash StakePoolMetadata))
-> Parser (HashGoal (Hash StakePoolMetadata))
-> Parser (HashGoal (Hash StakePoolMetadata))
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> HashGoal (Hash StakePoolMetadata)
-> Parser (HashGoal (Hash StakePoolMetadata))
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure HashGoal (Hash StakePoolMetadata)
forall hash. HashGoal hash
Cmd.HashToStdout

pExpectedStakePoolMetadataHash :: Parser (Hash StakePoolMetadata)
pExpectedStakePoolMetadataHash :: Parser (Hash StakePoolMetadata)
pExpectedStakePoolMetadataHash =
  (SafeHash StandardCrypto AnchorData -> Hash StakePoolMetadata)
-> String -> Parser (Hash StakePoolMetadata)
forall a.
(SafeHash StandardCrypto AnchorData -> a) -> String -> Parser a
pExpectedHash (Hash Blake2b_256 ByteString -> Hash StakePoolMetadata
Hash StandardCrypto ByteString -> Hash StakePoolMetadata
StakePoolMetadataHash (Hash Blake2b_256 ByteString -> Hash StakePoolMetadata)
-> (SafeHash StandardCrypto AnchorData
    -> Hash Blake2b_256 ByteString)
-> SafeHash StandardCrypto AnchorData
-> Hash StakePoolMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SafeHash StandardCrypto ByteString -> Hash Blake2b_256 ByteString
SafeHash StandardCrypto ByteString
-> Hash StandardCrypto ByteString
forall c i. SafeHash c i -> Hash (HASH c) i
L.extractHash (SafeHash StandardCrypto ByteString -> Hash Blake2b_256 ByteString)
-> (SafeHash StandardCrypto AnchorData
    -> SafeHash StandardCrypto ByteString)
-> SafeHash StandardCrypto AnchorData
-> Hash Blake2b_256 ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SafeHash StandardCrypto AnchorData
-> SafeHash StandardCrypto ByteString
forall i j c. SafeHash c i -> SafeHash c j
L.castSafeHash) String
"stake pool metadata"

pStakePoolRegistrationCertificateCmd
  :: ()
  => ShelleyBasedEra era
  -> EnvCli
  -> Maybe (Parser (Cmd.StakePoolCmds era))
pStakePoolRegistrationCertificateCmd :: forall era.
ShelleyBasedEra era -> EnvCli -> Maybe (Parser (StakePoolCmds era))
pStakePoolRegistrationCertificateCmd ShelleyBasedEra era
era EnvCli
envCli = do
  ShelleyBasedEra era
w <- ShelleyBasedEra era -> Maybe (ShelleyBasedEra era)
forall (eon :: * -> *) era.
Eon eon =>
ShelleyBasedEra era -> Maybe (eon era)
forShelleyBasedEraMaybeEon ShelleyBasedEra era
era
  Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era)))
-> Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a b. (a -> b) -> a -> b
$ String
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"registration-certificate"
    (ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era))
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$ Parser (StakePoolCmds era)
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info
      ( (StakePoolRegistrationCertificateCmdArgs era -> StakePoolCmds era)
-> Parser (StakePoolRegistrationCertificateCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StakePoolRegistrationCertificateCmdArgs era -> StakePoolCmds era
forall era.
StakePoolRegistrationCertificateCmdArgs era -> StakePoolCmds era
Cmd.StakePoolRegistrationCertificateCmd (Parser (StakePoolRegistrationCertificateCmdArgs era)
 -> Parser (StakePoolCmds era))
-> Parser (StakePoolRegistrationCertificateCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
          ShelleyBasedEra era
-> VerificationKeyOrFile StakePoolKey
-> VerificationKeyOrFile VrfKey
-> Coin
-> Coin
-> Rational
-> VerificationKeyOrFile StakeKey
-> [VerificationKeyOrFile StakeKey]
-> [StakePoolRelay]
-> Maybe
     (PotentiallyCheckedAnchor
        StakePoolMetadataReference StakePoolMetadataReference)
-> NetworkId
-> File () 'Out
-> StakePoolRegistrationCertificateCmdArgs era
forall era.
ShelleyBasedEra era
-> VerificationKeyOrFile StakePoolKey
-> VerificationKeyOrFile VrfKey
-> Coin
-> Coin
-> Rational
-> VerificationKeyOrFile StakeKey
-> [VerificationKeyOrFile StakeKey]
-> [StakePoolRelay]
-> Maybe
     (PotentiallyCheckedAnchor
        StakePoolMetadataReference StakePoolMetadataReference)
-> NetworkId
-> File () 'Out
-> StakePoolRegistrationCertificateCmdArgs era
Cmd.StakePoolRegistrationCertificateCmdArgs ShelleyBasedEra era
w
            (VerificationKeyOrFile StakePoolKey
 -> VerificationKeyOrFile VrfKey
 -> Coin
 -> Coin
 -> Rational
 -> VerificationKeyOrFile StakeKey
 -> [VerificationKeyOrFile StakeKey]
 -> [StakePoolRelay]
 -> Maybe
      (PotentiallyCheckedAnchor
         StakePoolMetadataReference StakePoolMetadataReference)
 -> NetworkId
 -> File () 'Out
 -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser
     (VerificationKeyOrFile VrfKey
      -> Coin
      -> Coin
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String -> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile Maybe String
forall a. Maybe a
Nothing
            Parser
  (VerificationKeyOrFile VrfKey
   -> Coin
   -> Coin
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser (VerificationKeyOrFile VrfKey)
-> Parser
     (Coin
      -> Coin
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile VrfKey)
pVrfVerificationKeyOrFile
            Parser
  (Coin
   -> Coin
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser Coin
-> Parser
     (Coin
      -> Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Coin
pPoolPledge
            Parser
  (Coin
   -> Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser Coin
-> Parser
     (Rational
      -> VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Coin
pPoolCost
            Parser
  (Rational
   -> VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser Rational
-> Parser
     (VerificationKeyOrFile StakeKey
      -> [VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Rational
pPoolMargin
            Parser
  (VerificationKeyOrFile StakeKey
   -> [VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser (VerificationKeyOrFile StakeKey)
-> Parser
     ([VerificationKeyOrFile StakeKey]
      -> [StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile StakeKey)
pRewardAcctVerificationKeyOrFile
            Parser
  ([VerificationKeyOrFile StakeKey]
   -> [StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser [VerificationKeyOrFile StakeKey]
-> Parser
     ([StakePoolRelay]
      -> Maybe
           (PotentiallyCheckedAnchor
              StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (VerificationKeyOrFile StakeKey)
-> Parser [VerificationKeyOrFile StakeKey]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some Parser (VerificationKeyOrFile StakeKey)
pPoolOwnerVerificationKeyOrFile
            Parser
  ([StakePoolRelay]
   -> Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser [StakePoolRelay]
-> Parser
     (Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference)
      -> NetworkId
      -> File () 'Out
      -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser StakePoolRelay -> Parser [StakePoolRelay]
forall a. Parser a -> Parser [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many Parser StakePoolRelay
pPoolRelay
            Parser
  (Maybe
     (PotentiallyCheckedAnchor
        StakePoolMetadataReference StakePoolMetadataReference)
   -> NetworkId
   -> File () 'Out
   -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser
     (Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference))
-> Parser
     (NetworkId
      -> File () 'Out -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser
  (PotentiallyCheckedAnchor
     StakePoolMetadataReference StakePoolMetadataReference)
-> Parser
     (Maybe
        (PotentiallyCheckedAnchor
           StakePoolMetadataReference StakePoolMetadataReference))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional
              ( Parser (MustCheckHash StakePoolMetadataReference)
-> Parser StakePoolMetadataReference
-> Parser
     (PotentiallyCheckedAnchor
        StakePoolMetadataReference StakePoolMetadataReference)
forall anchorType anchor.
Parser (MustCheckHash anchorType)
-> Parser anchor
-> Parser (PotentiallyCheckedAnchor anchorType anchor)
pPotentiallyCheckedAnchorData
                  Parser (MustCheckHash StakePoolMetadataReference)
pMustCheckStakeMetadataHash
                  Parser StakePoolMetadataReference
pStakePoolMetadataReference
              )
            Parser
  (NetworkId
   -> File () 'Out -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser NetworkId
-> Parser
     (File () 'Out -> StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> EnvCli -> Parser NetworkId
pNetworkId EnvCli
envCli
            Parser
  (File () 'Out -> StakePoolRegistrationCertificateCmdArgs era)
-> Parser (File () 'Out)
-> Parser (StakePoolRegistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (File () 'Out)
forall content. Parser (File content 'Out)
pOutputFile
      )
    (InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era))
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$ String -> InfoMod (StakePoolCmds era)
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake pool registration certificate"

pStakePoolDeregistrationCertificateCmd
  :: ()
  => ShelleyBasedEra era
  -> Maybe (Parser (Cmd.StakePoolCmds era))
pStakePoolDeregistrationCertificateCmd :: forall era.
ShelleyBasedEra era -> Maybe (Parser (StakePoolCmds era))
pStakePoolDeregistrationCertificateCmd ShelleyBasedEra era
era = do
  ShelleyBasedEra era
w <- ShelleyBasedEra era -> Maybe (ShelleyBasedEra era)
forall (eon :: * -> *) era.
Eon eon =>
ShelleyBasedEra era -> Maybe (eon era)
forShelleyBasedEraMaybeEon ShelleyBasedEra era
era
  Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era)))
-> Parser (StakePoolCmds era) -> Maybe (Parser (StakePoolCmds era))
forall a b. (a -> b) -> a -> b
$ String
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a. String -> ParserInfo a -> Parser a
subParser String
"deregistration-certificate"
    (ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era))
-> ParserInfo (StakePoolCmds era) -> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$ Parser (StakePoolCmds era)
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info
      ( (StakePoolDeregistrationCertificateCmdArgs era
 -> StakePoolCmds era)
-> Parser (StakePoolDeregistrationCertificateCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap StakePoolDeregistrationCertificateCmdArgs era -> StakePoolCmds era
forall era.
StakePoolDeregistrationCertificateCmdArgs era -> StakePoolCmds era
Cmd.StakePoolDeregistrationCertificateCmd (Parser (StakePoolDeregistrationCertificateCmdArgs era)
 -> Parser (StakePoolCmds era))
-> Parser (StakePoolDeregistrationCertificateCmdArgs era)
-> Parser (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$
          ShelleyBasedEra era
-> VerificationKeyOrFile StakePoolKey
-> EpochNo
-> File () 'Out
-> StakePoolDeregistrationCertificateCmdArgs era
forall era.
ShelleyBasedEra era
-> VerificationKeyOrFile StakePoolKey
-> EpochNo
-> File () 'Out
-> StakePoolDeregistrationCertificateCmdArgs era
Cmd.StakePoolDeregistrationCertificateCmdArgs ShelleyBasedEra era
w
            (VerificationKeyOrFile StakePoolKey
 -> EpochNo
 -> File () 'Out
 -> StakePoolDeregistrationCertificateCmdArgs era)
-> Parser (VerificationKeyOrFile StakePoolKey)
-> Parser
     (EpochNo
      -> File () 'Out -> StakePoolDeregistrationCertificateCmdArgs era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String -> Parser (VerificationKeyOrFile StakePoolKey)
pStakePoolVerificationKeyOrFile Maybe String
forall a. Maybe a
Nothing
            Parser
  (EpochNo
   -> File () 'Out -> StakePoolDeregistrationCertificateCmdArgs era)
-> Parser EpochNo
-> Parser
     (File () 'Out -> StakePoolDeregistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> String -> Parser EpochNo
pEpochNo String
"The epoch number."
            Parser
  (File () 'Out -> StakePoolDeregistrationCertificateCmdArgs era)
-> Parser (File () 'Out)
-> Parser (StakePoolDeregistrationCertificateCmdArgs era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (File () 'Out)
forall content. Parser (File content 'Out)
pOutputFile
      )
    (InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era))
-> InfoMod (StakePoolCmds era) -> ParserInfo (StakePoolCmds era)
forall a b. (a -> b) -> a -> b
$ String -> InfoMod (StakePoolCmds era)
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake pool deregistration certificate"