Skip to content

Commit 5c3978f

Browse files
committed
Bump cardano-api
1 parent dd03c5a commit 5c3978f

6 files changed

Lines changed: 66 additions & 42 deletions

File tree

cabal.project

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,11 @@ if impl (ghc >= 9.12)
6767
-- Do NOT add more source-repository-package stanzas here unless they are strictly
6868
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.
6969

70+
71+
72+
source-repository-package
73+
type: git
74+
location: https://github.com/IntersectMBO/cardano-api.git
75+
tag: 294ecd9c0bdcd34925992676c29a8102eb869d60
76+
--sha256: sha256-sLiVIz2pA7bXLa3lOecJF92upKlX1xEFhLG1THMD7yY=
77+
subdir: cardano-api

cardano-cli/cardano-cli.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ library
242242
binary,
243243
bytestring,
244244
canonical-json,
245-
cardano-api ^>=10.22,
245+
cardano-api ^>=10.23,
246246
cardano-binary,
247247
cardano-crypto,
248248
cardano-crypto-class ^>=2.2.3.2,

cardano-cli/src/Cardano/CLI/EraBased/Script/Mint/Read.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Cardano.CLI.EraBased.Script.Mint.Read
1010
)
1111
where
1212

13-
import Cardano.Api
13+
import Cardano.Api hiding (AnyScriptWitness)
1414
import Cardano.Api.Experimental qualified as Exp
1515
import Cardano.Api.Experimental.AnyScriptWitness
1616
import Cardano.Api.Experimental.Plutus qualified as Exp
@@ -27,13 +27,13 @@ import Cardano.Ledger.Core qualified as L
2727
readMintScriptWitness
2828
:: forall era e
2929
. Exp.IsEra era
30-
=> ScriptRequirements Exp.MintItem -> CIO e (PolicyId, Exp.AnyWitness (Exp.LedgerEra era))
30+
=> ScriptRequirements Exp.MintItem -> CIO e (PolicyId, AnyScriptWitness (Exp.LedgerEra era))
3131
readMintScriptWitness (OnDiskSimpleScript scriptFp) = do
3232
let sFp = unFile scriptFp
3333
s <- readFileSimpleScript sFp (Exp.useEra @era)
3434
let sHash :: L.ScriptHash =
3535
Exp.hashSimpleScript (s :: Exp.SimpleScript (Exp.LedgerEra era))
36-
return (fromMaryPolicyID $ L.PolicyID sHash, Exp.AnySimpleScriptWitness $ Exp.SScript s)
36+
return (fromMaryPolicyID $ L.PolicyID sHash, AnyScriptWitnessSimple $ Exp.SScript s)
3737
readMintScriptWitness
3838
( OnDiskPlutusScript
3939
(OnDiskPlutusScriptCliArgs scriptFp Exp.NoScriptDatumAllowed redeemerFile execUnits)
@@ -57,7 +57,7 @@ readMintScriptWitness
5757
execUnits
5858
return
5959
( polId
60-
, Exp.AnyPlutusScriptWitness $
60+
, AnyScriptWitnessPlutus $
6161
AnyPlutusMintingScriptWitness sw
6262
)
6363
readMintScriptWitness
@@ -83,9 +83,9 @@ readMintScriptWitness
8383
execUnits
8484
return
8585
( polId
86-
, Exp.AnyPlutusScriptWitness $
86+
, AnyScriptWitnessPlutus $
8787
AnyPlutusMintingScriptWitness
8888
sw
8989
)
9090
readMintScriptWitness (SimpleReferenceScript (SimpleRefScriptArgs refTxIn polId)) =
91-
return (polId, Exp.AnySimpleScriptWitness $ Exp.SReferenceScript refTxIn)
91+
return (polId, AnyScriptWitnessSimple $ Exp.SReferenceScript refTxIn)

cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,13 @@ runTransactionBuildCmd
203203

204204
requiredSigners <-
205205
mapM (fromEitherIOCli . readRequiredSigner) reqSigners
206-
mReturnCollateral <- forM mReturnColl toTxOutInShelleyBasedEra
206+
mReturnCollateral :: Maybe (Exp.TxOut (Exp.LedgerEra era)) <-
207+
forM mReturnColl toTxOutInShelleyBasedEra
207208

208-
txOuts <- mapM (toTxOutInAnyEra eon) txouts
209+
txOuts <-
210+
mapM
211+
toTxOutInEra
212+
txouts
209213

210214
-- Conway related
211215
votingProceduresAndMaybeScriptWits :: [(VotingProcedures era, Exp.AnyWitness (Exp.LedgerEra era))] <-
@@ -367,6 +371,15 @@ runTransactionBuildCmd
367371
then writeTxFileTextEnvelopeCanonical eon fpath noWitTx
368372
else writeTxFileTextEnvelope eon fpath noWitTx
369373

374+
toTxOutInEra
375+
:: Exp.IsEra era
376+
=> TxOutAnyEra
377+
-> CIO e (Exp.TxOut (Exp.LedgerEra era))
378+
toTxOutInEra (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do
379+
let addr = anyAddressInShelleyBasedEra (convert Exp.useEra) addr'
380+
o <- mkTxOut (convert Exp.useEra) addr val' mDatumHash refScriptFp
381+
fromEitherCli $ Exp.fromLegacyTxOut o
382+
370383
runTransactionBuildEstimateCmd
371384
:: forall era e
372385
. Exp.IsEra era
@@ -434,7 +447,7 @@ runTransactionBuildEstimateCmd -- TODO change type
434447

435448
mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
436449

437-
txOuts <- mapM (toTxOutInAnyEra sbe) txouts
450+
txOuts <- mapM toTxOutInEra txouts
438451

439452
-- the same collateral input can be used for several plutus scripts
440453
let filteredTxinsc = nubOrd txInsCollateral
@@ -531,7 +544,7 @@ runTransactionBuildEstimateCmd -- TODO change type
531544
txBodyOutFile
532545
$ unsignedToToApiTx unsignedTx
533546

534-
unsignedToToApiTx :: forall era. Exp.IsEra era => Exp.UnsignedTx era -> Api.Tx era
547+
unsignedToToApiTx :: forall era. Exp.IsEra era => Exp.UnsignedTx (Exp.LedgerEra era) -> Api.Tx era
535548
unsignedToToApiTx (Exp.UnsignedTx lTx) =
536549
ShelleyTx (convert $ Exp.useEra @era) $ obtainCommonConstraints (Exp.useEra @era) lTx
537550

@@ -642,7 +655,7 @@ runTransactionBuildRawCmd
642655

643656
mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
644657

645-
txOuts <- mapM (toTxOutInAnyEra (convert Exp.useEra)) txouts
658+
txOuts <- mapM toTxOutInEra txouts
646659

647660
-- the same collateral input can be used for several plutus scripts
648661
let filteredTxinsc = toList @(Set _) $ fromList txInsCollateral
@@ -664,7 +677,7 @@ runTransactionBuildRawCmd
664677
)
665678
| (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits
666679
]
667-
txBody :: Exp.UnsignedTx era <-
680+
txBody :: Exp.UnsignedTx (Exp.LedgerEra era) <-
668681
fromEitherCli $
669682
runTxBuildRaw
670683
mScriptValidity
@@ -687,7 +700,6 @@ runTransactionBuildRawCmd
687700
votingProceduresAndMaybeScriptWits
688701
proposals
689702
currentTreasuryValueAndDonation
690-
691703
let Exp.UnsignedTx lTx = txBody
692704
noWitTx = ShelleyTx (convert eon) lTx
693705
fromEitherIOCli $
@@ -705,18 +717,18 @@ runTxBuildRaw
705717
-- ^ Read only reference inputs
706718
-> [TxIn]
707719
-- ^ TxIn for collateral
708-
-> Maybe (TxOut CtxTx era)
720+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
709721
-- ^ Return collateral
710722
-> Maybe Lovelace
711723
-- ^ Total collateral
712-
-> [TxOut CtxTx era]
724+
-> [Exp.TxOut (Exp.LedgerEra era)]
713725
-> Maybe SlotNo
714726
-- ^ Tx lower bound
715727
-> TxValidityUpperBound era
716728
-- ^ Tx upper bound
717729
-> Lovelace
718730
-- ^ Tx fee
719-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
731+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
720732
-- ^ Multi-Asset minted value(s)
721733
-> [(Exp.Certificate (Exp.LedgerEra era), Exp.AnyWitness (Exp.LedgerEra era))]
722734
-- ^ Certificate with potential script witness
@@ -729,7 +741,7 @@ runTxBuildRaw
729741
-> [(VotingProcedures era, Exp.AnyWitness (Exp.LedgerEra era))]
730742
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
731743
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
732-
-> Either TxCmdError (Exp.UnsignedTx era)
744+
-> Either TxCmdError (Exp.UnsignedTx (Exp.LedgerEra era))
733745
runTxBuildRaw
734746
mScriptValidity
735747
inputsAndMaybeScriptWits
@@ -787,17 +799,17 @@ constructTxBodyContent
787799
-- ^ Read only reference inputs
788800
-> [TxIn]
789801
-- ^ TxIn for collateral
790-
-> Maybe (TxOut CtxTx era)
802+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
791803
-- ^ Return collateral
792804
-> Maybe Lovelace
793805
-- ^ Total collateral
794-
-> [TxOut CtxTx era]
806+
-> [Exp.TxOut (Exp.LedgerEra era)]
795807
-- ^ Normal outputs
796808
-> Maybe SlotNo
797809
-- ^ Tx lower bound
798810
-> TxValidityUpperBound era
799811
-- ^ Tx upper bound
800-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
812+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
801813
-- ^ Multi-Asset value(s)
802814
-> [(Exp.Certificate (Exp.LedgerEra era), Exp.AnyWitness (Exp.LedgerEra era))]
803815
-- ^ Certificate with potential script witness
@@ -850,17 +862,18 @@ constructTxBodyContent
850862
-- TODO The last argument of validateTxInsReference is a datum set from reference inputs
851863
-- Should we allow providing of datum from CLI?
852864
-- TODO: Figure how to expose resolved datums
865+
866+
txRetCollateral :: Maybe (Exp.TxReturnCollateral (Exp.LedgerEra era)) <- case mReturnCollateral of
867+
Just rc -> do
868+
let Exp.TxOut o = rc
869+
Right $ Just $ Exp.TxReturnCollateral (o :: (L.TxOut (Exp.LedgerEra era)))
870+
Nothing -> Right Nothing
871+
853872
let refInputs = Exp.TxInsReference allReferenceInputs Set.empty
854-
expTxouts = map Exp.fromLegacyTxOut txouts
855873
auxScripts = case txAuxScripts of
856874
TxAuxScriptsNone -> []
857875
-- TODO: Auxiliary scripts cannot be plutus scripts
858876
TxAuxScripts _ scripts -> mapMaybe scriptInEraToSimpleScript scripts
859-
txRetCollateral = case mReturnCollateral of
860-
Just rc ->
861-
let Exp.TxOut o _ = Exp.fromLegacyTxOut rc
862-
in Just $ Exp.TxReturnCollateral (o :: (L.TxOut (Exp.LedgerEra era)))
863-
Nothing -> Nothing
864877
txTotCollateral = Exp.TxTotalCollateral <$> (mTotCollateral :: Maybe L.Coin)
865878
expTxMetadata = case txMetadata of
866879
TxMetadataNone -> TxMetadata mempty
@@ -882,7 +895,7 @@ constructTxBodyContent
882895
& Exp.setTxIns inputsAndMaybeScriptWits
883896
& Exp.setTxInsCollateral txinsc
884897
& Exp.setTxInsReference refInputs
885-
& Exp.setTxOuts expTxouts
898+
& Exp.setTxOuts txouts
886899
& maybe id Exp.setTxReturnCollateral txRetCollateral
887900
& maybe id Exp.setTxTotalCollateral txTotCollateral
888901
& Exp.setTxFee fee
@@ -940,16 +953,15 @@ runTxBuild
940953
-- ^ TxIn with potential script witness
941954
-> [TxIn]
942955
-- ^ TxIn for collateral
943-
-> Maybe (TxOut CtxTx era)
956+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
944957
-- ^ Return collateral
945958
-> Maybe Lovelace
946959
-- ^ Total collateral
947-
-> [TxOut CtxTx era]
960+
-> [Exp.TxOut (Exp.LedgerEra era)]
948961
-- ^ Normal outputs
949962
-> TxOutChangeAddress
950963
-- ^ A change output
951-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))]) -- TODO: Double check why this is a list
952-
964+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
953965
-- ^ Multi-Asset value(s)
954966
-> Maybe SlotNo
955967
-- ^ Tx lower bound
@@ -968,7 +980,7 @@ runTxBuild
968980
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
969981
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
970982
-- ^ The current treasury value and the donation.
971-
-> ExceptT TxCmdError IO (Exp.UnsignedTx era, Exp.TxBodyContent (Exp.LedgerEra era))
983+
-> ExceptT TxCmdError IO (Exp.UnsignedTx (Exp.LedgerEra era), Exp.TxBodyContent (Exp.LedgerEra era))
972984
runTxBuild
973985
socketPath
974986
networkId
@@ -1109,7 +1121,7 @@ runTxBuild
11091121

