Skip to content

Commit

Permalink
Unify qualification of Cardano.Api.Ledger to L
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Feb 13, 2024
1 parent 46407d1 commit 47eaafa
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 161 deletions.
30 changes: 15 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Commands/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Cardano.CLI.EraBased.Commands.Governance.Actions
) where

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

import Cardano.CLI.Types.Common
Expand All @@ -44,11 +44,11 @@ data GovernanceActionCmds era
data GoveranceActionUpdateCommitteeCmdArgs era
= GoveranceActionUpdateCommitteeCmdArgs
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, oldCommitteeVkeySource :: ![VerificationKeyOrHashOrFile CommitteeColdKey]
, newCommitteeVkeySource :: ![(VerificationKeyOrHashOrFile CommitteeColdKey, EpochNo)]
, requiredQuorum :: !Rational
Expand All @@ -59,37 +59,37 @@ data GoveranceActionUpdateCommitteeCmdArgs era
data GovernanceActionCreateConstitutionCmdArgs era
= GovernanceActionCreateConstitutionCmdArgs
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, stakeCredential :: !(VerificationKeyOrHashOrFile StakeKey)
, mPrevGovernanceActionId :: !(Maybe (TxId, Word32))
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, constitutionUrl :: !ConstitutionUrl
, constitutionHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, constitutionHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, outFile :: !(File () Out)
} deriving Show

-- | Datatype to carry data for the create-info governance action
data GovernanceActionInfoCmdArgs era
= GovernanceActionInfoCmdArgs
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, returnStakeAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, outFile :: !(File () Out)
} deriving Show

data GovernanceActionCreateNoConfidenceCmdArgs era
= GovernanceActionCreateNoConfidenceCmdArgs
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, returnStakeAddress :: !(VerificationKeyOrHashOrFile StakeKey)
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, governanceActionId :: !TxId
, governanceActionIndex :: !Word32
, outFile :: !(File () Out)
Expand All @@ -115,11 +115,11 @@ data GovernanceActionProtocolParametersUpdateCmdArgs era
data GovernanceActionTreasuryWithdrawalCmdArgs era
= GovernanceActionTreasuryWithdrawalCmdArgs
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddr :: !(VerificationKeyOrHashOrFile StakeKey)
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, treasuryWithdrawal :: ![(VerificationKeyOrHashOrFile StakeKey, Lovelace)]
, constitutionScriptHash :: !(Maybe ScriptHash)
, outFile :: !(File () Out)
Expand All @@ -136,19 +136,19 @@ data GovernanceActionViewCmdArgs era
data UpdateProtocolParametersConwayOnwards era
= UpdateProtocolParametersConwayOnwards
{ eon :: !(ConwayEraOnwards era)
, networkId :: !Ledger.Network
, networkId :: !L.Network
, deposit :: !Lovelace
, returnAddr :: !(VerificationKeyOrHashOrFile StakeKey)
, proposalUrl :: !ProposalUrl
, proposalHash :: !(Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, proposalHash :: !(L.SafeHash L.StandardCrypto L.AnchorData)
, governanceActionId :: !(Maybe (TxId, Word32))
, constitutionScriptHash :: !(Maybe ScriptHash)
}

data CostModelsFile era
= CostModelsFile
{ eon :: !(AlonzoEraOnwards era)
, costModelsFile :: !(File Ledger.CostModels In)
, costModelsFile :: !(File L.CostModels In)
} deriving Show

deriving instance Show (UpdateProtocolParametersConwayOnwards era)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Cardano.CLI.EraBased.Commands.Governance.Committee
) where

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

import Cardano.CLI.Types.Key
Expand Down Expand Up @@ -61,7 +61,7 @@ data GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs era =
GovernanceCommitteeCreateColdKeyResignationCertificateCmdArgs
{ eon :: !(ConwayEraOnwards era)
, vkeyColdKeySource :: !(VerificationKeyOrHashOrFile CommitteeColdKey)
, anchor :: !(Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era))))
, anchor :: !(Maybe (L.Anchor (L.EraCrypto (ShelleyLedgerEra era))))
, outFile :: !(File () Out)
} deriving Show

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module Cardano.CLI.EraBased.Commands.Governance.DRep
where

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

