Skip to content

Commit 31953bc

Browse files
committed
feat(threatmodel): change ThreatModel to ConwayEra
- Change Era type from BabbageEra to ConwayEra - change TxBody patterns: BabbageTxBody -> ConwayTxBody - change field names: btbInputs -> ctbSpendInputs, btbOutputs -> ctbOutputs, etc. - change script witnesses: PlutusScriptV2InBabbage -> PlutusScriptV2InConway - change Plutus purposes: AlonzoSpending -> ConwaySpending (+ Voting, Proposing) - Fix BuiltinByteString conversion in DoubleSatisfaction
1 parent 813fc65 commit 31953bc

File tree

3 files changed

+75
-64
lines changed

3 files changed

+75
-64
lines changed

src/mockchain/lib/Convex/MockChain/ThreatModel/Cardano/Api.hs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import Cardano.Ledger.Alonzo.TxBody qualified as Ledger
1313
import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
1414
import Cardano.Ledger.Api.Tx.Body qualified as Ledger
1515
import Cardano.Ledger.Babbage.TxBody qualified as Ledger
16+
import Cardano.Ledger.Conway.Scripts qualified as Conway
17+
import Cardano.Ledger.Conway.TxBody qualified as Conway
1618
import Cardano.Ledger.Keys (WitVKey (..), coerceKeyRole, hashKey)
1719
import Cardano.Slotting.Time (SlotLength, mkSlotLength)
1820
import Data.SOP.NonEmpty (NonEmpty (NonEmptyOne))
@@ -28,7 +30,7 @@ import Data.Word
2830
import GHC.Exts (toList)
2931
import Ouroboros.Consensus.Block (GenesisWindow (..))
3032

31-
type Era = BabbageEra
33+
type Era = ConwayEra
3234
type LedgerEra = ShelleyLedgerEra Era
3335

3436
addressOfTxOut :: TxOut ctx Era -> AddressAny
@@ -48,12 +50,12 @@ referenceScriptOfTxOut (TxOut _ _ _ rscript) = rscript
4850
redeemerOfTxIn :: Tx Era -> TxIn -> Maybe ScriptData
4951
redeemerOfTxIn tx txIn = redeemer
5052
where
51-
Tx (ShelleyTxBody _ Ledger.BabbageTxBody{Ledger.btbInputs = inputs} _ scriptData _ _) _ = tx
53+
Tx (ShelleyTxBody _ Conway.ConwayTxBody{Conway.ctbSpendInputs = inputs} _ scriptData _ _) _ = tx
5254

5355
redeemer = case scriptData of
5456
TxBodyNoScriptData -> Nothing
5557
TxBodyScriptData _ _ (Ledger.Redeemers rdmrs) ->
56-
getScriptData . fromAlonzoData . fst <$> Map.lookup (Ledger.AlonzoSpending idx) rdmrs
58+
getScriptData . fromAlonzoData . fst <$> Map.lookup (Conway.ConwaySpending idx) rdmrs
5759

5860
idx = case Ledger.indexOf (Ledger.AsItem (toShelleyTxIn txIn)) inputs of
5961
SJust idx' -> idx'
@@ -89,17 +91,21 @@ recomputeScriptData i f (TxBodyScriptData era dats (Ledger.Redeemers rdmrs)) =
8991
where
9092
-- updatePtr = Ledger.hoistPlutusPurpose (\(Ledger.AsIx ix) -> Ledger.AsIx (f ix)) -- TODO: replace when hoistPlutusPurpose is available
9193
updatePtr = \case
92-
Ledger.AlonzoMinting (Ledger.AsIx ix) -> Ledger.AlonzoMinting (Ledger.AsIx (f ix))
93-
Ledger.AlonzoSpending (Ledger.AsIx ix) -> Ledger.AlonzoSpending (Ledger.AsIx (f ix))
94-
Ledger.AlonzoRewarding (Ledger.AsIx ix) -> Ledger.AlonzoRewarding (Ledger.AsIx (f ix))
95-
Ledger.AlonzoCertifying (Ledger.AsIx ix) -> Ledger.AlonzoCertifying (Ledger.AsIx (f ix))
96-
idxFilter (Ledger.AlonzoSpending (Ledger.AsIx idx)) _ = Just idx /= i
97-
idxFilter (Ledger.AlonzoMinting (Ledger.AsIx idx)) _ = Just idx /= i
98-
idxFilter (Ledger.AlonzoCertifying (Ledger.AsIx idx)) _ = Just idx /= i
99-
idxFilter (Ledger.AlonzoRewarding (Ledger.AsIx idx)) _ = Just idx /= i
94+
Conway.ConwayMinting (Ledger.AsIx ix) -> Conway.ConwayMinting (Ledger.AsIx (f ix))
95+
Conway.ConwaySpending (Ledger.AsIx ix) -> Conway.ConwaySpending (Ledger.AsIx (f ix))
96+
Conway.ConwayRewarding (Ledger.AsIx ix) -> Conway.ConwayRewarding (Ledger.AsIx (f ix))
97+
Conway.ConwayCertifying (Ledger.AsIx ix) -> Conway.ConwayCertifying (Ledger.AsIx (f ix))
98+
Conway.ConwayVoting (Ledger.AsIx ix) -> Conway.ConwayVoting (Ledger.AsIx (f ix))
99+
Conway.ConwayProposing (Ledger.AsIx ix) -> Conway.ConwayProposing (Ledger.AsIx (f ix))
100+
idxFilter (Conway.ConwaySpending (Ledger.AsIx idx)) _ = Just idx /= i
101+
idxFilter (Conway.ConwayMinting (Ledger.AsIx idx)) _ = Just idx /= i
102+
idxFilter (Conway.ConwayCertifying (Ledger.AsIx idx)) _ = Just idx /= i
103+
idxFilter (Conway.ConwayRewarding (Ledger.AsIx idx)) _ = Just idx /= i
104+
idxFilter (Conway.ConwayVoting (Ledger.AsIx idx)) _ = Just idx /= i
105+
idxFilter (Conway.ConwayProposing (Ledger.AsIx idx)) _ = Just idx /= i
100106

