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

module Cardano.CLI.EraBased.Commands.Governance.Vote
  ( GovernanceVoteCmds (..)
  , GovernanceVoteViewCmdArgs (..)
  , GovernanceVoteCreateCmdArgs (..)
  , renderGovernanceVoteCmds
  )
where

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

import           Cardano.CLI.Types.Common
import           Cardano.CLI.Types.Governance

import           Data.Text (Text)
import           Data.Word

data GovernanceVoteCmds era
  = GovernanceVoteCreateCmd
      (GovernanceVoteCreateCmdArgs era)
  | GovernanceVoteViewCmd
      (GovernanceVoteViewCmdArgs era)

data GovernanceVoteCreateCmdArgs era
  = GovernanceVoteCreateCmdArgs
  { forall era. GovernanceVoteCreateCmdArgs era -> ConwayEraOnwards era
eon :: ConwayEraOnwards era
  , forall era. GovernanceVoteCreateCmdArgs era -> Vote
voteChoice :: Vote
  , forall era. GovernanceVoteCreateCmdArgs era -> (TxId, Word16)
governanceAction :: (TxId, Word16)
  , forall era.
GovernanceVoteCreateCmdArgs era
-> AnyVotingStakeVerificationKeyOrHashOrFile
votingStakeCredentialSource :: AnyVotingStakeVerificationKeyOrHashOrFile
  , forall era.
GovernanceVoteCreateCmdArgs era
-> Maybe
     (PotentiallyCheckedAnchor
        VoteUrl (VoteUrl, SafeHash StandardCrypto AnchorData))
mAnchor
      :: !( Maybe
              ( PotentiallyCheckedAnchor
                  VoteUrl
                  (VoteUrl, L.SafeHash L.StandardCrypto L.AnchorData)
              )
          )
  , forall era. GovernanceVoteCreateCmdArgs era -> VoteFile 'Out
outFile :: VoteFile Out
  }

data GovernanceVoteViewCmdArgs era
  = GovernanceVoteViewCmdArgs
  { forall era. GovernanceVoteViewCmdArgs era -> ConwayEraOnwards era
eon :: ConwayEraOnwards era
  , forall era. GovernanceVoteViewCmdArgs era -> ViewOutputFormat
outFormat :: !ViewOutputFormat
  , forall era. GovernanceVoteViewCmdArgs era -> VoteFile 'In
voteFile :: VoteFile In
  , forall era. GovernanceVoteViewCmdArgs era -> Maybe (File () 'Out)
mOutFile :: Maybe (File () Out)
  }

renderGovernanceVoteCmds
  :: ()
  => GovernanceVoteCmds era
  -> Text
renderGovernanceVoteCmds :: forall era. GovernanceVoteCmds era -> Text
renderGovernanceVoteCmds = \case
  GovernanceVoteCreateCmd{} ->
    Text
"governance vote create"
  GovernanceVoteViewCmd{} ->
    Text
"governance vote view"