@@ -211,9 +211,8 @@ readScriptWitness era' (SimpleScriptWitnessFile (ScriptFile scriptFile)) = do
211
211
readFileScriptInAnyLang scriptFile
212
212
ScriptInEra langInEra script' <- validateScriptSupportedInEra era' script
213
213
case script' of
214
- SimpleScript version sscript ->
215
- return . SimpleScriptWitness
216
- langInEra version $ SScript sscript
214
+ SimpleScript sscript ->
215
+ return . SimpleScriptWitness langInEra $ SScript sscript
217
216
218
217
-- If the supplied cli flags were for a simple script (i.e. the user did
219
218
-- not supply the datum, redeemer or ex units), but the script file turns
@@ -262,7 +261,7 @@ readScriptWitness era' (PlutusReferenceScriptWitnessFiles refTxIn
262
261
case scriptLanguageSupportedInEra era' anyScriptLanguage of
263
262
Just sLangInEra ->
264
263
case languageOfScriptLanguageInEra sLangInEra of
265
- SimpleScriptLanguage _v ->
264
+ SimpleScriptLanguage ->
266
265
-- TODO: We likely need another datatype eg data ReferenceScriptWitness lang
267
266
-- in order to make this branch unrepresentable.
268
267
error " readScriptWitness: Should not be possible to specify a simple script"
@@ -287,8 +286,8 @@ readScriptWitness era' (SimpleReferenceScriptWitnessFiles refTxIn
287
286
case scriptLanguageSupportedInEra era' anyScriptLanguage of
288
287
Just sLangInEra ->
289
288
case languageOfScriptLanguageInEra sLangInEra of
290
- SimpleScriptLanguage v ->
291
- return . SimpleScriptWitness sLangInEra v
289
+ SimpleScriptLanguage ->
290
+ return . SimpleScriptWitness sLangInEra
292
291
$ SReferenceScript refTxIn (unPolicyId <$> mPid)
293
292
PlutusScriptLanguage {} ->
294
293
error " readScriptWitness: Should not be possible to specify a plutus script"
@@ -399,12 +398,11 @@ deserialiseScriptInAnyLang bs =
399
398
--
400
399
case deserialiseFromJSON AsTextEnvelope bs of
401
400
Left _ ->
402
- -- The SimpleScript language has the property that it is backwards
403
- -- compatible, so we can parse as the latest version and then downgrade
404
- -- to the minimum version that has all the features actually used.
405
- case deserialiseFromJSON (AsSimpleScript AsSimpleScriptV2 ) bs of
406
- Left err -> Left (ScriptDecodeSimpleScriptError err)
407
- Right script -> Right (toMinimumSimpleScriptVersion script)
401
+ -- In addition to the TextEnvelope format, we also try to
402
+ -- deserialize the JSON representation of SimpleScripts.
403
+ case Aeson. eitherDecodeStrict' bs of
404
+ Left err -> Left (ScriptDecodeSimpleScriptError $ JsonDecodeError err)
405
+ Right script -> Right $ ScriptInAnyLang SimpleScriptLanguage $ SimpleScript script
408
406
409
407
Right te ->
410
408
case deserialiseFromTextEnvelopeAnyOf textEnvTypes te of
@@ -416,11 +414,8 @@ deserialiseScriptInAnyLang bs =
416
414
-- script version.
417
415
textEnvTypes :: [FromSomeType HasTextEnvelope ScriptInAnyLang ]
418
416
textEnvTypes =
419
- [ FromSomeType (AsScript AsSimpleScriptV1 )
420
- (ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1 ))
421
-
422
- , FromSomeType (AsScript AsSimpleScriptV2 )
423
- (ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2 ))
417
+ [ FromSomeType (AsScript AsSimpleScript )
418
+ (ScriptInAnyLang SimpleScriptLanguage )
424
419
425
420
, FromSomeType (AsScript AsPlutusScriptV1 )
426
421
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV1 ))
@@ -429,19 +424,6 @@ deserialiseScriptInAnyLang bs =
429
424
(ScriptInAnyLang (PlutusScriptLanguage PlutusScriptV2 ))
430
425
]
431
426
432
- toMinimumSimpleScriptVersion :: SimpleScript SimpleScriptV2
433
- -> ScriptInAnyLang
434
- toMinimumSimpleScriptVersion s =
435
- -- TODO alonzo: this will need to be adjusted when more versions are added
436
- -- with appropriate helper functions it can probably be done in an
437
- -- era-generic style
438
- case adjustSimpleScriptVersion SimpleScriptV1 s of
439
- Nothing -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV2 )
440
- (SimpleScript SimpleScriptV2 s)
441
- Just s' -> ScriptInAnyLang (SimpleScriptLanguage SimpleScriptV1 )
442
- (SimpleScript SimpleScriptV1 s')
443
-
444
-
445
427
-- Tx & TxBody
446
428
447
429
newtype CddlTx = CddlTx { unCddlTx :: InAnyCardanoEra Tx } deriving (Show , Eq )
0 commit comments