{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}

module Cardano.CLI.Byron.Commands
  ( ByronCommand (..)
  , NodeCmds (..)
  , VerificationKeyFile
  , NewVerificationKeyFile (..)
  , CertificateFile (..)
  , NewCertificateFile (..)
  )
where

import           Cardano.Api hiding (GenesisParameters)
import qualified Cardano.Api.Byron as Byron

import           Cardano.CLI.Byron.Genesis
import           Cardano.CLI.Byron.Key
import           Cardano.CLI.Byron.Tx
import           Cardano.CLI.Types.Common

import           Data.String (IsString)

data ByronCommand
  = --- Node Related Commands ---
    NodeCmds
      NodeCmds
  | --- Genesis Related Commands ---
    Genesis
      NewDirectory
      GenesisParameters
  | PrintGenesisHash
      GenesisFile
  | --- Key Related Commands ---
    Keygen
      NewSigningKeyFile
  | ToVerification
      ByronKeyFormat
      (SigningKeyFile In)
      NewVerificationKeyFile
  | PrettySigningKeyPublic
      ByronKeyFormat
      (SigningKeyFile In)
  | MigrateDelegateKeyFrom
      (SigningKeyFile In)
      -- ^ Old key
      NewSigningKeyFile
      -- ^ New Key
  | PrintSigningKeyAddress
      ByronKeyFormat
      NetworkId
      (SigningKeyFile In)
  | -----------------------------------

    -- | Filepath of transaction to submit.
    SubmitTx
      SocketPath
      NetworkId
      (TxFile In)
  | SpendGenesisUTxO
      GenesisFile
      NetworkId
      ByronKeyFormat
      NewTxFile
      -- ^ Filepath of the newly created transaction.
      (SigningKeyFile In)
      -- ^ Signing key of genesis UTxO owner.
      (Address ByronAddr)
      -- ^ Genesis UTxO address.
      [TxOut CtxTx ByronEra]
      -- ^ Tx output.
  | SpendUTxO
      NetworkId
      ByronKeyFormat
      NewTxFile
      -- ^ Filepath of the newly created transaction.
      (SigningKeyFile In)
      -- ^ Signing key of Tx underwriter.
      [TxIn]
      -- ^ Inputs available for spending to the Tx underwriter's key.
      [TxOut CtxTx ByronEra]
      -- ^ Genesis UTxO output Address.
  | GetTxId (TxFile In)
  | --- Misc Commands ---

    ValidateCBOR
      CBORObject
      -- ^ Type of the CBOR object
      FilePath
  | PrettyPrintCBOR
      FilePath
  deriving Int -> ByronCommand -> ShowS
[ByronCommand] -> ShowS
ByronCommand -> String
(Int -> ByronCommand -> ShowS)
-> (ByronCommand -> String)
-> ([ByronCommand] -> ShowS)
-> Show ByronCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ByronCommand -> ShowS
showsPrec :: Int -> ByronCommand -> ShowS
$cshow :: ByronCommand -> String
show :: ByronCommand -> String
$cshowList :: [ByronCommand] -> ShowS
showList :: [ByronCommand] -> ShowS
Show

data NodeCmds
  = CreateVote
      NetworkId
      (SigningKeyFile In)
      FilePath
      -- ^ filepath to update proposal
      Bool
      FilePath
  | UpdateProposal
      NetworkId
      (SigningKeyFile In)
      Byron.ProtocolVersion
      Byron.SoftwareVersion
      Byron.SystemTag
      Byron.InstallerHash
      FilePath
      Byron.ByronProtocolParametersUpdate
  | -- | Update proposal filepath.
    SubmitUpdateProposal
      SocketPath
      NetworkId
      FilePath
  | -- | Vote filepath.
    SubmitVote
      SocketPath
      NetworkId
      FilePath
  deriving Int -> NodeCmds -> ShowS
[NodeCmds] -> ShowS
NodeCmds -> String
(Int -> NodeCmds -> ShowS)
-> (NodeCmds -> String) -> ([NodeCmds] -> ShowS) -> Show NodeCmds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NodeCmds -> ShowS
showsPrec :: Int -> NodeCmds -> ShowS
$cshow :: NodeCmds -> String
show :: NodeCmds -> String
$cshowList :: [NodeCmds] -> ShowS
showList :: [NodeCmds] -> ShowS
Show

newtype NewCertificateFile
  = NewCertificateFile {NewCertificateFile -> String
nFp :: FilePath}
  deriving (NewCertificateFile -> NewCertificateFile -> Bool
(NewCertificateFile -> NewCertificateFile -> Bool)
-> (NewCertificateFile -> NewCertificateFile -> Bool)
-> Eq NewCertificateFile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NewCertificateFile -> NewCertificateFile -> Bool
== :: NewCertificateFile -> NewCertificateFile -> Bool
$c/= :: NewCertificateFile -> NewCertificateFile -> Bool
/= :: NewCertificateFile -> NewCertificateFile -> Bool
Eq, Int -> NewCertificateFile -> ShowS
[NewCertificateFile] -> ShowS
NewCertificateFile -> String
(Int -> NewCertificateFile -> ShowS)
-> (NewCertificateFile -> String)
-> ([NewCertificateFile] -> ShowS)
-> Show NewCertificateFile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NewCertificateFile -> ShowS
showsPrec :: Int -> NewCertificateFile -> ShowS
$cshow :: NewCertificateFile -> String
show :: NewCertificateFile -> String
$cshowList :: [NewCertificateFile] -> ShowS
showList :: [NewCertificateFile] -> ShowS
Show, String -> NewCertificateFile
(String -> NewCertificateFile) -> IsString NewCertificateFile
forall a. (String -> a) -> IsString a
$cfromString :: String -> NewCertificateFile
fromString :: String -> NewCertificateFile
IsString)