11101122
getAllReferenceInputs
11111123
:: [Exp.AnyWitness (Exp.LedgerEra era)]
1112-
-> [Exp.AnyWitness (Exp.LedgerEra era)]
1124+
-> [Exp.AnyScriptWitness (Exp.LedgerEra era)]
11131125
-> [Exp.AnyWitness (Exp.LedgerEra era)]
11141126
-- \^ Certificate witnesses
11151127
-> [Exp.AnyWitness (Exp.LedgerEra era)]
@@ -1127,7 +1139,7 @@ getAllReferenceInputs
11271139
propProceduresAnMaybeScriptWits
11281140
readOnlyRefIns = do
11291141
let txinsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput spendingWitnesses
1130-
mintingRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput mintWitnesses
1142+
mintingRefInputs = mapMaybe Exp.getAnyScriptWitnessReferenceInput mintWitnesses
11311143
certsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput certScriptWitnesses
11321144
withdrawalsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput withdrawals
11331145
votesWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput votingProceduresAndMaybeScriptWits
@@ -1146,19 +1158,20 @@ getAllReferenceInputs
11461158
toTxOutInShelleyBasedEra
11471159
:: Exp.IsEra era
11481160
=> TxOutShelleyBasedEra
1149-
-> CIO e (TxOut CtxTx era)
1161+
-> CIO e (Exp.TxOut (Exp.LedgerEra era))
11501162
toTxOutInShelleyBasedEra (TxOutShelleyBasedEra addr' val' mDatumHash refScriptFp) = do
11511163
let sbe = convert Exp.useEra
11521164
addr = shelleyAddressInEra sbe addr'
1153-
mkTxOut sbe addr val' mDatumHash refScriptFp
1165+
o <- mkTxOut sbe addr val' mDatumHash refScriptFp
1166+
fromEitherCli $ Exp.fromLegacyTxOut o
11541167

