@@ -20,6 +20,7 @@ module Cardano.Mock.Forging.Tx.Alonzo (
20
20
mkUnlockScriptTx ,
21
21
mkScriptInp ,
22
22
mkScriptMint ,
23
+ mkScriptMint' ,
23
24
mkMAssetsScriptTx ,
24
25
mkDCertTx ,
25
26
mkSimpleDCertTx ,
@@ -44,11 +45,10 @@ import Cardano.Ledger.Alonzo.Tx
44
45
import Cardano.Ledger.Alonzo.TxBody
45
46
import Cardano.Ledger.Alonzo.TxWits
46
47
import Cardano.Ledger.BaseTypes
47
- import Cardano.Ledger.Block (txid )
48
48
import Cardano.Ledger.Coin
49
+ import Cardano.Ledger.Core
49
50
import qualified Cardano.Ledger.Core as Core
50
51
import Cardano.Ledger.Credential
51
- import Cardano.Ledger.Hashes
52
52
import Cardano.Ledger.Keys
53
53
import Cardano.Ledger.Mary.Value
54
54
import Cardano.Ledger.Shelley.TxCert
@@ -203,38 +203,45 @@ mkUnlockScriptTx inputIndex colInputIndex outputIndex succeeds amount fees sta =
203
203
204
204
mkScriptInp' ::
205
205
(Word64 , (TxIn StandardCrypto , Core. TxOut StandardAlonzo )) ->
206
- Maybe (RdmrPtr , Maybe (ScriptHash StandardCrypto , Core. Script StandardAlonzo ))
206
+ Maybe (AlonzoPlutusPurpose AsIndex era , Maybe (ScriptHash StandardCrypto , Core. Script StandardAlonzo ))
207
207
mkScriptInp' = map (second Just ) . mkScriptInp
208
208
209
209
mkScriptInp ::
210
210
(Word64 , (TxIn StandardCrypto , Core. TxOut StandardAlonzo )) ->
211
- Maybe (RdmrPtr , (ScriptHash StandardCrypto , Core. Script StandardAlonzo ))
211
+ Maybe (AlonzoPlutusPurpose AsIndex era , (ScriptHash StandardCrypto , Core. Script StandardAlonzo ))
212
212
mkScriptInp (n, (_txIn, txOut))
213
213
| addr == alwaysFailsScriptAddr =
214
214
Just
215
- (RdmrPtr Spend n , (alwaysFailsScriptHash, alwaysFailsScript))
215
+ (AlonzoSpending ( AsIndex $ fromIntegral n) , (alwaysFailsScriptHash, alwaysFailsScript))
216
216
| addr == alwaysSucceedsScriptAddr =
217
217
Just
218
- (RdmrPtr Spend n , (alwaysSucceedsScriptHash, alwaysSucceedsScript))
218
+ (AlonzoSpending ( AsIndex $ fromIntegral n) , (alwaysSucceedsScriptHash, alwaysSucceedsScript))
219
219
| addr == alwaysMintScriptAddr =
220
- Just (RdmrPtr Spend n , (alwaysMintScriptHash, alwaysMintScript))
220
+ Just (AlonzoSpending ( AsIndex $ fromIntegral n) , (alwaysMintScriptHash, alwaysMintScript))
221
221
| otherwise = Nothing
222
222
where
223
223
addr = txOut ^. Core. addrTxOutL
224
224
225
+ mkScriptMint' ::
226
+ AlonzoEraScript era =>
227
+ MultiAsset StandardCrypto ->
228
+ [(AlonzoPlutusPurpose AsIndex era , Maybe (ScriptHash StandardCrypto , AlonzoScript era ))]
229
+ mkScriptMint' = fmap (first $ AlonzoMinting . AsIndex ) . mkScriptMint
230
+
225
231
mkScriptMint ::
232
+ AlonzoEraScript era =>
226
233
MultiAsset StandardCrypto ->
227
- [(RdmrPtr , Maybe (ScriptHash StandardCrypto , Core. Script StandardAlonzo ))]
234
+ [(Word32 , Maybe (ScriptHash StandardCrypto , AlonzoScript era ))]
228
235
mkScriptMint (MultiAsset mp) = mapMaybe f $ zip [0 .. ] (Map. keys mp)
229
236
where
230
237
f (n, policyId)
231
238
| policyID policyId == alwaysFailsScriptHash =
232
- Just (RdmrPtr Mint n, Just (alwaysFailsScriptHash, alwaysFailsScript))
239
+ Just (n, Just (alwaysFailsScriptHash, alwaysFailsScript))
233
240
| policyID policyId == alwaysSucceedsScriptHash =
234
241
Just
235
- (RdmrPtr Mint n, Just (alwaysSucceedsScriptHash, alwaysSucceedsScript))
242
+ (n, Just (alwaysSucceedsScriptHash, alwaysSucceedsScript))
236
243
| policyID policyId == alwaysMintScriptHash =
237
- Just (RdmrPtr Mint n, Just (alwaysMintScriptHash, alwaysMintScript))
244
+ Just (n, Just (alwaysMintScriptHash, alwaysMintScript))
238
245
| otherwise = Nothing
239
246
240
247
mkMAssetsScriptTx ::
@@ -256,7 +263,7 @@ mkMAssetsScriptTx inputIndex colInputIndex outputIndex minted succeeds fees sta
256
263
$ mkScriptTx
257
264
succeeds
258
265
( mapMaybe mkScriptInp' (zip [0 .. ] inputPairs)
259
- ++ mkScriptMint minted
266
+ ++ mkScriptMint' minted
260
267
)
261
268
$ consPaymentTxBody inpts colInput (StrictSeq. fromList outps) (Coin fees) minted
262
269
where
@@ -314,8 +321,8 @@ mkScriptDCertTx consDert valid st = do
314
321
else
315
322
Just $
316
323
if bl
317
- then (RdmrPtr Cert n , (alwaysFailsScriptHash, alwaysFailsScript))
318
- else (RdmrPtr Cert n , (alwaysSucceedsScriptHash, alwaysSucceedsScript))
324
+ then (AlonzoCertifying ( AsIndex n) , (alwaysFailsScriptHash, alwaysFailsScript))
325
+ else (AlonzoCertifying ( AsIndex n) , (alwaysSucceedsScriptHash, alwaysSucceedsScript))
319
326
prepareRedeemer _ = Nothing
320
327
321
328
mkDepositTxPools ::
@@ -355,13 +362,13 @@ consPoolParamsTwoOwners _ _ = panic "expected 2 pool owners"
355
362
356
363
mkScriptTx ::
357
364
forall era .
358
- ( Core. Era era
359
- , Core. EraCrypto era ~ StandardCrypto
365
+ ( Core. EraCrypto era ~ StandardCrypto
360
366
, Core. Script era ~ AlonzoScript era
361
367
, Core. TxWits era ~ AlonzoTxWits era
368
+ , AlonzoEraScript era
362
369
) =>
363
370
Bool ->
364
- [(RdmrPtr , Maybe (ScriptHash StandardCrypto , Core. Script era ))] ->
371
+ [(PlutusPurpose AsIndex era , Maybe (ScriptHash StandardCrypto , Core. Script era ))] ->
365
372
Core. TxBody era ->
366
373
AlonzoTx era
367
374
mkScriptTx valid rdmrs txBody =
@@ -378,8 +385,11 @@ mkScriptTx valid rdmrs txBody =
378
385
[(hashData @ era plutusDataList, plutusDataList)]
379
386
380
387
mkWitnesses ::
381
- (Core. Era era , Core. EraCrypto era ~ StandardCrypto , Script era ~ AlonzoScript era ) =>
382
- [(RdmrPtr , Maybe (ScriptHash StandardCrypto , Core. Script era ))] ->
388
+ ( Core. EraCrypto era ~ StandardCrypto
389
+ , Script era ~ AlonzoScript era
390
+ , AlonzoEraScript era
391
+ ) =>
392
+ [(PlutusPurpose AsIndex era , Maybe (ScriptHash StandardCrypto , Core. Script era ))] ->
383
393
[(DataHash StandardCrypto , Data era )] ->
384
394
AlonzoTxWits era
385
395
mkWitnesses rdmrs datas =
@@ -404,7 +414,7 @@ mkUTxOAlonzo tx =
404
414
| (out, idx) <- zip (toList (tx ^. outputsL)) (TxIx <$> [0 .. ])
405
415
]
406
416
where
407
- transId = txid $ getField @ " body " tx
417
+ transId = txIdTx tx
408
418
outputsL = Core. bodyTxL . Core. outputsTxBodyL
409
419
410
420
emptyTxBody :: AlonzoTxBody StandardAlonzo
0 commit comments