Skip to content

Commit

Permalink
Remove extra imports and update references to Ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Feb 13, 2024
1 parent 06bb710 commit 46407d1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import Cardano.Api.Shelley

import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Key
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo

import Data.Text (Text)
import Data.Word
Expand Down
15 changes: 7 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Cardano.CLI.EraBased.Options.Common where

import Cardano.Api
import qualified Cardano.Api.Ledger as L
import qualified Cardano.Api.Ledger as Ledger
import Cardano.Api.Pretty
import Cardano.Api.Shelley

Expand Down Expand Up @@ -100,7 +99,7 @@ pNetworkId envCli = asum $ mconcat
]

toUnitIntervalOrErr :: Rational -> L.UnitInterval
toUnitIntervalOrErr r = case Ledger.boundRational r of
toUnitIntervalOrErr r = case L.boundRational r of
Nothing ->
error $ mconcat [ "toUnitIntervalOrErr: "
, "rational out of bounds " <> show r
Expand Down Expand Up @@ -883,10 +882,10 @@ pConstitutionHash =
, Opt.help "Hash of the constitution data (obtain it with \"cardano-cli conway governance hash anchor-data ...\")."
]

pUrl :: String -> String -> Parser Ledger.Url
pUrl :: String -> String -> Parser L.Url
pUrl l h =
let toUrl urlText = fromMaybe (error "Url longer than 64 bytes")
$ Ledger.textToUrl (Text.length urlText) urlText
$ L.textToUrl (Text.length urlText) urlText
in fmap toUrl . Opt.strOption
$ mconcat [ Opt.long l
, Opt.metavar "TEXT"
Expand Down Expand Up @@ -2855,9 +2854,9 @@ pProtocolVersion =
]
]

pPoolVotingThresholds :: Parser Ledger.PoolVotingThresholds
pPoolVotingThresholds :: Parser L.PoolVotingThresholds
pPoolVotingThresholds =
Ledger.PoolVotingThresholds
L.PoolVotingThresholds
<$> pMotionNoConfidence
<*> pCommitteeNormal
<*> pCommitteeNoConfidence
Expand Down Expand Up @@ -2895,9 +2894,9 @@ pPoolVotingThresholds =
, Opt.help "Acceptance threshold for stake pool votes on protocol parameters for parameters in the 'security' group."
]

pDRepVotingThresholds :: Parser Ledger.DRepVotingThresholds
pDRepVotingThresholds :: Parser L.DRepVotingThresholds
pDRepVotingThresholds =
Ledger.DRepVotingThresholds
L.DRepVotingThresholds
<$> pMotionNoConfidence
<*> pCommitteeNormal
<*> pCommitteeNoConfidence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ updateOutputTemplate

mkStuffedUtxo :: [AddressInEra ShelleyEra] -> [(AddressInEra ShelleyEra, Lovelace)]
mkStuffedUtxo xs = (, Lovelace minUtxoVal) <$> xs
where L.Coin minUtxoVal = sgProtocolParams template ^. L.ppMinUTxOValueL
where L.Coin minUtxoVal = sgProtocolParams ^. L.ppMinUTxOValueL

