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

module Cardano.CLI.EraBased.Commands.Governance.Poll
  ( GovernancePollCmds (..)
  , renderGovernancePollCmds
  , GovernanceCreatePollCmdArgs (..)
  , GovernanceAnswerPollCmdArgs (..)
  , GovernanceVerifyPollCmdArgs (..)
  )
where

import           Cardano.Api
import           Cardano.Api.Shelley

import           Data.Text (Text)

data GovernancePollCmds era
  = GovernanceCreatePoll !(GovernanceCreatePollCmdArgs era)
  | GovernanceAnswerPoll !(GovernanceAnswerPollCmdArgs era)
  | GovernanceVerifyPoll !(GovernanceVerifyPollCmdArgs era)

-- | Create a SPO poll
data GovernanceCreatePollCmdArgs era
  = GovernanceCreatePollCmdArgs
  { forall era.
GovernanceCreatePollCmdArgs era -> BabbageEraOnwards era
eon :: !(BabbageEraOnwards era)
  , forall era. GovernanceCreatePollCmdArgs era -> Text
prompt :: !Text
  , forall era. GovernanceCreatePollCmdArgs era -> [Text]
choices :: ![Text]
  , forall era. GovernanceCreatePollCmdArgs era -> Maybe Word
nonce :: !(Maybe Word)
  , forall era.
GovernanceCreatePollCmdArgs era -> File GovernancePoll 'Out
outFile :: !(File GovernancePoll Out)
  }
  deriving (GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
(GovernanceCreatePollCmdArgs era
 -> GovernanceCreatePollCmdArgs era -> Bool)
-> (GovernanceCreatePollCmdArgs era
    -> GovernanceCreatePollCmdArgs era -> Bool)
-> Eq (GovernanceCreatePollCmdArgs era)
forall era.
GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era.
GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
== :: GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
$c/= :: forall era.
GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
/= :: GovernanceCreatePollCmdArgs era
-> GovernanceCreatePollCmdArgs era -> Bool
Eq, Int -> GovernanceCreatePollCmdArgs era -> ShowS
[GovernanceCreatePollCmdArgs era] -> ShowS
GovernanceCreatePollCmdArgs era -> String
(Int -> GovernanceCreatePollCmdArgs era -> ShowS)
-> (GovernanceCreatePollCmdArgs era -> String)
-> ([GovernanceCreatePollCmdArgs era] -> ShowS)
-> Show (GovernanceCreatePollCmdArgs era)
forall era. Int -> GovernanceCreatePollCmdArgs era -> ShowS
forall era. [GovernanceCreatePollCmdArgs era] -> ShowS
forall era. GovernanceCreatePollCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceCreatePollCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceCreatePollCmdArgs era -> ShowS
$cshow :: forall era. GovernanceCreatePollCmdArgs era -> String
show :: GovernanceCreatePollCmdArgs era -> String
$cshowList :: forall era. [GovernanceCreatePollCmdArgs era] -> ShowS
showList :: [GovernanceCreatePollCmdArgs era] -> ShowS
Show)

