From 68dbd1211791648270be3ea16daf5a9464f52e29 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Thu, 10 Oct 2024 23:36:59 +0200 Subject: [PATCH 1/3] Remove transitive dependencies to `cardano-ledger-shelley` --- cardano-cli/cardano-cli.cabal | 2 -- cardano-cli/src/Cardano/CLI/Orphans.hs | 2 +- .../test/cardano-cli-golden/Test/Golden/CreateStaked.hs | 4 +--- .../cardano-cli-golden/Test/Golden/CreateTestnetData.hs | 9 ++++----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 6a819b8235..65538bcd23 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -205,7 +205,6 @@ library cardano-git-rev ^>=0.2.2, cardano-ledger-api, cardano-ledger-core, - cardano-ledger-shelley, cardano-ping ^>=0.5, cardano-prelude, cardano-slotting ^>=0.2.0.0, @@ -377,7 +376,6 @@ test-suite cardano-cli-golden cardano-cli, cardano-cli:cardano-cli-test-lib, cardano-crypto-wrapper, - cardano-ledger-shelley >=1.10.0.0, cardano-strict-containers ^>=0.1, cborg, containers, diff --git a/cardano-cli/src/Cardano/CLI/Orphans.hs b/cardano-cli/src/Cardano/CLI/Orphans.hs index 49ea88a225..469a87ff53 100644 --- a/cardano-cli/src/Cardano/CLI/Orphans.hs +++ b/cardano-cli/src/Cardano/CLI/Orphans.hs @@ -6,10 +6,10 @@ module Cardano.CLI.Orphans where import Cardano.Api +import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (scriptDataToJsonDetailedSchema) import qualified Cardano.Ledger.Api as L -import qualified Cardano.Ledger.Shelley.LedgerState as L import Data.Aeson diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateStaked.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateStaked.hs index 6382af380b..625761fc0c 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateStaked.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateStaked.hs @@ -2,11 +2,9 @@ module Test.Golden.CreateStaked where -import Cardano.Api.Ledger (StandardCrypto) +import Cardano.Api.Ledger (ShelleyGenesisStaking (sgsPools, sgsStake), StandardCrypto) import Cardano.Api.Shelley (ShelleyGenesis (sgNetworkMagic, sgStaking)) -import Cardano.Ledger.Shelley.Genesis (ShelleyGenesisStaking (sgsPools, sgsStake)) - import Control.Monad (filterM, void) import Control.Monad.IO.Class import qualified Data.Aeson as Aeson diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs index a7205a38c5..de04c4a41e 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.hs @@ -6,10 +6,9 @@ module Test.Golden.CreateTestnetData where import Cardano.Api import Cardano.Api.Ledger (ConwayGenesis (..), StandardCrypto) +import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (ShelleyGenesis (..)) -import qualified Cardano.Ledger.Shelley.API as L - import Control.Monad import Data.List (intercalate, sort) import qualified Data.Sequence.Strict as Seq @@ -177,9 +176,9 @@ hprop_golden_create_testnet_data_deleg_non_deleg = genesis :: ShelleyGenesis StandardCrypto <- H.readJsonFileOk $ outputDir "shelley-genesis.json" -- Because we don't test this elsewhere in this file: - (L.sgMaxLovelaceSupply genesis) H.=== (fromIntegral totalSupply) + (sgMaxLovelaceSupply genesis) H.=== (fromIntegral totalSupply) - let initialFunds = toList $ L.sgInitialFunds genesis + let initialFunds = toList $ sgInitialFunds genesis -- This checks that there is actually only one funded address (length initialFunds) H.=== 1 @@ -205,7 +204,7 @@ hprop_golden_create_testnet_data_shelley_genesis_output = vanillaShelleyGenesis :: ShelleyGenesis StandardCrypto <- H.readJsonFileOk "test/cardano-cli-golden/files/input/shelley/genesis/genesis.spec.json" let tweakedValue = 3_123_456_000_000 - tweakedShelleyGenesis = vanillaShelleyGenesis{L.sgMaxLovelaceSupply = tweakedValue} + tweakedShelleyGenesis = vanillaShelleyGenesis{sgMaxLovelaceSupply = tweakedValue} tweakedShelleyGenesisFp = tempDir "tweaked-shelley-genesis.json" void $ liftIO $ writeFileJSON tweakedShelleyGenesisFp tweakedShelleyGenesis From 6291993d004d5370ef41bbfbaf743a11351a59b1 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Wed, 16 Oct 2024 13:45:29 +0200 Subject: [PATCH 2/3] Remove transitive dependencies to `cardano-ledger-core` --- cardano-cli/cardano-cli.cabal | 1 - .../src/Cardano/CLI/EraBased/Options/Governance/DRep.hs | 4 +--- cardano-cli/src/Cardano/CLI/Json/Friendly.hs | 6 ++---- cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs | 9 ++++----- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 65538bcd23..cfa8699cfa 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-core, cardano-ping ^>=0.5, cardano-prelude, cardano-slotting ^>=0.2.0.0, diff --git a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs index e343be5486..8dfc867370 100644 --- a/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs +++ b/cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/DRep.hs @@ -10,7 +10,6 @@ module Cardano.CLI.EraBased.Options.Governance.DRep where import Cardano.Api -import Cardano.Api.Ledger (extractHash) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (Hash (DRepMetadataHash)) @@ -22,7 +21,6 @@ import Cardano.CLI.Parser import Cardano.CLI.Read import Cardano.CLI.Types.Common hiding (CheckHash) import Cardano.CLI.Types.Key -import Cardano.Ledger.SafeHash (castSafeHash) import Control.Applicative import Data.Foldable @@ -135,7 +133,7 @@ pDrepMetadataUrl = pExpectedDrepMetadataHash :: Parser (Hash DRepMetadata) pExpectedDrepMetadataHash = - pExpectedHash (DRepMetadataHash . extractHash . castSafeHash) "DRep metadata" + pExpectedHash (DRepMetadataHash . L.extractHash . L.castSafeHash) "DRep metadata" pDrepMetadataHash :: Parser (L.SafeHash L.StandardCrypto L.AnchorData) pDrepMetadataHash = diff --git a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index 857ad78d74..d92012d9c0 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -42,7 +42,7 @@ where import Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness)) -import Cardano.Api.Ledger (extractHash, strictMaybeToMaybe) +import Cardano.Api.Ledger (ExUnits (..), extractHash, strictMaybeToMaybe, unData) import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (Hash (..), KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..), @@ -56,9 +56,7 @@ import Cardano.CLI.Types.MonadWarning (MonadWarning, runWarningIO) import Cardano.Crypto.Hash (hashToTextAsHex) 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 +import qualified Cardano.Ledger.Api.Tx.In as Ledger import Data.Aeson (Value (..), object, toJSON, (.=)) import qualified Data.Aeson as Aeson diff --git a/cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs b/cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs index 8183f8e420..7441cc4fd1 100644 --- a/cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs +++ b/cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs @@ -13,7 +13,6 @@ import Cardano.Api import qualified Cardano.Api.Ledger as L import Cardano.CLI.Read (ScriptDecodeError) -import Cardano.Ledger.SafeHash (extractHash) import Cardano.Prelude (Exception (displayException), IOException) import Network.HTTP.Client (HttpException) @@ -35,9 +34,9 @@ instance Error HashCmdError where HashMismatchedHashError expectedHash actualHash -> "Hashes do not match!" <> "\nExpected:" - <+> pretty (show (extractHash expectedHash)) + <+> pretty (show (L.extractHash expectedHash)) <> "\n Actual:" - <+> pretty (show (extractHash actualHash)) + <+> pretty (show (L.extractHash actualHash)) HashReadFileError filepath exc -> "Cannot read" <+> pretty filepath <> ":" <+> pretty (displayException exc) HashWriteFileError fileErr -> @@ -92,7 +91,7 @@ instance Exception HashCheckError where displayException (HashMismatchError expectedHash actualHash) = "Hashes do not match!" <> "\nExpected: " - <> show (extractHash expectedHash) + <> show (L.extractHash expectedHash) <> "\n Actual: " - <> show (extractHash actualHash) + <> show (L.extractHash actualHash) displayException (FetchURLError fetchErr) = displayException fetchErr From 2f8cfb0e938bb5d9607d2069b5a2e3580b82f376 Mon Sep 17 00:00:00 2001 From: Pablo Lamela Date: Thu, 17 Oct 2024 14:21:38 +0200 Subject: [PATCH 3/3] Remove transitive dependencies to `cardano-ledger-api` --- cardano-cli/cardano-cli.cabal | 1 - cardano-cli/src/Cardano/CLI/Json/Friendly.hs | 10 ++++------ cardano-cli/src/Cardano/CLI/Orphans.hs | 2 -- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index cfa8699cfa..0f1fec824f 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -203,7 +203,6 @@ library cardano-crypto-wrapper ^>=1.5.1, cardano-data >=1.1, cardano-git-rev ^>=0.2.2, - cardano-ledger-api, cardano-ping ^>=0.5, cardano-prelude, cardano-slotting ^>=0.2.0.0, diff --git a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs index d92012d9c0..8549ae2a25 100644 --- a/cardano-cli/src/Cardano/CLI/Json/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Json/Friendly.hs @@ -42,8 +42,9 @@ where import Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness)) -import Cardano.Api.Ledger (ExUnits (..), extractHash, strictMaybeToMaybe, unData) +import Cardano.Api.Ledger (ExUnits (..), extractHash, strictMaybeToMaybe) import qualified Cardano.Api.Ledger as L +import qualified Cardano.Api.Ledger as Ledger import Cardano.Api.Shelley (Hash (..), KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..), ShelleyLedgerEra, StakeAddress (..), Tx (ShelleyTx), @@ -54,9 +55,6 @@ import Cardano.CLI.Orphans () import Cardano.CLI.Types.Common (ViewOutputFormat (..)) import Cardano.CLI.Types.MonadWarning (MonadWarning, runWarningIO) import Cardano.Crypto.Hash (hashToTextAsHex) -import qualified Cardano.Ledger.Api as Ledger -import Cardano.Ledger.Api.Tx.In (txIxToInt) -import qualified Cardano.Ledger.Api.Tx.In as Ledger import Data.Aeson (Value (..), object, toJSON, (.=)) import qualified Data.Aeson as Aeson @@ -357,7 +355,7 @@ getRedeemerDetails aeo tb = friendlyRedeemer :: Ledger.Data (ShelleyLedgerEra era) -> ExUnits -> Aeson.Value friendlyRedeemer scriptData ExUnits{exUnitsSteps = exSteps, exUnitsMem = exMemUnits} = object - [ "data" .= Aeson.String (T.pack $ show $ unData scriptData) + [ "data" .= Aeson.String (T.pack $ show $ Ledger.unData scriptData) , "execution units" .= object [ "steps" .= Aeson.Number (fromIntegral exSteps) @@ -392,7 +390,7 @@ getRedeemerDetails aeo tb = friendlyInput (Ledger.TxIn (Ledger.TxId txidHash) ix) = Aeson.String $ T.pack $ - T.unpack (hashToTextAsHex (extractHash txidHash)) ++ "#" ++ show (txIxToInt ix) + T.unpack (hashToTextAsHex (extractHash txidHash)) ++ "#" ++ show (Ledger.txIxToInt ix) addLabelToPurpose :: ToJSON v => EraIndependentPlutusScriptPurpose -> v -> Aeson.Value addLabelToPurpose Spending sp = Aeson.object ["spending script witnessed input" .= sp] diff --git a/cardano-cli/src/Cardano/CLI/Orphans.hs b/cardano-cli/src/Cardano/CLI/Orphans.hs index 469a87ff53..acf579f4b0 100644 --- a/cardano-cli/src/Cardano/CLI/Orphans.hs +++ b/cardano-cli/src/Cardano/CLI/Orphans.hs @@ -9,8 +9,6 @@ import Cardano.Api import qualified Cardano.Api.Ledger as L import Cardano.Api.Shelley (scriptDataToJsonDetailedSchema) -import qualified Cardano.Ledger.Api as L - import Data.Aeson -- TODO upstream this orphaned instance to the ledger