Skip to content

Commit

Permalink
Remove replace BundledProtocolParameters with Ledger.PParams
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Aug 14, 2023
1 parent 16cf1d7 commit 6cc0351
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Cardano.Api.Ledger
import Cardano.Api.Shelley

import Cardano.CLI.EraBased.Commands.Governance.Actions
import Cardano.CLI.EraBased.Legacy
import Cardano.CLI.EraBased.Options.Common
import Cardano.Ledger.BaseTypes (NonNegativeInterval)
import qualified Cardano.Ledger.BaseTypes as Ledger
Expand Down Expand Up @@ -122,9 +121,9 @@ mkProtocolVersionOrErr (majorProtVer, minorProtVer) =
Nothing ->
error $ "mkProtocolVersionOrErr: invalid protocol version " <> show (majorProtVer, minorProtVer)

pCommonProtocolParameters :: Parser CommonProtocolParameters
pCommonProtocolParameters :: Parser CommonProtocolParametersUpdate
pCommonProtocolParameters =
CommonProtocolParameters
CommonProtocolParametersUpdate
<$> convertToLedger toShelleyLovelace (optional pMinFeeConstantFactor)
<*> convertToLedger toShelleyLovelace (optional pMinFeePerByteFactor)
<*> convertToLedger id (optional pMaxBodySize)
Expand Down
22 changes: 14 additions & 8 deletions cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ data ShelleyTxCmdError
| ShelleyTxCmdTxCertificatesValidationError TxCertificatesValidationError
| ShelleyTxCmdTxUpdateProposalValidationError TxUpdateProposalValidationError
| ShelleyTxCmdScriptValidityValidationError TxScriptValidityValidationError
| ShelleyTxCmdProtocolParamsConverstionError ProtocolParametersConversionError

renderShelleyTxCmdError :: ShelleyTxCmdError -> Text
renderShelleyTxCmdError err =
case err of
ShelleyTxCmdProtocolParamsConverstionError err' ->
"Error while converting protocol parameters: " <> Text.pack (displayError err')
ShelleyTxCmdVoteError voteErr -> Text.pack $ show voteErr
ShelleyTxCmdConstitutionError constErr -> Text.pack $ show constErr
ShelleyTxCmdReadTextViewFileError fileErr -> Text.pack (displayError fileErr)
Expand Down Expand Up @@ -420,12 +423,14 @@ runTxBuildCmd
let BuildTxWith mTxProtocolParams = txProtocolParams txBodycontent

pparams <- pure mTxProtocolParams & onNothing (left ShelleyTxCmdProtocolParametersNotPresentInTxBody)
pp <- case cardanoEraStyle cEra of
LegacyByronEra -> left ShelleyTxCmdByronEra
ShelleyBasedEra sbe ->
hoistEither . first ShelleyTxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pparams

executionUnitPrices <- pure (protocolParamPrices pparams) & onNothing (left ShelleyTxCmdPParamExecutionUnitsNotAvailable)

let consensusMode = consensusModeOnly cModeParams
bpp <- hoistEither . first (ShelleyTxCmdTxBodyError . TxBodyProtocolParamsConversionError) $
bundleProtocolParams cEra pparams

case consensusMode of
CardanoMode -> do
Expand All @@ -447,7 +452,7 @@ runTxBuildCmd
firstExceptT ShelleyTxCmdTxExecUnitsErr $ hoistEither
$ evaluateTransactionExecutionUnits
systemStart (toLedgerEpochInfo eraHistory)
bpp txEraUtxo balancedTxBody
pp txEraUtxo balancedTxBody

scriptCostOutput <-
firstExceptT ShelleyTxCmdPlutusScriptCostErr $ hoistEither
Expand Down Expand Up @@ -714,7 +719,7 @@ runTxBuild
validatedTxScriptValidity <- hoistEither (first ShelleyTxCmdScriptValidityValidationError $ validateTxScriptValidity era mScriptValidity)

case (consensusMode, cardanoEraStyle era) of
(CardanoMode, ShelleyBasedEra _sbe) -> do
(CardanoMode, ShelleyBasedEra sbe) -> do
void $ pure (toEraInMode era CardanoMode)
& onNothing (left (ShelleyTxCmdEraConsensusModeMismatchTxBalance outputOptions
(AnyConsensusMode CardanoMode) (AnyCardanoEra era)))
Expand Down Expand Up @@ -743,6 +748,8 @@ runTxBuild
& onLeft (left . ShelleyTxCmdQueryConvenienceError . AcqFailure)
& onLeft (left . ShelleyTxCmdQueryConvenienceError)

pp <- hoistEither . first ShelleyTxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pparams

validatedPParams <- hoistEither $ first ShelleyTxCmdProtocolParametersValidationError
$ validateProtocolParameters era (Just pparams)
let validatedTxGovernanceActions = proposals
Expand Down Expand Up @@ -785,7 +792,7 @@ runTxBuild
firstExceptT ShelleyTxCmdBalanceTxBody
. hoistEither
$ makeTransactionBodyAutoBalance systemStart (toLedgerEpochInfo eraHistory)
pparams stakePools stakeDelegDeposits txEraUtxo
pp stakePools stakeDelegDeposits txEraUtxo
txBodyContent cAddr mOverrideWits

liftIO $ putStrLn $ "Estimated transaction fee: " <> (show fee :: String)
Expand Down Expand Up @@ -1256,9 +1263,8 @@ runTxCalculateMinRequiredUTxO (AnyCardanoEra era) pParamsFile txOut = do
ShelleyBasedEra sbe -> do
firstExceptT ShelleyTxCmdPParamsErr . hoistEither
$ checkProtocolParameters sbe pp
bpparams <- hoistEither . first (ShelleyTxCmdTxBodyError . TxBodyProtocolParamsConversionError) $
bundleProtocolParams era pp
let minValue = calculateMinimumUTxO sbe out bpparams
pp' <- hoistEither . first ShelleyTxCmdProtocolParamsConverstionError $ toLedgerPParams sbe pp
let minValue = calculateMinimumUTxO sbe out pp'
liftIO . IO.print $ minValue

runTxCreatePolicyId :: ScriptFile -> ExceptT ShelleyTxCmdError IO ()
Expand Down

0 comments on commit 6cc0351

Please sign in to comment.