Skip to content
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
8 changes: 8 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ if impl (ghc >= 9.12)
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
tag: 21c8a25e35fdeaf100600500c546874d7def77c0
subdir:
cardano-api
cardano-api-gen

56 changes: 41 additions & 15 deletions cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import Cardano.Api.Experimental.AnyScript qualified as Exp
import Cardano.Api.Experimental.AnyScriptWitness qualified as Exp
import Cardano.Api.Experimental.Tx qualified as Exp
import Cardano.Api.Ledger qualified as L
import Cardano.Ledger.Hashes (DataHash)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new import for DataHash is inserted between two qualified imports with different prefixes (Cardano.Api.Experimental.Tx as Exp and Cardano.Api.Network as Consensus), breaking the grouping pattern. Consider placing this import with other Cardano.Ledger imports or in a separate unqualified import group to maintain consistency with the existing import organization.

Copilot uses AI. Check for mistakes.
import Cardano.Api.Network qualified as Consensus
import Cardano.Api.Network qualified as Net.Tx

Expand Down Expand Up @@ -203,13 +204,14 @@ runTransactionBuildCmd

requiredSigners <-
mapM (fromEitherIOCli . readRequiredSigner) reqSigners
mReturnCollateral :: Maybe (Exp.TxOut (Exp.LedgerEra era)) <-
mReturnCollateralAndDatums <-
forM mReturnColl toTxOutInShelleyBasedEra
let mReturnCollateral = fst <$> mReturnCollateralAndDatums
returnCollDatums = maybe mempty snd mReturnCollateralAndDatums

txOuts <-
mapM
toTxOutInEra
txouts
txOutsAndDatums <- mapM toTxOutInEra txouts
let txOuts = map fst txOutsAndDatums
supplementalDatums = mconcat (map snd txOutsAndDatums) <> returnCollDatums

-- Conway related
votingProceduresAndMaybeScriptWits :: [(VotingProcedures era, Exp.AnyWitness (Exp.LedgerEra era))] <-
Expand Down Expand Up @@ -321,6 +323,7 @@ runTransactionBuildCmd
votingProceduresAndMaybeScriptWits
proposals
currentTreasuryValueAndDonation
supplementalDatums

-- TODO: Calculating the script cost should live as a different command.
-- Why? Because then we can simply read a txbody and figure out
Expand Down Expand Up @@ -374,7 +377,7 @@ runTransactionBuildCmd
toTxOutInEra
:: Exp.IsEra era
=> TxOutAnyEra
-> CIO e (Exp.TxOut (Exp.LedgerEra era))
-> CIO e (Exp.TxOut (Exp.LedgerEra era), Map.Map DataHash (L.Data (Exp.LedgerEra era)))
toTxOutInEra (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do
let addr = anyAddressInShelleyBasedEra (convert Exp.useEra) addr'
o <- mkTxOut (convert Exp.useEra) addr val' mDatumHash refScriptFp
Expand Down Expand Up @@ -445,9 +448,13 @@ runTransactionBuildEstimateCmd -- TODO change type
requiredSigners <-
mapM (fromEitherIOCli . readRequiredSigner) reqSigners

mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
mReturnCollateralAndDatums <- mapM toTxOutInShelleyBasedEra mReturnColl
let mReturnCollateral = fst <$> mReturnCollateralAndDatums
returnCollDatums = maybe mempty snd mReturnCollateralAndDatums

txOuts <- mapM toTxOutInEra txouts
txOutsAndDatums <- mapM toTxOutInEra txouts
let txOuts = map fst txOutsAndDatums
supplementalDatums = mconcat (map snd txOutsAndDatums) <> returnCollDatums

-- the same collateral input can be used for several plutus scripts
let filteredTxinsc = nubOrd txInsCollateral
Expand Down Expand Up @@ -498,6 +505,7 @@ runTransactionBuildEstimateCmd -- TODO change type
votingProceduresAndMaybeScriptWits
proposals
currentTreasuryValueAndDonation
supplementalDatums

let stakeCredentialsToDeregisterMap = fromList $ catMaybes [getStakeDeregistrationInfo cert | (cert, _) <- certsAndMaybeScriptWits]
drepsToDeregisterMap =
Expand Down Expand Up @@ -653,9 +661,13 @@ runTransactionBuildRawCmd
requiredSigners <-
mapM (fromEitherIOCli . readRequiredSigner) reqSigners

mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
mReturnCollateralAndDatums <- mapM toTxOutInShelleyBasedEra mReturnColl
let mReturnCollateral = fst <$> mReturnCollateralAndDatums
returnCollDatums = maybe mempty snd mReturnCollateralAndDatums

txOuts <- mapM toTxOutInEra txouts
txOutsAndDatums <- mapM toTxOutInEra txouts
let txOuts = map fst txOutsAndDatums
supplementalDatums = mconcat (map snd txOutsAndDatums) <> returnCollDatums

-- the same collateral input can be used for several plutus scripts
let filteredTxinsc = toList @(Set _) $ fromList txInsCollateral
Expand Down Expand Up @@ -700,6 +712,7 @@ runTransactionBuildRawCmd
votingProceduresAndMaybeScriptWits
proposals
currentTreasuryValueAndDonation
supplementalDatums
let Exp.UnsignedTx lTx = txBody
noWitTx = ShelleyTx (convert eon) lTx
fromEitherIOCli $
Expand Down Expand Up @@ -741,6 +754,8 @@ runTxBuildRaw
-> [(VotingProcedures era, Exp.AnyWitness (Exp.LedgerEra era))]
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
-> Map.Map DataHash (L.Data (Exp.LedgerEra era))
-- ^ Supplemental datums
-> Either TxCmdError (Exp.UnsignedTx (Exp.LedgerEra era))
runTxBuildRaw
mScriptValidity
Expand All @@ -762,7 +777,8 @@ runTxBuildRaw
mpparams
votingProcedures
proposals
mCurrentTreasuryValueAndDonation = do
mCurrentTreasuryValueAndDonation
suppDatums = do
txBodyContent <-
constructTxBodyContent
mScriptValidity
Expand All @@ -785,6 +801,7 @@ runTxBuildRaw
votingProcedures
proposals
mCurrentTreasuryValueAndDonation
suppDatums

return $ Exp.makeUnsignedTx Exp.useEra txBodyContent

Expand Down Expand Up @@ -827,6 +844,8 @@ constructTxBodyContent
-- ^ The current treasury value and the donation. This is a stop gap as the
-- semantics of the donation and treasury value depend on the script languages
-- being used.
-> Map.Map DataHash (L.Data (Exp.LedgerEra era))
-- ^ Supplemental datums
-> Either TxCmdError (Exp.TxBodyContent (Exp.LedgerEra era))
constructTxBodyContent
mScriptValidity
Expand All @@ -848,7 +867,8 @@ constructTxBodyContent
txMetadata
votingProcedures
proposals
mCurrentTreasuryValueAndDonation =
mCurrentTreasuryValueAndDonation
suppDatums =
do
let allReferenceInputs =
getAllReferenceInputs
Expand Down Expand Up @@ -912,6 +932,7 @@ constructTxBodyContent
& Exp.setTxProposalProcedures validatedTxProposals
& maybe id Exp.setTxCurrentTreasuryValue validatedCurrentTreasuryValue
& maybe id Exp.setTxTreasuryDonation validatedTreasuryDonation
& Exp.setTxSupplementalDatums suppDatums
)