import Cardano.CLI.Types.Common
Expand Down Expand Up @@ -50,7 +50,7 @@ data GovernanceDRepRegistrationCertificateCmdArgs era =
{ eon :: !(ConwayEraOnwards era)
, drepHashSource :: !DRepHashSource
, deposit :: !Lovelace
, mAnchor :: !(Maybe (Ledger.Anchor (Ledger.EraCrypto (ShelleyLedgerEra era))))
, mAnchor :: !(Maybe (L.Anchor (L.EraCrypto (ShelleyLedgerEra era))))
, outFile :: !(File () Out)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Cardano.CLI.EraBased.Commands.Governance.Vote
, GovernanceVoteCreateCmdArgs(..)
, renderGovernanceVoteCmds
) where
import qualified Cardano.Api.Ledger as Ledger
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley

import Cardano.CLI.Types.Common
Expand All @@ -30,7 +30,7 @@ data GovernanceVoteCreateCmdArgs era
, voteChoice :: Vote
, governanceAction :: (TxId, Word32)
, votingStakeCredentialSource :: AnyVotingStakeVerificationKeyOrHashOrFile
, mAnchor :: Maybe (VoteUrl, Ledger.SafeHash Ledger.StandardCrypto Ledger.AnchorData)
, mAnchor :: Maybe (VoteUrl, L.SafeHash L.StandardCrypto L.AnchorData)
, outFile :: VoteFile Out
}

Expand Down
25 changes: 12 additions & 13 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ module Cardano.CLI.EraBased.Options.Governance.Actions
) where

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

import qualified Cardano.CLI.EraBased.Commands.Governance.Actions as Cmd
Expand Down Expand Up @@ -219,20 +218,20 @@ pGovernanceActionProtocolParametersUpdateCmd era = do
<$> pUpdateProtocolParametersCmd w


convertToLedger :: (a -> b) -> Parser (Maybe a) -> Parser (StrictMaybe b)
convertToLedger conv = fmap (maybeToStrictMaybe . fmap conv)
convertToLedger :: (a -> b) -> Parser (Maybe a) -> Parser (L.StrictMaybe b)
convertToLedger conv = fmap (L.maybeToStrictMaybe . fmap conv)

toNonNegativeIntervalOrErr :: Rational -> NonNegativeInterval
toNonNegativeIntervalOrErr r = case Ledger.boundRational r of
toNonNegativeIntervalOrErr :: Rational -> L.NonNegativeInterval
toNonNegativeIntervalOrErr r = case L.boundRational r of
Nothing ->
error $ mconcat [ "toNonNegativeIntervalOrErr: "
, "rational out of bounds " <> show r
]
Just n -> n

mkProtocolVersionOrErr :: (Natural, Natural) -> Ledger.ProtVer
mkProtocolVersionOrErr :: (Natural, Natural) -> L.ProtVer
mkProtocolVersionOrErr (majorProtVer, minorProtVer) =
case (`Ledger.ProtVer` minorProtVer) <$> Ledger.mkVersion majorProtVer of
case (`L.ProtVer` minorProtVer) <$> L.mkVersion majorProtVer of
Just v -> v
Nothing ->
error $ "mkProtocolVersionOrErr: invalid protocol version " <> show (majorProtVer, minorProtVer)
Expand Down Expand Up @@ -273,7 +272,7 @@ pShelleyToAlonzoPParams =

