From df149dd97da455d669e0edb21a042d9ae5e8dd91 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 27 Sep 2024 22:23:53 +0200 Subject: [PATCH] Remove direct dependencies from `cardano-ledger-byron` --- cardano-cli/cardano-cli.cabal | 2 - cardano-cli/src/Cardano/CLI/Byron/Commands.hs | 9 +- .../src/Cardano/CLI/Byron/Delegation.hs | 40 ++++---- cardano-cli/src/Cardano/CLI/Byron/Genesis.hs | 76 +++++++-------- cardano-cli/src/Cardano/CLI/Byron/Key.hs | 4 +- cardano-cli/src/Cardano/CLI/Byron/Parsers.hs | 96 +++++++++---------- cardano-cli/src/Cardano/CLI/Byron/Run.hs | 8 +- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 47 +++++---- .../src/Cardano/CLI/Byron/UpdateProposal.hs | 12 +-- .../Cardano/CLI/EraBased/Commands/Genesis.hs | 3 +- .../Cardano/CLI/EraBased/Options/Genesis.hs | 3 +- .../src/Cardano/CLI/EraBased/Run/Genesis.hs | 48 ++++------ .../Cardano/CLI/EraBased/Run/Transaction.hs | 9 +- cardano-cli/src/Cardano/CLI/Helpers.hs | 15 ++- .../Cardano/CLI/Legacy/Commands/Genesis.hs | 3 +- cardano-cli/src/Cardano/CLI/Legacy/Options.hs | 3 +- .../src/Cardano/CLI/Legacy/Run/Genesis.hs | 3 +- cardano-cli/src/Cardano/CLI/Types/Common.hs | 4 +- .../Test/Golden/Byron/Tx.hs | 2 +- 19 files changed, 173 insertions(+), 214 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 055e18b008..10ee0d8214 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -204,7 +204,6 @@ library cardano-data >=1.1, cardano-git-rev ^>=0.2.2, cardano-ledger-api, - cardano-ledger-byron >=1.0.1.0, cardano-ledger-core, cardano-ledger-shelley, cardano-ping ^>=0.4, @@ -373,7 +372,6 @@ test-suite cardano-cli-golden cardano-cli, cardano-cli:cardano-cli-test-lib, cardano-crypto-wrapper, - cardano-ledger-byron, cardano-ledger-shelley >=1.10.0.0, cardano-strict-containers ^>=0.1, cborg, diff --git a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs index 84d077774d..1462cb46f6 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs @@ -13,9 +13,8 @@ where import Cardano.Api hiding (GenesisParameters) import Cardano.Api.Byron hiding (GenesisParameters) +import qualified Cardano.Api.Ledger as L -import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..), - SoftwareVersion (..), SystemTag (..)) import Cardano.CLI.Byron.Genesis import Cardano.CLI.Byron.Key import Cardano.CLI.Byron.Tx @@ -105,9 +104,9 @@ data NodeCmds NetworkId (SigningKeyFile In) ProtocolVersion - SoftwareVersion - SystemTag - InstallerHash + L.SoftwareVersion + L.SystemTag + L.InstallerHash FilePath ByronProtocolParametersUpdate | -- | Update proposal filepath. diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index 40002fbf4a..bbbc1214a7 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -16,8 +16,6 @@ where import Cardano.Api.Byron import qualified Cardano.Api.Ledger as L -import qualified Cardano.Chain.Delegation as Dlg -import Cardano.Chain.Slotting (EpochNumber) import Cardano.CLI.Byron.Key (ByronKeyFailure, renderByronKeyFailure) import Cardano.CLI.Types.Common (CertificateFile (..)) import Cardano.Crypto (ProtocolMagicId) @@ -54,12 +52,12 @@ renderByronDelegationError = \case -- issuer key, for a given protocol magic and coming into effect at given epoch. issueByronGenesisDelegation :: ProtocolMagicId - -> EpochNumber + -> L.EpochNumber -> Crypto.SigningKey -> Crypto.VerificationKey - -> Dlg.Certificate -issueByronGenesisDelegation magic epoch issuerSK delegateVK = - Dlg.signCertificate magic delegateVK epoch $ + -> L.Certificate +issueByronGenesisDelegation magic epoch issuerSK delegateVK' = + signCertificate magic delegateVK' epoch $ Crypto.noPassSafeSigner issuerSK -- | Verify that a certificate signifies genesis delegation by assumed genesis key @@ -75,14 +73,14 @@ checkByronGenesisDelegation (CertificateFile certF) magic issuer delegate = do ecert <- liftIO $ canonicalDecodePretty <$> LB.readFile certF case ecert of Left e -> left $ DlgCertificateDeserialisationFailed certF e - Right (cert :: Dlg.Certificate) -> do + Right (cert :: L.Certificate) -> do let issues = checkDlgCert cert magic issuer delegate unless (null issues) $ left $ CertificateValidationErrors certF issues checkDlgCert - :: Dlg.ACertificate a + :: ACertificate a -> ProtocolMagicId -> Crypto.VerificationKey -> Crypto.VerificationKey @@ -90,44 +88,44 @@ checkDlgCert checkDlgCert cert magic issuerVK' delegateVK' = mconcat [ [ sformat "Certificate does not have a valid signature." - | not (Dlg.isValid magic' cert') + | not (isValid magic' cert') ] , [ sformat ("Certificate issuer " . vkF . " doesn't match expected: " . vkF) - (Dlg.issuerVK cert) + (issuerVK cert) issuerVK' - | Dlg.issuerVK cert /= issuerVK' + | issuerVK cert /= issuerVK' ] , [ sformat ("Certificate delegate " . vkF . " doesn't match expected: " . vkF) - (Dlg.delegateVK cert) + (delegateVK cert) delegateVK' - | Dlg.delegateVK cert /= delegateVK' + | delegateVK cert /= delegateVK' ] ] where magic' :: L.Annotated ProtocolMagicId ByteString magic' = L.Annotated magic (L.serialize' L.byronProtVer magic) - epoch :: EpochNumber - epoch = L.unAnnotated $ Dlg.aEpoch cert + epoch :: L.EpochNumber + epoch = L.unAnnotated $ aEpoch cert - cert' :: Dlg.ACertificate ByteString + cert' :: ACertificate ByteString cert' = let unannotated = cert - { Dlg.aEpoch = L.Annotated epoch () - , Dlg.annotation = () + { aEpoch = L.Annotated epoch () + , annotation = () } in unannotated - { Dlg.annotation = L.serialize' L.byronProtVer unannotated - , Dlg.aEpoch = L.Annotated epoch (L.serialize' L.byronProtVer epoch) + { annotation = L.serialize' L.byronProtVer unannotated + , aEpoch = L.Annotated epoch (L.serialize' L.byronProtVer epoch) } vkF :: forall r. Format r (Crypto.VerificationKey -> r) vkF = Crypto.fullVerificationKeyF -serialiseDelegationCert :: Dlg.Certificate -> ByteString +serialiseDelegationCert :: L.Certificate -> ByteString serialiseDelegationCert = LB.toStrict . canonicalEncodePretty serialiseByronWitness :: SomeByronSigningKey -> ByteString diff --git a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs index 280e1dd161..6b01e2da6e 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs @@ -13,14 +13,10 @@ module Cardano.CLI.Byron.Genesis where import Cardano.Api (Key (..), NetworkId, writeSecrets) -import Cardano.Api.Byron (ByronKey, SerialiseAsRawBytes (..), SigningKey (..), +import Cardano.Api.Byron (ByronKey, SerialiseAsRawBytes (..), SigningKey (..), delegateVK, toByronRequiresNetworkMagic) +import qualified Cardano.Api.Ledger as L -import qualified Cardano.Chain.Common as Common -import Cardano.Chain.Delegation hiding (Map, epoch) -import Cardano.Chain.Genesis (GeneratedSecrets (..)) -import qualified Cardano.Chain.Genesis as Genesis -import qualified Cardano.Chain.UTxO as UTxO import Cardano.CLI.Byron.Delegation import Cardano.CLI.Byron.Key import Cardano.CLI.Pretty @@ -34,7 +30,6 @@ import Control.Monad.Trans.Except.Extra (firstExceptT, left, right) import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as LB import qualified Data.List as List -import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.String (IsString) import Data.Text (Text) @@ -48,11 +43,11 @@ import System.Directory (createDirectory, doesPathExist) data ByronGenesisError = ByronDelegationCertSerializationError !ByronDelegationError | ByronDelegationKeySerializationError ByronDelegationError - | GenesisGenerationError !Genesis.GenesisDataGenerationError + | GenesisGenerationError !L.GenesisDataGenerationError | GenesisOutputDirAlreadyExists FilePath - | GenesisReadError !FilePath !Genesis.GenesisDataError + | GenesisReadError !FilePath !L.GenesisDataError | GenesisSpecError !Text - | MakeGenesisDelegationError !Genesis.GenesisDelegationError + | MakeGenesisDelegationError !L.GenesisDelegationError | NoGenesisDelegationForKey !Text | ProtocolParametersParseFailed !FilePath !Text | PoorKeyFailure !ByronKeyFailure @@ -89,16 +84,16 @@ newtype NewDirectory data GenesisParameters = GenesisParameters { gpStartTime :: !UTCTime , gpProtocolParamsFile :: !FilePath - , gpK :: !Common.BlockCount + , gpK :: !L.BlockCount , gpProtocolMagic :: !Crypto.ProtocolMagic - , gpTestnetBalance :: !Genesis.TestnetBalanceOptions - , gpFakeAvvmOptions :: !Genesis.FakeAvvmOptions - , gpAvvmBalanceFactor :: !Common.LovelacePortion + , gpTestnetBalance :: !L.TestnetBalanceOptions + , gpFakeAvvmOptions :: !L.FakeAvvmOptions + , gpAvvmBalanceFactor :: !L.LovelacePortion , gpSeed :: !(Maybe Integer) } deriving Show -mkGenesisSpec :: GenesisParameters -> ExceptT ByronGenesisError IO Genesis.GenesisSpec +mkGenesisSpec :: GenesisParameters -> ExceptT ByronGenesisError IO L.GenesisSpec mkGenesisSpec gp = do protoParamsRaw <- lift . LB.readFile $ gpProtocolParamsFile gp @@ -111,24 +106,24 @@ mkGenesisSpec gp = do -- We're relying on the generator to fake AVVM and delegation. genesisDelegation <- withExceptT MakeGenesisDelegationError $ - Genesis.mkGenesisDelegation [] + L.mkGenesisDelegation [] withExceptT GenesisSpecError $ ExceptT . pure $ - Genesis.mkGenesisSpec - (Genesis.GenesisAvvmBalances mempty) + L.mkGenesisSpec + (L.GenesisAvvmBalances mempty) genesisDelegation protocolParameters (gpK gp) (gpProtocolMagic gp) (mkGenesisInitialiser True) where - mkGenesisInitialiser :: Bool -> Genesis.GenesisInitializer + mkGenesisInitialiser :: Bool -> L.GenesisInitializer mkGenesisInitialiser = - Genesis.GenesisInitializer + L.GenesisInitializer (gpTestnetBalance gp) (gpFakeAvvmOptions gp) - (Common.lovelacePortionToRational (gpAvvmBalanceFactor gp)) + (L.lovelacePortionToRational (gpAvvmBalanceFactor gp)) -- | Generate a genesis, for given blockchain start time, protocol parameters, -- security parameter, protocol magic, testnet balance options, fake AVVM options, @@ -138,27 +133,27 @@ mkGenesisSpec gp = do -- or if the genesis fails generation. mkGenesis :: GenesisParameters - -> ExceptT ByronGenesisError IO (Genesis.GenesisData, Genesis.GeneratedSecrets) + -> ExceptT ByronGenesisError IO (L.GenesisData, L.GeneratedSecrets) mkGenesis gp = do genesisSpec <- mkGenesisSpec gp withExceptT GenesisGenerationError $ - Genesis.generateGenesisData (gpStartTime gp) genesisSpec + L.generateGenesisData (gpStartTime gp) genesisSpec -- | Read genesis from a file. readGenesis :: GenesisFile -> NetworkId - -> ExceptT ByronGenesisError IO Genesis.Config + -> ExceptT ByronGenesisError IO L.Config readGenesis (GenesisFile file) nw = firstExceptT (GenesisReadError file) $ do - (genesisData, genesisHash) <- Genesis.readGenesisData file + (genesisData, genesisHash) <- L.readGenesisData file return - Genesis.Config - { Genesis.configGenesisData = genesisData - , Genesis.configGenesisHash = genesisHash - , Genesis.configReqNetMagic = toByronRequiresNetworkMagic nw - , Genesis.configUTxOConfiguration = UTxO.defaultUTxOConfiguration + L.Config + { L.configGenesisData = genesisData + , L.configGenesisHash = genesisHash + , L.configReqNetMagic = toByronRequiresNetworkMagic nw + , L.configUTxOConfiguration = L.defaultUTxOConfiguration } -- | Write out genesis into a directory that must not yet exist. An error is @@ -166,8 +161,8 @@ readGenesis (GenesisFile file) nw = -- are not delegated to. dumpGenesis :: NewDirectory - -> Genesis.GenesisData - -> Genesis.GeneratedSecrets + -> L.GenesisData + -> L.GeneratedSecrets -> ExceptT ByronGenesisError IO () dumpGenesis (NewDirectory outDir) genesisData gs = do exists <- liftIO $ doesPathExist outDir @@ -176,33 +171,32 @@ dumpGenesis (NewDirectory outDir) genesisData gs = do else liftIO $ createDirectory outDir liftIO $ LB.writeFile genesisJSONFile (canonicalEncodePretty genesisData) - dlgCerts <- mapM (findDelegateCert . ByronSigningKey) $ gsRichSecrets gs + dlgCerts <- mapM (findDelegateCert . ByronSigningKey) $ L.gsRichSecrets gs liftIO $ wOut "genesis-keys" "key" serialiseToRawBytes - (map ByronSigningKey $ gsDlgIssuersSecrets gs) + (map ByronSigningKey $ L.gsDlgIssuersSecrets gs) liftIO $ wOut "delegate-keys" "key" serialiseToRawBytes - (map ByronSigningKey $ gsRichSecrets gs) + (map ByronSigningKey $ L.gsRichSecrets gs) liftIO $ wOut "poor-keys" "key" serialiseToRawBytes - (map (ByronSigningKey . Genesis.poorSecretToKey) $ gsPoorSecrets gs) + (map (ByronSigningKey . L.poorSecretToKey) $ L.gsPoorSecrets gs) liftIO $ wOut "delegation-cert" "json" serialiseDelegationCert dlgCerts - liftIO $ wOut "avvm-secrets" "secret" printFakeAvvmSecrets $ gsFakeAvvmSecrets gs + liftIO $ wOut "avvm-secrets" "secret" printFakeAvvmSecrets $ L.gsFakeAvvmSecrets gs where - dlgCertMap :: Map Common.KeyHash Certificate - dlgCertMap = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation genesisData + dlgCertMap = L.unGenesisDelegation $ L.gdHeavyDelegation genesisData - findDelegateCert :: SigningKey ByronKey -> ExceptT ByronGenesisError IO Certificate + findDelegateCert :: SigningKey ByronKey -> ExceptT ByronGenesisError IO L.Certificate findDelegateCert bSkey@(ByronSigningKey sk) = case List.find (isCertForSK sk) (Map.elems dlgCertMap) of Nothing -> @@ -219,7 +213,7 @@ dumpGenesis (NewDirectory outDir) genesisData gs = do printFakeAvvmSecrets rskey = Text.encodeUtf8 . toStrict . toLazyText $ build rskey -- Compare a given 'SigningKey' with a 'Certificate' 'VerificationKey' - isCertForSK :: Crypto.SigningKey -> Certificate -> Bool + isCertForSK :: Crypto.SigningKey -> L.Certificate -> Bool isCertForSK sk cert = delegateVK cert == Crypto.toVerification sk wOut :: String -> String -> (a -> ByteString) -> [a] -> IO () diff --git a/cardano-cli/src/Cardano/CLI/Byron/Key.hs b/cardano-cli/src/Cardano/CLI/Byron/Key.hs index 50be69f03f..c11520bbac 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Key.hs @@ -17,8 +17,8 @@ module Cardano.CLI.Byron.Key where import Cardano.Api.Byron +import Cardano.Api.Ledger (addressHash) -import qualified Cardano.Chain.Common as Common import Cardano.CLI.Types.Common import qualified Cardano.Crypto.Signing as Crypto @@ -74,7 +74,7 @@ prettyPublicKey (ByronVerificationKey vk) = % "\n public key (hex): " % Crypto.fullVerificationKeyHexF ) - (Common.addressHash vk) + (addressHash vk) vk vk diff --git a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs index fe95eb12c5..9b81bd1458 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs @@ -26,18 +26,10 @@ where import Cardano.Api hiding (GenesisParameters, UpdateProposal, parseFilePath) import Cardano.Api.Byron (Address (..), ByronProtocolParametersUpdate (..), - toByronLovelace) + ProtocolVersion (..), toByronLovelace) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (ReferenceScript (ReferenceScriptNone)) -import Cardano.Chain.Common (BlockCount (..), TxFeePolicy (..), TxSizeLinear (..), - decodeAddressBase58, rationalToLovelacePortion) -import qualified Cardano.Chain.Common as Byron -import Cardano.Chain.Genesis (FakeAvvmOptions (..), TestnetBalanceOptions (..)) -import Cardano.Chain.Slotting (EpochNumber (..), SlotNumber (..)) -import Cardano.Chain.Update (ApplicationName (..), InstallerHash (..), NumSoftwareVersion, - ProtocolVersion (..), SoftforkRule (..), SoftwareVersion (..), SystemTag (..), - checkApplicationName, checkSystemTag) import Cardano.CLI.Byron.Commands import Cardano.CLI.Byron.Genesis import Cardano.CLI.Byron.Key @@ -167,7 +159,7 @@ parseGenesisParameters = <*> parseProtocolMagic <*> parseTestnetBalanceOptions <*> parseFakeAvvmOptions - <*> ( rationalToLovelacePortion + <*> ( L.rationalToLovelacePortion <$> parseFractionWithDefault "avvm-balance-factor" "AVVM balances will be multiplied by this factor (defaults to 1)." @@ -248,9 +240,9 @@ parseMiscellaneous = <$> parseFilePath "filepath" "Filepath of CBOR file." ] -parseTestnetBalanceOptions :: Parser TestnetBalanceOptions +parseTestnetBalanceOptions :: Parser L.TestnetBalanceOptions parseTestnetBalanceOptions = - TestnetBalanceOptions + L.TestnetBalanceOptions <$> parseIntegral "n-poor-addresses" "Number of poor nodes (with small balance)." @@ -306,7 +298,7 @@ parseTxOut = where pAddressInEra :: Text -> AddressInEra ByronEra pAddressInEra t = - case decodeAddressBase58 t of + case L.decodeAddressBase58 t of Left err -> error $ "Bad Base58 address: " <> show err Right byronAddress -> AddressInEra ByronAddressInAnyEra $ ByronAddress byronAddress @@ -455,7 +447,7 @@ parseSlotDuration = <> help "Proposed slot duration." ) -parseSystemTag :: Parser SystemTag +parseSystemTag :: Parser L.SystemTag parseSystemTag = Opt.option (eitherReader checkSysTag) @@ -464,16 +456,16 @@ parseSystemTag = <> help "Identify which system (linux, win64, etc) the update proposal is for." ) where - checkSysTag :: String -> Either String SystemTag + checkSysTag :: String -> Either String L.SystemTag checkSysTag name = - let tag = SystemTag $ Text.pack name - in case checkSystemTag tag of + let tag = L.SystemTag $ Text.pack name + in case L.checkSystemTag tag of Left err -> Left . Text.unpack $ sformat build err Right () -> Right tag -parseInstallerHash :: Parser InstallerHash +parseInstallerHash :: Parser L.InstallerHash parseInstallerHash = - InstallerHash . hashRaw . C8.pack + L.InstallerHash . hashRaw . C8.pack <$> strOption ( long "installer-hash" <> metavar "HASH" @@ -516,9 +508,9 @@ parseMaxProposalSize = <> help "Proposed max update proposal size." ) -parseMpcThd :: Parser Byron.LovelacePortion +parseMpcThd :: Parser L.LovelacePortion parseMpcThd = - rationalToLovelacePortion + L.rationalToLovelacePortion <$> parseFraction "max-mpc-thd" "Proposed max mpc threshold." parseProtocolVersion :: Parser ProtocolVersion @@ -528,24 +520,24 @@ parseProtocolVersion = <*> (parseWord "protocol-version-minor" "Protocol version minor." "WORD16" :: Parser Word16) <*> (parseWord "protocol-version-alt" "Protocol version alt." "WORD8" :: Parser Word8) -parseHeavyDelThd :: Parser Byron.LovelacePortion +parseHeavyDelThd :: Parser L.LovelacePortion parseHeavyDelThd = - rationalToLovelacePortion + L.rationalToLovelacePortion <$> parseFraction "heavy-del-thd" "Proposed heavy delegation threshold." -parseUpdateVoteThd :: Parser Byron.LovelacePortion +parseUpdateVoteThd :: Parser L.LovelacePortion parseUpdateVoteThd = - rationalToLovelacePortion + L.rationalToLovelacePortion <$> parseFraction "update-vote-thd" "Propose update vote threshold." -parseUpdateProposalThd :: Parser Byron.LovelacePortion +parseUpdateProposalThd :: Parser L.LovelacePortion parseUpdateProposalThd = - rationalToLovelacePortion + L.rationalToLovelacePortion <$> parseFraction "update-proposal-thd" "Propose update proposal threshold." -parseUpdateProposalTTL :: Parser SlotNumber +parseUpdateProposalTTL :: Parser L.SlotNumber parseUpdateProposalTTL = - SlotNumber + L.SlotNumber <$> Opt.option auto ( long "time-to-live" @@ -553,27 +545,27 @@ parseUpdateProposalTTL = <> help "Proposed time for an update proposal to live." ) -parseSoftforkRule :: Parser SoftforkRule +parseSoftforkRule :: Parser L.SoftforkRule parseSoftforkRule = - ( SoftforkRule . rationalToLovelacePortion + ( L.SoftforkRule . L.rationalToLovelacePortion <$> parseFraction "softfork-init-thd" "Propose initial threshold (right after proposal is confirmed)." ) - <*> ( rationalToLovelacePortion + <*> ( L.rationalToLovelacePortion <$> parseFraction "softfork-min-thd" "Propose minimum threshold (threshold can't be less than this)." ) - <*> ( rationalToLovelacePortion + <*> ( L.rationalToLovelacePortion <$> parseFraction "softfork-thd-dec" "Propose threshold decrement (threshold will decrease by this amount after each epoch)." ) -parseSoftwareVersion :: Parser SoftwareVersion +parseSoftwareVersion :: Parser L.SoftwareVersion parseSoftwareVersion = - SoftwareVersion <$> parseApplicationName <*> parseNumSoftwareVersion + L.SoftwareVersion <$> parseApplicationName <*> parseNumSoftwareVersion -parseApplicationName :: Parser ApplicationName +parseApplicationName :: Parser L.ApplicationName parseApplicationName = Opt.option (eitherReader checkAppNameLength) @@ -582,24 +574,24 @@ parseApplicationName = <> help "The name of the application." ) where - checkAppNameLength :: String -> Either String ApplicationName + checkAppNameLength :: String -> Either String L.ApplicationName checkAppNameLength name = - let appName = ApplicationName $ Text.pack name - in case checkApplicationName appName of + let appName = L.ApplicationName $ Text.pack name + in case L.checkApplicationName appName of Left err -> Left . Text.unpack $ sformat build err Right () -> Right appName -parseNumSoftwareVersion :: Parser NumSoftwareVersion +parseNumSoftwareVersion :: Parser L.NumSoftwareVersion parseNumSoftwareVersion = parseWord "software-version-num" "Numeric software version associated with application name." "WORD32" -parseTxFeePolicy :: Parser TxFeePolicy +parseTxFeePolicy :: Parser L.TxFeePolicy parseTxFeePolicy = - TxFeePolicyTxSizeLinear - <$> ( TxSizeLinear + L.TxFeePolicyTxSizeLinear + <$> ( L.TxSizeLinear <$> parseLovelace "tx-fee-a-constant" "Propose the constant a for txfee = a + b*s where s is the size." <*> parseFraction "tx-fee-b-constant" "Propose the constant b for txfee = a + b*s where s is the size." ) @@ -609,9 +601,9 @@ parseVoteBool = flag' True (long "vote-yes" <> help "Vote yes with respect to an update proposal.") <|> flag' False (long "vote-no" <> help "Vote no with respect to an update proposal.") -parseUnlockStakeEpoch :: Parser EpochNumber +parseUnlockStakeEpoch :: Parser L.EpochNumber parseUnlockStakeEpoch = - EpochNumber + L.EpochNumber <$> Opt.option auto ( long "unlock-stake-epoch" @@ -645,15 +637,15 @@ parseByronKeyFormat = pure NonLegacyByronKeyFormat ] -parseFakeAvvmOptions :: Parser FakeAvvmOptions +parseFakeAvvmOptions :: Parser L.FakeAvvmOptions parseFakeAvvmOptions = - FakeAvvmOptions + L.FakeAvvmOptions <$> parseIntegral "avvm-entry-count" "Number of AVVM addresses." <*> parseLovelace "avvm-entry-balance" "AVVM address." -parseK :: Parser BlockCount +parseK :: Parser L.BlockCount parseK = - BlockCount + L.BlockCount <$> parseIntegral "k" "The security parameter of the Ouroboros protocol." parseNewDirectory :: String -> String -> Parser NewDirectory @@ -711,7 +703,7 @@ parseUTCTime optname desc = cliParseBase58Address :: Text -> Address ByronAddr cliParseBase58Address t = - case decodeAddressBase58 t of + case L.decodeAddressBase58 t of Left err -> error $ "Bad Base58 address: " <> show err Right byronAddress -> ByronAddress byronAddress @@ -727,7 +719,7 @@ parseIntegral optname desc = Opt.option (fromInteger <$> auto) $ long optname <> metavar "INT" <> help desc -parseLovelace :: String -> String -> Parser Byron.Lovelace +parseLovelace :: String -> String -> Parser L.Lovelace parseLovelace optname desc = Opt.option (readerFromAttoParser parseLovelaceAtto) @@ -736,7 +728,7 @@ parseLovelace optname desc = <> help desc ) where - parseLovelaceAtto :: Atto.Parser Byron.Lovelace + parseLovelaceAtto :: Atto.Parser L.Lovelace parseLovelaceAtto = do i <- Atto.decimal if i > toInteger (maxBound :: Word64) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Run.hs b/cardano-cli/src/Cardano/CLI/Byron/Run.hs index e03c11cbc5..d5ceff2506 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Run.hs @@ -11,8 +11,8 @@ where import Cardano.Api hiding (GenesisParameters, UpdateProposal) import Cardano.Api.Byron (SomeByronSigningKey (..), serializeByronTx) +import qualified Cardano.Api.Ledger as L -import qualified Cardano.Chain.Genesis as Genesis import Cardano.CLI.Byron.Commands import Cardano.CLI.Byron.Delegation import Cardano.CLI.Byron.Genesis @@ -136,11 +136,11 @@ runPrintGenesisHash genFp = do dummyNetwork :: NetworkId dummyNetwork = Mainnet - formatter :: Genesis.Config -> Text + formatter :: L.Config -> Text formatter = F.sformat Crypto.hashHexF - . Genesis.unGenesisHash - . Genesis.configGenesisHash + . L.unGenesisHash + . L.configGenesisHash runPrintSigningKeyAddress :: ByronKeyFormat diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 517dcc26bd..adc6b18aad 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -28,9 +28,6 @@ import Cardano.Api.Byron import qualified Cardano.Api.Ledger as L import qualified Cardano.Binary as Binary -import qualified Cardano.Chain.Common as Common -import Cardano.Chain.Genesis as Genesis -import qualified Cardano.Chain.UTxO as UTxO import Cardano.CLI.Byron.Key (byronWitnessToVerKey) import Cardano.CLI.Types.Common (TxFile) import qualified Cardano.Crypto.Signing as Crypto @@ -82,12 +79,12 @@ newtype NewTxFile prettyAddress :: Address ByronAddr -> Text prettyAddress (ByronAddress addr) = sformat - (Common.addressF % "\n" % Common.addressDetailedF) + (L.addressF % "\n" % L.addressDetailedF) addr addr -- TODO: Move to cardano-api -readByronTx :: TxFile In -> ExceptT ByronTxError IO (UTxO.ATxAux ByteString) +readByronTx :: TxFile In -> ExceptT ByronTxError IO (ATxAux ByteString) readByronTx (File fp) = do txBS <- liftIO $ LB.readFile fp case fromCborTxAux txBS of @@ -96,45 +93,45 @@ readByronTx (File fp) = do -- | The 'GenTx' is all the kinds of transactions that can be submitted -- and \"normal\" Byron transactions are just one of the kinds. -normalByronTxToGenTx :: UTxO.ATxAux ByteString -> GenTx ByronBlock +normalByronTxToGenTx :: ATxAux ByteString -> GenTx ByronBlock normalByronTxToGenTx tx' = Byron.ByronTx (Byron.byronIdTx tx') tx' -- | Given a genesis, and a pair of a genesis public key and address, -- reconstruct a TxIn corresponding to the genesis UTxO entry. -genesisUTxOTxIn :: Genesis.Config -> Crypto.VerificationKey -> Common.Address -> UTxO.TxIn +genesisUTxOTxIn :: L.Config -> Crypto.VerificationKey -> L.Address -> ByronTxIn genesisUTxOTxIn gc vk genAddr = handleMissingAddr $ fst <$> Map.lookup genAddr initialUtxo where - initialUtxo :: Map Common.Address (UTxO.TxIn, UTxO.TxOut) + initialUtxo :: Map L.Address (ByronTxIn, ByronTxOut) initialUtxo = fromList . mapMaybe (\(inp, out) -> mkEntry inp genAddr <$> keyMatchesUTxO vk out) . fromCompactTxInTxOutList . toList - . UTxO.unUTxO - . UTxO.genesisUtxo + . L.unUTxO + . L.genesisUtxo $ gc where mkEntry - :: UTxO.TxIn - -> Common.Address - -> UTxO.TxOut - -> (Common.Address, (UTxO.TxIn, UTxO.TxOut)) + :: ByronTxIn + -> L.Address + -> ByronTxOut + -> (L.Address, (ByronTxIn, ByronTxOut)) mkEntry inp addr out = (addr, (inp, out)) fromCompactTxInTxOutList - :: [(UTxO.CompactTxIn, UTxO.CompactTxOut)] - -> [(UTxO.TxIn, UTxO.TxOut)] + :: [(L.CompactTxIn, L.CompactTxOut)] + -> [(ByronTxIn, ByronTxOut)] fromCompactTxInTxOutList = - map (bimap UTxO.fromCompactTxIn UTxO.fromCompactTxOut) + map (bimap L.fromCompactTxIn L.fromCompactTxOut) - keyMatchesUTxO :: Crypto.VerificationKey -> UTxO.TxOut -> Maybe UTxO.TxOut + keyMatchesUTxO :: Crypto.VerificationKey -> ByronTxOut -> Maybe ByronTxOut keyMatchesUTxO key out = - if Common.checkVerKeyAddress key (UTxO.txOutAddress out) + if L.checkVerKeyAddress key (L.txOutAddress out) then Just out else Nothing - handleMissingAddr :: Maybe UTxO.TxIn -> UTxO.TxIn + handleMissingAddr :: Maybe ByronTxIn -> ByronTxIn handleMissingAddr = fromMaybe . error $ "\nGenesis UTxO has no address\n" @@ -145,7 +142,7 @@ genesisUTxOTxIn gc vk genAddr = -- | Generate a transaction spending genesis UTxO at a given address, -- to given outputs, signed by the given key. txSpendGenesisUTxOByronPBFT - :: Genesis.Config + :: L.Config -> NetworkId -> SomeByronSigningKey -> Address ByronAddr @@ -161,7 +158,7 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = where ByronVerificationKey vKey = byronWitnessToVerKey sk - txIn :: UTxO.TxIn + txIn :: ByronTxIn txIn = genesisUTxOTxIn gc vKey bAddr -- | Generate a transaction from given Tx inputs to outputs, @@ -212,7 +209,7 @@ nodeSubmitTx nodeSocketPath network gentx = do return () -- TODO: remove these local definitions when the updated ledger lib is available -fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (UTxO.ATxAux B.ByteString) +fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (ATxAux B.ByteString) fromCborTxAux lbs = annotationBytes lbs <$> Binary.decodeFullDecoder @@ -223,5 +220,5 @@ fromCborTxAux lbs = annotationBytes :: Functor f => LB.ByteString -> f L.ByteSpan -> f B.ByteString annotationBytes bytes = fmap (LB.toStrict . L.slice bytes) -toCborTxAux :: UTxO.ATxAux ByteString -> LB.ByteString -toCborTxAux = LB.fromStrict . UTxO.aTaAnnotation -- The ByteString anotation is the CBOR encoded version. +toCborTxAux :: ATxAux ByteString -> LB.ByteString +toCborTxAux = LB.fromStrict . L.aTaAnnotation -- The ByteString anotation is the CBOR encoded version. diff --git a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs index 7528e8281e..0c54a5a3f4 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs @@ -13,10 +13,10 @@ where import Cardano.Api (NetworkId, SerialiseAsRawBytes (..), SocketPath) import Cardano.Api.Byron (AsType (AsByronUpdateProposal), ByronProtocolParametersUpdate, - ByronUpdateProposal, makeByronUpdateProposal, toByronLedgerUpdateProposal) + ByronUpdateProposal, ProtocolVersion, makeByronUpdateProposal, + toByronLedgerUpdateProposal) +import qualified Cardano.Api.Ledger as L -import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..), - SoftwareVersion (..), SystemTag (..)) import Cardano.CLI.Byron.Genesis (ByronGenesisError) import Cardano.CLI.Byron.Key (ByronKeyFailure, readByronSigningKey) import Cardano.CLI.Byron.Tx (ByronTxError, nodeSubmitTx) @@ -63,9 +63,9 @@ runProposalCreation :: NetworkId -> SigningKeyFile In -> ProtocolVersion - -> SoftwareVersion - -> SystemTag - -> InstallerHash + -> L.SoftwareVersion + -> L.SystemTag + -> L.InstallerHash -> FilePath -> ByronProtocolParametersUpdate -> ExceptT ByronUpdateProposalError IO () diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs index b37258c7bb..0d1f2942d2 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs @@ -18,10 +18,9 @@ module Cardano.CLI.EraBased.Commands.Genesis ) where -import Cardano.Api.Ledger (Coin) +import Cardano.Api.Ledger (BlockCount, Coin) import Cardano.Api.Shelley -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.Types.Common import Data.Text (Text) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index b427bad9f3..19118a6b75 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -10,9 +10,8 @@ module Cardano.CLI.EraBased.Options.Genesis where import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) -import Cardano.Api.Ledger (Coin (..)) +import Cardano.Api.Ledger (BlockCount (..), Coin (..)) -import Cardano.Chain.Common (BlockCount (BlockCount)) import Cardano.CLI.Environment (EnvCli (..)) import Cardano.CLI.EraBased.Commands.Genesis import Cardano.CLI.EraBased.Options.Common diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index 8949681677..b61d2d763e 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -28,19 +28,11 @@ module Cardano.CLI.EraBased.Run.Genesis where import Cardano.Api -import Cardano.Api.Byron (toByronLovelace, toByronProtocolMagicId, - toByronRequiresNetworkMagic) +import Cardano.Api.Byron (ACertificate (..), KeyHash, toByronLovelace, + toByronProtocolMagicId, toByronRequiresNetworkMagic) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley -import Cardano.Chain.Common (BlockCount (unBlockCount)) -import qualified Cardano.Chain.Common as Byron (KeyHash, mkKnownLovelace, rationalToLovelacePortion) -import Cardano.Chain.Delegation (delegateVK) -import qualified Cardano.Chain.Delegation as Dlg -import Cardano.Chain.Genesis (FakeAvvmOptions (..), TestnetBalanceOptions (..), - gdProtocolParameters, gsDlgIssuersSecrets, gsPoorSecrets, gsRichSecrets) -import qualified Cardano.Chain.Genesis as Genesis -import Cardano.Chain.Update hiding (ProtocolParameters) import Cardano.CLI.Byron.Delegation import Cardano.CLI.Byron.Genesis as Byron import qualified Cardano.CLI.Byron.Key as Byron @@ -404,28 +396,28 @@ runGenesisCreateCardanoCmd let byronGenesis = byronGenesis' - { gdProtocolParameters = - (gdProtocolParameters byronGenesis') - { ppSlotDuration = floor (toRational slotLength * recip slotCoeff) + { L.gdProtocolParameters = + (L.gdProtocolParameters byronGenesis') + { L.ppSlotDuration = floor (toRational slotLength * recip slotCoeff) } } - genesisKeys = gsDlgIssuersSecrets byronSecrets + genesisKeys = L.gsDlgIssuersSecrets byronSecrets byronGenesisKeys = map ByronSigningKey genesisKeys shelleyGenesisKeys = map convertGenesisKey genesisKeys shelleyGenesisvkeys :: [VerificationKey GenesisKey] shelleyGenesisvkeys = map (castVerificationKey . getVerificationKey) shelleyGenesisKeys - delegateKeys = gsRichSecrets byronSecrets + delegateKeys = L.gsRichSecrets byronSecrets byronDelegateKeys = map ByronSigningKey delegateKeys shelleyDelegateKeys :: [SigningKey GenesisDelegateExtendedKey] shelleyDelegateKeys = map convertDelegate delegateKeys shelleyDelegatevkeys :: [VerificationKey GenesisDelegateKey] shelleyDelegatevkeys = map (castVerificationKey . getVerificationKey) shelleyDelegateKeys - utxoKeys = gsPoorSecrets byronSecrets - byronUtxoKeys = map (ByronSigningKey . Genesis.poorSecretToKey) utxoKeys - shelleyUtxoKeys = map (convertPoor . Genesis.poorSecretToKey) utxoKeys + utxoKeys = L.gsPoorSecrets byronSecrets + byronUtxoKeys = map (ByronSigningKey . L.poorSecretToKey) utxoKeys + shelleyUtxoKeys = map (convertPoor . L.poorSecretToKey) utxoKeys era = toCardanoEra eon dlgCerts <- convertToShelleyError $ mapM (findDelegateCert byronGenesis) byronDelegateKeys @@ -435,9 +427,9 @@ runGenesisCreateCardanoCmd { sgNetworkMagic = unNetworkMagic (toNetworkMagic network) , sgNetworkId = toShelleyNetwork network , sgActiveSlotsCoeff = unsafeBoundedRational slotCoeff - , sgSecurityParam = unBlockCount security + , sgSecurityParam = L.unBlockCount security , sgUpdateQuorum = fromIntegral $ ((numGenesisKeys `div` 3) * 2) + 1 - , sgEpochLength = EpochSize $ floor $ (fromIntegral (unBlockCount security) * 10) / slotCoeff + , sgEpochLength = EpochSize $ floor $ (fromIntegral (L.unBlockCount security) * 10) / slotCoeff , sgMaxLovelaceSupply = 45_000_000_000_000_000 , sgSystemStart = getSystemStart start , sgSlotLength = L.secondsToNominalDiffTimeMicro $ MkFixed (fromIntegral slotLength) * 1_000 @@ -540,26 +532,26 @@ runGenesisCreateCardanoCmd (L.Annotated (toByronProtocolMagicId network) ()) (toByronRequiresNetworkMagic network) byronBalance = - TestnetBalanceOptions + L.TestnetBalanceOptions { tboRichmen = numGenesisKeys , tboPoors = numUTxOKeys , tboTotalBalance = fromMaybe zeroLovelace $ toByronLovelace (fromMaybe 0 mSupply) , tboRichmenShare = 0 } byronFakeAvvm = - FakeAvvmOptions + L.FakeAvvmOptions { faoCount = 0 , faoOneBalance = zeroLovelace } - byronAvvmFactor = Byron.rationalToLovelacePortion 0.0 - zeroLovelace = Byron.mkKnownLovelace @0 + byronAvvmFactor = L.rationalToLovelacePortion 0.0 + zeroLovelace = L.mkKnownLovelace @0 -- Compare a given 'SigningKey' with a 'Certificate' 'VerificationKey' - isCertForSK :: CC.SigningKey -> Dlg.Certificate -> Bool + isCertForSK :: CC.SigningKey -> L.Certificate -> Bool isCertForSK sk cert = delegateVK cert == CC.toVerification sk findDelegateCert - :: Genesis.GenesisData -> SigningKey ByronKey -> ExceptT ByronGenesisError IO Dlg.Certificate + :: L.GenesisData -> SigningKey ByronKey -> ExceptT ByronGenesisError IO L.Certificate findDelegateCert byronGenesis bSkey@(ByronSigningKey sk) = do case List.find (isCertForSK sk) (Map.elems $ dlgCertMap byronGenesis) of Nothing -> @@ -569,8 +561,8 @@ runGenesisCreateCardanoCmd $ getVerificationKey bSkey Just x -> pure x - dlgCertMap :: Genesis.GenesisData -> Map Byron.KeyHash Dlg.Certificate - dlgCertMap byronGenesis = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation byronGenesis + dlgCertMap :: L.GenesisData -> Map KeyHash L.Certificate + dlgCertMap byronGenesis = L.unGenesisDelegation $ L.gdHeavyDelegation byronGenesis runGenesisCreateStakedCmd :: GenesisCreateStakedCmdArgs era diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 6e16700432..64a2323618 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -40,7 +40,6 @@ import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley import qualified Cardano.Binary as CBOR -import qualified Cardano.Chain.Common as Byron import qualified Cardano.CLI.EraBased.Commands.Transaction as Cmd import Cardano.CLI.EraBased.Run.Genesis.Common (readProtocolParameters) import Cardano.CLI.EraBased.Run.Query @@ -1577,10 +1576,10 @@ calculateByronWitnessFees txFeePerByte byronwitcount = -- in mainnet transaction by one Word32 per witness. attributes = CBOR.serialize' $ - Byron.mkAttributes - Byron.AddrAttributes - { Byron.aaVKDerivationPath = Nothing - , Byron.aaNetworkMagic = Byron.NetworkTestnet maxBound + L.mkAttributes + L.AddrAttributes + { L.aaVKDerivationPath = Nothing + , L.aaNetworkMagic = L.NetworkTestnet maxBound } -- ---------------------------------------------------------------------------- diff --git a/cardano-cli/src/Cardano/CLI/Helpers.hs b/cardano-cli/src/Cardano/CLI/Helpers.hs index 588321d233..4b377fd47a 100644 --- a/cardano-cli/src/Cardano/CLI/Helpers.hs +++ b/cardano-cli/src/Cardano/CLI/Helpers.hs @@ -19,12 +19,9 @@ module Cardano.CLI.Helpers where import Cardano.Api (AnyCardanoEra (..), CardanoEra (ConwayEra), ToCardanoEra (..)) +import qualified Cardano.Api.Byron as Byron import qualified Cardano.Api.Ledger as L -import Cardano.Chain.Block (decCBORABlockOrBoundary) -import qualified Cardano.Chain.Delegation as Delegation -import qualified Cardano.Chain.Update as Update -import qualified Cardano.Chain.UTxO as UTxO import Cardano.CLI.Pretty (Doc, pretty, pshow) import Cardano.CLI.Types.Common @@ -123,19 +120,19 @@ validateCBOR :: CBORObject -> LB.ByteString -> Either HelpersError Text validateCBOR cborObject bs = case cborObject of CBORBlockByron epochSlots -> do - void $ decodeCBOR bs (L.toPlainDecoder L.byronProtVer (decCBORABlockOrBoundary epochSlots)) + void $ decodeCBOR bs (L.toPlainDecoder L.byronProtVer (L.decCBORABlockOrBoundary epochSlots)) Right "Valid Byron block." CBORDelegationCertificateByron -> do - void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Delegation.Certificate) + void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s L.Certificate) Right "Valid Byron delegation certificate." CBORTxByron -> do - void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s UTxO.Tx) + void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s L.Tx) Right "Valid Byron Tx." CBORUpdateProposalByron -> do - void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Update.Proposal) + void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s L.Proposal) Right "Valid Byron update proposal." CBORVoteByron -> do - void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Update.Vote) + void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Byron.Vote) Right "Valid Byron vote." printEraDeprecationWarning :: Typeable era => MonadIO m => ToCardanoEra eon => eon era -> m () diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs index 8d07aca335..92f47f4ded 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs @@ -7,10 +7,9 @@ module Cardano.CLI.Legacy.Commands.Genesis ) where -import Cardano.Api.Ledger (Coin) +import Cardano.Api.Ledger (BlockCount, Coin) import Cardano.Api.Shelley -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.Types.Common import Data.Text (Text) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index 4187470f6f..32a6fac45b 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -19,9 +19,8 @@ module Cardano.CLI.Legacy.Options where import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) -import Cardano.Api.Ledger (Coin (..)) +import Cardano.Api.Ledger (BlockCount (..), Coin (..)) -import Cardano.Chain.Common (BlockCount (BlockCount)) import Cardano.CLI.Environment import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.Legacy.Commands diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs index 20b56b42aa..29d640a17d 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs @@ -10,9 +10,8 @@ module Cardano.CLI.Legacy.Run.Genesis where import Cardano.Api -import Cardano.Api.Ledger (Coin (..)) +import Cardano.Api.Ledger (BlockCount, Coin (..)) -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.EraBased.Commands.Genesis (GenesisKeyGenGenesisCmdArgs (GenesisKeyGenGenesisCmdArgs)) import qualified Cardano.CLI.EraBased.Commands.Genesis as Cmd diff --git a/cardano-cli/src/Cardano/CLI/Types/Common.hs b/cardano-cli/src/Cardano/CLI/Types/Common.hs index 9639f606a4..bf507ac447 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Common.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Common.hs @@ -93,8 +93,6 @@ where import Cardano.Api hiding (Script) import qualified Cardano.Api.Ledger as L -import qualified Cardano.Chain.Slotting as Byron - import Data.Aeson (FromJSON (..), ToJSON (..), object, pairs, (.=)) import qualified Data.Aeson as Aeson import Data.String (IsString) @@ -191,7 +189,7 @@ data TxBuildOutputOptions -- | Specify what the CBOR file is -- i.e a block, a tx, etc data CBORObject - = CBORBlockByron Byron.EpochSlots + = CBORBlockByron EpochSlots | CBORDelegationCertificateByron | CBORTxByron | CBORUpdateProposalByron diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs index 02d73e9ba5..489af73f52 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Byron/Tx.hs @@ -3,8 +3,8 @@ module Test.Golden.Byron.Tx where import Cardano.Api +import Cardano.Api.Byron (ATxAux) -import Cardano.Chain.UTxO (ATxAux) import Cardano.CLI.Byron.Tx import Control.Monad (void)