11551168
-- TODO: Currently we specify the policyId with the '--mint' option on the cli
11561169
-- and we added a separate '--policy-id' parser that parses the policy id for the
11571170
-- given reference input (since we don't have the script in this case). To avoid asking
11581171
-- for the policy id twice (in the build command) we can potentially query the UTxO and
11591172
-- access the script (and therefore the policy id).
11601173
createTxMintValue
1161-
:: (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
1174+
:: (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
11621175
-> Either TxCmdError (Exp.TxMintValue (Exp.LedgerEra era))
11631176
createTxMintValue (val, scriptWitnesses) =
11641177
if mempty == val && List.null scriptWitnesses
@@ -1421,16 +1434,16 @@ runTransactionCalculateMinValueCmd
14211434
-> CIO e ()
14221435
runTransactionCalculateMinValueCmd
14231436
Cmd.TransactionCalculateMinValueCmdArgs
1424-
{ era
1437+
{ era = era :: Exp.Era era
14251438
, protocolParamsFile
14261439
, txOut
14271440
} = do
1428-
pp <-
1441+
pp :: L.PParams ((Exp.LedgerEra era)) <-
14291442
fromExceptTCli @ProtocolParamsError
14301443
(obtainCommonConstraints era $ readProtocolParameters protocolParamsFile)
14311444
out <- obtainCommonConstraints era $ toTxOutInShelleyBasedEra txOut
14321445

1433-
let minValue = calculateMinimumUTxO (convert era) pp out
1446+
let minValue = Exp.calculateMinimumUTxO pp out
14341447
liftIO . IO.print $ minValue
14351448

14361449
runTransactionCalculatePlutusScriptCostCmd

cardano-cli/src/Cardano/CLI/Type/Error/TxCmdError.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ data AnyTxBodyErrorAutoBalance where
4242

4343
data TxCmdError
4444
= TxCmdCBORDecodeError !CBOR.DecoderError
45+
| TxCmdDatumDecodingError Exp.DatumDecodingError
4546
| TxCmdProtocolParamsError ProtocolParamsError
4647
| forall era. LostScriptWitnesses
4748
[Exp.AnyIndexedPlutusScriptWitness (Exp.LedgerEra era)]
@@ -195,6 +196,8 @@ renderTxCmdError = \case
195196
, pretty (length after)
196197
, "."
197198
]
199+
TxCmdDatumDecodingError err ->
200+
"Error decoding datum: " <> pshow err
198201

199202
prettyPolicyIdList :: [PolicyId] -> Doc ann
200203
prettyPolicyIdList =
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"type": "Tx ConwayEra",
33
"description": "Ledger Cddl Format",
4-
"cborHex": "84a300d90102818258202392d2b1200b5139fe555c81261697b29a8ccf561c5c783d46e78a479d977053000181a3005839016b837ca50316ee4e00033482ed128887d72c2bae5b0438d692dc1251b0c8b17595ebdb93c1f974be0a9b1ef26c474649d9c2ae766ed135cf011864028201d81842182a020ca0f5f6"
4+
"cborHex": "84a300d90102818258202392d2b1200b5139fe555c81261697b29a8ccf561c5c783d46e78a479d977053000181a3005839016b837ca50316ee4e00033482ed128887d72c2bae5b0438d692dc1251b0c8b17595ebdb93c1f974be0a9b1ef26c474649d9c2ae766ed135cf011864028201d81842182a020ca104d9010281182af5f6"
55
}

0 commit comments

Comments
 (0)