convertWithdrawals
Expand Down Expand Up @@ -978,6 +999,8 @@ runTxBuild
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
-- ^ The current treasury value and the donation.
-> Map.Map DataHash (L.Data (Exp.LedgerEra era))
-- ^ Supplemental datums
-> ExceptT TxCmdError IO (Exp.UnsignedTx (Exp.LedgerEra era), Exp.TxBodyContent (Exp.LedgerEra era))
runTxBuild
socketPath
Expand All @@ -1002,7 +1025,8 @@ runTxBuild
mOverrideWits
votingProcedures
proposals
mCurrentTreasuryValueAndDonation = do
mCurrentTreasuryValueAndDonation
suppDatums = do
let sbe = convert (Exp.useEra @era)
shelleyBasedEraConstraints sbe $ do
-- TODO: All functions should be parameterized by ShelleyBasedEra
Expand Down Expand Up @@ -1068,6 +1092,7 @@ runTxBuild
votingProcedures
proposals
mCurrentTreasuryValueAndDonation
suppDatums

firstExceptT TxCmdTxInsDoNotExist
. hoistEither
Expand Down Expand Up @@ -1156,7 +1181,7 @@ getAllReferenceInputs
toTxOutInShelleyBasedEra
:: Exp.IsEra era
=> TxOutShelleyBasedEra
-> CIO e (Exp.TxOut (Exp.LedgerEra era))
-> CIO e (Exp.TxOut (Exp.LedgerEra era), Map.Map DataHash (L.Data (Exp.LedgerEra era)))
toTxOutInShelleyBasedEra (TxOutShelleyBasedEra addr' val' mDatumHash refScriptFp) = do
let sbe = convert Exp.useEra
addr = shelleyAddressInEra sbe addr'
Expand Down Expand Up @@ -1439,7 +1464,8 @@ runTransactionCalculateMinValueCmd
pp :: L.PParams (Exp.LedgerEra era) <-
fromExceptTCli @ProtocolParamsError
(obtainCommonConstraints era $ readProtocolParameters protocolParamsFile)
out <- obtainCommonConstraints era $ toTxOutInShelleyBasedEra txOut
(out, _suppDatums :: Map.Map DataHash (L.Data (Exp.LedgerEra era))) <-
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name _suppDatums uses an underscore prefix typically reserved for intentionally unused variables in Haskell, but includes an explicit type annotation. If the datums are truly unused here, remove the type annotation. If they might be used in the future, use a name without the underscore prefix like suppDatums.

Suggested change
(out, _suppDatums :: Map.Map DataHash (L.Data (Exp.LedgerEra era))) <-
(out, _suppDatums) <-

Copilot uses AI. Check for mistakes.
obtainCommonConstraints era $ toTxOutInShelleyBasedEra txOut

let minValue = Exp.calculateMinimumUTxO pp out
liftIO . IO.print $ minValue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "Tx ConwayEra",
"description": "Ledger Cddl Format",
"cborHex": "84a300d90102818258202392d2b1200b5139fe555c81261697b29a8ccf561c5c783d46e78a479d977053000181a3005839016b837ca50316ee4e00033482ed128887d72c2bae5b0438d692dc1251b0c8b17595ebdb93c1f974be0a9b1ef26c474649d9c2ae766ed135cf011864028201d81842182a020ca104d9010281182af5f6"
"cborHex": "84a300d90102818258202392d2b1200b5139fe555c81261697b29a8ccf561c5c783d46e78a479d977053000181a3005839016b837ca50316ee4e00033482ed128887d72c2bae5b0438d692dc1251b0c8b17595ebdb93c1f974be0a9b1ef26c474649d9c2ae766ed135cf011864028201d81842182a020ca0f5f6"
}
Loading