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

module Cardano.CLI.EraBased.Commands.Governance
  ( GovernanceCmds (..)
  , renderGovernanceCmds
  )
where

import           Cardano.Api
import           Cardano.Api.Ledger (Coin)
import           Cardano.Api.Shelley (VrfKey)

import           Cardano.CLI.EraBased.Commands.Governance.Actions
import           Cardano.CLI.EraBased.Commands.Governance.Committee
import           Cardano.CLI.EraBased.Commands.Governance.DRep
import           Cardano.CLI.EraBased.Commands.Governance.Poll
import           Cardano.CLI.EraBased.Commands.Governance.Vote
import           Cardano.CLI.Types.Key (VerificationKeyOrHashOrFile)

import           Data.Text (Text)

data GovernanceCmds era
  = GovernanceCreateMirCertificateStakeAddressesCmd
      (ShelleyToBabbageEra era)
      MIRPot
      [StakeAddress]
      [Coin]
      (File () Out)
  | GovernanceCreateMirCertificateTransferToTreasuryCmd
      (ShelleyToBabbageEra era)
      Coin
      (File () Out)
  | GovernanceCreateMirCertificateTransferToReservesCmd
      (ShelleyToBabbageEra era)
      Coin
      (File () Out)
  | GovernanceGenesisKeyDelegationCertificate
      (ShelleyToBabbageEra era)
      (VerificationKeyOrHashOrFile GenesisKey)
      (VerificationKeyOrHashOrFile GenesisDelegateKey)
      (VerificationKeyOrHashOrFile VrfKey)
      (File () Out)
  | GovernanceActionCmds
      (GovernanceActionCmds era)
  | GovernanceCommitteeCmds
      (GovernanceCommitteeCmds era)
  | GovernanceDRepCmds
      (GovernanceDRepCmds era)
  | GovernancePollCmds
      (GovernancePollCmds era)
  | GovernanceVoteCmds
      (GovernanceVoteCmds era)

renderGovernanceCmds :: GovernanceCmds era -> Text
renderGovernanceCmds :: forall era. GovernanceCmds era -> Text
renderGovernanceCmds = \case
  GovernanceCreateMirCertificateStakeAddressesCmd{} ->
    Text
"governance create-mir-certificate stake-addresses"
  GovernanceCreateMirCertificateTransferToTreasuryCmd{} ->
    Text
"governance create-mir-certificate transfer-to-treasury"
  GovernanceCreateMirCertificateTransferToReservesCmd{} ->
    Text
"governance create-mir-certificate transfer-to-reserves"
  GovernanceGenesisKeyDelegationCertificate{} ->
    Text
"governance create-genesis-key-delegation-certificate"
  GovernanceActionCmds GovernanceActionCmds era
cmds ->
    GovernanceActionCmds era -> Text
forall era. GovernanceActionCmds era -> Text
renderGovernanceActionCmds GovernanceActionCmds era
cmds
  GovernanceCommitteeCmds GovernanceCommitteeCmds era
cmds ->
    GovernanceCommitteeCmds era -> Text
forall era. GovernanceCommitteeCmds era -> Text
renderGovernanceCommitteeCmds GovernanceCommitteeCmds era
cmds
  GovernanceDRepCmds GovernanceDRepCmds era
cmds ->
    GovernanceDRepCmds era -> Text
forall era. GovernanceDRepCmds era -> Text
renderGovernanceDRepCmds GovernanceDRepCmds era
cmds
  GovernancePollCmds GovernancePollCmds era
cmds ->
    GovernancePollCmds era -> Text
forall era. GovernancePollCmds era -> Text
renderGovernancePollCmds GovernancePollCmds era
cmds
  GovernanceVoteCmds GovernanceVoteCmds era
cmds ->
    GovernanceVoteCmds era -> Text
forall era. GovernanceVoteCmds era -> Text
renderGovernanceVoteCmds GovernanceVoteCmds era
cmds