{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.EraBased.Commands.Governance.Committee
  ( GovernanceCommitteeCmds (..)
  , GovernanceCommitteeKeyGenColdCmdArgs (..)
  , GovernanceCommitteeKeyGenHotCmdArgs (..)
  , GovernanceCommitteeKeyHashCmdArgs (..)
  , GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs (..)
  , GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs (..)
  , renderGovernanceCommitteeCmds
  )
where

import           Cardano.Api
import qualified Cardano.Api.Ledger as L
import           Cardano.Api.Shelley

import           Cardano.CLI.Types.Common (PotentiallyCheckedAnchor, ResignationMetadataUrl)
import           Cardano.CLI.Types.Key
import           Cardano.CLI.Types.Key.VerificationKey

import           Data.Text (Text)

data GovernanceCommitteeCmds era
  = GovernanceCommitteeKeyGenColdCmd
      (GovernanceCommitteeKeyGenColdCmdArgs era)
  | GovernanceCommitteeKeyGenHotCmd
      (GovernanceCommitteeKeyGenHotCmdArgs era)
  | GovernanceCommitteeKeyHashCmd
      (GovernanceCommitteeKeyHashCmdArgs era)
  | GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd
      (GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era)
  | GovernanceCommitteeCreateColdKeyResignationCertificateCmd
      (GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era)
  deriving Int -> GovernanceCommitteeCmds era -> ShowS
[GovernanceCommitteeCmds era] -> ShowS
GovernanceCommitteeCmds era -> String
(Int -> GovernanceCommitteeCmds era -> ShowS)
-> (GovernanceCommitteeCmds era -> String)
-> ([GovernanceCommitteeCmds era] -> ShowS)
-> Show (GovernanceCommitteeCmds era)
forall era. Int -> GovernanceCommitteeCmds era -> ShowS
forall era. [GovernanceCommitteeCmds era] -> ShowS
forall era. GovernanceCommitteeCmds era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceCommitteeCmds era -> ShowS
showsPrec :: Int -> GovernanceCommitteeCmds era -> ShowS
$cshow :: forall era. GovernanceCommitteeCmds era -> String
show :: GovernanceCommitteeCmds era -> String
$cshowList :: forall era. [GovernanceCommitteeCmds era] -> ShowS
showList :: [GovernanceCommitteeCmds era] -> ShowS
Show

data GovernanceCommitteeKeyGenColdCmdArgs era
  = GovernanceCommitteeKeyGenColdCmdArgs
  { forall era.
GovernanceCommitteeKeyGenColdCmdArgs era -> ConwayEraOnwards era
eon :: !(ConwayEraOnwards era)
  , forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> File (VerificationKey ()) 'Out
vkeyOutFile :: !(File (VerificationKey ()) Out)
  , forall era.
GovernanceCommitteeKeyGenColdCmdArgs era
-> File (SigningKey ()) 'Out
skeyOutFile :: !(File (SigningKey ()) Out)
  }
  deriving Int -> GovernanceCommitteeKeyGenColdCmdArgs era -> ShowS
[GovernanceCommitteeKeyGenColdCmdArgs era] -> ShowS
GovernanceCommitteeKeyGenColdCmdArgs era -> String
(Int -> GovernanceCommitteeKeyGenColdCmdArgs era -> ShowS)
-> (GovernanceCommitteeKeyGenColdCmdArgs era -> String)
-> ([GovernanceCommitteeKeyGenColdCmdArgs era] -> ShowS)
-> Show (GovernanceCommitteeKeyGenColdCmdArgs era)
forall era.
Int -> GovernanceCommitteeKeyGenColdCmdArgs era -> ShowS
forall era. [GovernanceCommitteeKeyGenColdCmdArgs era] -> ShowS
forall era. GovernanceCommitteeKeyGenColdCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era.
Int -> GovernanceCommitteeKeyGenColdCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceCommitteeKeyGenColdCmdArgs era -> ShowS
$cshow :: forall era. GovernanceCommitteeKeyGenColdCmdArgs era -> String
show :: GovernanceCommitteeKeyGenColdCmdArgs era -> String
$cshowList :: forall era. [GovernanceCommitteeKeyGenColdCmdArgs era] -> ShowS
showList :: [GovernanceCommitteeKeyGenColdCmdArgs era] -> ShowS
Show

data GovernanceCommitteeKeyGenHotCmdArgs era
  = GovernanceCommitteeKeyGenHotCmdArgs
  { forall era.
GovernanceCommitteeKeyGenHotCmdArgs era -> ConwayEraOnwards era
eon :: !(ConwayEraOnwards era)
  , forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> File (VerificationKey ()) 'Out
vkeyOutFile :: !(File (VerificationKey ()) Out)
  , forall era.
GovernanceCommitteeKeyGenHotCmdArgs era
-> File (SigningKey ()) 'Out
skeyOutFile :: !(File (SigningKey ()) Out)
  }
  deriving Int -> GovernanceCommitteeKeyGenHotCmdArgs era -> ShowS
[GovernanceCommitteeKeyGenHotCmdArgs era] -> ShowS
GovernanceCommitteeKeyGenHotCmdArgs era -> String
(Int -> GovernanceCommitteeKeyGenHotCmdArgs era -> ShowS)
-> (GovernanceCommitteeKeyGenHotCmdArgs era -> String)
-> ([GovernanceCommitteeKeyGenHotCmdArgs era] -> ShowS)
-> Show (GovernanceCommitteeKeyGenHotCmdArgs era)
forall era. Int -> GovernanceCommitteeKeyGenHotCmdArgs era -> ShowS
forall era. [GovernanceCommitteeKeyGenHotCmdArgs era] -> ShowS
forall era. GovernanceCommitteeKeyGenHotCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceCommitteeKeyGenHotCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceCommitteeKeyGenHotCmdArgs era -> ShowS
$cshow :: forall era. GovernanceCommitteeKeyGenHotCmdArgs era -> String
show :: GovernanceCommitteeKeyGenHotCmdArgs era -> String
$cshowList :: forall era. [GovernanceCommitteeKeyGenHotCmdArgs era] -> ShowS
showList :: [GovernanceCommitteeKeyGenHotCmdArgs era] -> ShowS
Show

data GovernanceCommitteeKeyHashCmdArgs era
  = GovernanceCommitteeKeyHashCmdArgs
  { forall era.
GovernanceCommitteeKeyHashCmdArgs era -> ConwayEraOnwards era
eon :: !(ConwayEraOnwards era)
  , forall era.
GovernanceCommitteeKeyHashCmdArgs era -> AnyVerificationKeySource
vkeySource :: !AnyVerificationKeySource
  }
  deriving Int -> GovernanceCommitteeKeyHashCmdArgs era -> ShowS
[GovernanceCommitteeKeyHashCmdArgs era] -> ShowS
GovernanceCommitteeKeyHashCmdArgs era -> String
(Int -> GovernanceCommitteeKeyHashCmdArgs era -> ShowS)
-> (GovernanceCommitteeKeyHashCmdArgs era -> String)
-> ([GovernanceCommitteeKeyHashCmdArgs era] -> ShowS)
-> Show (GovernanceCommitteeKeyHashCmdArgs era)
forall era. Int -> GovernanceCommitteeKeyHashCmdArgs era -> ShowS
forall era. [GovernanceCommitteeKeyHashCmdArgs era] -> ShowS
forall era. GovernanceCommitteeKeyHashCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceCommitteeKeyHashCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceCommitteeKeyHashCmdArgs era -> ShowS
$cshow :: forall era. GovernanceCommitteeKeyHashCmdArgs era -> String
show :: GovernanceCommitteeKeyHashCmdArgs era -> String
$cshowList :: forall era. [GovernanceCommitteeKeyHashCmdArgs era] -> ShowS
showList :: [GovernanceCommitteeKeyHashCmdArgs era] -> ShowS
Show

data GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
  = GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
  { forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> ConwayEraOnwards era
eon :: !(ConwayEraOnwards era)
  , forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: !(VerificationKeySource CommitteeColdKey)
  , forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> VerificationKeySource CommitteeHotKey
vkeyHotKeySource :: !(VerificationKeySource CommitteeHotKey)
  , forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> File () 'Out
outFile :: !(File () Out)
  }
  deriving Int
-> GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
     era
-> ShowS
[GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
   era]
-> ShowS
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> String
(Int
 -> GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
      era
 -> ShowS)
-> (GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
      era
    -> String)
-> ([GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
       era]
    -> ShowS)
-> Show
     (GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
        era)
forall era.
Int
-> GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
     era
-> ShowS
forall era.
[GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
   era]
-> ShowS
forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era.
Int
-> GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
     era
-> ShowS
showsPrec :: Int
-> GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
     era
-> ShowS
$cshow :: forall era.
GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> String
show :: GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs era
-> String
$cshowList :: forall era.
[GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
   era]
-> ShowS
showList :: [GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmdArgs
   era]
-> ShowS
Show

data GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
  = GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
  { forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> ConwayEraOnwards era
eon :: !(ConwayEraOnwards era)
  , forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> VerificationKeySource CommitteeColdKey
vkeyColdKeySource :: !(VerificationKeySource CommitteeColdKey)
  , forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> Maybe
     (PotentiallyCheckedAnchor
        ResignationMetadataUrl (Anchor (EraCrypto (ShelleyLedgerEra era))))
anchor
      :: !( Maybe
              ( PotentiallyCheckedAnchor
                  ResignationMetadataUrl
                  (L.Anchor (L.EraCrypto (ShelleyLedgerEra era)))
              )
          )
  , forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> File () 'Out
outFile :: !(File () Out)
  }
  deriving Int
-> GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
     era
-> ShowS
[GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era]
-> ShowS
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> String
(Int
 -> GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
      era
 -> ShowS)
-> (GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
      era
    -> String)
-> ([GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
       era]
    -> ShowS)
-> Show
     (GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era)
forall era.
Int
-> GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
     era
-> ShowS
forall era.
[GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era]
-> ShowS
forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era.
Int
-> GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
     era
-> ShowS
showsPrec :: Int
-> GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
     era
-> ShowS
$cshow :: forall era.
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> String
show :: GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era
-> String
$cshowList :: forall era.
[GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era]
-> ShowS
showList :: [GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era]
-> ShowS
Show

renderGovernanceCommitteeCmds :: GovernanceCommitteeCmds era -> Text
renderGovernanceCommitteeCmds :: forall era. GovernanceCommitteeCmds era -> Text
renderGovernanceCommitteeCmds =
  (Text
"governance committee " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>) (Text -> Text)
-> (GovernanceCommitteeCmds era -> Text)
-> GovernanceCommitteeCmds era
-> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \case
    GovernanceCommitteeKeyGenColdCmd{} ->
      Text
"key-gen-cold"
    GovernanceCommitteeKeyGenHotCmd{} ->
      Text
"key-gen-hot"
    GovernanceCommitteeKeyHashCmd{} ->
      Text
"key-hash"
    GovernanceCommitteeCreateHotKeyAuthorizationCertificateCmd{} ->
      Text
"create-hot-key-authorization-certificate"
    GovernanceCommitteeCreateColdKeyResignationCertificateCmd{} ->
      Text
"create-cold-key-resignation-certificate"