diff --git a/cardano-api/ChangeLog.md b/cardano-api/ChangeLog.md index 1ae13defbf0..0f1e1dee015 100644 --- a/cardano-api/ChangeLog.md +++ b/cardano-api/ChangeLog.md @@ -10,6 +10,8 @@ - Expand `BalancedTxBody` to include `TxBodyContent` ([PR 4491](https://github.com/input-output-hk/cardano-node/pull/4491)) +- Change `calculateMinimumUTxO` to return `Lovelace` instead of a `Value` ([PR 4482](https://github.com/input-output-hk/cardano-node/pull/4482)) + ### Bugs - Allow reading text envelopes from pipes ([PR 4384](https://github.com/input-output-hk/cardano-node/pull/4384)) diff --git a/cardano-api/src/Cardano/Api/Fees.hs b/cardano-api/src/Cardano/Api/Fees.hs index 2ee4e73b924..07fc5c18813 100644 --- a/cardano-api/src/Cardano/Api/Fees.hs +++ b/cardano-api/src/Cardano/Api/Fees.hs @@ -1156,11 +1156,11 @@ makeTransactionBodyAutoBalance eraInMode systemstart history pparams checkMinUTxOValue txout@(TxOut _ v _ _) pparams' = do minUTxO <- first TxBodyErrorMinUTxOMissingPParams $ calculateMinimumUTxO era txout pparams' - if txOutValueToLovelace v >= selectLovelace minUTxO + if txOutValueToLovelace v >= minUTxO then Right () else Left $ TxBodyErrorMinUTxONotMet (txOutInAnyEra txout) - (selectLovelace minUTxO) + minUTxO substituteExecutionUnits :: Map ScriptWitnessIndex ExecutionUnits -> TxBodyContent BuildTx era @@ -1317,30 +1317,30 @@ calculateMinimumUTxO :: ShelleyBasedEra era -> TxOut CtxTx era -> ProtocolParameters - -> Either MinimumUTxOError Value + -> Either MinimumUTxOError Lovelace calculateMinimumUTxO era txout@(TxOut _ v _ _) pparams' = case era of - ShelleyBasedEraShelley -> lovelaceToValue <$> getMinUTxOPreAlonzo pparams' + ShelleyBasedEraShelley -> getMinUTxOPreAlonzo pparams' ShelleyBasedEraAllegra -> calcMinUTxOAllegraMary ShelleyBasedEraMary -> calcMinUTxOAllegraMary ShelleyBasedEraAlonzo -> let lTxOut = toShelleyTxOutAny era txout babPParams = toAlonzoPParams pparams' minUTxO = Shelley.evaluateMinLovelaceOutput babPParams lTxOut - val = lovelaceToValue $ fromShelleyLovelace minUTxO + val = fromShelleyLovelace minUTxO in Right val ShelleyBasedEraBabbage -> let lTxOut = toShelleyTxOutAny era txout babPParams = toBabbagePParams pparams' minUTxO = Shelley.evaluateMinLovelaceOutput babPParams lTxOut - val = lovelaceToValue $ fromShelleyLovelace minUTxO + val = fromShelleyLovelace minUTxO in Right val where - calcMinUTxOAllegraMary :: Either MinimumUTxOError Value + calcMinUTxOAllegraMary :: Either MinimumUTxOError Lovelace calcMinUTxOAllegraMary = do let val = txOutValueToValue v minUTxO <- getMinUTxOPreAlonzo pparams' - Right . lovelaceToValue $ calcMinimumDeposit val minUTxO + Right $ calcMinimumDeposit val minUTxO getMinUTxOPreAlonzo :: ProtocolParameters -> Either MinimumUTxOError Lovelace diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index 0e739ed3aec..27128f3f46a 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -1463,7 +1463,7 @@ runTxCalculateMinRequiredUTxO (AnyCardanoEra era) protocolParamsSourceSpec txOut $ checkProtocolParameters sbe pp minValue <- firstExceptT ShelleyTxCmdMinimumUTxOErr . hoistEither $ calculateMinimumUTxO sbe out pp - liftIO . IO.print $ selectLovelace minValue + liftIO . IO.print $ minValue runTxCreatePolicyId :: ScriptFile -> ExceptT ShelleyTxCmdError IO () runTxCreatePolicyId (ScriptFile sFile) = do