@@ -13,6 +13,8 @@ import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
1313import Cardano.Ledger.Api.Era qualified as Ledger
1414import Cardano.Ledger.Babbage.TxBody qualified as Ledger
1515import Cardano.Ledger.Binary qualified as CBOR
16+ import Cardano.Ledger.Conway.Scripts qualified as Conway
17+ import Cardano.Ledger.Conway.TxBody qualified as Conway
1618import Data.Coerce
1719
1820import Cardano.Ledger.Alonzo.Scripts qualified as Ledger
@@ -201,47 +203,47 @@ mkNewTxIn utxos = TxIn dummyTxId (TxIx txIx)
201203
202204applyTxMod :: Tx Era -> UTxO Era -> TxMod -> (Tx Era , UTxO Era )
203205applyTxMod tx utxos (ChangeValidityRange mlo mhi) =
204- (Tx (ShelleyTxBody era body{Ledger. btbValidityInterval = validity'} scripts scriptData auxData scriptValidity) wits, utxos)
206+ (Tx (ShelleyTxBody era body{Conway. ctbVldt = validity'} scripts scriptData auxData scriptValidity) wits, utxos)
205207 where
206208 Tx bdy@ (ShelleyTxBody era body scripts scriptData auxData scriptValidity) wits = tx
207209 TxBodyContent {txValidityLowerBound = lo, txValidityUpperBound = hi} = getTxBodyContent bdy
208210 validity' = convValidityInterval (fromMaybe lo mlo, fromMaybe hi mhi)
209211applyTxMod tx utxos (RemoveInput i) =
210212 (Tx (ShelleyTxBody era body' scripts scriptData' auxData validity) wits, utxos)
211213 where
212- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
213- inputs' = Set. delete (toShelleyTxIn i) btbInputs
214- refInputs' = Set. delete (toShelleyTxIn i) btbReferenceInputs
214+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
215+ inputs' = Set. delete (toShelleyTxIn i) ctbSpendInputs
216+ refInputs' = Set. delete (toShelleyTxIn i) ctbReferenceInputs
215217 body' =
216218 body
217- { Ledger. btbInputs = inputs'
218- , Ledger. btbReferenceInputs = refInputs'
219+ { Conway. ctbSpendInputs = inputs'
220+ , Conway. ctbReferenceInputs = refInputs'
219221 }
220- scriptData' = case Ledger. indexOf (Ledger. AsItem (toShelleyTxIn i)) btbInputs of
222+ scriptData' = case Ledger. indexOf (Ledger. AsItem (toShelleyTxIn i)) ctbSpendInputs of
221223 SNothing -> scriptData
222224 SJust (Ledger. AsIx idx) -> recomputeScriptData (Just idx) idxUpdate scriptData
223225 where
224226 idxUpdate idx'
225227 | idx' > idx = idx' - 1
226228 | otherwise = idx'
227229applyTxMod tx utxos (RemoveOutput (TxIx i)) =
228- (Tx (ShelleyTxBody era body{Ledger. btbOutputs = outputs'} scripts scriptData auxData validity) wits, utxos)
230+ (Tx (ShelleyTxBody era body{Conway. ctbOutputs = outputs'} scripts scriptData auxData validity) wits, utxos)
229231 where
230- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
231- outputs' = case Seq. splitAt (fromIntegral i) btbOutputs of
232+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
233+ outputs' = case Seq. splitAt (fromIntegral i) ctbOutputs of
232234 (before, _ Seq. :<| after) -> before <> after
233235 (_, Seq. Empty ) ->
234236 error $
235237 " RemoveOutput: Can't remove index "
236238 ++ show i
237239 ++ " from "
238- ++ show (Seq. length btbOutputs )
240+ ++ show (Seq. length ctbOutputs )
239241 ++ " outputs"
240242applyTxMod tx utxos (AddOutput addr value datum refscript) =
241- (Tx (ShelleyTxBody era body{Ledger. btbOutputs = outputs'} scripts scriptData' auxData validity) wits, utxos)
243+ (Tx (ShelleyTxBody era body{Conway. ctbOutputs = outputs'} scripts scriptData' auxData validity) wits, utxos)
242244 where
243- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
244- outputs' = btbOutputs Seq. :|> CBOR. mkSized (Ledger. eraProtVerLow @ LedgerEra ) out
245+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
246+ outputs' = ctbOutputs Seq. :|> CBOR. mkSized (Ledger. eraProtVerLow @ LedgerEra ) out
245247 out =
246248 toShelleyTxOut
247249 shelleyBasedEra
@@ -252,15 +254,15 @@ applyTxMod tx utxos (AddOutput addr value datum refscript) =
252254 TxOutSupplementalDatum _ d -> addDatum (toAlonzoData d) scriptData
253255 TxOutDatumInline _ d -> addDatum (toAlonzoData d) scriptData
254256applyTxMod tx utxos (AddInput addr value datum rscript False ) =
255- ( Tx (ShelleyTxBody era body{Ledger. btbInputs = inputs'} scripts scriptData'' auxData validity) wits
257+ ( Tx (ShelleyTxBody era body{Conway. ctbSpendInputs = inputs'} scripts scriptData'' auxData validity) wits
256258 , utxos'
257259 )
258260 where
259- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
261+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
260262 txIn = mkNewTxIn utxos
261263
262264 input = toShelleyTxIn txIn
263- inputs' = Set. insert input btbInputs
265+ inputs' = Set. insert input ctbSpendInputs
264266 SJust (Ledger. AsIx idx) = Ledger. indexOf (Ledger. AsItem input) inputs'
265267
266268 txOut = makeTxOut addr value datum rscript
@@ -278,52 +280,52 @@ applyTxMod tx utxos (AddInput addr value datum rscript False) =
278280
279281 scriptData' = recomputeScriptData Nothing idxUpdate scriptData
280282applyTxMod tx utxos (AddInput addr value datum rscript True ) =
281- ( Tx (ShelleyTxBody era body{Ledger. btbReferenceInputs = refInputs} scripts scriptData auxData validity) wits
283+ ( Tx (ShelleyTxBody era body{Conway. ctbReferenceInputs = refInputs} scripts scriptData auxData validity) wits
282284 , utxos'
283285 )
284286 where
285- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
287+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
286288
287289 txIn = mkNewTxIn utxos
288290
289291 input = toShelleyTxIn txIn
290- refInputs = Set. insert input btbReferenceInputs
292+ refInputs = Set. insert input ctbReferenceInputs
291293
292294 txOut = makeTxOut addr value datum rscript
293295 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
294296applyTxMod tx utxos (AddPlutusScriptReferenceInput script value datum rscript) =
295- ( Tx (ShelleyTxBody era body{Ledger. btbReferenceInputs = refInputs'} scripts' scriptData auxData validity) wits
297+ ( Tx (ShelleyTxBody era body{Conway. ctbReferenceInputs = refInputs'} scripts' scriptData auxData validity) wits
296298 , utxos'
297299 )
298300 where
299- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
301+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
300302
301303 txIn = mkNewTxIn utxos
302304 input = toShelleyTxIn txIn
303- refInputs' = Set. insert input btbReferenceInputs
305+ refInputs' = Set. insert input ctbReferenceInputs
304306
305307 txOut = makeTxOut addr value datum rscript
306308 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
307309
308310 scriptInEra =
309311 ScriptInEra
310- PlutusScriptV2InBabbage
312+ PlutusScriptV2InConway
311313 (PlutusScript PlutusScriptV2 script)
312314 newScript = toShelleyScript @ Era scriptInEra
313315 scripts' = scripts ++ [newScript]
314316
315317 hash = hashScript $ PlutusScript PlutusScriptV2 script
316318 addr = scriptAddressAny hash
317319applyTxMod tx utxos (AddReferenceScriptInput script value datum redeemer) =
318- ( Tx (ShelleyTxBody era body{Ledger. btbInputs = inputs'} scripts scriptData' auxData validity) wits
320+ ( Tx (ShelleyTxBody era body{Conway. ctbSpendInputs = inputs'} scripts scriptData' auxData validity) wits
319321 , utxos'
320322 )
321323 where
322- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
324+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
323325
324326 txIn = mkNewTxIn utxos
325327 input = toShelleyTxIn txIn
326- inputs' = Set. insert input btbInputs
328+ inputs' = Set. insert input ctbSpendInputs
327329
328330 txOut = makeTxOut addr value datum ReferenceScriptNone
329331 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
@@ -345,22 +347,22 @@ applyTxMod tx utxos (AddReferenceScriptInput script value datum redeemer) =
345347
346348 addr = scriptAddressAny script
347349applyTxMod tx utxos (AddPlutusScriptInput script value datum redeemer rscript) =
348- ( Tx (ShelleyTxBody era body{Ledger. btbInputs = inputs'} scripts' scriptData' auxData validity) wits
350+ ( Tx (ShelleyTxBody era body{Conway. ctbSpendInputs = inputs'} scripts' scriptData' auxData validity) wits
349351 , utxos'
350352 )
351353 where
352- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
354+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
353355
354356 txIn = mkNewTxIn utxos
355357 input = toShelleyTxIn txIn
356- inputs' = Set. insert input btbInputs
358+ inputs' = Set. insert input ctbSpendInputs
357359
358360 txOut = makeTxOut addr value datum rscript
359361 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
360362
361363 scriptInEra =
362364 ScriptInEra
363- PlutusScriptV2InBabbage
365+ PlutusScriptV2InConway
364366 (PlutusScript PlutusScriptV2 script)
365367 newScript = toShelleyScript @ Era scriptInEra
366368 scripts' = scripts ++ [newScript]
@@ -383,23 +385,23 @@ applyTxMod tx utxos (AddPlutusScriptInput script value datum redeemer rscript) =
383385 hash = hashScript $ PlutusScript PlutusScriptV2 script
384386 addr = scriptAddressAny hash
385387applyTxMod tx utxos (AddSimpleScriptInput script value rscript False ) =
386- ( Tx (ShelleyTxBody era body{Ledger. btbInputs = inputs'} scripts' scriptData' auxData validity) wits
388+ ( Tx (ShelleyTxBody era body{Conway. ctbSpendInputs = inputs'} scripts' scriptData' auxData validity) wits
387389 , utxos'
388390 )
389391 where
390- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
392+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
391393
392394 txIn = mkNewTxIn utxos
393395
394396 input = toShelleyTxIn txIn
395- inputs' = Set. insert input btbInputs
397+ inputs' = Set. insert input ctbSpendInputs
396398
397399 txOut = makeTxOut addr value TxOutDatumNone rscript
398400 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
399401
400402 scriptInEra =
401403 ScriptInEra
402- SimpleScriptInBabbage
404+ SimpleScriptInConway
403405 (SimpleScript script)
404406 newScript = toShelleyScript @ Era scriptInEra
405407 scripts' = scripts ++ [newScript]
@@ -416,35 +418,35 @@ applyTxMod tx utxos (AddSimpleScriptInput script value rscript False) =
416418-- NOTE: this is okay (??) because there is no requirement to provide the
417419-- data for reference inputs
418420applyTxMod tx utxos (AddSimpleScriptInput script value rscript True ) =
419- ( Tx (ShelleyTxBody era body{Ledger. btbReferenceInputs = refInputs} scripts' scriptData auxData validity) wits
421+ ( Tx (ShelleyTxBody era body{Conway. ctbReferenceInputs = refInputs} scripts' scriptData auxData validity) wits
420422 , utxos'
421423 )
422424 where
423- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
425+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
424426
425427 txIn = mkNewTxIn utxos
426428 input = toShelleyTxIn txIn
427- refInputs = Set. insert input btbReferenceInputs
429+ refInputs = Set. insert input ctbReferenceInputs
428430
429431 txOut = makeTxOut addr value TxOutDatumNone rscript
430432 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
431433
432434 scriptInEra =
433435 ScriptInEra
434- SimpleScriptInBabbage
436+ SimpleScriptInConway
435437 (SimpleScript script)
436438 newScript = toShelleyScript @ Era scriptInEra
437439 scripts' = scripts ++ [newScript]
438440
439441 addr = scriptAddressAny $ hashScript (SimpleScript script)
440442applyTxMod tx utxos (ChangeOutput ix maddr mvalue mdatum mrscript) =
441- (Tx (ShelleyTxBody era body{Ledger. btbOutputs = outputs'} scripts scriptData' auxData validity) wits, utxos)
443+ (Tx (ShelleyTxBody era body{Conway. ctbOutputs = outputs'} scripts scriptData' auxData validity) wits, utxos)
442444 where
443445 TxIx (fromIntegral -> idx) = ix
444- Tx bdy@ (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
446+ Tx bdy@ (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
445447 TxBodyContent {txOuts = txOuts} = getTxBodyContent bdy
446448 TxOut (AddressInEra _ (toAddressAny -> addr)) (txOutValueToValue -> value) datum rscript = txOuts !! idx
447- (outputsStart, _ Seq. :<| outputsEnd) = Seq. splitAt idx btbOutputs
449+ (outputsStart, _ Seq. :<| outputsEnd) = Seq. splitAt idx ctbOutputs
448450 outputs' = outputsStart Seq. >< (CBOR. mkSized (Ledger. eraProtVerLow @ LedgerEra ) out Seq. :<| outputsEnd)
449451 out =
450452 toShelleyTxOut shelleyBasedEra $
@@ -487,7 +489,7 @@ applyTxMod tx utxos (ChangeInput txIn maddr mvalue mdatum mrscript) =
487489applyTxMod tx utxos (ChangeScriptInput txIn mvalue mdatum mredeemer mrscript) =
488490 (Tx (ShelleyTxBody era body scripts scriptData' auxData validity) wits, utxos')
489491 where
490- Tx (ShelleyTxBody era body@ Ledger. BabbageTxBody {.. } scripts scriptData auxData validity) wits = tx
492+ Tx (ShelleyTxBody era body@ Conway. ConwayTxBody {.. } scripts scriptData auxData validity) wits = tx
491493 (addr, value, utxoDatum, rscript) = case Map. lookup txIn $ unUTxO utxos of
492494 Just (TxOut addr' (txOutValueToValue -> value') utxoDatum' rscript') ->
493495 (addr', value', utxoDatum', rscript')
@@ -497,7 +499,7 @@ applyTxMod tx utxos (ChangeScriptInput txIn mvalue mdatum mredeemer mrscript) =
497499 TxBodyNoScriptData -> error " No script data available"
498500 TxBodyScriptData _ (Ledger. TxDats dats) (Ledger. Redeemers rdmrs) ->
499501 ( fromJust $ Map. lookup utxoDatumHash dats
500- , fromJust $ Map. lookup (Ledger. AlonzoSpending (Ledger. AsIx idx)) rdmrs
502+ , fromJust $ Map. lookup (Conway. ConwaySpending (Ledger. AsIx idx)) rdmrs
501503 )
502504
503505 utxoDatumHash = case utxoDatum of
@@ -522,7 +524,7 @@ applyTxMod tx utxos (ChangeScriptInput txIn mvalue mdatum mredeemer mrscript) =
522524
523525 utxos' = UTxO . Map. insert txIn txOut . unUTxO $ utxos
524526
525- idx = case Ledger. indexOf (Ledger. AsItem (toShelleyTxIn txIn)) btbInputs of
527+ idx = case Ledger. indexOf (Ledger. AsItem (toShelleyTxIn txIn)) ctbSpendInputs of
526528 SJust (Ledger. AsIx idx') -> idx'
527529 _ -> error " The impossible happened!"
528530
0 commit comments