Skip to content

Commit 761209a

Browse files
Jimbo4350carbolymer
authored andcommitted
Bump cardano-api
1 parent e6abfc1 commit 761209a

4 files changed

Lines changed: 58 additions & 42 deletions

File tree

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: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ runTransactionBuildCmd
204204

205205
requiredSigners <-
206206
mapM (fromEitherIOCli . readRequiredSigner) reqSigners
207-
mReturnCollateral <- forM mReturnColl toTxOutInShelleyBasedEra
207+
mReturnCollateral :: Maybe (Exp.TxOut (Exp.LedgerEra era)) <-
208+
forM mReturnColl toTxOutInShelleyBasedEra
208209

209-
txOuts <- mapM (toTxOutInAnyEra eon) txouts
210+
txOuts <-
211+
mapM
212+
toTxOutInEra
213+
txouts
210214

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

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

436449
mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
437450

438-
txOuts <- mapM (toTxOutInAnyEra sbe) txouts
451+
txOuts <- mapM toTxOutInEra txouts
439452

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

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

@@ -643,7 +656,7 @@ runTransactionBuildRawCmd
643656

644657
mReturnCollateral <- mapM toTxOutInShelleyBasedEra mReturnColl
645658

646-
txOuts <- mapM (toTxOutInAnyEra (convert Exp.useEra)) txouts
659+
txOuts <- mapM toTxOutInEra txouts
647660