-- | Answer a SPO poll
data GovernanceAnswerPollCmdArgs era
  = GovernanceAnswerPollCmdArgs
  { forall era.
GovernanceAnswerPollCmdArgs era -> BabbageEraOnwards era
eon :: !(BabbageEraOnwards era)
  , forall era.
GovernanceAnswerPollCmdArgs era -> File GovernancePoll 'In
pollFile :: !(File GovernancePoll In)
  , forall era. GovernanceAnswerPollCmdArgs era -> Maybe Word
answerIndex :: !(Maybe Word)
  , forall era. GovernanceAnswerPollCmdArgs era -> Maybe (File () 'Out)
mOutFile :: !(Maybe (File () Out))
  }
  deriving (GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
(GovernanceAnswerPollCmdArgs era
 -> GovernanceAnswerPollCmdArgs era -> Bool)
-> (GovernanceAnswerPollCmdArgs era
    -> GovernanceAnswerPollCmdArgs era -> Bool)
-> Eq (GovernanceAnswerPollCmdArgs era)
forall era.
GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era.
GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
== :: GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
$c/= :: forall era.
GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
/= :: GovernanceAnswerPollCmdArgs era
-> GovernanceAnswerPollCmdArgs era -> Bool
Eq, Int -> GovernanceAnswerPollCmdArgs era -> ShowS
[GovernanceAnswerPollCmdArgs era] -> ShowS
GovernanceAnswerPollCmdArgs era -> String
(Int -> GovernanceAnswerPollCmdArgs era -> ShowS)
-> (GovernanceAnswerPollCmdArgs era -> String)
-> ([GovernanceAnswerPollCmdArgs era] -> ShowS)
-> Show (GovernanceAnswerPollCmdArgs era)
forall era. Int -> GovernanceAnswerPollCmdArgs era -> ShowS
forall era. [GovernanceAnswerPollCmdArgs era] -> ShowS
forall era. GovernanceAnswerPollCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceAnswerPollCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceAnswerPollCmdArgs era -> ShowS
$cshow :: forall era. GovernanceAnswerPollCmdArgs era -> String
show :: GovernanceAnswerPollCmdArgs era -> String
$cshowList :: forall era. [GovernanceAnswerPollCmdArgs era] -> ShowS
showList :: [GovernanceAnswerPollCmdArgs era] -> ShowS
Show)

-- | Verify answer to a given SPO poll
data GovernanceVerifyPollCmdArgs era
  = GovernanceVerifyPollCmdArgs
  { forall era.
GovernanceVerifyPollCmdArgs era -> BabbageEraOnwards era
eon :: !(BabbageEraOnwards era)
  , forall era.
GovernanceVerifyPollCmdArgs era -> File GovernancePoll 'In
pollFile :: !(File GovernancePoll In)
  , forall era. GovernanceVerifyPollCmdArgs era -> File (Tx ()) 'In
txFile :: !(File (Tx ()) In)
  , forall era. GovernanceVerifyPollCmdArgs era -> Maybe (File () 'Out)
mOutFile :: !(Maybe (File () Out))
  }
  deriving (GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
(GovernanceVerifyPollCmdArgs era
 -> GovernanceVerifyPollCmdArgs era -> Bool)
-> (GovernanceVerifyPollCmdArgs era
    -> GovernanceVerifyPollCmdArgs era -> Bool)
-> Eq (GovernanceVerifyPollCmdArgs era)
forall era.
GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall era.
GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
== :: GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
$c/= :: forall era.
GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
/= :: GovernanceVerifyPollCmdArgs era
-> GovernanceVerifyPollCmdArgs era -> Bool
Eq, Int -> GovernanceVerifyPollCmdArgs era -> ShowS
[GovernanceVerifyPollCmdArgs era] -> ShowS
GovernanceVerifyPollCmdArgs era -> String
(Int -> GovernanceVerifyPollCmdArgs era -> ShowS)
-> (GovernanceVerifyPollCmdArgs era -> String)
-> ([GovernanceVerifyPollCmdArgs era] -> ShowS)
-> Show (GovernanceVerifyPollCmdArgs era)
forall era. Int -> GovernanceVerifyPollCmdArgs era -> ShowS
forall era. [GovernanceVerifyPollCmdArgs era] -> ShowS
forall era. GovernanceVerifyPollCmdArgs era -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall era. Int -> GovernanceVerifyPollCmdArgs era -> ShowS
showsPrec :: Int -> GovernanceVerifyPollCmdArgs era -> ShowS
$cshow :: forall era. GovernanceVerifyPollCmdArgs era -> String
show :: GovernanceVerifyPollCmdArgs era -> String
$cshowList :: forall era. [GovernanceVerifyPollCmdArgs era] -> ShowS
showList :: [GovernanceVerifyPollCmdArgs era] -> ShowS
Show)

renderGovernancePollCmds
  :: ()
  => GovernancePollCmds era
  -> Text
renderGovernancePollCmds :: forall era. GovernancePollCmds era -> Text
renderGovernancePollCmds = \case
  GovernanceCreatePoll{} -> Text
"governance create-poll"
  GovernanceAnswerPoll{} -> Text
"governance answer-poll"
  GovernanceVerifyPoll{} -> Text
"governance verify-poll"