From 6a46d9ae491efbd959643eea635e8c272c72c408 Mon Sep 17 00:00:00 2001 From: John Ky Date: Tue, 18 Apr 2023 13:32:27 +1000 Subject: [PATCH] Use existing types instead of "Of" types. --- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 4 +-- .../src/Cardano/CLI/Shelley/Commands.hs | 6 ++-- .../src/Cardano/CLI/Shelley/Run/Genesis.hs | 36 +++++++++---------- cardano-cli/src/Cardano/CLI/Types.hs | 24 ++++--------- 4 files changed, 30 insertions(+), 40 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 209d96d074e..7d5eca9394a 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -5,7 +5,7 @@ module Cardano.CLI.Byron.Tx ( ByronTxError(..) - , OfTx + , Tx , TxFile , NewTxFile(..) , prettyAddress @@ -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 (..)) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Commands.hs b/cardano-cli/src/Cardano/CLI/Shelley/Commands.hs index a8ea4336743..a9866211d09 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Commands.hs @@ -24,7 +24,7 @@ module Cardano.CLI.Shelley.Commands , ByronKeyFormat (..) , CardanoAddressKeyType (..) , GenesisDir (..) - , OfOpCertCounter + , OpCertCounter , TxInCount (..) , TxOutCount (..) , TxShelleyWitnessCount (..) @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs index 631f8811f16..2006caf14c1 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs @@ -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) @@ -856,8 +856,8 @@ 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 () @@ -865,8 +865,8 @@ 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 () @@ -874,8 +874,8 @@ 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 @@ -883,12 +883,12 @@ createPoolCredentials dir index = do 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 @@ -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 diff --git a/cardano-cli/src/Cardano/CLI/Types.hs b/cardano-cli/src/Cardano/CLI/Types.hs index c21cf0c1c05..78c2dd06096 100644 --- a/cardano-cli/src/Cardano/CLI/Types.hs +++ b/cardano-cli/src/Cardano/CLI/Types.hs @@ -12,8 +12,6 @@ module Cardano.CLI.Types , CurrentKesPeriod (..) , EpochLeadershipSchedule (..) , GenesisFile (..) - , OfSigningKey - , OfVerificationKey , OpCertEndingKesPeriod (..) , OpCertIntervalInformation (..) , OpCertOnDiskCounter (..) @@ -31,12 +29,10 @@ module Cardano.CLI.Types , ScriptDatumOrFile (..) , SlotsTillKesKeyExpiry (..) , TransferDirection(..) - , OfTxBody , TxBodyFile , TxOutAnyEra (..) , TxOutChangeAddress (..) , TxOutDatumAnyEra (..) - , OfTx , TxFile , TxMempoolQuery (..) , UpdateProposalFile (..) @@ -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 @@ -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) @@ -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