648661
-- the same collateral input can be used for several plutus scripts
649662
let filteredTxinsc = toList @(Set _) $ fromList txInsCollateral
@@ -665,7 +678,7 @@ runTransactionBuildRawCmd
665678
)
666679
| (CertificateFile certFile, mSwit) <- certFilesAndMaybeScriptWits
667680
]
668-
txBody :: Exp.UnsignedTx era <-
681+
txBody :: Exp.UnsignedTx (Exp.LedgerEra era) <-
669682
fromEitherCli $
670683
runTxBuildRaw
671684
mScriptValidity
@@ -688,7 +701,6 @@ runTransactionBuildRawCmd
688701
votingProceduresAndMaybeScriptWits
689702
proposals
690703
currentTreasuryValueAndDonation
691-
692704
let Exp.UnsignedTx lTx = txBody
693705
noWitTx = ShelleyTx (convert eon) lTx
694706
fromEitherIOCli $
@@ -706,18 +718,18 @@ runTxBuildRaw
706718
-- ^ Read only reference inputs
707719
-> [TxIn]
708720
-- ^ TxIn for collateral
709-
-> Maybe (TxOut CtxTx era)
721+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
710722
-- ^ Return collateral
711723
-> Maybe Lovelace
712724
-- ^ Total collateral
713-
-> [TxOut CtxTx era]
725+
-> [Exp.TxOut (Exp.LedgerEra era)]
714726
-> Maybe SlotNo
715727
-- ^ Tx lower bound
716728
-> TxValidityUpperBound era
717729
-- ^ Tx upper bound
718730
-> Lovelace
719731
-- ^ Tx fee
720-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
732+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
721733
-- ^ Multi-Asset minted value(s)
722734
-> [(Exp.Certificate (Exp.LedgerEra era), Exp.AnyWitness (Exp.LedgerEra era))]
723735
-- ^ Certificate with potential script witness
@@ -730,7 +742,7 @@ runTxBuildRaw
730742
-> [(VotingProcedures era, Exp.AnyWitness (Exp.LedgerEra era))]
731743
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
732744
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
733-
-> Either TxCmdError (Exp.UnsignedTx era)
745+
-> Either TxCmdError (Exp.UnsignedTx (Exp.LedgerEra era))
734746
runTxBuildRaw
735747
mScriptValidity
736748
inputsAndMaybeScriptWits
@@ -788,17 +800,17 @@ constructTxBodyContent
788800
-- ^ Read only reference inputs
789801
-> [TxIn]
790802
-- ^ TxIn for collateral
791-
-> Maybe (TxOut CtxTx era)
803+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
792804
-- ^ Return collateral
793805
-> Maybe Lovelace
794806
-- ^ Total collateral
795-
-> [TxOut CtxTx era]
807+
-> [Exp.TxOut (Exp.LedgerEra era)]
796808
-- ^ Normal outputs
797809
-> Maybe SlotNo
798810
-- ^ Tx lower bound
799811
-> TxValidityUpperBound era
800812
-- ^ Tx upper bound
801-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
813+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
802814
-- ^ Multi-Asset value(s)
803815
-> [(Exp.Certificate (Exp.LedgerEra era), Exp.AnyWitness (Exp.LedgerEra era))]
804816
-- ^ Certificate with potential script witness
@@ -851,17 +863,18 @@ constructTxBodyContent
851863
-- TODO The last argument of validateTxInsReference is a datum set from reference inputs
852864
-- Should we allow providing of datum from CLI?
853865
-- TODO: Figure how to expose resolved datums
866+
867+
txRetCollateral :: Maybe (Exp.TxReturnCollateral (Exp.LedgerEra era)) <- case mReturnCollateral of
868+
Just rc -> do
869+
let Exp.TxOut o = rc
870+
Right $ Just $ Exp.TxReturnCollateral (o :: (L.TxOut (Exp.LedgerEra era)))
871+
Nothing -> Right Nothing
872+
854873
let refInputs = Exp.TxInsReference allReferenceInputs Set.empty
855-
expTxouts = map Exp.fromLegacyTxOut txouts
856874
auxScripts = case txAuxScripts of
857875
TxAuxScriptsNone -> []
858876
-- TODO: Auxiliary scripts cannot be plutus scripts
859877
TxAuxScripts _ scripts -> mapMaybe scriptInEraToSimpleScript scripts
860-
txRetCollateral = case mReturnCollateral of
861-
Just rc ->
862-
let Exp.TxOut o _ = Exp.fromLegacyTxOut rc
863-
in Just $ Exp.TxReturnCollateral (o :: (L.TxOut (Exp.LedgerEra era)))
864-
Nothing -> Nothing
865878
txTotCollateral = Exp.TxTotalCollateral <$> (mTotCollateral :: Maybe L.Coin)
866879
expTxMetadata = case txMetadata of
867880
TxMetadataNone -> TxMetadata mempty
@@ -883,7 +896,7 @@ constructTxBodyContent
883896
& Exp.setTxIns inputsAndMaybeScriptWits
884897
& Exp.setTxInsCollateral txinsc
885898
& Exp.setTxInsReference refInputs
886-
& Exp.setTxOuts expTxouts
899+
& Exp.setTxOuts txouts
887900
& maybe id Exp.setTxReturnCollateral txRetCollateral
888901
& maybe id Exp.setTxTotalCollateral txTotCollateral
889902
& Exp.setTxFee fee
@@ -941,16 +954,15 @@ runTxBuild
941954
-- ^ TxIn with potential script witness
942955
-> [TxIn]
943956
-- ^ TxIn for collateral
944-
-> Maybe (TxOut CtxTx era)
957+
-> Maybe (Exp.TxOut (Exp.LedgerEra era))
945958
-- ^ Return collateral
946959
-> Maybe Lovelace
947960
-- ^ Total collateral
948-
-> [TxOut CtxTx era]
961+
-> [Exp.TxOut (Exp.LedgerEra era)]
949962
-- ^ Normal outputs
950963
-> TxOutChangeAddress
951964
-- ^ A change output
952-
-> (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))]) -- TODO: Double check why this is a list
953-
965+
-> (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
954966
-- ^ Multi-Asset value(s)
955967
-> Maybe SlotNo
956968
-- ^ Tx lower bound
@@ -969,7 +981,7 @@ runTxBuild
969981
-> [(Proposal era, Exp.AnyWitness (Exp.LedgerEra era))]
970982
-> Maybe (TxCurrentTreasuryValue, TxTreasuryDonation)
971983
-- ^ The current treasury value and the donation.
972-
-> ExceptT TxCmdError IO (Exp.UnsignedTx era, Exp.TxBodyContent (Exp.LedgerEra era))
984+
-> ExceptT TxCmdError IO (Exp.UnsignedTx (Exp.LedgerEra era), Exp.TxBodyContent (Exp.LedgerEra era))
973985
runTxBuild
974986
socketPath
975987
networkId
@@ -1110,7 +1122,7 @@ runTxBuild
11101122

11111123
getAllReferenceInputs
11121124
:: [Exp.AnyWitness (Exp.LedgerEra era)]
1113-
-> [Exp.AnyWitness (Exp.LedgerEra era)]
1125+
-> [Exp.AnyScriptWitness (Exp.LedgerEra era)]
11141126
-> [Exp.AnyWitness (Exp.LedgerEra era)]
11151127
-- \^ Certificate witnesses
11161128
-> [Exp.AnyWitness (Exp.LedgerEra era)]
@@ -1128,7 +1140,7 @@ getAllReferenceInputs
11281140
propProceduresAnMaybeScriptWits
11291141
readOnlyRefIns = do
11301142
let txinsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput spendingWitnesses
1131-
mintingRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput mintWitnesses
1143+
mintingRefInputs = mapMaybe Exp.getAnyScriptWitnessReferenceInput mintWitnesses
11321144
certsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput certScriptWitnesses
11331145
withdrawalsWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput withdrawals
11341146
votesWitByRefInputs = mapMaybe Exp.getAnyWitnessReferenceInput votingProceduresAndMaybeScriptWits
@@ -1147,19 +1159,20 @@ getAllReferenceInputs
11471159
toTxOutInShelleyBasedEra
11481160
:: Exp.IsEra era
11491161
=> TxOutShelleyBasedEra
1150-
-> CIO e (TxOut CtxTx era)
1162+
-> CIO e (Exp.TxOut (Exp.LedgerEra era))
11511163
toTxOutInShelleyBasedEra (TxOutShelleyBasedEra addr' val' mDatumHash refScriptFp) = do
11521164
let sbe = convert Exp.useEra
11531165
addr = shelleyAddressInEra sbe addr'
1154-
mkTxOut sbe addr val' mDatumHash refScriptFp
1166+
o <- mkTxOut sbe addr val' mDatumHash refScriptFp
1167+
fromEitherCli $ Exp.fromLegacyTxOut o
11551168

11561169
-- TODO: Currently we specify the policyId with the '--mint' option on the cli
11571170
-- and we added a separate '--policy-id' parser that parses the policy id for the
11581171
-- given reference input (since we don't have the script in this case). To avoid asking
11591172
-- for the policy id twice (in the build command) we can potentially query the UTxO and
11601173
-- access the script (and therefore the policy id).
11611174
createTxMintValue
1162-
:: (L.MultiAsset, [(PolicyId, Exp.AnyWitness (Exp.LedgerEra era))])
1175+
:: (L.MultiAsset, [(PolicyId, Exp.AnyScriptWitness (Exp.LedgerEra era))])
11631176
-> Either TxCmdError (Exp.TxMintValue (Exp.LedgerEra era))
11641177
createTxMintValue (val, scriptWitnesses) =
11651178
if mempty == val && List.null scriptWitnesses
@@ -1181,7 +1194,7 @@ createTxMintValue (val, scriptWitnesses) =
11811194
pure $
11821195
Exp.TxMintValue $
11831196
Map.intersectionWith
1184-
(\assets wit -> (assets, wit))
1197+
(,)
11851198
policiesWithAssets
11861199
witnessesProvidedMap
11871200
where
@@ -1422,16 +1435,16 @@ runTransactionCalculateMinValueCmd
14221435
-> CIO e ()
14231436
runTransactionCalculateMinValueCmd
14241437
Cmd.TransactionCalculateMinValueCmdArgs
1425-
{ era
1438+
{ era = era :: Exp.Era era
14261439
, protocolParamsFile
14271440
, txOut
14281441
} = do
1429-
pp <-
1442+
pp :: L.PParams (Exp.LedgerEra era) <-
14301443
fromExceptTCli @ProtocolParamsError
14311444
(obtainCommonConstraints era $ readProtocolParameters protocolParamsFile)
14321445
out <- obtainCommonConstraints era $ toTxOutInShelleyBasedEra txOut
14331446

1434-
let minValue = calculateMinimumUTxO (convert era) pp out
1447+
let minValue = Exp.calculateMinimumUTxO pp out
14351448
liftIO . IO.print $ minValue
14361449

14371450
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)