{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}

module Cardano.CLI.Compatible.StakeAddress.Option
  ( pCompatibleStakeAddressCmds
  )
where

import Cardano.Api

import Cardano.CLI.Compatible.StakeAddress.Command
import Cardano.CLI.EraBased.Common.Option
import Cardano.CLI.Parser

import Options.Applicative
import Options.Applicative qualified as Opt

pCompatibleStakeAddressCmds
  :: ()
  => ShelleyBasedEra era
  -> Maybe (Parser (CompatibleStakeAddressCmds era))
pCompatibleStakeAddressCmds :: forall era.
ShelleyBasedEra era
-> Maybe (Parser (CompatibleStakeAddressCmds era))
pCompatibleStakeAddressCmds ShelleyBasedEra era
era =
  String
-> InfoMod (CompatibleStakeAddressCmds era)
-> [Maybe (Parser (CompatibleStakeAddressCmds era))]
-> Maybe (Parser (CompatibleStakeAddressCmds era))
forall a.
String -> InfoMod a -> [Maybe (Parser a)] -> Maybe (Parser a)
subInfoParser
    String
"stake-address"
    ( String -> InfoMod (CompatibleStakeAddressCmds era)
forall a. String -> InfoMod a
Opt.progDesc (String -> InfoMod (CompatibleStakeAddressCmds era))
-> String -> InfoMod (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$
        [String] -> String
forall a. Monoid a => [a] -> a
mconcat
          [ String
"Stake address commands."
          ]
    )
    [ Parser (CompatibleStakeAddressCmds era)
-> Maybe (Parser (CompatibleStakeAddressCmds era))
forall a. a -> Maybe a
Just (Parser (CompatibleStakeAddressCmds era)
 -> Maybe (Parser (CompatibleStakeAddressCmds era)))
-> Parser (CompatibleStakeAddressCmds era)
-> Maybe (Parser (CompatibleStakeAddressCmds era))
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
forall era.
ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressRegistrationCertificateCmd ShelleyBasedEra era
era
    , Parser (CompatibleStakeAddressCmds era)
-> Maybe (Parser (CompatibleStakeAddressCmds era))
forall a. a -> Maybe a
Just (Parser (CompatibleStakeAddressCmds era)
 -> Maybe (Parser (CompatibleStakeAddressCmds era)))
-> Parser (CompatibleStakeAddressCmds era)
-> Maybe (Parser (CompatibleStakeAddressCmds era))
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
forall era.
ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressStakeDelegationCertificateCmd ShelleyBasedEra era
era
    ]

pStakeAddressRegistrationCertificateCmd
  :: ()
  => ShelleyBasedEra era
  -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressRegistrationCertificateCmd :: forall era.
ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressRegistrationCertificateCmd ShelleyBasedEra era
sbe = do
  Mod CommandFields (CompatibleStakeAddressCmds era)
-> Parser (CompatibleStakeAddressCmds era)
forall a. Mod CommandFields a -> Parser a
Opt.hsubparser (Mod CommandFields (CompatibleStakeAddressCmds era)
 -> Parser (CompatibleStakeAddressCmds era))
-> Mod CommandFields (CompatibleStakeAddressCmds era)
-> Parser (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$
    String
-> ParserInfo (CompatibleStakeAddressCmds era)
-> Mod CommandFields (CompatibleStakeAddressCmds era)
forall a. String -> ParserInfo a -> Mod CommandFields a
commandWithMetavar String
"registration-certificate" (ParserInfo (CompatibleStakeAddressCmds era)
 -> Mod CommandFields (CompatibleStakeAddressCmds era))
-> ParserInfo (CompatibleStakeAddressCmds era)
-> Mod CommandFields (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$
      Parser (CompatibleStakeAddressCmds era)
-> InfoMod (CompatibleStakeAddressCmds era)
-> ParserInfo (CompatibleStakeAddressCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info
        ( ShelleyBasedEra era
-> StakeIdentifier
-> Maybe (Featured ConwayEraOnwards era Coin)
-> File () 'Out
-> CompatibleStakeAddressCmds era
forall era.
ShelleyBasedEra era
-> StakeIdentifier
-> Maybe (Featured ConwayEraOnwards era Coin)
-> File () 'Out
-> CompatibleStakeAddressCmds era
CompatibleStakeAddressRegistrationCertificateCmd ShelleyBasedEra era
sbe
            (StakeIdentifier
 -> Maybe (Featured ConwayEraOnwards era Coin)
 -> File () 'Out
 -> CompatibleStakeAddressCmds era)
-> Parser StakeIdentifier
-> Parser
     (Maybe (Featured ConwayEraOnwards era Coin)
      -> File () 'Out -> CompatibleStakeAddressCmds era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String -> Parser StakeIdentifier
pStakeIdentifier Maybe String
forall a. Maybe a
Nothing
            Parser
  (Maybe (Featured ConwayEraOnwards era Coin)
   -> File () 'Out -> CompatibleStakeAddressCmds era)
-> Parser (Maybe (Featured ConwayEraOnwards era Coin))
-> Parser (File () 'Out -> CompatibleStakeAddressCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CardanoEra era
-> Parser Coin
-> Parser (Maybe (Featured ConwayEraOnwards era Coin))
forall (eon :: * -> *) (f :: * -> *) era a.
(Eon eon, ToCardanoEra f) =>
f era -> Parser a -> Parser (Maybe (Featured eon era a))
pFeatured (ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe) Parser Coin
pKeyRegistDeposit
            Parser (File () 'Out -> CompatibleStakeAddressCmds era)
-> Parser (File () 'Out) -> Parser (CompatibleStakeAddressCmds 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 (CompatibleStakeAddressCmds era)
forall {a}. InfoMod a
desc
 where
  desc :: InfoMod a
desc = String -> InfoMod a
forall a. String -> InfoMod a
Opt.progDesc String
"Create a stake address registration certificate"

pStakeAddressStakeDelegationCertificateCmd
  :: ()
  => ShelleyBasedEra era
  -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressStakeDelegationCertificateCmd :: forall era.
ShelleyBasedEra era -> Parser (CompatibleStakeAddressCmds era)
pStakeAddressStakeDelegationCertificateCmd ShelleyBasedEra era
sbe = do
  Mod CommandFields (CompatibleStakeAddressCmds era)
-> Parser (CompatibleStakeAddressCmds era)
forall a. Mod CommandFields a -> Parser a
Opt.hsubparser
    (Mod CommandFields (CompatibleStakeAddressCmds era)
 -> Parser (CompatibleStakeAddressCmds era))
-> Mod CommandFields (CompatibleStakeAddressCmds era)
-> Parser (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$ String
-> ParserInfo (CompatibleStakeAddressCmds era)
-> Mod CommandFields (CompatibleStakeAddressCmds era)
forall a. String -> ParserInfo a -> Mod CommandFields a
commandWithMetavar String
"stake-delegation-certificate"
    (ParserInfo (CompatibleStakeAddressCmds era)
 -> Mod CommandFields (CompatibleStakeAddressCmds era))
-> ParserInfo (CompatibleStakeAddressCmds era)
-> Mod CommandFields (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$ Parser (CompatibleStakeAddressCmds era)
-> InfoMod (CompatibleStakeAddressCmds era)
-> ParserInfo (CompatibleStakeAddressCmds era)
forall a. Parser a -> InfoMod a -> ParserInfo a
Opt.info
      ( ShelleyBasedEra era
-> StakeIdentifier
-> VerificationKeyOrHashOrFile StakePoolKey
-> File () 'Out
-> CompatibleStakeAddressCmds era
forall era.
ShelleyBasedEra era
-> StakeIdentifier
-> VerificationKeyOrHashOrFile StakePoolKey
-> File () 'Out
-> CompatibleStakeAddressCmds era
CompatibleStakeAddressStakeDelegationCertificateCmd ShelleyBasedEra era
sbe
          (StakeIdentifier
 -> VerificationKeyOrHashOrFile StakePoolKey
 -> File () 'Out
 -> CompatibleStakeAddressCmds era)
-> Parser StakeIdentifier
-> Parser
     (VerificationKeyOrHashOrFile StakePoolKey
      -> File () 'Out -> CompatibleStakeAddressCmds era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe String -> Parser StakeIdentifier
pStakeIdentifier Maybe String
forall a. Maybe a
Nothing
          Parser
  (VerificationKeyOrHashOrFile StakePoolKey
   -> File () 'Out -> CompatibleStakeAddressCmds era)
-> Parser (VerificationKeyOrHashOrFile StakePoolKey)
-> Parser (File () 'Out -> CompatibleStakeAddressCmds era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe String -> Parser (VerificationKeyOrHashOrFile StakePoolKey)
pStakePoolVerificationKeyOrHashOrFile Maybe String
forall a. Maybe a
Nothing
          Parser (File () 'Out -> CompatibleStakeAddressCmds era)
-> Parser (File () 'Out) -> Parser (CompatibleStakeAddressCmds 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 (CompatibleStakeAddressCmds era)
 -> ParserInfo (CompatibleStakeAddressCmds era))
-> InfoMod (CompatibleStakeAddressCmds era)
-> ParserInfo (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$ String -> InfoMod (CompatibleStakeAddressCmds era)
forall a. String -> InfoMod a
Opt.progDesc
    (String -> InfoMod (CompatibleStakeAddressCmds era))
-> String -> InfoMod (CompatibleStakeAddressCmds era)
forall a b. (a -> b) -> a -> b
$ [String] -> String
forall a. Monoid a => [a] -> a
mconcat
      [ String
"Create a stake address stake delegation certificate, which when submitted in a transaction "
      , String
"delegates stake to a stake pool."
      ]