shelleyDelKeys = Map.fromList
[ (gh, L.GenDelegPair gdh h)
Expand Down
12 changes: 6 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -657,14 +657,14 @@ updateOutputTemplate
-> Maybe Lovelace -- ^ Amount of lovelace not delegated
-> Int -- ^ Number of UTxO addresses that are delegating
-> [AddressInEra ShelleyEra] -- ^ UTxO addresses that are not delegating
-> [(Ledger.KeyHash 'Ledger.StakePool StandardCrypto, Ledger.PoolParams StandardCrypto)] -- ^ Pool map
-> [(Ledger.KeyHash 'Ledger.Staking StandardCrypto, Ledger.KeyHash 'Ledger.StakePool StandardCrypto)] -- ^ Delegaton map
-> [(L.KeyHash 'L.StakePool L.StandardCrypto, L.PoolParams L.StandardCrypto)] -- ^ Pool map
-> [(L.KeyHash 'L.Staking L.StandardCrypto, L.KeyHash 'L.StakePool L.StandardCrypto)] -- ^ Delegaton map
-> Maybe Lovelace -- ^ Amount of lovelace to delegate
-> Int -- ^ Number of UTxO address for delegation
-> [AddressInEra ShelleyEra] -- ^ UTxO address for delegation
-> [AddressInEra ShelleyEra] -- ^ Stuffed UTxO addresses
-> ShelleyGenesis StandardCrypto -- ^ Template from which to build a genesis
-> ShelleyGenesis StandardCrypto -- ^ Updated genesis
-> ShelleyGenesis L.StandardCrypto -- ^ Template from which to build a genesis
-> ShelleyGenesis L.StandardCrypto -- ^ Updated genesis
updateOutputTemplate
(SystemStart sgSystemStart)
genDelegMap mAmountNonDeleg nUtxoAddrsNonDeleg utxoAddrsNonDeleg pools stake
Expand Down Expand Up @@ -709,10 +709,10 @@ updateOutputTemplate

mkStuffedUtxo :: [AddressInEra ShelleyEra] -> [(AddressInEra ShelleyEra, Lovelace)]
mkStuffedUtxo xs = (, Lovelace minUtxoVal) <$> xs
where Coin minUtxoVal = sgProtocolParams ^. ppMinUTxOValueL
where L.Coin minUtxoVal = sgProtocolParams ^. L.ppMinUTxOValueL

shelleyDelKeys = Map.fromList
[ (gh, Ledger.GenDelegPair gdh h)
[ (gh, L.GenDelegPair gdh h)
| (GenesisKeyHash gh,
(GenesisDelegateKeyHash gdh, VrfKeyHash h)) <- Map.toList genDelegMap
]
Expand Down
12 changes: 5 additions & 7 deletions cardano-cli/src/Cardano/CLI/Types/Errors/TxValidationError.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import Cardano.Api.Pretty
import Cardano.Api.Shelley

import Cardano.CLI.Types.Common
import qualified Cardano.Ledger.Conway.Governance as Conway
import qualified Cardano.Ledger.Core as Ledger

import Prelude

Expand Down Expand Up @@ -311,14 +309,14 @@ conjureWitness era errF =

getVotingScriptCredentials
:: VotingProcedures era
-> Maybe (Conway.Voter (L.EraCrypto (ShelleyLedgerEra era)))
getVotingScriptCredentials (VotingProcedures (Conway.VotingProcedures m)) =
-> Maybe (L.Voter (L.EraCrypto (ShelleyLedgerEra era)))
getVotingScriptCredentials (VotingProcedures (L.VotingProcedures m)) =
listToMaybe $ Map.keys m

votingScriptWitnessSingleton
:: VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map (Conway.Voter (L.EraCrypto (ShelleyLedgerEra era))) (ScriptWitness WitCtxStake era)
-> Map (L.Voter (L.EraCrypto (ShelleyLedgerEra era))) (ScriptWitness WitCtxStake era)
votingScriptWitnessSingleton _ Nothing = Map.empty
votingScriptWitnessSingleton votingProcedures (Just scriptWitness) =
let voter = fromJust $ getVotingScriptCredentials votingProcedures
Expand All @@ -344,13 +342,13 @@ convertToTxVotingProcedures votingProcedures =
proposingScriptWitnessSingleton
:: Proposal era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map (Conway.ProposalProcedure (ShelleyLedgerEra era)) (ScriptWitness WitCtxStake era)
-> Map (L.ProposalProcedure (ShelleyLedgerEra era)) (ScriptWitness WitCtxStake era)
proposingScriptWitnessSingleton _ Nothing = Map.empty
proposingScriptWitnessSingleton (Proposal proposalProcedure) (Just scriptWitness) =
Map.singleton proposalProcedure scriptWitness

convToTxProposalProcedures
:: Ledger.EraPParams (ShelleyLedgerEra era)
:: L.EraPParams (ShelleyLedgerEra era)
=> [(Proposal era, Maybe (ScriptWitness WitCtxStake era))]
-> TxProposalProcedures BuildTx era
convToTxProposalProcedures proposalProcedures =
Expand Down

0 comments on commit 46407d1

Please sign in to comment.