From 3a2d66eea65eedf515733ee864ae55935cee9934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 14 Oct 2024 11:19:36 +0200 Subject: [PATCH 1/5] Update cardano-api to 9.4.0.0 --- cabal.project | 4 ++-- cardano-cli/cardano-cli.cabal | 2 +- flake.lock | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cabal.project b/cabal.project index e50bba650d..2605b44dd2 100644 --- a/cabal.project +++ b/cabal.project @@ -13,8 +13,8 @@ repository cardano-haskell-packages -- See CONTRIBUTING for information about these, including some Nix commands -- you need to run if you change them index-state: - , hackage.haskell.org 2024-08-08T19:27:29Z - , cardano-haskell-packages 2024-09-09T11:32:44Z + , hackage.haskell.org 2024-10-11T15:49:11Z + , cardano-haskell-packages 2024-10-11T15:49:11Z packages: cardano-cli diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 5f4f68b9f3..7bb2f50afe 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -196,7 +196,7 @@ library binary, bytestring, canonical-json, - cardano-api ^>=9.3, + cardano-api ^>=9.4, cardano-binary, cardano-crypto, cardano-crypto-class ^>=2.1.2, diff --git a/flake.lock b/flake.lock index 3bf375dbd3..f0b611b237 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1725882485, - "narHash": "sha256-lL70EjKqXpTazTu7VkoGzQOEvEmdpa9/yD3W9x4t+KU=", + "lastModified": 1728663083, + "narHash": "sha256-ejmJzPYPKdIwN53Arz3ycNcMO1YnS4k4uSBC7XeBRsQ=", "owner": "intersectmbo", "repo": "cardano-haskell-packages", - "rev": "dd0b250a0c215e0e617739e3928deb7e7c8a2f79", + "rev": "16d7391e69a69b9954acf097ffca3bda61a4faf0", "type": "github" }, "original": { From 9736ecbcb5915c2bef64e53e831c5809938d61c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 14 Oct 2024 17:00:59 +0200 Subject: [PATCH 2/5] Print supplementalDatums in "transaction view" --- cardano-cli/src/Cardano/CLI/Json/Friendly.hs | 16 ++++++++++++++++ cardano-cli/src/Cardano/CLI/Orphans.hs | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index 11acac2315..4a7ad5b66e 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -50,6 +50,7 @@ import Cardano.Api.Shelley (Address (ShelleyAddress), Hash (..), fromShelleyPaymentCredential, fromShelleyStakeReference, toShelleyStakeCredential) +import Cardano.CLI.Orphans () import Cardano.CLI.Types.Common (ViewOutputFormat (..)) import Cardano.CLI.Types.MonadWarning (MonadWarning, runWarningIO) import Cardano.Crypto.Hash (hashToTextAsHex) @@ -217,6 +218,7 @@ friendlyTxBodyImpl txValidityUpperBound txMetadata txAuxScripts + txSupplementalData txExtraKeyWits _txProtocolParams txWithdrawals @@ -256,6 +258,10 @@ friendlyTxBodyImpl era (`getRedeemerDetails` tb) ) + ++ ( monoidForEraInEon @AlonzoEraOnwards + era + (`friendlySupplementalDatums` txSupplementalData) + ) ++ ( monoidForEraInEon @ConwayEraOnwards era ( \cOnwards -> @@ -293,6 +299,16 @@ friendlyTxBodyImpl friendlyLedgerProposals cOnwards proposalProcedures = Array $ fromList $ map (friendlyLedgerProposal cOnwards) proposalProcedures +-- | API doesn't yet show that supplemental datums are alonzo onwards. So we do it in this function prototype, +-- even if we don't use the witness. +friendlySupplementalDatums + :: AlonzoEraOnwards era -> BuildTxWith build (TxSupplementalDatums era) -> [Aeson.Pair] +friendlySupplementalDatums _era = \case + ViewTx -> [] + BuildTxWith TxSupplementalDataNone -> [] + BuildTxWith (TxSupplementalDatums hashableScriptDatas) -> + ["supplemental datums" .= toJSON hashableScriptDatas] + friendlyLedgerProposal :: ConwayEraOnwards era -> L.ProposalProcedure (ShelleyLedgerEra era) -> Aeson.Value friendlyLedgerProposal cOnwards proposalProcedure = object $ friendlyProposalImpl cOnwards (Proposal proposalProcedure) diff --git a/cardano-cli/src/Cardano/CLI/Orphans.hs b/cardano-cli/src/Cardano/CLI/Orphans.hs index c7bf205d83..49ea88a225 100644 --- a/cardano-cli/src/Cardano/CLI/Orphans.hs +++ b/cardano-cli/src/Cardano/CLI/Orphans.hs @@ -6,6 +6,7 @@ module Cardano.CLI.Orphans where import Cardano.Api +import Cardano.Api.Shelley (scriptDataToJsonDetailedSchema) import qualified Cardano.Ledger.Api as L import qualified Cardano.Ledger.Shelley.LedgerState as L @@ -23,3 +24,10 @@ instance (L.EraTxOut ledgerera, L.EraGov ledgerera) => ToJSON (L.NewEpochState l , "rewardUpdate" .= nesRu , "currentStakeDistribution" .= nesPd ] + +instance ToJSON HashableScriptData where + toJSON hsd = + object + [ "hash" .= hashScriptDataBytes hsd + , "json" .= scriptDataToJsonDetailedSchema hsd + ] From d0298f09a53968387cdb94f83d33cc29de9c61d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Mon, 14 Oct 2024 17:00:47 +0200 Subject: [PATCH 3/5] Adapting to changes to imports --- cardano-cli/src/Cardano/CLI/Byron/Commands.hs | 4 +--- cardano-cli/src/Cardano/CLI/Byron/Delegation.hs | 3 +-- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs | 1 - cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs | 6 +++--- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs index 84d077774d..9325744739 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs @@ -12,10 +12,8 @@ module Cardano.CLI.Byron.Commands where import Cardano.Api hiding (GenesisParameters) -import Cardano.Api.Byron hiding (GenesisParameters) +import Cardano.Api.Byron hiding (Address, GenesisParameters, TxIn, TxOut) -import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..), - SoftwareVersion (..), SystemTag (..)) import Cardano.CLI.Byron.Genesis import Cardano.CLI.Byron.Key import Cardano.CLI.Byron.Tx diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index 40002fbf4a..c2065cd58e 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -13,11 +13,10 @@ module Cardano.CLI.Byron.Delegation ) where -import Cardano.Api.Byron +import Cardano.Api.Byron hiding (delegateVK) 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) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 517dcc26bd..8aa6264287 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -24,7 +24,7 @@ module Cardano.CLI.Byron.Tx where import Cardano.Api -import Cardano.Api.Byron +import Cardano.Api.Byron hiding (Address, TxIn, TxOut) import qualified Cardano.Api.Ledger as L import qualified Cardano.Binary as Binary diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs index 3b60bf9088..42211b9bbf 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs @@ -39,7 +39,6 @@ where import Cardano.Api hiding (QueryInShelleyBasedEra (..)) import qualified Cardano.Api as Api -import Cardano.Api.Byron hiding (QueryInShelleyBasedEra (..)) import Cardano.Api.Ledger (strictMaybeToMaybe) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 6e16700432..23c068ba44 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs @@ -34,7 +34,7 @@ module Cardano.CLI.EraBased.Run.Transaction where import Cardano.Api -import Cardano.Api.Byron hiding (SomeByronSigningKey (..)) +import qualified Cardano.Api.Byron as Byron import qualified Cardano.Api.Experimental as Exp import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley @@ -1645,9 +1645,9 @@ mkShelleyBootstrapWitness mkShelleyBootstrapWitness _ Nothing _ (ShelleyBootstrapWitnessSigningKeyData _ Nothing) = Left MissingNetworkIdOrByronAddressError mkShelleyBootstrapWitness sbe (Just nw) txBody (ShelleyBootstrapWitnessSigningKeyData skey Nothing) = - Right $ makeShelleyBootstrapWitness sbe (WitnessNetworkId nw) txBody skey + Right $ makeShelleyBootstrapWitness sbe (Byron.WitnessNetworkId nw) txBody skey mkShelleyBootstrapWitness sbe _ txBody (ShelleyBootstrapWitnessSigningKeyData skey (Just addr)) = - Right $ makeShelleyBootstrapWitness sbe (WitnessByronAddress addr) txBody skey + Right $ makeShelleyBootstrapWitness sbe (Byron.WitnessByronAddress addr) txBody skey -- | Attempt to construct Shelley bootstrap witnesses until an error is -- encountered. From 105d59688d2323334e2fbb7d4c9da7ebeb3e5354 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Fri, 27 Sep 2024 17:30:06 +0200 Subject: [PATCH 4/5] Remove dependencies from `cardano-ledger-alonzo` and `cardano-ledger-byron` --- cardano-cli/cardano-cli.cabal | 4 - cardano-cli/src/Cardano/CLI/Byron/Commands.hs | 12 +-- .../src/Cardano/CLI/Byron/Delegation.hs | 35 ++++---- cardano-cli/src/Cardano/CLI/Byron/Genesis.hs | 76 ++++++++-------- cardano-cli/src/Cardano/CLI/Byron/Key.hs | 3 +- cardano-cli/src/Cardano/CLI/Byron/Parsers.hs | 90 +++++++++---------- cardano-cli/src/Cardano/CLI/Byron/Run.hs | 8 +- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 65 +++++++------- .../src/Cardano/CLI/Byron/UpdateProposal.hs | 11 ++- .../Cardano/CLI/EraBased/Commands/Genesis.hs | 4 +- .../Cardano/CLI/EraBased/Options/Genesis.hs | 4 +- .../src/Cardano/CLI/EraBased/Run/Genesis.hs | 43 ++++----- .../CLI/EraBased/Run/Genesis/Common.hs | 3 +- .../Cardano/CLI/EraBased/Run/Transaction.hs | 1 - cardano-cli/src/Cardano/CLI/Helpers.hs | 15 ++-- cardano-cli/src/Cardano/CLI/Json/Friendly.hs | 36 ++++---- .../Cardano/CLI/Legacy/Commands/Genesis.hs | 4 +- cardano-cli/src/Cardano/CLI/Legacy/Options.hs | 4 +- .../src/Cardano/CLI/Legacy/Run/Genesis.hs | 4 +- cardano-cli/src/Cardano/CLI/Types/Common.hs | 4 +- .../Test/Golden/Byron/Tx.hs | 2 +- .../Test/Cli/AddCostModels.hs | 8 +- 22 files changed, 198 insertions(+), 238 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 7bb2f50afe..43592756d0 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -203,9 +203,7 @@ library cardano-crypto-wrapper ^>=1.5.1, cardano-data >=1.1, cardano-git-rev ^>=0.2.2, - cardano-ledger-alonzo, cardano-ledger-api, - cardano-ledger-byron >=1.0.1.0, cardano-ledger-core, cardano-ledger-shelley, cardano-ping ^>=0.4, @@ -312,7 +310,6 @@ test-suite cardano-cli-test cardano-api:{cardano-api, gen, internal}, cardano-cli, cardano-cli:cardano-cli-test-lib, - cardano-ledger-alonzo, cardano-slotting, containers, directory, @@ -378,7 +375,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 9325744739..1bf4e06bc8 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs @@ -12,7 +12,7 @@ module Cardano.CLI.Byron.Commands where import Cardano.Api hiding (GenesisParameters) -import Cardano.Api.Byron hiding (Address, GenesisParameters, TxIn, TxOut) +import qualified Cardano.Api.Byron as Byron import Cardano.CLI.Byron.Genesis import Cardano.CLI.Byron.Key @@ -102,12 +102,12 @@ data NodeCmds | UpdateProposal NetworkId (SigningKeyFile In) - ProtocolVersion - SoftwareVersion - SystemTag - InstallerHash + Byron.ProtocolVersion + Byron.SoftwareVersion + Byron.SystemTag + Byron.InstallerHash FilePath - ByronProtocolParametersUpdate + Byron.ByronProtocolParametersUpdate | -- | Update proposal filepath. SubmitUpdateProposal SocketPath diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index c2065cd58e..a9c59a36dc 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -16,7 +16,6 @@ where import Cardano.Api.Byron hiding (delegateVK) import qualified Cardano.Api.Ledger as L -import qualified Cardano.Chain.Delegation as Dlg import Cardano.CLI.Byron.Key (ByronKeyFailure, renderByronKeyFailure) import Cardano.CLI.Types.Common (CertificateFile (..)) import Cardano.Crypto (ProtocolMagicId) @@ -56,9 +55,9 @@ issueByronGenesisDelegation -> EpochNumber -> Crypto.SigningKey -> Crypto.VerificationKey - -> Dlg.Certificate -issueByronGenesisDelegation magic epoch issuerSK delegateVK = - Dlg.signCertificate magic delegateVK epoch $ + -> Certificate +issueByronGenesisDelegation magic epoch issuerSK delegateVK' = + signCertificate magic delegateVK' epoch $ Crypto.noPassSafeSigner issuerSK -- | Verify that a certificate signifies genesis delegation by assumed genesis key @@ -74,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 :: 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 @@ -89,19 +88,19 @@ 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 @@ -109,24 +108,24 @@ checkDlgCert cert magic issuerVK' delegateVK' = magic' = L.Annotated magic (L.serialize' L.byronProtVer magic) epoch :: EpochNumber - epoch = L.unAnnotated $ Dlg.aEpoch cert + 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 :: 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..2abec861bb 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs @@ -15,12 +15,8 @@ where import Cardano.Api (Key (..), NetworkId, writeSecrets) import Cardano.Api.Byron (ByronKey, SerialiseAsRawBytes (..), SigningKey (..), toByronRequiresNetworkMagic) +import qualified Cardano.Api.Byron as Byron -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 !Byron.GenesisDataGenerationError | GenesisOutputDirAlreadyExists FilePath - | GenesisReadError !FilePath !Genesis.GenesisDataError + | GenesisReadError !FilePath !Byron.GenesisDataError | GenesisSpecError !Text - | MakeGenesisDelegationError !Genesis.GenesisDelegationError + | MakeGenesisDelegationError !Byron.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 :: !Byron.BlockCount , gpProtocolMagic :: !Crypto.ProtocolMagic - , gpTestnetBalance :: !Genesis.TestnetBalanceOptions - , gpFakeAvvmOptions :: !Genesis.FakeAvvmOptions - , gpAvvmBalanceFactor :: !Common.LovelacePortion + , gpTestnetBalance :: !Byron.TestnetBalanceOptions + , gpFakeAvvmOptions :: !Byron.FakeAvvmOptions + , gpAvvmBalanceFactor :: !Byron.LovelacePortion , gpSeed :: !(Maybe Integer) } deriving Show -mkGenesisSpec :: GenesisParameters -> ExceptT ByronGenesisError IO Genesis.GenesisSpec +mkGenesisSpec :: GenesisParameters -> ExceptT ByronGenesisError IO Byron.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 [] + Byron.mkGenesisDelegation [] withExceptT GenesisSpecError $ ExceptT . pure $ - Genesis.mkGenesisSpec - (Genesis.GenesisAvvmBalances mempty) + Byron.mkGenesisSpec + (Byron.GenesisAvvmBalances mempty) genesisDelegation protocolParameters (gpK gp) (gpProtocolMagic gp) (mkGenesisInitialiser True) where - mkGenesisInitialiser :: Bool -> Genesis.GenesisInitializer + mkGenesisInitialiser :: Bool -> Byron.GenesisInitializer mkGenesisInitialiser = - Genesis.GenesisInitializer + Byron.GenesisInitializer (gpTestnetBalance gp) (gpFakeAvvmOptions gp) - (Common.lovelacePortionToRational (gpAvvmBalanceFactor gp)) + (Byron.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 (Byron.GenesisData, Byron.GeneratedSecrets) mkGenesis gp = do genesisSpec <- mkGenesisSpec gp withExceptT GenesisGenerationError $ - Genesis.generateGenesisData (gpStartTime gp) genesisSpec + Byron.generateGenesisData (gpStartTime gp) genesisSpec -- | Read genesis from a file. readGenesis :: GenesisFile -> NetworkId - -> ExceptT ByronGenesisError IO Genesis.Config + -> ExceptT ByronGenesisError IO Byron.Config readGenesis (GenesisFile file) nw = firstExceptT (GenesisReadError file) $ do - (genesisData, genesisHash) <- Genesis.readGenesisData file + (genesisData, genesisHash) <- Byron.readGenesisData file return - Genesis.Config - { Genesis.configGenesisData = genesisData - , Genesis.configGenesisHash = genesisHash - , Genesis.configReqNetMagic = toByronRequiresNetworkMagic nw - , Genesis.configUTxOConfiguration = UTxO.defaultUTxOConfiguration + Byron.Config + { Byron.configGenesisData = genesisData + , Byron.configGenesisHash = genesisHash + , Byron.configReqNetMagic = toByronRequiresNetworkMagic nw + , Byron.configUTxOConfiguration = Byron.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 + -> Byron.GenesisData + -> Byron.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) $ Byron.gsRichSecrets gs liftIO $ wOut "genesis-keys" "key" serialiseToRawBytes - (map ByronSigningKey $ gsDlgIssuersSecrets gs) + (map ByronSigningKey $ Byron.gsDlgIssuersSecrets gs) liftIO $ wOut "delegate-keys" "key" serialiseToRawBytes - (map ByronSigningKey $ gsRichSecrets gs) + (map ByronSigningKey $ Byron.gsRichSecrets gs) liftIO $ wOut "poor-keys" "key" serialiseToRawBytes - (map (ByronSigningKey . Genesis.poorSecretToKey) $ gsPoorSecrets gs) + (map (ByronSigningKey . Byron.poorSecretToKey) $ Byron.gsPoorSecrets gs) liftIO $ wOut "delegation-cert" "json" serialiseDelegationCert dlgCerts - liftIO $ wOut "avvm-secrets" "secret" printFakeAvvmSecrets $ gsFakeAvvmSecrets gs + liftIO $ wOut "avvm-secrets" "secret" printFakeAvvmSecrets $ Byron.gsFakeAvvmSecrets gs where - dlgCertMap :: Map Common.KeyHash Certificate - dlgCertMap = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation genesisData + dlgCertMap = Byron.unGenesisDelegation $ Byron.gdHeavyDelegation genesisData - findDelegateCert :: SigningKey ByronKey -> ExceptT ByronGenesisError IO Certificate + findDelegateCert :: SigningKey ByronKey -> ExceptT ByronGenesisError IO Byron.Certificate findDelegateCert bSkey@(ByronSigningKey sk) = case List.find (isCertForSK sk) (Map.elems dlgCertMap) of Nothing -> @@ -219,8 +213,8 @@ 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 sk cert = delegateVK cert == Crypto.toVerification sk + isCertForSK :: Crypto.SigningKey -> Byron.Certificate -> Bool + isCertForSK sk cert = Byron.delegateVK cert == Crypto.toVerification sk wOut :: String -> String -> (a -> ByteString) -> [a] -> IO () wOut = writeSecrets outDir diff --git a/cardano-cli/src/Cardano/CLI/Byron/Key.hs b/cardano-cli/src/Cardano/CLI/Byron/Key.hs index 50be69f03f..d439619373 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Key.hs @@ -18,7 +18,6 @@ where import Cardano.Api.Byron -import qualified Cardano.Chain.Common as Common import Cardano.CLI.Types.Common import qualified Cardano.Crypto.Signing as Crypto @@ -74,7 +73,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..e678e0de29 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs @@ -25,19 +25,11 @@ module Cardano.CLI.Byron.Parsers where import Cardano.Api hiding (GenesisParameters, UpdateProposal, parseFilePath) -import Cardano.Api.Byron (Address (..), ByronProtocolParametersUpdate (..), - toByronLovelace) +import Cardano.Api.Byron (ByronProtocolParametersUpdate (..), toByronLovelace) +import qualified Cardano.Api.Byron as Byron 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 + <*> ( Byron.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 Byron.TestnetBalanceOptions parseTestnetBalanceOptions = - TestnetBalanceOptions + Byron.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 Byron.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 Byron.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 Byron.SystemTag checkSysTag name = - let tag = SystemTag $ Text.pack name - in case checkSystemTag tag of + let tag = Byron.SystemTag $ Text.pack name + in case Byron.checkSystemTag tag of Left err -> Left . Text.unpack $ sformat build err Right () -> Right tag -parseInstallerHash :: Parser InstallerHash +parseInstallerHash :: Parser Byron.InstallerHash parseInstallerHash = - InstallerHash . hashRaw . C8.pack + Byron.InstallerHash . hashRaw . C8.pack <$> strOption ( long "installer-hash" <> metavar "HASH" @@ -518,34 +510,34 @@ parseMaxProposalSize = parseMpcThd :: Parser Byron.LovelacePortion parseMpcThd = - rationalToLovelacePortion + Byron.rationalToLovelacePortion <$> parseFraction "max-mpc-thd" "Proposed max mpc threshold." -parseProtocolVersion :: Parser ProtocolVersion +parseProtocolVersion :: Parser Byron.ProtocolVersion parseProtocolVersion = - ProtocolVersion + Byron.ProtocolVersion <$> (parseWord "protocol-version-major" "Protocol version major." "WORD16" :: Parser Word16) <*> (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 = - rationalToLovelacePortion + Byron.rationalToLovelacePortion <$> parseFraction "heavy-del-thd" "Proposed heavy delegation threshold." parseUpdateVoteThd :: Parser Byron.LovelacePortion parseUpdateVoteThd = - rationalToLovelacePortion + Byron.rationalToLovelacePortion <$> parseFraction "update-vote-thd" "Propose update vote threshold." parseUpdateProposalThd :: Parser Byron.LovelacePortion parseUpdateProposalThd = - rationalToLovelacePortion + Byron.rationalToLovelacePortion <$> parseFraction "update-proposal-thd" "Propose update proposal threshold." -parseUpdateProposalTTL :: Parser SlotNumber +parseUpdateProposalTTL :: Parser Byron.SlotNumber parseUpdateProposalTTL = - SlotNumber + Byron.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 Byron.SoftforkRule parseSoftforkRule = - ( SoftforkRule . rationalToLovelacePortion + ( Byron.SoftforkRule . Byron.rationalToLovelacePortion <$> parseFraction "softfork-init-thd" "Propose initial threshold (right after proposal is confirmed)." ) - <*> ( rationalToLovelacePortion + <*> ( Byron.rationalToLovelacePortion <$> parseFraction "softfork-min-thd" "Propose minimum threshold (threshold can't be less than this)." ) - <*> ( rationalToLovelacePortion + <*> ( Byron.rationalToLovelacePortion <$> parseFraction "softfork-thd-dec" "Propose threshold decrement (threshold will decrease by this amount after each epoch)." ) -parseSoftwareVersion :: Parser SoftwareVersion +parseSoftwareVersion :: Parser Byron.SoftwareVersion parseSoftwareVersion = - SoftwareVersion <$> parseApplicationName <*> parseNumSoftwareVersion + Byron.SoftwareVersion <$> parseApplicationName <*> parseNumSoftwareVersion -parseApplicationName :: Parser ApplicationName +parseApplicationName :: Parser Byron.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 Byron.ApplicationName checkAppNameLength name = - let appName = ApplicationName $ Text.pack name - in case checkApplicationName appName of + let appName = Byron.ApplicationName $ Text.pack name + in case Byron.checkApplicationName appName of Left err -> Left . Text.unpack $ sformat build err Right () -> Right appName -parseNumSoftwareVersion :: Parser NumSoftwareVersion +parseNumSoftwareVersion :: Parser Byron.NumSoftwareVersion parseNumSoftwareVersion = parseWord "software-version-num" "Numeric software version associated with application name." "WORD32" -parseTxFeePolicy :: Parser TxFeePolicy +parseTxFeePolicy :: Parser Byron.TxFeePolicy parseTxFeePolicy = - TxFeePolicyTxSizeLinear - <$> ( TxSizeLinear + Byron.TxFeePolicyTxSizeLinear + <$> ( Byron.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 Byron.EpochNumber parseUnlockStakeEpoch = - EpochNumber + Byron.EpochNumber <$> Opt.option auto ( long "unlock-stake-epoch" @@ -645,15 +637,15 @@ parseByronKeyFormat = pure NonLegacyByronKeyFormat ] -parseFakeAvvmOptions :: Parser FakeAvvmOptions +parseFakeAvvmOptions :: Parser Byron.FakeAvvmOptions parseFakeAvvmOptions = - FakeAvvmOptions + Byron.FakeAvvmOptions <$> parseIntegral "avvm-entry-count" "Number of AVVM addresses." <*> parseLovelace "avvm-entry-balance" "AVVM address." -parseK :: Parser BlockCount +parseK :: Parser Byron.BlockCount parseK = - BlockCount + Byron.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 Byron.decodeAddressBase58 t of Left err -> error $ "Bad Base58 address: " <> show err Right byronAddress -> ByronAddress byronAddress diff --git a/cardano-cli/src/Cardano/CLI/Byron/Run.hs b/cardano-cli/src/Cardano/CLI/Byron/Run.hs index e03c11cbc5..e24ccd27ae 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.Byron as Byron -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 :: Byron.Config -> Text formatter = F.sformat Crypto.hashHexF - . Genesis.unGenesisHash - . Genesis.configGenesisHash + . Byron.unGenesisHash + . Byron.configGenesisHash runPrintSigningKeyAddress :: ByronKeyFormat diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 8aa6264287..0fc3099ef4 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -24,13 +24,10 @@ module Cardano.CLI.Byron.Tx where import Cardano.Api -import Cardano.Api.Byron hiding (Address, TxIn, TxOut) +import qualified Cardano.Api.Byron as 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) + (Byron.addressF % "\n" % Byron.addressDetailedF) addr addr -- TODO: Move to cardano-api -readByronTx :: TxFile In -> ExceptT ByronTxError IO (UTxO.ATxAux ByteString) +readByronTx :: TxFile In -> ExceptT ByronTxError IO (Byron.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 :: Byron.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 :: Byron.Config -> Crypto.VerificationKey -> Byron.Address -> Byron.TxIn genesisUTxOTxIn gc vk genAddr = handleMissingAddr $ fst <$> Map.lookup genAddr initialUtxo where - initialUtxo :: Map Common.Address (UTxO.TxIn, UTxO.TxOut) + initialUtxo :: Map Byron.Address (Byron.TxIn, Byron.TxOut) initialUtxo = fromList . mapMaybe (\(inp, out) -> mkEntry inp genAddr <$> keyMatchesUTxO vk out) . fromCompactTxInTxOutList . toList - . UTxO.unUTxO - . UTxO.genesisUtxo + . Byron.unUTxO + . Byron.genesisUtxo $ gc where mkEntry - :: UTxO.TxIn - -> Common.Address - -> UTxO.TxOut - -> (Common.Address, (UTxO.TxIn, UTxO.TxOut)) + :: Byron.TxIn + -> Byron.Address + -> Byron.TxOut + -> (Byron.Address, (Byron.TxIn, Byron.TxOut)) mkEntry inp addr out = (addr, (inp, out)) fromCompactTxInTxOutList - :: [(UTxO.CompactTxIn, UTxO.CompactTxOut)] - -> [(UTxO.TxIn, UTxO.TxOut)] + :: [(Byron.CompactTxIn, Byron.CompactTxOut)] + -> [(Byron.TxIn, Byron.TxOut)] fromCompactTxInTxOutList = - map (bimap UTxO.fromCompactTxIn UTxO.fromCompactTxOut) + map (bimap Byron.fromCompactTxIn Byron.fromCompactTxOut) - keyMatchesUTxO :: Crypto.VerificationKey -> UTxO.TxOut -> Maybe UTxO.TxOut + keyMatchesUTxO :: Crypto.VerificationKey -> Byron.TxOut -> Maybe Byron.TxOut keyMatchesUTxO key out = - if Common.checkVerKeyAddress key (UTxO.txOutAddress out) + if Byron.checkVerKeyAddress key (Byron.txOutAddress out) then Just out else Nothing - handleMissingAddr :: Maybe UTxO.TxIn -> UTxO.TxIn + handleMissingAddr :: Maybe Byron.TxIn -> Byron.TxIn handleMissingAddr = fromMaybe . error $ "\nGenesis UTxO has no address\n" @@ -145,14 +142,14 @@ 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 + :: Byron.Config -> NetworkId - -> SomeByronSigningKey + -> Byron.SomeByronSigningKey -> Address ByronAddr -> [TxOut CtxTx ByronEra] - -> ATxAux ByteString + -> Byron.ATxAux ByteString txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = - let txins = [(fromByronTxIn txIn, BuildTxWith (KeyWitness KeyWitnessForSpending))] + let txins = [(Byron.fromByronTxIn txIn, BuildTxWith (KeyWitness KeyWitnessForSpending))] in case makeByronTransactionBody txins outs of Left err -> error $ "Error occurred while creating a Byron genesis based UTxO transaction: " <> show err Right txBody -> @@ -161,17 +158,17 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs = where ByronVerificationKey vKey = byronWitnessToVerKey sk - txIn :: UTxO.TxIn + txIn :: Byron.TxIn txIn = genesisUTxOTxIn gc vKey bAddr -- | Generate a transaction from given Tx inputs to outputs, -- signed by the given key. txSpendUTxOByronPBFT :: NetworkId - -> SomeByronSigningKey + -> Byron.SomeByronSigningKey -> [TxIn] -> [TxOut CtxTx ByronEra] - -> ATxAux ByteString + -> Byron.ATxAux ByteString txSpendUTxOByronPBFT nId sk txIns outs = do let apiTxIns = [(txIn, BuildTxWith (KeyWitness KeyWitnessForSpending)) | txIn <- txIns] @@ -182,11 +179,11 @@ txSpendUTxOByronPBFT nId sk txIns outs = do in makeSignedByronTransaction [bWit] txBody fromByronWitness - :: SomeByronSigningKey -> NetworkId -> L.Annotated L.Tx ByteString -> KeyWitness ByronEra + :: Byron.SomeByronSigningKey -> NetworkId -> L.Annotated L.Tx ByteString -> KeyWitness ByronEra fromByronWitness bw nId txBody = case bw of - AByronSigningKeyLegacy sk -> makeByronKeyWitness nId txBody sk - AByronSigningKey sk' -> makeByronKeyWitness nId txBody sk' + Byron.AByronSigningKeyLegacy sk -> makeByronKeyWitness nId txBody sk + Byron.AByronSigningKey sk' -> makeByronKeyWitness nId txBody sk' -- | Submit a transaction to a node specified by topology info. nodeSubmitTx @@ -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 (Byron.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 :: Byron.ATxAux ByteString -> LB.ByteString +toCborTxAux = LB.fromStrict . Byron.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..0c81225b0f 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs @@ -14,9 +14,8 @@ where import Cardano.Api (NetworkId, SerialiseAsRawBytes (..), SocketPath) import Cardano.Api.Byron (AsType (AsByronUpdateProposal), ByronProtocolParametersUpdate, ByronUpdateProposal, makeByronUpdateProposal, toByronLedgerUpdateProposal) +import qualified Cardano.Api.Byron as Byron -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) @@ -62,10 +61,10 @@ renderByronUpdateProposalError = \case runProposalCreation :: NetworkId -> SigningKeyFile In - -> ProtocolVersion - -> SoftwareVersion - -> SystemTag - -> InstallerHash + -> Byron.ProtocolVersion + -> Byron.SoftwareVersion + -> Byron.SystemTag + -> Byron.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..0c7abbc8fe 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs @@ -18,10 +18,10 @@ module Cardano.CLI.EraBased.Commands.Genesis ) where +import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin) import Cardano.Api.Shelley -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.Types.Common import Data.Text (Text) @@ -60,7 +60,7 @@ data GenesisCreateCardanoCmdArgs era = GenesisCreateCardanoCmdArgs , numUTxOKeys :: !Word , mSystemStart :: !(Maybe SystemStart) , mSupply :: !(Maybe Coin) - , security :: !BlockCount + , security :: !Byron.BlockCount , slotLength :: !Word , slotCoeff :: !Rational , network :: !NetworkId diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index 23d0072294..826d7d5680 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -10,9 +10,9 @@ module Cardano.CLI.EraBased.Options.Genesis where import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) +import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin (..)) -import Cardano.Chain.Common (BlockCount (BlockCount)) import Cardano.CLI.Environment (EnvCli (..)) import Cardano.CLI.EraBased.Commands.Genesis import Cardano.CLI.EraBased.Options.Common @@ -164,7 +164,7 @@ pGenesisCreateCardano sbe envCli = <*> pGenesisNumUTxOKeys <*> pMaybeSystemStart <*> pInitialSupplyNonDelegated - <*> (BlockCount <$> pSecurityParam) + <*> (Byron.BlockCount <$> pSecurityParam) <*> pSlotLength <*> pSlotCoefficient <*> pNetworkId envCli diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs index 30b975924a..87cdab28f0 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs @@ -30,17 +30,10 @@ where import Cardano.Api import Cardano.Api.Byron (toByronLovelace, toByronProtocolMagicId, toByronRequiresNetworkMagic) +import qualified Cardano.Api.Byron as Byron hiding (GenesisParameters, SigningKey) 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 +397,28 @@ runGenesisCreateCardanoCmd let byronGenesis = byronGenesis' - { gdProtocolParameters = - (gdProtocolParameters byronGenesis') - { ppSlotDuration = floor (toRational slotLength * recip slotCoeff) + { Byron.gdProtocolParameters = + (Byron.gdProtocolParameters byronGenesis') + { Byron.ppSlotDuration = floor (toRational slotLength * recip slotCoeff) } } - genesisKeys = gsDlgIssuersSecrets byronSecrets + genesisKeys = Byron.gsDlgIssuersSecrets byronSecrets byronGenesisKeys = map ByronSigningKey genesisKeys shelleyGenesisKeys = map convertGenesisKey genesisKeys shelleyGenesisvkeys :: [VerificationKey GenesisKey] shelleyGenesisvkeys = map (castVerificationKey . getVerificationKey) shelleyGenesisKeys - delegateKeys = gsRichSecrets byronSecrets + delegateKeys = Byron.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 = Byron.gsPoorSecrets byronSecrets + byronUtxoKeys = map (ByronSigningKey . Byron.poorSecretToKey) utxoKeys + shelleyUtxoKeys = map (convertPoor . Byron.poorSecretToKey) utxoKeys era = toCardanoEra eon dlgCerts <- convertToShelleyError $ mapM (findDelegateCert byronGenesis) byronDelegateKeys @@ -435,9 +428,9 @@ runGenesisCreateCardanoCmd { sgNetworkMagic = unNetworkMagic (toNetworkMagic network) , sgNetworkId = toShelleyNetwork network , sgActiveSlotsCoeff = unsafeBoundedRational slotCoeff - , sgSecurityParam = unBlockCount security + , sgSecurityParam = Byron.unBlockCount security , sgUpdateQuorum = fromIntegral $ ((numGenesisKeys `div` 3) * 2) + 1 - , sgEpochLength = EpochSize $ floor $ (fromIntegral (unBlockCount security) * 10) / slotCoeff + , sgEpochLength = EpochSize $ floor $ (fromIntegral (Byron.unBlockCount security) * 10) / slotCoeff , sgMaxLovelaceSupply = 45_000_000_000_000_000 , sgSystemStart = getSystemStart start , sgSlotLength = L.secondsToNominalDiffTimeMicro $ MkFixed (fromIntegral slotLength) * 1_000 @@ -531,14 +524,14 @@ runGenesisCreateCardanoCmd (L.Annotated (toByronProtocolMagicId network) ()) (toByronRequiresNetworkMagic network) byronBalance = - TestnetBalanceOptions + Byron.TestnetBalanceOptions { tboRichmen = numGenesisKeys , tboPoors = numUTxOKeys , tboTotalBalance = fromMaybe zeroLovelace $ toByronLovelace (fromMaybe 0 mSupply) , tboRichmenShare = 0 } byronFakeAvvm = - FakeAvvmOptions + Byron.FakeAvvmOptions { faoCount = 0 , faoOneBalance = zeroLovelace } @@ -546,11 +539,11 @@ runGenesisCreateCardanoCmd zeroLovelace = Byron.mkKnownLovelace @0 -- Compare a given 'SigningKey' with a 'Certificate' 'VerificationKey' - isCertForSK :: CC.SigningKey -> Dlg.Certificate -> Bool - isCertForSK sk cert = delegateVK cert == CC.toVerification sk + isCertForSK :: CC.SigningKey -> Byron.Certificate -> Bool + isCertForSK sk cert = Byron.delegateVK cert == CC.toVerification sk findDelegateCert - :: Genesis.GenesisData -> SigningKey ByronKey -> ExceptT ByronGenesisError IO Dlg.Certificate + :: Byron.GenesisData -> SigningKey ByronKey -> ExceptT ByronGenesisError IO Byron.Certificate findDelegateCert byronGenesis bSkey@(ByronSigningKey sk) = do case List.find (isCertForSK sk) (Map.elems $ dlgCertMap byronGenesis) of Nothing -> @@ -560,8 +553,8 @@ runGenesisCreateCardanoCmd $ getVerificationKey bSkey Just x -> pure x - dlgCertMap :: Genesis.GenesisData -> Map Byron.KeyHash Dlg.Certificate - dlgCertMap byronGenesis = Genesis.unGenesisDelegation $ Genesis.gdHeavyDelegation byronGenesis + dlgCertMap :: Byron.GenesisData -> Map Byron.KeyHash Byron.Certificate + dlgCertMap byronGenesis = Byron.unGenesisDelegation $ Byron.gdHeavyDelegation byronGenesis -- | @writeGenesisHashesToNodeConfigFile src hashes dest@ reads the node configuration file -- at @src@ and the writes an augmented version of this file at @dest@, with the hashes. diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs index 287c14002c..70af39090f 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs @@ -24,8 +24,7 @@ where import Cardano.Api hiding (ConwayEra) import Cardano.Api.Ledger (AlonzoGenesis, ConwayGenesis, StandardCrypto) import qualified Cardano.Api.Ledger as L -import Cardano.Api.Shelley (Address (ShelleyAddress), ShelleyGenesis, ShelleyLedgerEra, - decodeAlonzoGenesis) +import Cardano.Api.Shelley (ShelleyGenesis, ShelleyLedgerEra, decodeAlonzoGenesis) import Cardano.CLI.Types.Common import Cardano.CLI.Types.Errors.GenesisCmdError diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs index 23c068ba44..8339e3e90a 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 diff --git a/cardano-cli/src/Cardano/CLI/Helpers.hs b/cardano-cli/src/Cardano/CLI/Helpers.hs index 588321d233..1e0687b8ad 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 (Byron.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 Byron.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 Byron.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/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index 4a7ad5b66e..857ad78d74 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -44,7 +44,7 @@ import Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness)) import Cardano.Api.Ledger (extractHash, strictMaybeToMaybe) import qualified Cardano.Api.Ledger as L -import Cardano.Api.Shelley (Address (ShelleyAddress), Hash (..), +import Cardano.Api.Shelley (Hash (..), KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..), ShelleyLedgerEra, StakeAddress (..), Tx (ShelleyTx), fromShelleyPaymentCredential, fromShelleyStakeReference, @@ -54,11 +54,9 @@ import Cardano.CLI.Orphans () import Cardano.CLI.Types.Common (ViewOutputFormat (..)) import Cardano.CLI.Types.MonadWarning (MonadWarning, runWarningIO) import Cardano.Crypto.Hash (hashToTextAsHex) -import Cardano.Ledger.Alonzo.Core (AsIxItem) -import Cardano.Ledger.Alonzo.Scripts (ExUnits (..)) -import qualified Cardano.Ledger.Alonzo.Scripts as Ledger import qualified Cardano.Ledger.Api as Ledger import Cardano.Ledger.Api.Tx.In (txIxToInt) +import Cardano.Ledger.Plutus (ExUnits (..)) import Cardano.Ledger.Plutus.Data (unData) import qualified Cardano.Ledger.TxIn as Ledger @@ -370,27 +368,27 @@ getRedeemerDetails aeo tb = ] friendlyPurpose - :: AlonzoEraOnwards era -> Ledger.PlutusPurpose AsIxItem (ShelleyLedgerEra era) -> Aeson.Value + :: AlonzoEraOnwards era -> Ledger.PlutusPurpose L.AsIxItem (ShelleyLedgerEra era) -> Aeson.Value friendlyPurpose AlonzoEraOnwardsAlonzo purpose = case purpose of - Ledger.AlonzoSpending (Ledger.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) - Ledger.AlonzoMinting (Ledger.AsIxItem _ mp) -> addLabelToPurpose Minting mp - Ledger.AlonzoCertifying (Ledger.AsIxItem _ cp) -> addLabelToPurpose Certifying cp - Ledger.AlonzoRewarding (Ledger.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp + Ledger.AlonzoSpending (L.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) + Ledger.AlonzoMinting (L.AsIxItem _ mp) -> addLabelToPurpose Minting mp + Ledger.AlonzoCertifying (L.AsIxItem _ cp) -> addLabelToPurpose Certifying cp + Ledger.AlonzoRewarding (L.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp friendlyPurpose AlonzoEraOnwardsBabbage purpose = case purpose of - Ledger.AlonzoSpending (Ledger.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) - Ledger.AlonzoMinting (Ledger.AsIxItem _ mp) -> addLabelToPurpose Minting mp - Ledger.AlonzoCertifying (Ledger.AsIxItem _ cp) -> addLabelToPurpose Certifying cp - Ledger.AlonzoRewarding (Ledger.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp + Ledger.AlonzoSpending (L.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) + Ledger.AlonzoMinting (L.AsIxItem _ mp) -> addLabelToPurpose Minting mp + Ledger.AlonzoCertifying (L.AsIxItem _ cp) -> addLabelToPurpose Certifying cp + Ledger.AlonzoRewarding (L.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp friendlyPurpose AlonzoEraOnwardsConway purpose = case purpose of - Ledger.ConwaySpending (Ledger.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) - Ledger.ConwayMinting (Ledger.AsIxItem _ mp) -> addLabelToPurpose Minting mp - Ledger.ConwayCertifying (Ledger.AsIxItem _ cp) -> addLabelToPurpose Certifying cp - Ledger.ConwayRewarding (Ledger.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp - Ledger.ConwayVoting (Ledger.AsIxItem _ vp) -> addLabelToPurpose Voting vp - Ledger.ConwayProposing (Ledger.AsIxItem _ pp) -> addLabelToPurpose Proposing pp + Ledger.ConwaySpending (L.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp) + Ledger.ConwayMinting (L.AsIxItem _ mp) -> addLabelToPurpose Minting mp + Ledger.ConwayCertifying (L.AsIxItem _ cp) -> addLabelToPurpose Certifying cp + Ledger.ConwayRewarding (L.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp + Ledger.ConwayVoting (L.AsIxItem _ vp) -> addLabelToPurpose Voting vp + Ledger.ConwayProposing (L.AsIxItem _ pp) -> addLabelToPurpose Proposing pp friendlyInput :: Ledger.TxIn Ledger.StandardCrypto -> Aeson.Value friendlyInput (Ledger.TxIn (Ledger.TxId txidHash) ix) = diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs index 8d07aca335..ce34840f43 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs @@ -7,10 +7,10 @@ module Cardano.CLI.Legacy.Commands.Genesis ) where +import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin) import Cardano.Api.Shelley -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.Types.Common import Data.Text (Text) @@ -32,7 +32,7 @@ data LegacyGenesisCmds Word (Maybe SystemStart) (Maybe Coin) - BlockCount + Byron.BlockCount Word Rational NetworkId diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index 4187470f6f..e618806008 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -19,9 +19,9 @@ module Cardano.CLI.Legacy.Options where import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) +import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin (..)) -import Cardano.Chain.Common (BlockCount (BlockCount)) import Cardano.CLI.Environment import Cardano.CLI.EraBased.Options.Common import Cardano.CLI.Legacy.Commands @@ -229,7 +229,7 @@ pGenesisCmds envCli = <*> pGenesisNumUTxOKeys <*> pMaybeSystemStart <*> pInitialSupplyNonDelegated - <*> (BlockCount <$> pSecurityParam) + <*> (Byron.BlockCount <$> pSecurityParam) <*> pSlotLength <*> pSlotCoefficient <*> pNetworkId envCli diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs index 20b56b42aa..fa1dac1c68 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs @@ -10,9 +10,9 @@ module Cardano.CLI.Legacy.Run.Genesis where import Cardano.Api +import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin (..)) -import Cardano.Chain.Common (BlockCount) import Cardano.CLI.EraBased.Commands.Genesis (GenesisKeyGenGenesisCmdArgs (GenesisKeyGenGenesisCmdArgs)) import qualified Cardano.CLI.EraBased.Commands.Genesis as Cmd @@ -158,7 +158,7 @@ runLegacyGenesisCreateCardanoCmd -- ^ num utxo keys to make -> Maybe SystemStart -> Maybe Coin - -> BlockCount + -> Byron.BlockCount -> Word -- ^ slot length in ms -> Rational diff --git a/cardano-cli/src/Cardano/CLI/Types/Common.hs b/cardano-cli/src/Cardano/CLI/Types/Common.hs index e3c22e51fa..6942f4ea29 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Common.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Common.hs @@ -95,8 +95,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) @@ -197,7 +195,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) diff --git a/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs b/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs index e6658ebed7..04f2eeac51 100644 --- a/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs +++ b/cardano-cli/test/cardano-cli-test/Test/Cli/AddCostModels.hs @@ -4,10 +4,10 @@ module Test.Cli.AddCostModels where import Cardano.Api import Cardano.Api.Ledger (StrictMaybe (..)) +import qualified Cardano.Api.Ledger as L import Cardano.Api.ProtocolParameters import Cardano.CLI.EraBased.Run.Governance.Actions -import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo import Test.Gen.Cardano.Api.ProtocolParameters import Test.Gen.Cardano.Api.Typed @@ -24,7 +24,7 @@ hprop_roundtrip_Alonzo_addCostModelsToEraBasedProtocolParametersUpdate = (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsAlonzo) ppu) getCostModels where - getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe L.CostModels getCostModels (AlonzoEraBasedProtocolParametersUpdate _ _ AlonzoOnwardsPParams{alCostModels = SJust cmdls} _) = Just cmdls getCostModels _ = Nothing @@ -38,7 +38,7 @@ hprop_roundtrip_Babbage_addCostModelsToEraBasedProtocolParametersUpdate = (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsBabbage) ppu) getCostModels where - getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe L.CostModels getCostModels (BabbageEraBasedProtocolParametersUpdate _ AlonzoOnwardsPParams{alCostModels = SJust cmdls} _ _) = Just cmdls getCostModels _ = Nothing @@ -52,6 +52,6 @@ hprop_roundtrip_Conway_addCostModelsToEraBasedProtocolParametersUpdate = (flip (addCostModelsToEraBasedProtocolParametersUpdate AlonzoEraOnwardsConway) ppu) getCostModels where - getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe Alonzo.CostModels + getCostModels :: EraBasedProtocolParametersUpdate era -> Maybe L.CostModels getCostModels (ConwayEraBasedProtocolParametersUpdate _ AlonzoOnwardsPParams{alCostModels = SJust cmdls} _ _) = Just cmdls getCostModels _ = Nothing From a27d5f8415c436c5ce02bfc7e4b5eddf0a490783 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Mon, 14 Oct 2024 18:13:11 +0200 Subject: [PATCH 5/5] Fix other compilation/import errors --- cardano-cli/src/Cardano/CLI/Byron/Delegation.hs | 1 + cardano-cli/src/Cardano/CLI/Byron/Parsers.hs | 2 +- cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs | 4 ++-- cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs | 2 +- cardano-cli/src/Cardano/CLI/Legacy/Options.hs | 2 +- cardano-cli/src/Cardano/CLI/Options/Debug.hs | 2 +- cardano-cli/src/Cardano/CLI/Options/Key.hs | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index a9c59a36dc..bbd64013f7 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -13,6 +13,7 @@ module Cardano.CLI.Byron.Delegation ) where +import Cardano.Api.Byron (ACertificate (delegateVK)) import Cardano.Api.Byron hiding (delegateVK) import qualified Cardano.Api.Ledger as L diff --git a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs index e678e0de29..dbf82deab7 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs @@ -24,7 +24,7 @@ module Cardano.CLI.Byron.Parsers ) where -import Cardano.Api hiding (GenesisParameters, UpdateProposal, parseFilePath) +import Cardano.Api hiding (GenesisParameters, UpdateProposal) import Cardano.Api.Byron (ByronProtocolParametersUpdate (..), toByronLovelace) import qualified Cardano.Api.Byron as Byron import qualified Cardano.Api.Ledger as L diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs index 6e3c9494c7..d6cbb47366 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs @@ -12,9 +12,9 @@ module Cardano.CLI.EraBased.Options.Common where -import Cardano.Api hiding (bounded, parseFilePath) +import Cardano.Api import qualified Cardano.Api.Ledger as L -import Cardano.Api.Shelley hiding (bounded, parseFilePath) +import Cardano.Api.Shelley import Cardano.CLI.Environment (EnvCli (..), envCliAnyEon) import Cardano.CLI.Parser diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs index 826d7d5680..ab8caa71ba 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs @@ -9,7 +9,7 @@ module Cardano.CLI.EraBased.Options.Genesis ) where -import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) +import Cardano.Api hiding (QueryInShelleyBasedEra (..)) import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin (..)) diff --git a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs index e618806008..b30106c092 100644 --- a/cardano-cli/src/Cardano/CLI/Legacy/Options.hs +++ b/cardano-cli/src/Cardano/CLI/Legacy/Options.hs @@ -18,7 +18,7 @@ module Cardano.CLI.Legacy.Options ) where -import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) +import Cardano.Api hiding (QueryInShelleyBasedEra (..)) import qualified Cardano.Api.Byron as Byron import Cardano.Api.Ledger (Coin (..)) diff --git a/cardano-cli/src/Cardano/CLI/Options/Debug.hs b/cardano-cli/src/Cardano/CLI/Options/Debug.hs index a7ecbf9a3a..36fa113efc 100644 --- a/cardano-cli/src/Cardano/CLI/Options/Debug.hs +++ b/cardano-cli/src/Cardano/CLI/Options/Debug.hs @@ -11,7 +11,7 @@ module Cardano.CLI.Options.Debug ) where -import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..), parseFilePath) +import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..)) import Cardano.CLI.Commands.Debug import Cardano.CLI.Commands.Debug.LogEpochState diff --git a/cardano-cli/src/Cardano/CLI/Options/Key.hs b/cardano-cli/src/Cardano/CLI/Options/Key.hs index 2b93c6f7b0..3124e68d62 100644 --- a/cardano-cli/src/Cardano/CLI/Options/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Options/Key.hs @@ -8,7 +8,7 @@ module Cardano.CLI.Options.Key ) where -import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath) +import Cardano.Api hiding (QueryInShelleyBasedEra (..)) import Cardano.CLI.Commands.Key import Cardano.CLI.EraBased.Options.Common