Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.

Commit 14ae5a4

Browse files
authored
#1078 Use correct envelope type when decoding (#1081)
1 parent 70309cb commit 14ae5a4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

plutus-example/src/PlutusExample/ScriptContextChecker.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ customRedeemerToScriptData (AnyPV2CustomRedeemer cRedeem) =
7575

7676
data ScriptContextError = NoScriptsInByronEra
7777
| NoScriptsInEra
78-
| ReadTxBodyError (FileError TextEnvelopeError)
78+
| ReadTxBodyError (FileError TextEnvelopeCddlError)
7979
| IntervalConvError Text
8080
| AcquireFail AcquiringFailure
8181
| NoTipLocalStateError
@@ -188,6 +188,9 @@ seqToList :: Seq.StrictSeq a -> [a]
188188
seqToList (x Seq.:<| rest) = x : seqToList rest
189189
seqToList Seq.Empty = []
190190

191+
newtype CddlTx = CddlTx { unCddlTx :: InAnyCardanoEra Tx }
192+
deriving (Show, Eq)
193+
191194
createAnyCustomRedeemerFromTxFp
192195
:: PlutusScriptVersion lang
193196
-> FilePath
@@ -196,12 +199,14 @@ createAnyCustomRedeemerFromTxFp
196199
-> ExceptT ScriptContextError IO AnyCustomRedeemer
197200
createAnyCustomRedeemerFromTxFp pScriptVer fp (AnyConsensusModeParams cModeParams) network = do
198201
-- TODO: Expose readFileTx from cardano-cli
199-
InAnyCardanoEra cEra alonzoTx
202+
CddlTx (InAnyCardanoEra cEra alonzoTx)
200203
<- firstExceptT ReadTxBodyError
201204
. newExceptT
202-
$ readFileTextEnvelopeAnyOf
203-
[ FromSomeType (AsTx AsAlonzoEra) (InAnyCardanoEra AlonzoEra)
204-
, FromSomeType (AsTx AsBabbageEra) (InAnyCardanoEra BabbageEra)
205+
$ readFileTextEnvelopeCddlAnyOf
206+
[ FromCDDLTx "Witnessed Tx AlonzoEra" CddlTx
207+
, FromCDDLTx "Unwitnessed Tx AlonzoEra" CddlTx
208+
, FromCDDLTx "Witnessed Tx BabbageEra" CddlTx
209+
, FromCDDLTx "Unwitnessed Tx BabbageEra" CddlTx
205210
]
206211
fp
207212

0 commit comments

Comments
 (0)