pAlonzoOnwardsPParams :: Parser (AlonzoOnwardsPParams ledgerera)
pAlonzoOnwardsPParams =
AlonzoOnwardsPParams SNothing -- The cost models are read separately from a file, so we use 'SNothing' as the place holder here
AlonzoOnwardsPParams L.SNothing -- The cost models are read separately from a file, so we use 'SNothing' as the place holder here
<$> convertToLedger (either (\e -> error $ "pAlonzoOnwardsPParams: " <> show e) id . toAlonzoPrices)
(optional pExecutionUnitPrices)
<*> convertToLedger toAlonzoExUnits (optional pMaxTxExecutionUnits)
Expand All @@ -286,7 +285,7 @@ pAlonzoOnwardsPParams =
pIntroducedInBabbagePParams :: Parser (IntroducedInBabbagePParams ledgerera)
pIntroducedInBabbagePParams =
IntroducedInBabbagePParams
<$> convertToLedger (CoinPerByte . toShelleyLovelace) (optional pUTxOCostPerByte)
<$> convertToLedger (L.CoinPerByte . toShelleyLovelace) (optional pUTxOCostPerByte)

pIntroducedInConwayPParams :: Parser (IntroducedInConwayPParams ledgerera)
pIntroducedInConwayPParams =
Expand Down Expand Up @@ -363,13 +362,13 @@ pGovernanceActionTreasuryWithdrawalCmd era = do
)
$ Opt.progDesc "Create a treasury withdrawal."

pNetwork :: Parser Ledger.Network
pNetwork :: Parser L.Network
pNetwork = asum $ mconcat
[ [ Opt.flag' Ledger.Mainnet $ mconcat
[ [ Opt.flag' L.Mainnet $ mconcat
[ Opt.long "mainnet"
, Opt.help "Use the mainnet magic id."
]
, Opt.flag' Ledger.Testnet $ mconcat
, Opt.flag' L.Testnet $ mconcat
[ Opt.long "testnet"
, Opt.help "Use the testnet magic id."
]
Expand Down
16 changes: 8 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module Cardano.CLI.EraBased.Run.Governance
) where

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

import qualified Cardano.CLI.EraBased.Commands.Governance as Cmd
Expand Down Expand Up @@ -79,7 +79,7 @@ runGovernanceCmds = \case

runGovernanceMIRCertificatePayStakeAddrs
:: ShelleyToBabbageEra era
-> Ledger.MIRPot
-> L.MIRPot
-> [StakeAddress] -- ^ Stake addresses
-> [Lovelace] -- ^ Corresponding reward amounts (same length)
-> File () Out
Expand All @@ -90,8 +90,8 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do
(unFile oFp) (length sAddrs) (length rwdAmts)

let sCreds = map stakeAddressCredential sAddrs
mirTarget = Ledger.StakeAddressesMIR
$ Map.fromList [ (toShelleyStakeCredential scred, Ledger.toDeltaCoin (toShelleyLovelace rwdAmt))
mirTarget = L.StakeAddressesMIR
$ Map.fromList [ (toShelleyStakeCredential scred, L.toDeltaCoin (toShelleyLovelace rwdAmt))
| (scred, rwdAmt) <- zip sCreds rwdAmts
]
let mirCert = makeMIRCertificate
Expand All @@ -113,9 +113,9 @@ runGovernanceCreateMirCertificateTransferToTreasuryCmd :: ()
-> File () Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToTreasuryCmd w ll oFp = do
let mirTarget = Ledger.SendToOppositePotMIR (toShelleyLovelace ll)
let mirTarget = L.SendToOppositePotMIR (toShelleyLovelace ll)

let mirCert = makeMIRCertificate $ MirCertificateRequirements w Ledger.ReservesMIR mirTarget
let mirCert = makeMIRCertificate $ MirCertificateRequirements w L.ReservesMIR mirTarget

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand All @@ -132,9 +132,9 @@ runGovernanceCreateMirCertificateTransferToReservesCmd :: ()
-> File () Out
-> ExceptT GovernanceCmdError IO ()
runGovernanceCreateMirCertificateTransferToReservesCmd w ll oFp = do
let mirTarget = Ledger.SendToOppositePotMIR (toShelleyLovelace ll)
let mirTarget = L.SendToOppositePotMIR (toShelleyLovelace ll)

let mirCert = makeMIRCertificate $ MirCertificateRequirements w Ledger.TreasuryMIR mirTarget
let mirCert = makeMIRCertificate $ MirCertificateRequirements w L.TreasuryMIR mirTarget

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand Down
Loading

0 comments on commit 47eaafa

Please sign in to comment.