Skip to content

Commit

Permalink
Use existing types instead of "Of" types.
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Apr 18, 2023
1 parent 948bc61 commit 6a46d9a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

module Cardano.CLI.Byron.Tx
( ByronTxError(..)
, OfTx
, Tx
, TxFile
, NewTxFile(..)
, prettyAddress
Expand Down Expand Up @@ -53,7 +53,7 @@ import qualified Cardano.Crypto.Signing as Crypto

import Cardano.Api.Byron
import Cardano.CLI.Byron.Key (byronWitnessToVerKey)
import Cardano.CLI.Types (OfTx, TxFile)
import Cardano.CLI.Types (TxFile)
import Ouroboros.Consensus.Byron.Ledger (ByronBlock, GenTx (..))
import qualified Ouroboros.Consensus.Byron.Ledger as Byron
import Ouroboros.Consensus.Cardano.Block (EraMismatch (..))
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/Shelley/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Cardano.CLI.Shelley.Commands
, ByronKeyFormat (..)
, CardanoAddressKeyType (..)
, GenesisDir (..)
, OfOpCertCounter
, OpCertCounter
, TxInCount (..)
, TxOutCount (..)
, TxShelleyWitnessCount (..)
Expand Down Expand Up @@ -559,9 +559,9 @@ data CardanoAddressKeyType
| CardanoAddressByronPaymentKey
deriving Show

data OfOpCertCounter
data OpCertCounter

type OpCertCounterFile = File OfOpCertCounter
type OpCertCounterFile = File OpCertCounter

newtype PrivKeyFile
= PrivKeyFile FilePath
Expand Down
36 changes: 18 additions & 18 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -838,16 +838,16 @@ createDelegateKeys :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createDelegateKeys dir index = do
liftIO $ createDirectoryIfMissing False dir
runGenesisKeyGenDelegate
(File @OfVerificationKey $ dir </> "delegate" ++ strIndex ++ ".vkey")
(File @(VerificationKey ()) $ dir </> "delegate" ++ strIndex ++ ".vkey")
(onlyOut coldSK)
(onlyOut opCertCtr)
runGenesisKeyGenDelegateVRF
(File @OfVerificationKey $ dir </> "delegate" ++ strIndex ++ ".vrf.vkey")
(File @OfSigningKey $ dir </> "delegate" ++ strIndex ++ ".vrf.skey")
(File @(VerificationKey ()) $ dir </> "delegate" ++ strIndex ++ ".vrf.vkey")
(File @(SigningKey ()) $ dir </> "delegate" ++ strIndex ++ ".vrf.skey")
firstExceptT ShelleyGenesisCmdNodeCmdError $ do
runNodeKeyGenKES
(onlyOut kesVK)
(File @OfSigningKey $ dir </> "delegate" ++ strIndex ++ ".kes.skey")
(File @(SigningKey ()) $ dir </> "delegate" ++ strIndex ++ ".kes.skey")
runNodeIssueOpCert
(VerificationKeyFilePath (onlyIn kesVK))
(onlyIn coldSK)
Expand All @@ -856,39 +856,39 @@ createDelegateKeys dir index = do
(File $ dir </> "opcert" ++ strIndex ++ ".cert")
where
strIndex = show index
kesVK = File @OfVerificationKey $ dir </> "delegate" ++ strIndex ++ ".kes.vkey"
coldSK = File @OfSigningKey $ dir </> "delegate" ++ strIndex ++ ".skey"
kesVK = File @(VerificationKey ()) $ dir </> "delegate" ++ strIndex ++ ".kes.vkey"
coldSK = File @(SigningKey ()) $ dir </> "delegate" ++ strIndex ++ ".skey"
opCertCtr = File $ dir </> "delegate" ++ strIndex ++ ".counter"

createGenesisKeys :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createGenesisKeys dir index = do
liftIO $ createDirectoryIfMissing False dir
let strIndex = show index
runGenesisKeyGenGenesis
(File @OfVerificationKey $ dir </> "genesis" ++ strIndex ++ ".vkey")
(File @OfSigningKey $ dir </> "genesis" ++ strIndex ++ ".skey")
(File @(VerificationKey ()) $ dir </> "genesis" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "genesis" ++ strIndex ++ ".skey")


createUtxoKeys :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createUtxoKeys dir index = do
liftIO $ createDirectoryIfMissing False dir
let strIndex = show index
runGenesisKeyGenUTxO
(File @OfVerificationKey $ dir </> "utxo" ++ strIndex ++ ".vkey")
(File @OfSigningKey $ dir </> "utxo" ++ strIndex ++ ".skey")
(File @(VerificationKey ()) $ dir </> "utxo" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "utxo" ++ strIndex ++ ".skey")

createPoolCredentials :: FilePath -> Word -> ExceptT ShelleyGenesisCmdError IO ()
createPoolCredentials dir index = do
liftIO $ createDirectoryIfMissing False dir
firstExceptT ShelleyGenesisCmdNodeCmdError $ do
runNodeKeyGenKES
(onlyOut kesVK)
(File @OfSigningKey $ dir </> "kes" ++ strIndex ++ ".skey")
(File @(SigningKey ()) $ dir </> "kes" ++ strIndex ++ ".skey")
runNodeKeyGenVRF
(File @OfVerificationKey $ dir </> "vrf" ++ strIndex ++ ".vkey")
(File @OfSigningKey $ dir </> "vrf" ++ strIndex ++ ".skey")
(File @(VerificationKey ()) $ dir </> "vrf" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "vrf" ++ strIndex ++ ".skey")
runNodeKeyGenCold
(File @OfVerificationKey $ dir </> "cold" ++ strIndex ++ ".vkey")
(File @(VerificationKey ()) $ dir </> "cold" ++ strIndex ++ ".vkey")
(onlyOut coldSK)
(onlyOut opCertCtr)
runNodeIssueOpCert
Expand All @@ -899,12 +899,12 @@ createPoolCredentials dir index = do
(File $ dir </> "opcert" ++ strIndex ++ ".cert")
firstExceptT ShelleyGenesisCmdStakeAddressCmdError $
runStakeAddressKeyGenToFile
(File @OfVerificationKey $ dir </> "staking-reward" ++ strIndex ++ ".vkey")
(File @OfSigningKey $ dir </> "staking-reward" ++ strIndex ++ ".skey")
(File @(VerificationKey ()) $ dir </> "staking-reward" ++ strIndex ++ ".vkey")
(File @(SigningKey ()) $ dir </> "staking-reward" ++ strIndex ++ ".skey")
where
strIndex = show index
kesVK = File @OfVerificationKey $ dir </> "kes" ++ strIndex ++ ".vkey"
coldSK = File @OfSigningKey $ dir </> "cold" ++ strIndex ++ ".skey"
kesVK = File @(VerificationKey ()) $ dir </> "kes" ++ strIndex ++ ".vkey"
coldSK = File @(SigningKey ()) $ dir </> "cold" ++ strIndex ++ ".skey"
opCertCtr = File $ dir </> "opcert" ++ strIndex ++ ".counter"

data Delegation = Delegation
Expand Down
24 changes: 7 additions & 17 deletions cardano-cli/src/Cardano/CLI/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ module Cardano.CLI.Types
, CurrentKesPeriod (..)
, EpochLeadershipSchedule (..)
, GenesisFile (..)
, OfSigningKey
, OfVerificationKey
, OpCertEndingKesPeriod (..)
, OpCertIntervalInformation (..)
, OpCertOnDiskCounter (..)
Expand All @@ -31,12 +29,10 @@ module Cardano.CLI.Types
, ScriptDatumOrFile (..)
, SlotsTillKesKeyExpiry (..)
, TransferDirection(..)
, OfTxBody
, TxBodyFile
, TxOutAnyEra (..)
, TxOutChangeAddress (..)
, TxOutDatumAnyEra (..)
, OfTx
, TxFile
, TxMempoolQuery (..)
, UpdateProposalFile (..)
Expand All @@ -57,8 +53,9 @@ import Data.Word (Word64)
import qualified Cardano.Chain.Slotting as Byron

import Cardano.Api (AddressAny, AnyScriptLanguage, EpochNo, ExecutionUnits, File (..),
FileDirection (..), Hash, HashableScriptData, PaymentKey, PolicyId, ScriptData,
SlotNo (SlotNo), TxId, TxIn, Value, WitCtxMint, WitCtxStake, WitCtxTxIn)
FileDirection (..), Hash, HashableScriptData, Key (..), PaymentKey, PolicyId,
ScriptData, SlotNo (SlotNo), Tx, TxBody, TxId, TxIn, Value, WitCtxMint,
WitCtxStake, WitCtxTxIn)

import qualified Cardano.Ledger.Crypto as Crypto

Expand Down Expand Up @@ -227,16 +224,12 @@ instance Crypto.Crypto crypto => ToJSON (Params crypto) where
, "retiring" .= r
]

data OfSigningKey

type SigningKeyFile = File OfSigningKey
type SigningKeyFile = File (SigningKey ())

newtype UpdateProposalFile = UpdateProposalFile { unUpdateProposalFile :: FilePath }
deriving newtype (Eq, Show)

data OfVerificationKey

type VerificationKeyFile = File OfVerificationKey
type VerificationKeyFile = File (VerificationKey ())

newtype ScriptFile = ScriptFile { unScriptFile :: FilePath }
deriving (Eq, Show)
Expand Down Expand Up @@ -357,12 +350,9 @@ data EpochLeadershipSchedule
| NextEpoch
deriving Show

data OfTxBody
type TxBodyFile = File OfTxBody

data OfTx
type TxBodyFile = File (TxBody ())

type TxFile = File OfTx
type TxFile = File (Tx ())

data TxMempoolQuery =
TxMempoolQueryTxExists TxId
Expand Down

0 comments on commit 6a46d9a

Please sign in to comment.