101107
emptyTxBodyScriptData :: TxBodyScriptData Era
102-
emptyTxBodyScriptData = TxBodyScriptData AlonzoEraOnwardsBabbage (Ledger.TxDats mempty) (Ledger.Redeemers mempty)
108+
emptyTxBodyScriptData = TxBodyScriptData AlonzoEraOnwardsConway (Ledger.TxDats mempty) (Ledger.Redeemers mempty)
103109

104110
addScriptData
105111
:: Word32
@@ -112,7 +118,7 @@ addScriptData ix dat rdmr (TxBodyScriptData era (Ledger.TxDats dats) (Ledger.Red
112118
TxBodyScriptData
113119
era
114120
(Ledger.TxDats $ Map.insert (Ledger.hashData dat) dat dats)
115-
(Ledger.Redeemers $ Map.insert (Ledger.AlonzoSpending (Ledger.AsIx ix)) rdmr rdmrs)
121+
(Ledger.Redeemers $ Map.insert (Conway.ConwaySpending (Ledger.AsIx ix)) rdmr rdmrs)
116122

117123
addDatum
118124
:: Ledger.Data (ShelleyLedgerEra Era)
@@ -134,7 +140,7 @@ toCtxUTxODatum d = case d of
134140

135141
-- | Convert ScriptData to a `Test.QuickCheck.ContractModel.ThreatModel.Datum`.
136142
txOutDatum :: ScriptData -> TxOutDatum CtxTx Era
137-
txOutDatum d = TxOutDatumInline BabbageEraOnwardsBabbage (unsafeHashableScriptData d)
143+
txOutDatum d = TxOutDatumInline BabbageEraOnwardsConway (unsafeHashableScriptData d)
138144

139145
{- | Convert a Haskell value to ScriptData for use as a
140146
`Test.QuickCheck.ContractModel.ThreatModel.Redeemer` or convert to a
@@ -223,7 +229,7 @@ validateTx pparams tx utxos =
223229
where
224230
report =
225231
evaluateTransactionExecutionUnits
226-
BabbageEra
232+
ConwayEra
227233
systemStart
228234
(toLedgerEpochInfo eraHistory)
229235
pparams

src/mockchain/lib/Convex/MockChain/ThreatModel/Pretty.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Cardano.Ledger.Alonzo.Tx qualified as Ledger (Data)
1010
import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
1111

1212
import Cardano.Ledger.Alonzo.Scripts qualified as Ledger
13+
import Cardano.Ledger.Conway.Scripts qualified as Conway
1314
import Cardano.Ledger.Hashes qualified as Ledger
1415
import Data.ByteString qualified as BS
1516
import Data.Char
@@ -176,10 +177,12 @@ prettyRedeemer inps mints purpose (dat, _) = pTag <:> prettyScriptData (getScrip
176177
where
177178
pTag =
178179
case purpose of
179-
Ledger.AlonzoSpending (Ledger.AsIx ix) -> text "Spend" <+> prettyIn (inps !! fromIntegral ix)
180-
Ledger.AlonzoMinting (Ledger.AsIx ix) -> text "Mint" <+> prettyHash (mints !! fromIntegral ix)
181-
Ledger.AlonzoCertifying _ -> text "Certify"
182-
Ledger.AlonzoRewarding _ -> text "Reward"
180+
Conway.ConwaySpending (Ledger.AsIx ix) -> text "Spend" <+> prettyIn (inps !! fromIntegral ix)
181+
Conway.ConwayMinting (Ledger.AsIx ix) -> text "Mint" <+> prettyHash (mints !! fromIntegral ix)
182+
Conway.ConwayCertifying _ -> text "Certify"
183+
Conway.ConwayRewarding _ -> text "Reward"
184+
Conway.ConwayVoting _ -> text "Vote"
185+
Conway.ConwayProposing _ -> text "Propose"
183186

184187
prettyDatumMap :: TxBodyScriptData Era -> Doc
185188
prettyDatumMap (TxBodyScriptData _ (Ledger.TxDats dats) _)

src/mockchain/lib/Convex/MockChain/ThreatModel/TxModifier.hs

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
1313
import Cardano.Ledger.Api.Era qualified as Ledger
1414
import Cardano.Ledger.Babbage.TxBody qualified as Ledger
1515
import Cardano.Ledger.Binary qualified as CBOR
16+
import Cardano.Ledger.Conway.Scripts qualified as Conway
17+
import Cardano.Ledger.Conway.TxBody qualified as Conway
1618
import Data.Coerce
1719

1820
import Cardano.Ledger.Alonzo.Scripts qualified as Ledger
@@ -201,47 +203,47 @@ mkNewTxIn utxos = TxIn dummyTxId (TxIx txIx)
201203

202204
applyTxMod :: Tx Era -> UTxO Era -> TxMod -> (Tx Era, UTxO Era)
203205
applyTxMod 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)
209211
applyTxMod 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'
227229
applyTxMod 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"
240242
applyTxMod 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
254256
applyTxMod 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
280282
applyTxMod 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
294296
applyTxMod 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
317319
applyTxMod 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
347349
applyTxMod 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
385387
applyTxMod 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
418420
applyTxMod 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)
440442
applyTxMod 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) =
487489
applyTxMod 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

Comments
 (0)