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