Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove direct dependencies from cardano-ledger-* #941

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ repository cardano-haskell-packages
c00aae8461a256275598500ea0e187588c35a5d5d7454fb57eac18d9edb86a56
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

source-repository-package
type: git
location: https://github.com/intersectmbo/cardano-api.git
tag: f85788ec556508446ddfd54eba89690aa9988cb0
subdir: cardano-api
--sha256: sha256-UGL0U1JLJ6yWBAfLDnnDjODnqxutLzVwArNEDmnx+X4=

-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
Expand Down
4 changes: 0 additions & 4 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ library
cardano-crypto-wrapper ^>=1.5.1,
cardano-data >=1.1,
cardano-git-rev ^>=0.2.2,
cardano-ledger-api,
cardano-ledger-core,
cardano-ledger-shelley,
cardano-ping ^>=0.4,
cardano-prelude,
cardano-slotting ^>=0.2.0.0,
Expand Down Expand Up @@ -377,7 +374,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,
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ txSpendUTxOByronPBFT nId sk txIns outs = do
in makeSignedByronTransaction [bWit] txBody

fromByronWitness
:: Byron.SomeByronSigningKey -> NetworkId -> L.Annotated L.Tx ByteString -> KeyWitness ByronEra
:: Byron.SomeByronSigningKey -> NetworkId -> L.Annotated Byron.Tx ByteString -> KeyWitness ByronEra
fromByronWitness bw nId txBody =
case bw of
Byron.AByronSigningKeyLegacy sk -> makeByronKeyWitness nId txBody sk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import qualified Cardano.CLI.Commands.Hash as Cmd
import Cardano.CLI.Environment (EnvCli (..))
import qualified Cardano.CLI.EraBased.Commands.StakePool as Cmd
import Cardano.CLI.EraBased.Options.Common
import qualified Cardano.Ledger.SafeHash as L

import qualified Data.Foldable as F
import Options.Applicative hiding (help, str)
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import Cardano.CLI.Types.Output (QueryDRepStateOutput (..))
import qualified Cardano.CLI.Types.Output as O
import Cardano.Crypto.Hash (hashToBytesAsHex)
import qualified Cardano.Crypto.Hash.Blake2b as Blake2b
import qualified Cardano.Ledger.Shelley.LedgerState as L
import Cardano.Slotting.EpochInfo (EpochInfo (..), epochInfoSlotToUTCTime, hoistEpochInfo)
import Ouroboros.Consensus.BlockchainTime.WallClock.Types (RelativeTime (..),
toRelativeTime)
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import Cardano.CLI.Types.Errors.TxCmdError
import Cardano.CLI.Types.Errors.TxValidationError
import Cardano.CLI.Types.Output (renderScriptCosts)
import Cardano.CLI.Types.TxFeature
import qualified Cardano.Ledger.Api.PParams as L
import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Consensus
import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Client as Net.Tx

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ validateCBOR cborObject bs =
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 L.Tx)
void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Byron.Tx)
Right "Valid Byron Tx."
CBORUpdateProposalByron -> do
void $ decodeCBOR bs (L.fromCBOR :: L.Decoder s Byron.Proposal)
Expand Down
12 changes: 4 additions & 8 deletions cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ 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)
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),
Expand All @@ -54,11 +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 Cardano.Ledger.Plutus (ExUnits (..))
import Cardano.Ledger.Plutus.Data (unData)
import qualified Cardano.Ledger.TxIn as Ledger

import Data.Aeson (Value (..), object, toJSON, (.=))
import qualified Data.Aeson as Aeson
Expand Down Expand Up @@ -359,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)
Expand Down Expand Up @@ -394,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]
Expand Down
4 changes: 1 addition & 3 deletions cardano-cli/src/Cardano/CLI/Orphans.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ 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

-- TODO upstream this orphaned instance to the ledger
Expand Down
9 changes: 4 additions & 5 deletions cardano-cli/src/Cardano/CLI/Types/Errors/HashCmdError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 ->
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down